summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-06-18 18:06:03 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-06-22 10:40:38 +0200
commita656febccf6614008086bf124858826615924df7 (patch)
tree53a896814e6e6055a45570be90a003aa76e48d76 /test cases
parentd729ea3f6936dd7ea68a41cf178ee6a9afcf0ddd (diff)
downloadmeson-a656febccf6614008086bf124858826615924df7.tar.gz
extract_objects: test and document using the result in a custom_target
QEMU would like to use the result of extract_objects in a custom_target; examples are using objcopy, or using the object files as the key to look up command line arguments in compile_commands.json. This is slightly peculiar and not covered by the test suite, but it works; in order to avoid regressions, add a test case and document it.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/22 object extraction/check-obj.py21
-rw-r--r--test cases/common/22 object extraction/meson.build6
2 files changed, 27 insertions, 0 deletions
diff --git a/test cases/common/22 object extraction/check-obj.py b/test cases/common/22 object extraction/check-obj.py
new file mode 100644
index 000000000..99c2cc546
--- /dev/null
+++ b/test cases/common/22 object extraction/check-obj.py
@@ -0,0 +1,21 @@
+#! /usr/bin/env python3
+
+import json
+import sys
+import os
+
+cc = None
+output = None
+
+# Only the ninja backend produces compile_commands.json
+if sys.argv[1] == 'ninja':
+ with open('compile_commands.json', 'r') as f:
+ cc = json.load(f)
+ output = set((x['output'] for x in cc))
+
+for obj in sys.argv[2:]:
+ if not os.path.exists(obj):
+ sys.exit(1)
+ if sys.argv[1] == 'ninja' and obj not in output:
+ sys.exit(1)
+ print('Verified', obj)
diff --git a/test cases/common/22 object extraction/meson.build b/test cases/common/22 object extraction/meson.build
index 18be1dbeb..407c5e83b 100644
--- a/test cases/common/22 object extraction/meson.build
+++ b/test cases/common/22 object extraction/meson.build
@@ -16,6 +16,12 @@ else
e3 = executable('main3', 'main.c', objects : obj3)
e4 = executable('main4', 'main.c', objects : obj4)
+ custom_target('custom_target with object inputs', output: 'objs',
+ input: [obj1, obj2, obj3],
+ build_by_default: true,
+ command: [find_program('check-obj.py'), meson.backend(), '@INPUT@'],
+ capture: true)
+
test('extraction test 1', e1)
test('extraction test 2', e2)
test('extraction test 3', e3)