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'
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},
143 # FIXME: This list will probably grow; see
144 # https://gitlab.gnome.org/GNOME/glib/issues/1739
145 no_libdl_systems = ['freebsd', 'netbsd', 'openbsd']
148 'gsocketclient-slow' : {
150 shared_library('slow-connect-preload',
151 'slow-connect-preload.c',
153 dependencies: cc.find_library('dl', required: not no_libdl_systems.contains(host_machine.system())),
154 install_dir : installed_tests_execdir,
155 install: installed_tests_enabled,
159 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir())
161 'installed_tests_env' : {
162 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir),
168 # Uninstalled because of the check-for-executable logic in DesktopAppInfo
169 # unable to find the installed executable
170 if not glib_have_cocoa
175 'desktop-app-info' : {
181 test_extra_programs += {
182 'basic-application' : {},
187 if not glib_have_cocoa
188 test_extra_programs += {
196 # Test programs that need to bring up a session bus (requires dbus-daemon)
197 have_dbus_daemon = find_program('dbus-daemon', required : false).found()
200 '--annotate', 'org.project.Bar', 'Key1', 'Value1',
201 '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
202 '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
203 '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
204 '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
205 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
206 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
207 '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
209 # Generate gdbus-test-codegen-generated.{c,h}
210 gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
211 input : ['test-codegen.xml'],
212 output : ['gdbus-test-codegen-generated.h',
213 'gdbus-test-codegen-generated.c'],
214 depend_files : gdbus_codegen_built_files,
215 command : [python, gdbus_codegen,
216 '--interface-prefix', 'org.project.',
217 '--output-directory', '@OUTDIR@',
218 '--generate-c-code', 'gdbus-test-codegen-generated',
219 '--c-generate-object-manager',
220 '--c-generate-autocleanup', 'all',
221 '--c-namespace', 'Foo_iGen',
222 '--generate-docbook', 'gdbus-test-codegen-generated-doc',
226 gdbus_test_codegen_generated_interface_info = [
227 custom_target('gdbus-test-codegen-generated-interface-info-h',
228 input : ['test-codegen.xml'],
229 output : ['gdbus-test-codegen-generated-interface-info.h'],
230 depend_files : gdbus_codegen_built_files,
231 command : [python, gdbus_codegen,
232 '--interface-info-header',
234 '--output', '@OUTPUT@',
236 custom_target('gdbus-test-codegen-generated-interface-info-c',
237 input : ['test-codegen.xml'],
238 output : ['gdbus-test-codegen-generated-interface-info.c'],
239 depend_files : gdbus_codegen_built_files,
240 command : [python, gdbus_codegen,
241 '--interface-info-body',
243 '--output', '@OUTPUT@',
247 extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
251 'extra_sources' : extra_sources,
254 'gdbus-auth' : {'extra_sources' : extra_sources},
255 'gdbus-bz627724' : {'extra_sources' : extra_sources},
256 'gdbus-close-pending' : {'extra_sources' : extra_sources},
257 'gdbus-connection' : {'extra_sources' : extra_sources},
258 'gdbus-connection-loss' : {'extra_sources' : extra_sources},
259 'gdbus-connection-slow' : {'extra_sources' : extra_sources},
260 'gdbus-error' : {'extra_sources' : extra_sources},
261 'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
263 'extra_sources' : extra_sources,
266 'gdbus-introspection' : {'extra_sources' : extra_sources},
267 'gdbus-names' : {'extra_sources' : extra_sources},
268 'gdbus-proxy' : {'extra_sources' : extra_sources},
269 'gdbus-proxy-threads' : {
270 'extra_sources' : extra_sources,
271 'dependencies' : [dbus1_dep],
273 'gdbus-proxy-unique-name' : {'extra_sources' : extra_sources},
274 'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources},
275 'gdbus-test-codegen' : {
276 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
278 'gdbus-threading' : {
279 'extra_sources' : extra_sources,
280 'suite' : ['slow', 'flaky'],
283 'extra_sources' : extra_sources,
287 'extra_sources' : [extra_sources, 'gnotification-server.c'],
289 'gdbus-test-codegen-old' : {
290 'source' : 'gdbus-test-codegen.c',
291 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
292 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
293 '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
295 'gapplication' : {'extra_sources' : extra_sources},
298 if not glib_have_cocoa
301 'extra_sources' : extra_sources,
305 endif # have_dbus_daemon
307 # This test is currently unreliable
308 executable('gdbus-overflow', 'gdbus-overflow.c',
309 c_args : test_c_args,
310 dependencies : common_gio_tests_deps,
311 install_dir : installed_tests_execdir,
312 install : installed_tests_enabled)
315 'gdbus-connection-flush' : {
316 'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
318 'gdbus-non-socket' : {
319 'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
323 # Generate test.mo from de.po using msgfmt
324 msgfmt = find_program('msgfmt', required : false)
326 subdir('de/LC_MESSAGES')
329 'extra_sources' : [test_mo],
330 'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()),
331 '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)],
338 # Test programs buildable on Windows only
339 if host_machine.system() == 'windows'
340 gio_tests += {'win32-streams' : {}}
343 if cc.get_id() != 'msvc'
346 'source' : 'autoptr.c',
351 test_extra_programs += {
352 'gio-du' : {'install' : false},
353 'echo-server' : {'install' : false},
354 'filter-cat' : {'install' : false},
355 'gapplication-example-actions' : {'install' : false},
356 'gapplication-example-cmdline' : {'install' : false},
357 'gapplication-example-cmdline2' : {'install' : false},
358 'gapplication-example-cmdline3' : {'install' : false},
359 'gapplication-example-cmdline4' : {'install' : false},
360 'gapplication-example-dbushooks' : {'install' : false},
361 'gapplication-example-open' : {'install' : false},
363 'extra_sources' : gdbus_daemon_sources,
366 'gdbus-example-export' : {'install' : false},
367 'gdbus-example-own-name' : {'install' : false},
368 'gdbus-example-peer' : {'install' : false},
369 'gdbus-example-proxy-subclass' : {'install' : false},
370 'gdbus-example-server' : {'install' : false},
371 'gdbus-example-subtree' : {'install' : false},
372 'gdbus-example-watch-name' : {'install' : false},
373 'gdbus-example-watch-proxy' : {'install' : false},
374 'httpd' : {'install' : false},
375 'proxy' : {'install' : false},
376 'resolver' : {'install' : false},
377 'send-data' : {'install' : false},
378 'socket-server' : {'install' : false},
380 'extra_sources' : ['gtlsconsoleinteraction.c'],
385 if cc.get_id() != 'msvc'
386 test_extra_programs += {
387 # These three are manual-run tests because they need a session bus but don't bring one up themselves
388 # FIXME: these build but don't seem to work!
389 'gdbus-example-objectmanager-client' : {
390 'dependencies' : [libgdbus_example_objectmanager_dep],
393 'gdbus-example-objectmanager-server' : {
394 'dependencies' : [libgdbus_example_objectmanager_dep],
397 'gdbus-test-fixture' : {
398 'dependencies' : [libgdbus_example_objectmanager_dep],
404 if host_machine.system() != 'windows'
405 test_extra_programs += {
406 'gdbus-example-unix-fd-client' : {
412 appinfo_test_desktop_files = [
413 'appinfo-test-gnome.desktop',
414 'appinfo-test-notgnome.desktop',
415 'appinfo-test.desktop',
416 'appinfo-test2.desktop',
419 cdata = configuration_data()
420 if installed_tests_enabled
421 cdata.set('installed_tests_dir', installed_tests_execdir)
423 cdata.set('installed_tests_dir', meson.current_build_dir())
426 foreach appinfo_test_desktop_file : appinfo_test_desktop_files
428 input: appinfo_test_desktop_file + '.in',
429 output: appinfo_test_desktop_file,
430 install_dir: installed_tests_execdir,
431 install: installed_tests_enabled,
432 configuration: cdata,
436 if installed_tests_enabled
440 'appinfo-test-actions.desktop',
441 'appinfo-test-static.desktop',
443 'org.gtk.test.dbusappinfo.desktop',
445 install_dir : installed_tests_execdir,
447 install_subdir('x-content', install_dir : installed_tests_execdir)
448 install_subdir('desktop-files', install_dir : installed_tests_execdir)
449 install_subdir('thumbnails', install_dir : installed_tests_execdir)
450 install_subdir('cert-tests', install_dir : installed_tests_execdir)
452 cdata = configuration_data()
453 cdata.set('installed_tests_dir', installed_tests_execdir)
454 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
456 input: installed_tests_template,
457 output: 'static-link.test',
458 install_dir: installed_tests_metadir,
461 install_subdir('static-link', install_dir : installed_tests_execdir)
462 install_data('static-link.py', install_dir : installed_tests_execdir)
465 if not meson.is_cross_build() or meson.has_exe_wrapper()
467 plugin_resources_c = custom_target('plugin-resources.c',
468 input : 'test4.gresource.xml',
469 output : 'plugin-resources.c',
470 command : [glib_compile_resources,
472 '--sourcedir=' + meson.current_source_dir(),
474 '--c-name', '_g_plugin',
477 shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
478 link_args : export_dynamic_ldflags,
479 dependencies : common_gio_tests_deps,
480 install_dir : installed_tests_execdir,
481 install : installed_tests_enabled
484 # referenced by test2.gresource.xml
485 big_test_resource = custom_target(
486 'gresource-big-test.txt',
487 input : ['gen-big-test-resource.py'],
488 output : ['gresource-big-test.txt'],
489 command : [python, '@INPUT0@', '@OUTPUT@'])
491 test_gresource = custom_target('test.gresource',
492 input : 'test.gresource.xml',
493 output : 'test.gresource',
494 command : [glib_compile_resources,
496 '--sourcedir=' + meson.current_source_dir(),
497 '--sourcedir=' + meson.current_build_dir(),
499 install_dir : installed_tests_execdir,
500 install : installed_tests_enabled)
502 test_resources2_c = custom_target('test_resources2.c',
503 input : 'test3.gresource.xml',
504 output : 'test_resources2.c',
505 command : [glib_compile_resources,
507 '--sourcedir=' + meson.current_source_dir(),
509 '--c-name', '_g_test2',
513 test_resources2_h = custom_target('test_resources2.h',
514 input : 'test3.gresource.xml',
515 output : 'test_resources2.h',
516 command : [glib_compile_resources,
518 '--sourcedir=' + meson.current_source_dir(),
520 '--c-name', '_g_test2',
524 test_resources_c = custom_target('test_resources.c',
525 input : 'test2.gresource.xml',
526 depends : big_test_resource,
527 output : 'test_resources.c',
528 command : [glib_compile_resources,
530 '--sourcedir=' + meson.current_source_dir(),
531 '--sourcedir=' + meson.current_build_dir(),
533 '--c-name', '_g_test1',
536 digit_test_resources_c = custom_target('digit_test_resources.c',
537 input : '111_digit_test.gresource.xml',
538 output : 'digit_test_resources.c',
539 command : [glib_compile_resources,
541 '--sourcedir=' + meson.current_source_dir(),
542 '--sourcedir=' + meson.current_build_dir(),
547 digit_test_resources_h = custom_target('digit_test_resources.h',
548 input : '111_digit_test.gresource.xml',
549 output : 'digit_test_resources.h',
550 command : [glib_compile_resources,
552 '--sourcedir=' + meson.current_source_dir(),
557 # referenced by test.gresource.xml
558 test_generated_txt = configure_file(input : 'test1.txt',
559 output : 'test-generated.txt',
563 resources_extra_sources = [
568 digit_test_resources_c,
569 digit_test_resources_h,
572 # Create object file containing resource data for testing the --external-data
573 # option. Currently only GNU ld and GNU objcopy support the right options.
574 # Support for --add-symbol was added to LLVM objcopy in 2019
575 # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for
576 # LLVM once that support is in a stable release.
577 if build_machine.system() == 'linux' and cc.get_id() == 'gcc'
578 test_gresource_binary = custom_target('test5.gresource',
579 input : 'test5.gresource.xml',
580 output : 'test5.gresource',
581 command : [glib_compile_resources,
583 '--sourcedir=' + meson.current_source_dir(),
584 '--sourcedir=' + meson.current_build_dir(),
586 install_dir : installed_tests_execdir,
587 install : installed_tests_enabled)
589 # Create resource data file
590 test_resources_binary_c = custom_target('test_resources_binary.c',
591 input : 'test5.gresource.xml',
592 output : 'test_resources_binary.c',
593 command : [glib_compile_resources,
595 '--sourcedir=' + meson.current_source_dir(),
596 '--sourcedir=' + meson.current_build_dir(),
599 '--c-name', '_g_binary_test1',
602 # Create object file containing resource data
603 test_resources_binary = custom_target('test_resources.o',
604 input : test_gresource_binary,
605 output : 'test_resources.o',
612 # Rename symbol to match the one in the C file
613 test_resources_binary2 = custom_target('test_resources2.o',
614 input : test_resources_binary,
615 output : 'test_resources2.o',
616 command : ['objcopy',
617 '--add-symbol','_g_binary_test1_resource_data=.data:0',
621 resources_extra_sources += [
622 test_resources_binary_c,
623 test_resources_binary2,
629 'extra_sources' : resources_extra_sources,
634 foreach test_name, extra_args : gio_tests
635 source = extra_args.get('source', test_name + '.c')
636 extra_sources = extra_args.get('extra_sources', [])
637 install = installed_tests_enabled and extra_args.get('install', true)
638 installed_tests_env = extra_args.get('installed_tests_env', {})
641 test_conf = configuration_data()
642 test_conf.set('installed_tests_dir', installed_tests_execdir)
643 test_conf.set('program', test_name)
644 test_env_override = ''
645 if installed_tests_env != {}
647 foreach var, value : installed_tests_env
648 envs += '@0@=@1@'.format(var, value)
650 test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs))
652 test_conf.set('env', test_env_override)
654 input: installed_tests_template_tap,
655 output: test_name + '.test',
656 install_dir: installed_tests_metadir,
657 configuration: test_conf
661 exe = executable(test_name, [source, extra_sources],
662 c_args : test_c_args + extra_args.get('c_args', []),
663 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
664 install_rpath : extra_args.get('install_rpath', ''),
665 install_dir: installed_tests_execdir,
669 suite = ['gio'] + extra_args.get('suite', [])
670 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
671 local_test_env = test_env
673 foreach var, value : extra_args.get('env', {})
674 local_test_env.append(var, value)
678 env : local_test_env,
681 is_parallel : extra_args.get('is_parallel', true),
682 depends : extra_args.get('depends', []),
686 foreach program_name, extra_args : test_extra_programs
687 source = extra_args.get('source', program_name + '.c')
688 extra_sources = extra_args.get('extra_sources', [])
689 install = installed_tests_enabled and extra_args.get('install', true)
690 executable(program_name, [source, extra_sources],
691 c_args : test_c_args,
692 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
693 install_dir : installed_tests_execdir,
698 # FIXME: subdir('services')