meson.build 9.8 KB
Newer Older
Daniel Stone's avatar
Daniel Stone committed
1 2 3
plugin_test_shell_desktop = shared_library(
	'weston-test-desktop-shell',
	'weston-test-desktop-shell.c',
4
	include_directories: common_inc,
5
	dependencies: [ dep_lib_desktop, dep_libweston_public ],
Daniel Stone's avatar
Daniel Stone committed
6 7 8 9 10 11 12 13
	name_prefix: '',
	install: false
)
env_modmap += 'weston-test-desktop-shell.so=@0@;'.format(plugin_test_shell_desktop.full_path())

lib_test_runner = static_library(
	'test-runner',
	'weston-test-runner.c',
14 15 16 17
	dependencies: [
		dep_libweston_private_h_deps,
		dep_wayland_client,
	],
18
	include_directories: common_inc,
Daniel Stone's avatar
Daniel Stone committed
19 20
	install: false,
)
21 22 23 24
dep_test_runner = declare_dependency(
	dependencies: dep_wayland_client,
	link_with: lib_test_runner
)
Daniel Stone's avatar
Daniel Stone committed
25 26 27

lib_test_client = static_library(
	'test-client',
28 29 30 31 32 33
	[
		'weston-test-client-helper.c',
		'weston-test-fixture-compositor.c',
		weston_test_client_protocol_h,
		weston_test_protocol_c,
	],
34
	include_directories: common_inc,
Daniel Stone's avatar
Daniel Stone committed
35 36 37
	dependencies: [
		dep_libshared,
		dep_wayland_client,
38
		dep_libexec_weston,
Daniel Stone's avatar
Daniel Stone committed
39 40 41 42 43 44 45 46
		dep_pixman,
		dependency('cairo'),
	],
	install: false,
)
dep_test_client = declare_dependency(
	link_with: lib_test_client,
	dependencies: [
47
		dep_wayland_client,
Daniel Stone's avatar
Daniel Stone committed
48 49 50 51 52 53 54 55 56 57
		dep_test_runner,
		dep_pixman,
	]
)

exe_plugin_test = shared_library(
	'test-plugin',
	'weston-test.c',
	weston_test_server_protocol_h,
	weston_test_protocol_c,
58
	include_directories: common_inc,
59 60 61 62 63
	dependencies: [
		dep_libexec_weston,
		dep_libweston_private,
		dep_threads
	],
Daniel Stone's avatar
Daniel Stone committed
64 65 66 67 68 69
	name_prefix: '',
	install: false,
)

deps_zuc = [ dep_libshared ]
if get_option('test-junit-xml')
70 71 72 73 74
	d = dependency('libxml-2.0', version: '>= 2.6', required: false)
	if not d.found()
		error('JUnit XML support requires libxml-2.0 >= 2.6 which was not found. Or, you can use \'-Dtest-junit-xml=false\'.')
	endif
	deps_zuc += d
Daniel Stone's avatar
Daniel Stone committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
	config_h.set('ENABLE_JUNIT_XML', '1')
endif

lib_zuc = static_library(
	'zunitc',
	'../tools/zunitc/inc/zunitc/zunitc.h',
	'../tools/zunitc/inc/zunitc/zunitc_impl.h',
	'../tools/zunitc/src/zuc_base_logger.c',
	'../tools/zunitc/src/zuc_base_logger.h',
	'../tools/zunitc/src/zuc_collector.c',
	'../tools/zunitc/src/zuc_collector.h',
	'../tools/zunitc/src/zuc_context.h',
	'../tools/zunitc/src/zuc_event.h',
	'../tools/zunitc/src/zuc_event_listener.h',
	'../tools/zunitc/src/zuc_junit_reporter.c',
	'../tools/zunitc/src/zuc_junit_reporter.h',
	'../tools/zunitc/src/zuc_types.h',
	'../tools/zunitc/src/zunitc_impl.c',
93
	include_directories: [ common_inc, include_directories('../tools/zunitc/inc') ],
Daniel Stone's avatar
Daniel Stone committed
94 95 96 97 98 99 100 101 102 103 104
	dependencies: deps_zuc,
)
dep_zuc = declare_dependency(
	link_with: lib_zuc,
	dependencies: dep_libshared,
	include_directories: include_directories('../tools/zunitc/inc')
)

lib_zucmain = static_library(
	'zunitcmain',
	'../tools/zunitc/src/main.c',
105
	include_directories: [ common_inc, include_directories('../tools/zunitc/inc') ],
Daniel Stone's avatar
Daniel Stone committed
106 107 108 109 110 111 112
	dependencies: [ dep_libshared, dep_zuc ],
)
dep_zucmain = declare_dependency(
	link_with: lib_zucmain,
	dependencies: dep_zuc
)

113
tests = [
Pekka Paalanen's avatar
Pekka Paalanen committed
114
	{	'name': 'bad-buffer', },
Pekka Paalanen's avatar
Pekka Paalanen committed
115
	{	'name': 'devices', },
Pekka Paalanen's avatar
Pekka Paalanen committed
116
	{	'name': 'event', },
117
	{	'name': 'internal-screenshot', },
Pekka Paalanen's avatar
Pekka Paalanen committed
118 119 120 121 122 123 124 125 126
	{
		'name': 'keyboard',
		'sources': [
			'keyboard-test.c',
			'input-timestamps-helper.c',
			input_timestamps_unstable_v1_client_protocol_h,
			input_timestamps_unstable_v1_protocol_c,
		],
	},
127
	{	'name': 'plugin-registry', },
Pekka Paalanen's avatar
Pekka Paalanen committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
	{
		'name': 'pointer',
		'sources': [
			'pointer-test.c',
			'input-timestamps-helper.c',
			input_timestamps_unstable_v1_client_protocol_h,
			input_timestamps_unstable_v1_protocol_c,
		],
	},
	{
		'name': 'presentation',
		'sources': [
			'presentation-test.c',
			presentation_time_client_protocol_h,
			presentation_time_protocol_c,
		],
	},
145
	{	'name': 'roles', },
146
	{	'name': 'string', },
Pekka Paalanen's avatar
Pekka Paalanen committed
147
	{	'name': 'subsurface', },
148
	{	'name': 'subsurface-shot', },
149 150
	{	'name': 'surface', },
	{	'name': 'surface-global', },
Pekka Paalanen's avatar
Pekka Paalanen committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
	{
		'name': 'text',
		'sources': [
			'text-test.c',
			text_input_unstable_v1_client_protocol_h,
			text_input_unstable_v1_protocol_c,
		],
	},
	{
		'name': 'touch',
		'sources': [
			'touch-test.c',
			'input-timestamps-helper.c',
			input_timestamps_unstable_v1_client_protocol_h,
			input_timestamps_unstable_v1_protocol_c,
		],
	},
168 169 170 171
	{
		'name': 'vertex-clip',
		'dep_objs': dep_vertex_clipping,
	},
Pekka Paalanen's avatar
Pekka Paalanen committed
172 173 174 175 176 177 178 179
	{
		'name': 'viewporter',
		'sources': [
			'viewporter-test.c',
			viewporter_client_protocol_h,
			viewporter_protocol_c,
		],
	},
180 181
]

Daniel Stone's avatar
Daniel Stone committed
182 183
tests_standalone = [
	['config-parser', [], [ dep_zucmain ]],
184
	['matrix', [], [ dep_libm, dep_matrix_c ]],
Daniel Stone's avatar
Daniel Stone committed
185 186 187 188 189 190 191 192 193 194 195
	['timespec', [], [ dep_zucmain ]],
	['zuc',
		[
			'../tools/zunitc/test/fixtures_test.c',
			'../tools/zunitc/test/zunitc_test.c'
		],
		[ dep_zucmain ]
	],
]

tests_weston = [
196 197 198 199 200 201 202
	[
		'linux-explicit-synchronization',
		[
			linux_explicit_synchronization_unstable_v1_client_protocol_h,
			linux_explicit_synchronization_unstable_v1_protocol_c,
		]
	],
Daniel Stone's avatar
Daniel Stone committed
203 204 205
]

if get_option('xwayland')
206 207 208 209 210
	d = dependency('x11', required: false)
	if not d.found()
		error('Xwayland tests require libX11 which was not found. Or, you can use \'-Dxwayland=false\'.')
	endif
	tests_weston += [ [ 'xwayland', [], d ] ]
Daniel Stone's avatar
Daniel Stone committed
211 212
endif

213 214 215 216 217 218 219 220 221
# Manual test plugin, not used in the automatic suite
surface_screenshot_test = shared_library(
	'test-surface-screenshot',
	'surface-screenshot-test.c',
	include_directories: common_inc,
	dependencies: [ dep_libweston_private, dep_libshared ],
	name_prefix: '',
	install: false,
)
Daniel Stone's avatar
Daniel Stone committed
222 223

if get_option('shell-ivi')
224 225 226 227 228 229 230
	ivi_layout_test_plugin = shared_library(
		'test-ivi-layout',
		[
			'ivi-layout-test-plugin.c',
			weston_test_server_protocol_h,
			weston_test_protocol_c,
		],
231
		include_directories: common_inc,
232 233 234
		dependencies: [ dep_libweston_private, dep_libexec_weston ],
		name_prefix: '',
		install: false,
Daniel Stone's avatar
Daniel Stone committed
235
	)
236
	env_modmap += 'test-ivi-layout.so=' + ivi_layout_test_plugin.full_path() + ';'
Daniel Stone's avatar
Daniel Stone committed
237

238 239 240 241 242 243 244 245 246 247
	tests += [
		{
			'name': 'ivi-layout-client',
			'sources': [
				'ivi-layout-test-client.c',
				ivi_application_client_protocol_h,
				ivi_application_protocol_c,
			],
			'test_deps': [ ivi_layout_test_plugin ],
		},
248
		{	'name': 'ivi-layout-internal', },
Pekka Paalanen's avatar
Pekka Paalanen committed
249 250 251 252 253 254 255 256
		{
			'name': 'ivi-shell-app',
			'sources': [
				'ivi-shell-app-test.c',
				ivi_application_client_protocol_h,
				ivi_application_protocol_c,
			],
		},
257
	]
Daniel Stone's avatar
Daniel Stone committed
258 259 260 261 262
endif

env_test_weston = [
	'WESTON_TEST_REFERENCE_PATH=@0@/reference'.format(meson.current_source_dir()),
	'WESTON_MODULE_MAP=@0@'.format(env_modmap),
263
	'WESTON_DATA_DIR=' + join_paths(meson.current_source_dir(), '..', 'data'),
Daniel Stone's avatar
Daniel Stone committed
264 265
]

266 267 268 269 270
test_config_h = configuration_data()
test_config_h.set_quoted('WESTON_TEST_REFERENCE_PATH', meson.current_source_dir() + '/reference')
test_config_h.set_quoted('WESTON_MODULE_MAP', env_modmap)
test_config_h.set_quoted('WESTON_DATA_DIR', join_paths(meson.current_source_dir(), '..', 'data'))
test_config_h.set_quoted('TESTSUITE_PLUGIN_PATH', exe_plugin_test.full_path())
Pekka Paalanen's avatar
Pekka Paalanen committed
271
test_config_h.set_quoted('TESTSUITE_IVI_CONFIG_PATH', join_paths(meson.current_build_dir(), '../ivi-shell/weston-ivi-test.ini'))
272
test_config_h.set_quoted('TESTSUITE_INTERNAL_SCREENSHOT_CONFIG_PATH', join_paths(meson.current_source_dir(), 'internal-screenshot.ini'))
273 274
configure_file(output: 'test-config.h', configuration: test_config_h)

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
foreach t : tests
	t_name = 'test-' + t.get('name')
	t_sources = t.get('sources', [t.get('name') + '-test.c'])
	t_sources += weston_test_client_protocol_h

	t_deps = [ dep_test_client, dep_libweston_private_h ]
	t_deps += t.get('dep_objs', [])

	t_exe = executable(
		t_name,
		t_sources,
		c_args: [
			'-DUNIT_TEST',
			'-DTHIS_TEST_NAME="' + t_name + '"',
		],
		build_by_default: true,
		include_directories: common_inc,
		dependencies: t_deps,
		install: false,
	)

296
	test(t.get('name'), t_exe, depends: t.get('test_deps', []))
297 298
endforeach

Daniel Stone's avatar
Daniel Stone committed
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
# FIXME: the multiple loops is lame. rethink this.
foreach t : tests_standalone
	if t[0] != 'zuc'
		srcs_t = [
			'@0@-test.c'.format(t.get(0)),
			weston_test_client_protocol_h,
		]
	else
		srcs_t = []
	endif

	if t.length() > 1
		srcs_t += t.get(1)
	endif

	if t.length() > 2
		deps_t = t[2]
	else
		deps_t = [ dep_test_client ]
	endif

	exe_t = executable(
		'test-@0@'.format(t.get(0)),
		srcs_t,
		c_args: [ '-DUNIT_TEST' ],
		build_by_default: true,
325
		include_directories: common_inc,
Daniel Stone's avatar
Daniel Stone committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
		dependencies: deps_t,
		install: false,
	)

	# matrix-test is a manual test
	if t[0] != 'matrix'
		test(t.get(0), exe_t)
	endif
endforeach

foreach t : tests_weston
	srcs_t = [
		'@0@-test.c'.format(t.get(0)),
		weston_test_client_protocol_h,
	]
	if t.length() > 1
		srcs_t += t.get(1)
	endif

	deps_t = [
		dep_test_client
	]
	if t.length() > 2
		deps_t += t.get(2)
	endif

	args_t = [
		'--backend=headless-backend.so',
		'--socket=test-@0@'.format(t.get(0)),
		'--modules=@0@'.format(exe_plugin_test.full_path()),
		'--width=320',
		'--height=240',
	]

	if t.get(0) == 'xwayland'
		args_t += '--xwayland'
	endif

	# FIXME: Get this from the array ... ?
	if t.get(0) == 'internal-screenshot'
		args_t += [ '--config=@0@/internal-screenshot.ini'.format(meson.current_source_dir()) ]
		args_t += [ '--use-pixman' ]
		args_t += [ '--shell=desktop-shell.so' ]
	elif t[0] == 'subsurface-shot'
		args_t += [ '--no-config' ]
		args_t += [ '--use-pixman' ]
		args_t += [ '--width=320' ]
		args_t += [ '--height=240' ]
		args_t += [ '--shell=weston-test-desktop-shell.so' ]
375 376
	elif t.get(0) == 'linux-explicit-synchronization'
		args_t += [ '--use-pixman' ]
Daniel Stone's avatar
Daniel Stone committed
377 378 379 380 381 382 383 384 385 386 387 388
	elif t.get(0).startswith('ivi-')
		args_t += [ '--config=@0@/../ivi-shell/weston-ivi-test.ini'.format(meson.current_build_dir()) ]
		args_t += [ '--shell=ivi-shell.so' ]
	else
		args_t += [ '--no-config' ]
		args_t += [ '--shell=desktop-shell.so' ]
	endif

	exe_t = executable(
		'test-@0@'.format(t.get(0)),
		srcs_t,
		c_args: [ '-DUNIT_TEST' ],
389
		include_directories: common_inc,
Daniel Stone's avatar
Daniel Stone committed
390 391 392 393 394 395 396 397 398 399 400 401
		dependencies: deps_t,
		install: false,
	)

	env_t = [
		'WESTON_TEST_CLIENT_PATH=@0@'.format(exe_t.full_path())
	]
	env_t += env_test_weston

	test(t.get(0), exe_weston, env: env_t, args: args_t)
endforeach

Pekka Paalanen's avatar
Pekka Paalanen committed
402 403 404 405 406 407 408 409 410
if get_option('backend-drm')
	executable(
		'setbacklight',
		'setbacklight.c',
		dependencies: [
			dep_backlight,
			dep_libdrm,
			dependency('libudev')
		],
411
		include_directories: common_inc,
Pekka Paalanen's avatar
Pekka Paalanen committed
412 413 414
		install: false
	)
endif