diff --git a/test cases/windows/17 gui app/gui_app_tester.py b/test cases/windows/17 gui app/gui_app_tester.py new file mode 100644 index 000000000..9cba806f0 --- /dev/null +++ b/test cases/windows/17 gui app/gui_app_tester.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import re +import subprocess +import sys + +tool = sys.argv[1] +executable = sys.argv[2] +expected = int(sys.argv[3]) +actual = -1 + +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)) + +print('subsystem expected: %d, actual: %d' % (expected, actual)) +sys.exit(0 if (expected == actual) else 1) diff --git a/test cases/windows/17 gui app/gui_prog.c b/test cases/windows/17 gui app/gui_prog.c new file mode 100644 index 000000000..4bc688a35 --- /dev/null +++ b/test cases/windows/17 gui app/gui_prog.c @@ -0,0 +1,6 @@ +#include + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) { + return 0; +} diff --git a/test cases/windows/17 gui app/meson.build b/test cases/windows/17 gui app/meson.build index d5e6f5b50..243521834 100644 --- a/test cases/windows/17 gui app/meson.build +++ b/test cases/windows/17 gui app/meson.build @@ -7,3 +7,16 @@ project('gui_app_test', 'c') console_lib = static_library('main', 'console_prog.c') executable('console', 'dummy.c', link_with: console_lib, gui_app: false) + +# +# also verify that the correct subsystem is set by executable(gui_app:) +# + +gui_prog = executable('gui_prog', 'gui_prog.c', gui_app: true) +console_prog = executable('console_prog', 'console_prog.c', gui_app: false) + +tester = find_program('gui_app_tester.py') + +tool = find_program('objdump', 'dumpbin') +test('is_gui', tester, args: [tool.path(), gui_prog, '2']) +test('not_gui', tester, args: [tool.path(), console_prog, '3'])