aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test cases/windows/16 gui app/gui_app_tester.py29
-rw-r--r--test cases/windows/16 gui app/meson.build9
2 files changed, 13 insertions, 25 deletions
diff --git a/test cases/windows/16 gui app/gui_app_tester.py b/test cases/windows/16 gui app/gui_app_tester.py
index 9cba806..53e7649 100644
--- a/test cases/windows/16 gui app/gui_app_tester.py
+++ b/test cases/windows/16 gui app/gui_app_tester.py
@@ -1,26 +1,19 @@
#!/usr/bin/env python3
-import re
-import subprocess
+import os
import sys
+try:
+ import pefile
+except ImportError:
+ if 'CI' in os.environ:
+ raise
+ # Skip the test if not on CI
+ sys.exit(77)
-tool = sys.argv[1]
-executable = sys.argv[2]
-expected = int(sys.argv[3])
-actual = -1
+executable = sys.argv[1]
+expected = int(sys.argv[2])
-if 'objdump' in tool:
- result = subprocess.check_output([tool, '-p', executable]).decode()
- match = re.search(r'^Subsystem\s+(\d+)', result, re.MULTILINE)
-elif 'dumpbin' in tool:
- result = subprocess.check_output([tool, '/headers', executable]).decode()
- match = re.search(r'^\s*(\d+) subsystem(?! version)', result, re.MULTILINE)
-else:
- print('unknown tool')
- sys.exit(1)
-
-if match:
- actual = int(match.group(1))
+actual = pefile.PE(executable).dump_dict()['OPTIONAL_HEADER']['Subsystem']['Value']
print('subsystem expected: %d, actual: %d' % (expected, actual))
sys.exit(0 if (expected == actual) else 1)
diff --git a/test cases/windows/16 gui app/meson.build b/test cases/windows/16 gui app/meson.build
index 224d708..1570555 100644
--- a/test cases/windows/16 gui app/meson.build
+++ b/test cases/windows/16 gui app/meson.build
@@ -17,10 +17,5 @@ console_prog = executable('console_prog', 'console_prog.c', gui_app: false)
tester = find_program('gui_app_tester.py')
-tool = find_program('objdump', 'dumpbin', required: false)
-# TODO: when 'llvm-objdump -f' emits the subsystem type, we could use that also
-
-if tool.found()
- test('is_gui', tester, args: [tool.path(), gui_prog, '2'])
- test('not_gui', tester, args: [tool.path(), console_prog, '3'])
-endif
+test('is_gui', tester, args: [gui_prog, '2'])
+test('not_gui', tester, args: [console_prog, '3'])