xref: /aosp_15_r20/external/wayland/tests/meson.build (revision 84e872a0dc482bffdb63672969dd03a827d67c73)
1if not get_option('libraries')
2	error('-Dtests=true requires -Dlibraries=true')
3endif
4
5test_runner = static_library(
6	'test-runner',
7	sources: [
8		'test-runner.c',
9		'test-helpers.c',
10		'test-compositor.c'
11	],
12	include_directories: [ root_inc, src_inc ],
13	dependencies: [
14		cc.find_library('dl', required: false),
15		dependency('threads'),
16		epoll_dep,
17		ffi_dep,
18		wayland_util_dep,
19		wayland_private_dep,
20		wayland_client_dep,
21		wayland_server_dep
22	]
23)
24
25test_runner_dep = declare_dependency(
26	link_with: test_runner,
27	include_directories: [ src_inc ],
28	dependencies: [
29		dependency('threads'),
30		cc.find_library('dl', required: false)
31	]
32)
33
34tests_protocol_xml = files('../protocol/tests.xml')
35
36tests_server_protocol_h = custom_target(
37	'test server protocol header',
38	command: [ wayland_scanner_for_build, '-s', 'server-header', '@INPUT@', '@OUTPUT@' ],
39	input: tests_protocol_xml,
40	output: 'tests-server-protocol.h'
41)
42
43tests_client_protocol_c = custom_target(
44	'test client protocol header',
45	command: [ wayland_scanner_for_build, '-s', 'client-header', '@INPUT@', '@OUTPUT@' ],
46	input: tests_protocol_xml,
47	output: 'tests-client-protocol.h'
48)
49
50tests_protocol_c = custom_target(
51	'test protocol source',
52	command: [ wayland_scanner_for_build, '-s', 'public-code', '@INPUT@', '@OUTPUT@' ],
53	input: tests_protocol_xml,
54	output: 'tests-protocol.c'
55)
56
57benchmark(
58	'fixed-benchmark',
59	executable(
60		'fixed-benchmark',
61		'fixed-benchmark.c',
62		dependencies: [ test_runner_dep, rt_dep ]
63	)
64)
65
66executable(
67	'exec-fd-leak-checker',
68	'exec-fd-leak-checker.c',
69	dependencies: test_runner_dep
70)
71
72if add_languages('cpp', native: false)
73	test(
74		'cpp-compile-test',
75		executable(
76			'cpp-compile-test',
77			'cpp-compile-test.cpp',
78			wayland_server_protocol_h,
79			include_directories: src_inc
80		)
81	)
82endif
83
84sed_path = find_program('sed').full_path()
85
86if get_option('scanner')
87	test(
88		'scanner-test',
89		find_program('scanner-test.sh'),
90		env: [
91			'TEST_DATA_DIR=@0@/data'.format(meson.current_source_dir()),
92			'TEST_OUTPUT_DIR=@0@/output'.format(meson.current_build_dir()),
93			'SED=@0@'.format(sed_path),
94			'WAYLAND_SCANNER=@0@'.format(wayland_scanner.full_path()),
95		],
96	)
97endif
98
99tests = {
100	'array-test': [],
101	'client-test': [ wayland_server_protocol_h ],
102	'display-test': [
103		wayland_client_protocol_h,
104		wayland_server_protocol_h,
105		tests_server_protocol_h,
106		tests_client_protocol_c,
107		tests_protocol_c,
108	],
109	'connection-test': [
110		wayland_client_protocol_h,
111		wayland_server_protocol_h,
112	],
113	'event-loop-test': [ wayland_server_protocol_h ],
114	'fixed-test': [],
115	'interface-test': [ wayland_client_protocol_h ],
116	'list-test': [],
117	'map-test': [],
118	'sanity-test' : [
119		wayland_client_protocol_h,
120		wayland_server_protocol_h,
121	],
122	'socket-test': [
123		wayland_client_protocol_h,
124		wayland_server_protocol_h,
125	],
126	'queue-test': [
127		wayland_client_protocol_h,
128		wayland_server_protocol_h,
129	],
130	'signal-test': [ wayland_server_protocol_h ],
131	'newsignal-test': [
132		# wayland-server.c is needed here to access wl_priv_* functions
133		files('../src/wayland-server.c'),
134		wayland_server_protocol_h,
135	],
136	'resources-test': [ wayland_server_protocol_h ],
137	'message-test': [
138		wayland_client_protocol_h,
139		wayland_server_protocol_h,
140	],
141	'compositor-introspection-test': [
142		wayland_client_protocol_h,
143		wayland_server_protocol_h,
144	],
145	'protocol-logger-test': [
146		wayland_client_protocol_h,
147		wayland_server_protocol_h,
148	],
149	'headers-test': [
150		wayland_client_protocol_h,
151		wayland_server_protocol_h,
152		'headers-protocol-test.c',
153		wayland_client_protocol_core_h,
154		wayland_server_protocol_core_h,
155		'headers-protocol-core-test.c',
156	],
157	'os-wrappers-test': [],
158}
159
160foreach test_name, test_extra_sources: tests
161	test_sources = [ test_name + '.c' ] + test_extra_sources
162	test_deps = [test_runner_dep, epoll_dep]
163	bin = executable(test_name, test_sources, dependencies: test_deps)
164	test(
165		test_name,
166		bin,
167		env: [
168			'TEST_SRC_DIR=@0@'.format(meson.current_source_dir()),
169			'TEST_BUILD_DIR=@0@'.format(meson.current_build_dir()),
170		],
171	)
172endforeach
173