1
2common_src = static_library(
3	'common',
4	'common.c',
5	include_directories: waypipe_includes
6)
7# Testing
8test_diff = executable(
9	'diff_roundtrip',
10	['diff_roundtrip.c'],
11	include_directories: waypipe_includes,
12	link_with: [lib_waypipe_src, common_src]
13)
14test('Whether diff operations successfully roundtrip', test_diff, timeout: 60)
15test_damage = executable(
16	'damage_merge',
17	['damage_merge.c'],
18	include_directories: waypipe_includes,
19	link_with: [lib_waypipe_src, common_src]
20)
21test('If damage rectangles merge efficiently', test_damage, timeout: 5)
22test_mirror = executable(
23	'fd_mirror',
24	['fd_mirror.c'],
25	include_directories: waypipe_includes,
26	link_with: [lib_waypipe_src, common_src],
27	dependencies: [libgbm]
28)
29# disable leak checking, because library code is often responsible
30test('How well buffers are replicated', test_mirror, env: ['ASAN_OPTIONS=detect_leaks=0'], timeout: 40)
31test_proto_functions = files('protocol_functions.txt')
32proto_send_src = custom_target(
33	'protocol_control message serialization',
34	output: 'protocol_functions.h',
35	depend_files: [test_proto_functions, sendgen_path] + abs_protocols,
36	command: [python3, sendgen_path, test_proto_functions, '@OUTPUT@'] + abs_protocols,
37)
38test_protocol = executable(
39	'protocol_control',
40	['protocol_control.c', proto_send_src],
41	include_directories: waypipe_includes,
42	link_with: [lib_waypipe_src, common_src]
43)
44test('That common Wayland message patterns work', test_protocol, env: ['ASAN_OPTIONS=detect_leaks=0'], timeout: 20)
45test_pipe = executable(
46	'pipe_mirror',
47	['pipe_mirror.c'],
48	include_directories: waypipe_includes,
49	link_with: [lib_waypipe_src, common_src]
50)
51test('How well pipes are replicated', test_pipe, timeout: 20)
52test_fnlist = files('test_fnlist.txt')
53testproto_src = custom_target(
54	'test-proto code',
55	output: 'protocol-@BASENAME@.c',
56	input: 'test-proto.xml',
57	depend_files: [test_fnlist, symgen_path],
58	command: [python3, symgen_path, 'data', test_fnlist,  '@OUTPUT@', '@INPUT@'],
59)
60testproto_header = custom_target(
61	'test-proto client-header',
62	output: 'protocol-@BASENAME@.h',
63	input: 'test-proto.xml',
64	depend_files: [test_fnlist, symgen_path],
65	command: [python3, symgen_path, 'header', test_fnlist,  '@OUTPUT@', '@INPUT@'],
66)
67test_parse = executable(
68	'wire_parse',
69	['wire_parse.c', testproto_src, testproto_header],
70	include_directories: waypipe_includes,
71	link_with: [lib_waypipe_src, common_src],
72)
73test('That protocol parsing fails cleanly', test_parse, timeout: 5)
74
75fake_ssh = executable(
76	'ssh',
77	['fake_ssh.c']
78)
79
80weston_dep = dependency('weston', required: false)
81testprog_paths = []
82if weston_dep.found()
83	# Sometimes weston's test clients are installed here instead
84	testprog_paths += weston_dep.get_pkgconfig_variable('libexecdir')
85endif
86weston_prog = find_program('weston', required: false)
87base_envlist = [
88	'TEST_WAYPIPE_PATH=@0@'.format(waypipe_prog.full_path()),
89]
90
91headless_envlist = base_envlist
92if weston_prog.found()
93	headless_envlist += 'TEST_WESTON_PATH=@0@'.format(weston_prog.path())
94endif
95test_programs = [
96	['TEST_WESTON_SHM_PATH', 'weston-simple-shm'],
97	# ['TEST_WESTON_EGL_PATH', 'weston-simple-egl'],
98	['TEST_WESTON_TERM_PATH', 'weston-terminal'],
99	['TEST_WESTON_PRES_PATH', 'weston-presentation-shm'],
100	['TEST_WESTON_SUBSURF_PATH', 'weston-subsurfaces'],
101]
102if has_dmabuf
103	test_programs += [['TEST_WESTON_DMA_PATH', 'weston-simple-dmabuf-egl']]
104endif
105have_test_progs = false
106foreach t : test_programs
107	test_prog = find_program(t[1], required: false)
108	foreach p : testprog_paths
109		if not test_prog.found()
110			test_prog = find_program(join_paths(p, t[1]), required: false)
111		endif
112	endforeach
113	if test_prog.found()
114		have_test_progs = true
115		headless_envlist += '@0@=@1@'.format(t[0], test_prog.path())
116	endif
117endforeach
118
119if weston_prog.found() and have_test_progs
120	test_headless = join_paths(meson.current_source_dir(), 'headless.py')
121	test('If clients crash when run with weston via waypipe', python3, args: test_headless, env: headless_envlist, timeout: 30)
122endif
123
124sleep_prog = find_program('sleep')
125startup_envlist = base_envlist
126startup_envlist += ['TEST_SLEEP_PATH=' + sleep_prog.path()]
127startup_envlist += ['TEST_FAKE_SSH_PATH=' + fake_ssh.full_path()]
128test_startup = join_paths(meson.current_source_dir(), 'startup_failure.py')
129test('That waypipe exits cleanly given a bad setup',
130        python3, args: test_startup, env: startup_envlist, timeout: 10
131)
132
133fuzz_hook_ext = executable(
134	'fuzz_hook_ext',
135	['fuzz_hook_ext.c'],
136	include_directories: waypipe_includes,
137	link_with: [lib_waypipe_src, common_src],
138	dependencies: [pthreads]
139)
140fuzz_hook_int = executable(
141	'fuzz_hook_int',
142	['fuzz_hook_int.c'],
143	include_directories: waypipe_includes,
144	link_with: [lib_waypipe_src, common_src],
145	dependencies: [pthreads]
146)
147fuzz_hook_det = executable(
148	'fuzz_hook_det',
149	['fuzz_hook_det.c'],
150	include_directories: waypipe_includes,
151	link_with: [lib_waypipe_src, common_src]
152)
153test('That `waypipe bench` doesn\'t crash',
154	waypipe_prog, timeout: 20,
155	args:  ['--threads', '2', '--test-size', '16384', 'bench', '100.0']
156)
157