1 common_gio_tests_deps = [
9 '-DG_LOG_DOMAIN="GLib-GIO"',
10 '-DTEST_SERVICES="@0@/gio/tests/services"'.format(meson.build_root()),
11 '-DGLIB_MKENUMS="@0@"'.format(glib_mkenums),
12 '-DGLIB_COMPILE_SCHEMAS="@0@"'.format(glib_compile_schemas.full_path()),
16 if host_machine.system() == 'windows'
17 common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')]
20 subdir('gdbus-object-manager-example')
22 gengiotypefuncs_prog = find_program('gengiotypefuncs.py')
23 giotypefuncs_inc = custom_target(
25 output : 'giotypefuncs.inc',
26 input : gio_headers + [gioenumtypes_h] + gobject_install_headers,
27 command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@'])
29 # Test programs buildable on all platforms
32 'async-close-output-stream' : {},
33 'async-splice-output-stream' : {},
34 'buffered-input-stream' : {},
35 'buffered-output-stream' : {},
39 'converter-stream' : {},
41 'data-input-stream' : {},
42 'data-output-stream' : {},
43 'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
44 'fileattributematcher' : {},
45 'filter-streams' : {},
51 'gdbus-addresses' : {},
55 'memory-input-stream' : {},
56 'memory-output-stream' : {},
57 'mount-operation' : {},
58 'network-address' : {'extra_sources': ['mock-resolver.c']},
59 'network-monitor' : {},
60 'network-monitor-race' : {},
65 'simple-async-result' : {},
69 'socket-listener' : {},
70 'socket-service' : {},
76 'testfilemonitor' : {'suite' : ['slow', 'flaky']},
77 'thumbnail-verification' : {},
78 'tls-certificate' : {'extra_sources' : ['gtesttlsbackend.c']},
79 'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']},
80 'tls-database' : {'extra_sources' : ['gtesttlsbackend.c']},
81 'gdbus-address-get-session' : {},
84 test_extra_programs = {
85 'gdbus-connection-flush-helper' : {},
86 'gdbus-testserver' : {},
87 'gsubprocess-testprog' : {},
90 test_env = environment()
91 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
92 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
93 test_env.set('GIO_MODULE_DIR', '')
94 test_env.set('GIO_LAUNCH_DESKTOP', meson.build_root() + '/gio/gio-launch-desktop')
96 # Check for libdbus1 - Optional - is only used in the GDBus test cases
97 # 1.2.14 required for dbus_message_set_serial
98 dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14')
99 if not dbus1_dep.found()
100 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
101 # MSVC: Search for the DBus library by the configuration, which corresponds
102 # to the output of CMake builds of DBus. Note that debugoptimized
103 # is really a Release build with .PDB files.
104 if buildtype == 'debug'
105 dbus1_dep = cc.find_library('dbus-1d', required : false)
107 dbus1_dep = cc.find_library('dbus-1', required : false)
112 glib_conf.set('HAVE_DBUS1', 1)
115 'gdbus-serialization' : {
116 'extra_sources' : ['gdbus-tests.c'],
117 'dependencies' : [dbus1_dep],
122 # Test programs buildable on UNIX only
123 if host_machine.system() != 'windows'
127 'dependencies' : [libgdbus_example_objectmanager_dep],
128 'install_rpath' : installed_tests_execdir
130 'gdbus-peer-object-manager' : {},
132 'socket-address' : {},
133 'stream-rw_all' : {},
137 'g-file-info-filesystem-readonly' : {},
138 'gschema-compile' : {'install' : false},
144 'gsocketclient-slow' : {
146 shared_library('slow-connect-preload',
147 'slow-connect-preload.c',
149 dependencies: libdl_dep,
150 install_dir : installed_tests_execdir,
151 install: installed_tests_enabled,
155 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir())
157 'installed_tests_env' : {
158 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir),
164 # Uninstalled because of the check-for-executable logic in DesktopAppInfo
165 # unable to find the installed executable
166 if not glib_have_cocoa
171 'desktop-app-info' : {
177 test_extra_programs += {
178 'basic-application' : {},
183 if not glib_have_cocoa
184 test_extra_programs += {
192 # Test programs that need to bring up a session bus (requires dbus-daemon)
193 have_dbus_daemon = find_program('dbus-daemon', required : false).found()
196 '--annotate', 'org.project.Bar', 'Key1', 'Value1',
197 '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
198 '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
199 '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
200 '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
201 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
202 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
203 '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
205 # Generate gdbus-test-codegen-generated.{c,h}
206 gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
207 input : ['test-codegen.xml'],
208 output : ['gdbus-test-codegen-generated.h',
209 'gdbus-test-codegen-generated.c'],
210 depend_files : gdbus_codegen_built_files,
211 command : [python, gdbus_codegen,
212 '--interface-prefix', 'org.project.',
213 '--output-directory', '@OUTDIR@',
214 '--generate-c-code', 'gdbus-test-codegen-generated',
215 '--c-generate-object-manager',
216 '--c-generate-autocleanup', 'all',
217 '--c-namespace', 'Foo_iGen',
218 '--generate-docbook', 'gdbus-test-codegen-generated-doc',
222 gdbus_test_codegen_generated_interface_info = [
223 custom_target('gdbus-test-codegen-generated-interface-info-h',
224 input : ['test-codegen.xml'],
225 output : ['gdbus-test-codegen-generated-interface-info.h'],
226 depend_files : gdbus_codegen_built_files,
227 command : [python, gdbus_codegen,
228 '--interface-info-header',
230 '--output', '@OUTPUT@',
232 custom_target('gdbus-test-codegen-generated-interface-info-c',
233 input : ['test-codegen.xml'],
234 output : ['gdbus-test-codegen-generated-interface-info.c'],
235 depend_files : gdbus_codegen_built_files,
236 command : [python, gdbus_codegen,
237 '--interface-info-body',
239 '--output', '@OUTPUT@',
243 extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
247 'extra_sources' : extra_sources,
250 'gdbus-auth' : {'extra_sources' : extra_sources},
251 'gdbus-bz627724' : {'extra_sources' : extra_sources},
252 'gdbus-close-pending' : {'extra_sources' : extra_sources},
253 'gdbus-connection' : {'extra_sources' : extra_sources},
254 'gdbus-connection-loss' : {'extra_sources' : extra_sources},
255 'gdbus-connection-slow' : {'extra_sources' : extra_sources},
256 'gdbus-error' : {'extra_sources' : extra_sources},
257 'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
259 'extra_sources' : extra_sources,
262 'gdbus-introspection' : {'extra_sources' : extra_sources},
263 'gdbus-names' : {'extra_sources' : extra_sources},
264 'gdbus-proxy' : {'extra_sources' : extra_sources},
265 'gdbus-proxy-threads' : {
266 'extra_sources' : extra_sources,
267 'dependencies' : [dbus1_dep],
269 'gdbus-proxy-unique-name' : {'extra_sources' : extra_sources},
270 'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources},
271 'gdbus-test-codegen' : {
272 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
274 'gdbus-threading' : {
275 'extra_sources' : extra_sources,
276 'suite' : ['slow', 'flaky'],
279 'extra_sources' : extra_sources,
283 'extra_sources' : [extra_sources, 'gnotification-server.c'],
285 'gdbus-test-codegen-old' : {
286 'source' : 'gdbus-test-codegen.c',
287 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
288 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
289 '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
291 'gapplication' : {'extra_sources' : extra_sources},
294 if not glib_have_cocoa
297 'extra_sources' : extra_sources,
301 endif # have_dbus_daemon
303 # This test is currently unreliable
304 executable('gdbus-overflow', 'gdbus-overflow.c',
305 c_args : test_c_args,
306 dependencies : common_gio_tests_deps,
307 install_dir : installed_tests_execdir,
308 install : installed_tests_enabled)
311 'gdbus-connection-flush' : {
312 'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
314 'gdbus-non-socket' : {
315 'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
319 # Generate test.mo from de.po using msgfmt
320 msgfmt = find_program('msgfmt', required : false)
322 subdir('de/LC_MESSAGES')
325 'extra_sources' : [test_mo],
326 'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()),
327 '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)],
334 # Test programs buildable on Windows only
335 if host_machine.system() == 'windows'
336 gio_tests += {'win32-streams' : {}}
339 if cc.get_id() != 'msvc'
342 'source' : 'autoptr.c',
347 test_extra_programs += {
348 'gio-du' : {'install' : false},
349 'echo-server' : {'install' : false},
350 'filter-cat' : {'install' : false},
351 'gapplication-example-actions' : {'install' : false},
352 'gapplication-example-cmdline' : {'install' : false},
353 'gapplication-example-cmdline2' : {'install' : false},
354 'gapplication-example-cmdline3' : {'install' : false},
355 'gapplication-example-cmdline4' : {'install' : false},
356 'gapplication-example-dbushooks' : {'install' : false},
357 'gapplication-example-open' : {'install' : false},
359 'extra_sources' : gdbus_daemon_sources,
362 'gdbus-example-export' : {'install' : false},
363 'gdbus-example-own-name' : {'install' : false},
364 'gdbus-example-peer' : {'install' : false},
365 'gdbus-example-proxy-subclass' : {'install' : false},
366 'gdbus-example-server' : {'install' : false},
367 'gdbus-example-subtree' : {'install' : false},
368 'gdbus-example-watch-name' : {'install' : false},
369 'gdbus-example-watch-proxy' : {'install' : false},
370 'httpd' : {'install' : false},
371 'proxy' : {'install' : false},
372 'resolver' : {'install' : false},
373 'send-data' : {'install' : false},
374 'socket-server' : {'install' : false},
376 'extra_sources' : ['gtlsconsoleinteraction.c'],
381 if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
382 test_extra_programs += {
383 # These three are manual-run tests because they need a session bus but don't bring one up themselves
384 # FIXME: these build but don't seem to work!
385 'gdbus-example-objectmanager-client' : {
386 'dependencies' : [libgdbus_example_objectmanager_dep],
389 'gdbus-example-objectmanager-server' : {
390 'dependencies' : [libgdbus_example_objectmanager_dep],
393 'gdbus-test-fixture' : {
394 'dependencies' : [libgdbus_example_objectmanager_dep],
400 if host_machine.system() != 'windows'
401 test_extra_programs += {
402 'gdbus-example-unix-fd-client' : {
408 appinfo_test_desktop_files = [
409 'appinfo-test-gnome.desktop',
410 'appinfo-test-notgnome.desktop',
411 'appinfo-test.desktop',
412 'appinfo-test2.desktop',
415 cdata = configuration_data()
416 if installed_tests_enabled
417 cdata.set('installed_tests_dir', installed_tests_execdir)
419 cdata.set('installed_tests_dir', meson.current_build_dir())
422 foreach appinfo_test_desktop_file : appinfo_test_desktop_files
423 if installed_tests_enabled
425 input: appinfo_test_desktop_file + '.in',
426 output: appinfo_test_desktop_file,
427 install_dir: installed_tests_execdir,
428 configuration: cdata,
432 input: appinfo_test_desktop_file + '.in',
433 output: appinfo_test_desktop_file,
434 configuration: cdata,
439 if installed_tests_enabled
443 'appinfo-test-actions.desktop',
444 'appinfo-test-static.desktop',
446 'org.gtk.test.dbusappinfo.desktop',
448 install_dir : installed_tests_execdir,
450 install_subdir('x-content', install_dir : installed_tests_execdir)
451 install_subdir('desktop-files', install_dir : installed_tests_execdir)
452 install_subdir('thumbnails', install_dir : installed_tests_execdir)
453 install_subdir('cert-tests', install_dir : installed_tests_execdir)
455 cdata = configuration_data()
456 cdata.set('installed_tests_dir', installed_tests_execdir)
457 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
459 input: installed_tests_template,
460 output: 'static-link.test',
461 install_dir: installed_tests_metadir,
464 install_subdir('static-link', install_dir : installed_tests_execdir)
465 install_data('static-link.py', install_dir : installed_tests_execdir)
468 if not meson.is_cross_build() or meson.has_exe_wrapper()
470 plugin_resources_c = custom_target('plugin-resources.c',
471 input : 'test4.gresource.xml',
472 output : 'plugin-resources.c',
473 command : [glib_compile_resources,
475 '--sourcedir=' + meson.current_source_dir(),
477 '--c-name', '_g_plugin',
480 shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
481 link_args : export_dynamic_ldflags,
482 dependencies : common_gio_tests_deps,
483 install_dir : installed_tests_execdir,
484 install : installed_tests_enabled
487 # referenced by test2.gresource.xml
488 big_test_resource = custom_target(
489 'gresource-big-test.txt',
490 input : ['gen-big-test-resource.py'],
491 output : ['gresource-big-test.txt'],
492 command : [python, '@INPUT0@', '@OUTPUT@'])
494 test_gresource = custom_target('test.gresource',
495 input : 'test.gresource.xml',
496 output : 'test.gresource',
497 command : [glib_compile_resources,
499 '--sourcedir=' + meson.current_source_dir(),
500 '--sourcedir=' + meson.current_build_dir(),
502 install_dir : installed_tests_execdir,
503 install : installed_tests_enabled)
505 test_resources2_c = custom_target('test_resources2.c',
506 input : 'test3.gresource.xml',
507 output : 'test_resources2.c',
508 command : [glib_compile_resources,
510 '--sourcedir=' + meson.current_source_dir(),
512 '--c-name', '_g_test2',
516 test_resources2_h = custom_target('test_resources2.h',
517 input : 'test3.gresource.xml',
518 output : 'test_resources2.h',
519 command : [glib_compile_resources,
521 '--sourcedir=' + meson.current_source_dir(),
523 '--c-name', '_g_test2',
527 test_resources_c = custom_target('test_resources.c',
528 input : 'test2.gresource.xml',
529 depends : big_test_resource,
530 output : 'test_resources.c',
531 command : [glib_compile_resources,
533 '--sourcedir=' + meson.current_source_dir(),
534 '--sourcedir=' + meson.current_build_dir(),
536 '--c-name', '_g_test1',
539 digit_test_resources_c = custom_target('digit_test_resources.c',
540 input : '111_digit_test.gresource.xml',
541 output : 'digit_test_resources.c',
542 command : [glib_compile_resources,
544 '--sourcedir=' + meson.current_source_dir(),
545 '--sourcedir=' + meson.current_build_dir(),
550 digit_test_resources_h = custom_target('digit_test_resources.h',
551 input : '111_digit_test.gresource.xml',
552 output : 'digit_test_resources.h',
553 command : [glib_compile_resources,
555 '--sourcedir=' + meson.current_source_dir(),
560 # referenced by test.gresource.xml
561 test_generated_txt = configure_file(input : 'test1.txt',
562 output : 'test-generated.txt',
566 resources_extra_sources = [
571 digit_test_resources_c,
572 digit_test_resources_h,
575 # Create object file containing resource data for testing the --external-data
576 # option. Currently only GNU ld and GNU objcopy support the right options.
577 # Support for --add-symbol was added to LLVM objcopy in 2019
578 # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for
579 # LLVM once that support is in a stable release.
580 objcopy = find_program('objcopy', required : false)
582 if build_machine.system() == 'linux' and cc.get_id() == 'gcc' and objcopy.found()
583 test_gresource_binary = custom_target('test5.gresource',
584 input : 'test5.gresource.xml',
585 output : 'test5.gresource',
586 command : [glib_compile_resources,
588 '--sourcedir=' + meson.current_source_dir(),
589 '--sourcedir=' + meson.current_build_dir(),
591 install_dir : installed_tests_execdir,
592 install : installed_tests_enabled)
594 # Create resource data file
595 test_resources_binary_c = custom_target('test_resources_binary.c',
596 input : 'test5.gresource.xml',
597 output : 'test_resources_binary.c',
598 command : [glib_compile_resources,
600 '--sourcedir=' + meson.current_source_dir(),
601 '--sourcedir=' + meson.current_build_dir(),
604 '--c-name', '_g_binary_test1',
607 # Create object file containing resource data
608 test_resources_binary = custom_target('test_resources.o',
609 input : test_gresource_binary,
610 output : 'test_resources.o',
617 # Rename symbol to match the one in the C file
618 test_resources_binary2 = custom_target('test_resources2.o',
619 input : test_resources_binary,
620 output : 'test_resources2.o',
622 '--add-symbol','_g_binary_test1_resource_data=.data:0',
626 resources_extra_sources += [
627 test_resources_binary_c,
628 test_resources_binary2,
634 'extra_sources' : resources_extra_sources,
639 foreach test_name, extra_args : gio_tests
640 source = extra_args.get('source', test_name + '.c')
641 extra_sources = extra_args.get('extra_sources', [])
642 install = installed_tests_enabled and extra_args.get('install', true)
643 installed_tests_env = extra_args.get('installed_tests_env', {})
646 test_conf = configuration_data()
647 test_conf.set('installed_tests_dir', installed_tests_execdir)
648 test_conf.set('program', test_name)
649 test_env_override = ''
650 if installed_tests_env != {}
652 foreach var, value : installed_tests_env
653 envs += '@0@=@1@'.format(var, value)
655 test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs))
657 test_conf.set('env', test_env_override)
659 input: installed_tests_template_tap,
660 output: test_name + '.test',
661 install_dir: installed_tests_metadir,
662 configuration: test_conf
666 exe = executable(test_name, [source, extra_sources],
667 c_args : test_c_args + extra_args.get('c_args', []),
668 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
669 install_rpath : extra_args.get('install_rpath', ''),
670 install_dir: installed_tests_execdir,
674 suite = ['gio'] + extra_args.get('suite', [])
675 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
676 local_test_env = test_env
678 foreach var, value : extra_args.get('env', {})
679 local_test_env.append(var, value)
683 env : local_test_env,
686 is_parallel : extra_args.get('is_parallel', true),
687 depends : extra_args.get('depends', []),
691 foreach program_name, extra_args : test_extra_programs
692 source = extra_args.get('source', program_name + '.c')
693 extra_sources = extra_args.get('extra_sources', [])
694 install = installed_tests_enabled and extra_args.get('install', true)
695 executable(program_name, [source, extra_sources],
696 c_args : test_c_args,
697 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
698 install_dir : installed_tests_execdir,
703 # FIXME: subdir('services')