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},
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' and cc.get_id() != 'clang-cl'
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
427 if installed_tests_enabled
429 input: appinfo_test_desktop_file + '.in',
430 output: appinfo_test_desktop_file,
431 install_dir: installed_tests_execdir,
432 configuration: cdata,
436 input: appinfo_test_desktop_file + '.in',
437 output: appinfo_test_desktop_file,
438 configuration: cdata,
443 if installed_tests_enabled
447 'appinfo-test-actions.desktop',
448 'appinfo-test-static.desktop',
450 'org.gtk.test.dbusappinfo.desktop',
452 install_dir : installed_tests_execdir,
454 install_subdir('x-content', install_dir : installed_tests_execdir)
455 install_subdir('desktop-files', install_dir : installed_tests_execdir)
456 install_subdir('thumbnails', install_dir : installed_tests_execdir)
457 install_subdir('cert-tests', install_dir : installed_tests_execdir)
459 cdata = configuration_data()
460 cdata.set('installed_tests_dir', installed_tests_execdir)
461 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
463 input: installed_tests_template,
464 output: 'static-link.test',
465 install_dir: installed_tests_metadir,
468 install_subdir('static-link', install_dir : installed_tests_execdir)
469 install_data('static-link.py', install_dir : installed_tests_execdir)
472 if not meson.is_cross_build() or meson.has_exe_wrapper()
474 plugin_resources_c = custom_target('plugin-resources.c',
475 input : 'test4.gresource.xml',
476 output : 'plugin-resources.c',
477 command : [glib_compile_resources,
479 '--sourcedir=' + meson.current_source_dir(),
481 '--c-name', '_g_plugin',
484 shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
485 link_args : export_dynamic_ldflags,
486 dependencies : common_gio_tests_deps,
487 install_dir : installed_tests_execdir,
488 install : installed_tests_enabled
491 # referenced by test2.gresource.xml
492 big_test_resource = custom_target(
493 'gresource-big-test.txt',
494 input : ['gen-big-test-resource.py'],
495 output : ['gresource-big-test.txt'],
496 command : [python, '@INPUT0@', '@OUTPUT@'])
498 test_gresource = custom_target('test.gresource',
499 input : 'test.gresource.xml',
500 output : 'test.gresource',
501 command : [glib_compile_resources,
503 '--sourcedir=' + meson.current_source_dir(),
504 '--sourcedir=' + meson.current_build_dir(),
506 install_dir : installed_tests_execdir,
507 install : installed_tests_enabled)
509 test_resources2_c = custom_target('test_resources2.c',
510 input : 'test3.gresource.xml',
511 output : 'test_resources2.c',
512 command : [glib_compile_resources,
514 '--sourcedir=' + meson.current_source_dir(),
516 '--c-name', '_g_test2',
520 test_resources2_h = custom_target('test_resources2.h',
521 input : 'test3.gresource.xml',
522 output : 'test_resources2.h',
523 command : [glib_compile_resources,
525 '--sourcedir=' + meson.current_source_dir(),
527 '--c-name', '_g_test2',
531 test_resources_c = custom_target('test_resources.c',
532 input : 'test2.gresource.xml',
533 depends : big_test_resource,
534 output : 'test_resources.c',
535 command : [glib_compile_resources,
537 '--sourcedir=' + meson.current_source_dir(),
538 '--sourcedir=' + meson.current_build_dir(),
540 '--c-name', '_g_test1',
543 digit_test_resources_c = custom_target('digit_test_resources.c',
544 input : '111_digit_test.gresource.xml',
545 output : 'digit_test_resources.c',
546 command : [glib_compile_resources,
548 '--sourcedir=' + meson.current_source_dir(),
549 '--sourcedir=' + meson.current_build_dir(),
554 digit_test_resources_h = custom_target('digit_test_resources.h',
555 input : '111_digit_test.gresource.xml',
556 output : 'digit_test_resources.h',
557 command : [glib_compile_resources,
559 '--sourcedir=' + meson.current_source_dir(),
564 # referenced by test.gresource.xml
565 test_generated_txt = configure_file(input : 'test1.txt',
566 output : 'test-generated.txt',
570 resources_extra_sources = [
575 digit_test_resources_c,
576 digit_test_resources_h,
579 # Create object file containing resource data for testing the --external-data
580 # option. Currently only GNU ld and GNU objcopy support the right options.
581 # Support for --add-symbol was added to LLVM objcopy in 2019
582 # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for
583 # LLVM once that support is in a stable release.
584 if build_machine.system() == 'linux' and cc.get_id() == 'gcc'
585 test_gresource_binary = custom_target('test5.gresource',
586 input : 'test5.gresource.xml',
587 output : 'test5.gresource',
588 command : [glib_compile_resources,
590 '--sourcedir=' + meson.current_source_dir(),
591 '--sourcedir=' + meson.current_build_dir(),
593 install_dir : installed_tests_execdir,
594 install : installed_tests_enabled)
596 # Create resource data file
597 test_resources_binary_c = custom_target('test_resources_binary.c',
598 input : 'test5.gresource.xml',
599 output : 'test_resources_binary.c',
600 command : [glib_compile_resources,
602 '--sourcedir=' + meson.current_source_dir(),
603 '--sourcedir=' + meson.current_build_dir(),
606 '--c-name', '_g_binary_test1',
609 # Create object file containing resource data
610 test_resources_binary = custom_target('test_resources.o',
611 input : test_gresource_binary,
612 output : 'test_resources.o',
619 # Rename symbol to match the one in the C file
620 test_resources_binary2 = custom_target('test_resources2.o',
621 input : test_resources_binary,
622 output : 'test_resources2.o',
623 command : ['objcopy',
624 '--add-symbol','_g_binary_test1_resource_data=.data:0',
628 resources_extra_sources += [
629 test_resources_binary_c,
630 test_resources_binary2,
636 'extra_sources' : resources_extra_sources,
641 foreach test_name, extra_args : gio_tests
642 source = extra_args.get('source', test_name + '.c')
643 extra_sources = extra_args.get('extra_sources', [])
644 install = installed_tests_enabled and extra_args.get('install', true)
645 installed_tests_env = extra_args.get('installed_tests_env', {})
648 test_conf = configuration_data()
649 test_conf.set('installed_tests_dir', installed_tests_execdir)
650 test_conf.set('program', test_name)
651 test_env_override = ''
652 if installed_tests_env != {}
654 foreach var, value : installed_tests_env
655 envs += '@0@=@1@'.format(var, value)
657 test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs))
659 test_conf.set('env', test_env_override)
661 input: installed_tests_template_tap,
662 output: test_name + '.test',
663 install_dir: installed_tests_metadir,
664 configuration: test_conf
668 exe = executable(test_name, [source, extra_sources],
669 c_args : test_c_args + extra_args.get('c_args', []),
670 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
671 install_rpath : extra_args.get('install_rpath', ''),
672 install_dir: installed_tests_execdir,
676 suite = ['gio'] + extra_args.get('suite', [])
677 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
678 local_test_env = test_env
680 foreach var, value : extra_args.get('env', {})
681 local_test_env.append(var, value)
685 env : local_test_env,
688 is_parallel : extra_args.get('is_parallel', true),
689 depends : extra_args.get('depends', []),
693 foreach program_name, extra_args : test_extra_programs
694 source = extra_args.get('source', program_name + '.c')
695 extra_sources = extra_args.get('extra_sources', [])
696 install = installed_tests_enabled and extra_args.get('install', true)
697 executable(program_name, [source, extra_sources],
698 c_args : test_c_args,
699 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
700 install_dir : installed_tests_execdir,
705 # FIXME: subdir('services')