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