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' : {},
58 'mount-operation' : {},
59 'network-address' : {'extra_sources': ['mock-resolver.c']},
60 'network-monitor' : {},
61 'network-monitor-race' : {},
66 'simple-async-result' : {},
70 'socket-listener' : {},
71 'socket-service' : {},
77 'testfilemonitor' : {'suite' : ['slow', 'flaky']},
78 'thumbnail-verification' : {},
79 'tls-certificate' : {'extra_sources' : ['gtesttlsbackend.c']},
80 'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']},
81 'tls-database' : {'extra_sources' : ['gtesttlsbackend.c']},
82 'gdbus-address-get-session' : {},
85 test_extra_programs = {
86 'gdbus-connection-flush-helper' : {},
87 'gdbus-testserver' : {},
88 'gsubprocess-testprog' : {},
91 test_env = environment()
92 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
93 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
94 test_env.set('GIO_MODULE_DIR', '')
95 test_env.set('GIO_LAUNCH_DESKTOP', meson.build_root() + '/gio/gio-launch-desktop')
97 # Check for libdbus1 - Optional - is only used in the GDBus test cases
98 # 1.2.14 required for dbus_message_set_serial
99 dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14')
100 if not dbus1_dep.found()
101 if cc.get_id() == 'msvc'
102 # MSVC: Search for the DBus library by the configuration, which corresponds
103 # to the output of CMake builds of DBus. Note that debugoptimized
104 # is really a Release build with .PDB files.
105 if buildtype == 'debug'
106 dbus1_dep = cc.find_library('dbus-1d', required : false)
108 dbus1_dep = cc.find_library('dbus-1', required : false)
113 glib_conf.set('HAVE_DBUS1', 1)
116 'gdbus-serialization' : {
117 'extra_sources' : ['gdbus-tests.c'],
118 'dependencies' : [dbus1_dep],
123 # Test programs buildable on UNIX only
124 if host_machine.system() != 'windows'
128 'dependencies' : [libgdbus_example_objectmanager_dep],
129 'install_rpath' : installed_tests_execdir
131 'gdbus-peer-object-manager' : {},
133 'socket-address' : {},
134 'stream-rw_all' : {},
138 'g-file-info-filesystem-readonly' : {},
139 'gschema-compile' : {'install' : false},
145 'gsocketclient-slow' : {
147 shared_library('slow-connect-preload',
148 'slow-connect-preload.c',
150 dependencies: cc.find_library('dl'),
151 install_dir : installed_tests_execdir,
152 install: installed_tests_enabled,
156 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir())
158 'installed_tests_env' : {
159 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir),
165 # Uninstalled because of the check-for-executable logic in DesktopAppInfo
166 # unable to find the installed executable
167 if not glib_have_cocoa
172 'desktop-app-info' : {
178 test_extra_programs += {
179 'basic-application' : {},
184 if not glib_have_cocoa
185 test_extra_programs += {
193 # Test programs that need to bring up a session bus (requires dbus-daemon)
194 have_dbus_daemon = find_program('dbus-daemon', required : false).found()
197 '--annotate', 'org.project.Bar', 'Key1', 'Value1',
198 '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
199 '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
200 '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
201 '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
202 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
203 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
204 '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
206 # Generate gdbus-test-codegen-generated.{c,h}
207 gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
208 input : ['test-codegen.xml'],
209 output : ['gdbus-test-codegen-generated.h',
210 'gdbus-test-codegen-generated.c'],
211 depend_files : gdbus_codegen_built_files,
212 command : [python, gdbus_codegen,
213 '--interface-prefix', 'org.project.',
214 '--output-directory', '@OUTDIR@',
215 '--generate-c-code', 'gdbus-test-codegen-generated',
216 '--c-generate-object-manager',
217 '--c-generate-autocleanup', 'all',
218 '--c-namespace', 'Foo_iGen',
219 '--generate-docbook', 'gdbus-test-codegen-generated-doc',
223 gdbus_test_codegen_generated_interface_info = [
224 custom_target('gdbus-test-codegen-generated-interface-info-h',
225 input : ['test-codegen.xml'],
226 output : ['gdbus-test-codegen-generated-interface-info.h'],
227 depend_files : gdbus_codegen_built_files,
228 command : [python, gdbus_codegen,
229 '--interface-info-header',
231 '--output', '@OUTPUT@',
233 custom_target('gdbus-test-codegen-generated-interface-info-c',
234 input : ['test-codegen.xml'],
235 output : ['gdbus-test-codegen-generated-interface-info.c'],
236 depend_files : gdbus_codegen_built_files,
237 command : [python, gdbus_codegen,
238 '--interface-info-body',
240 '--output', '@OUTPUT@',
244 extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
248 'extra_sources' : extra_sources,
251 'gdbus-auth' : {'extra_sources' : extra_sources},
252 'gdbus-bz627724' : {'extra_sources' : extra_sources},
253 'gdbus-close-pending' : {'extra_sources' : extra_sources},
254 'gdbus-connection' : {'extra_sources' : extra_sources},
255 'gdbus-connection-loss' : {'extra_sources' : extra_sources},
256 'gdbus-connection-slow' : {'extra_sources' : extra_sources},
257 'gdbus-error' : {'extra_sources' : extra_sources},
258 'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
260 'extra_sources' : extra_sources,
263 'gdbus-introspection' : {'extra_sources' : extra_sources},
264 'gdbus-names' : {'extra_sources' : extra_sources},
265 'gdbus-proxy' : {'extra_sources' : extra_sources},
266 'gdbus-proxy-threads' : {
267 'extra_sources' : extra_sources,
268 'dependencies' : [dbus1_dep],
270 'gdbus-proxy-unique-name' : {'extra_sources' : extra_sources},
271 'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources},
272 'gdbus-test-codegen' : {
273 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
275 'gdbus-threading' : {
276 'extra_sources' : extra_sources,
277 'suite' : ['slow', 'flaky'],
280 'extra_sources' : extra_sources,
284 'extra_sources' : [extra_sources, 'gnotification-server.c'],
286 'gdbus-test-codegen-old' : {
287 'source' : 'gdbus-test-codegen.c',
288 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
289 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
290 '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
292 'gapplication' : {'extra_sources' : extra_sources},
295 if not glib_have_cocoa
298 'extra_sources' : extra_sources,
302 endif # have_dbus_daemon
304 # This test is currently unreliable
305 executable('gdbus-overflow', 'gdbus-overflow.c',
306 c_args : test_c_args,
307 dependencies : common_gio_tests_deps,
308 install_dir : installed_tests_execdir,
309 install : installed_tests_enabled)
312 'gdbus-connection-flush' : {
313 'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
315 'gdbus-non-socket' : {
316 'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
320 # Generate test.mo from de.po using msgfmt
321 msgfmt = find_program('msgfmt', required : false)
323 subdir('de/LC_MESSAGES')
326 'extra_sources' : [test_mo],
327 'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()),
328 '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)],
335 # Test programs buildable on Windows only
336 if host_machine.system() == 'windows'
337 gio_tests += {'win32-streams' : {}}
340 if cc.get_id() != 'msvc'
343 'source' : 'autoptr.c',
348 test_extra_programs += {
349 'gio-du' : {'install' : false},
350 'echo-server' : {'install' : false},
351 'filter-cat' : {'install' : false},
352 'gapplication-example-actions' : {'install' : false},
353 'gapplication-example-cmdline' : {'install' : false},
354 'gapplication-example-cmdline2' : {'install' : false},
355 'gapplication-example-cmdline3' : {'install' : false},
356 'gapplication-example-cmdline4' : {'install' : false},
357 'gapplication-example-dbushooks' : {'install' : false},
358 'gapplication-example-open' : {'install' : false},
360 'extra_sources' : gdbus_daemon_sources,
363 'gdbus-example-export' : {'install' : false},
364 'gdbus-example-own-name' : {'install' : false},
365 'gdbus-example-peer' : {'install' : false},
366 'gdbus-example-proxy-subclass' : {'install' : false},
367 'gdbus-example-server' : {'install' : false},
368 'gdbus-example-subtree' : {'install' : false},
369 'gdbus-example-watch-name' : {'install' : false},
370 'gdbus-example-watch-proxy' : {'install' : false},
371 'httpd' : {'install' : false},
372 'proxy' : {'install' : false},
373 'resolver' : {'install' : false},
374 'send-data' : {'install' : false},
375 'socket-server' : {'install' : false},
377 'extra_sources' : ['gtlsconsoleinteraction.c'],
382 if cc.get_id() != 'msvc'
383 test_extra_programs += {
384 # These three are manual-run tests because they need a session bus but don't bring one up themselves
385 # FIXME: these build but don't seem to work!
386 'gdbus-example-objectmanager-client' : {
387 'dependencies' : [libgdbus_example_objectmanager_dep],
390 'gdbus-example-objectmanager-server' : {
391 'dependencies' : [libgdbus_example_objectmanager_dep],
394 'gdbus-test-fixture' : {
395 'dependencies' : [libgdbus_example_objectmanager_dep],
401 if host_machine.system() != 'windows'
402 test_extra_programs += {
403 'gdbus-example-unix-fd-client' : {
409 appinfo_test_desktop_files = [
410 'appinfo-test-gnome.desktop',
411 'appinfo-test-notgnome.desktop',
412 'appinfo-test.desktop',
413 'appinfo-test2.desktop',
416 cdata = configuration_data()
417 if installed_tests_enabled
418 cdata.set('installed_tests_dir', installed_tests_execdir)
420 cdata.set('installed_tests_dir', meson.current_build_dir())
423 foreach appinfo_test_desktop_file : appinfo_test_desktop_files
425 input: appinfo_test_desktop_file + '.in',
426 output: appinfo_test_desktop_file,
427 install_dir: installed_tests_execdir,
428 install: installed_tests_enabled,
429 configuration: cdata,
433 if installed_tests_enabled
437 'appinfo-test-actions.desktop',
438 'appinfo-test-static.desktop',
440 'org.gtk.test.dbusappinfo.desktop',
442 install_dir : installed_tests_execdir,
444 install_subdir('x-content', install_dir : installed_tests_execdir)
445 install_subdir('desktop-files', install_dir : installed_tests_execdir)
446 install_subdir('thumbnails', install_dir : installed_tests_execdir)
447 install_subdir('cert-tests', install_dir : installed_tests_execdir)
449 cdata = configuration_data()
450 cdata.set('installed_tests_dir', installed_tests_execdir)
451 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
453 input: installed_tests_template,
454 output: 'static-link.test',
455 install_dir: installed_tests_metadir,
458 install_subdir('static-link', install_dir : installed_tests_execdir)
459 install_data('static-link.py', install_dir : installed_tests_execdir)
462 if not meson.is_cross_build() or meson.has_exe_wrapper()
464 plugin_resources_c = custom_target('plugin-resources.c',
465 input : 'test4.gresource.xml',
466 output : 'plugin-resources.c',
467 command : [glib_compile_resources,
469 '--sourcedir=' + meson.current_source_dir(),
471 '--c-name', '_g_plugin',
474 shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c,
475 link_args : export_dynamic_ldflags,
476 dependencies : common_gio_tests_deps,
477 install_dir : installed_tests_execdir,
478 install : installed_tests_enabled
481 # referenced by test2.gresource.xml
482 big_test_resource = custom_target(
483 'gresource-big-test.txt',
484 input : ['gen-big-test-resource.py'],
485 output : ['gresource-big-test.txt'],
486 command : [python, '@INPUT0@', '@OUTPUT@'])
488 test_gresource = custom_target('test.gresource',
489 input : 'test.gresource.xml',
490 output : 'test.gresource',
491 command : [glib_compile_resources,
493 '--sourcedir=' + meson.current_source_dir(),
494 '--sourcedir=' + meson.current_build_dir(),
496 install_dir : installed_tests_execdir,
497 install : installed_tests_enabled)
499 test_resources2_c = custom_target('test_resources2.c',
500 input : 'test3.gresource.xml',
501 output : 'test_resources2.c',
502 command : [glib_compile_resources,
504 '--sourcedir=' + meson.current_source_dir(),
506 '--c-name', '_g_test2',
510 test_resources2_h = custom_target('test_resources2.h',
511 input : 'test3.gresource.xml',
512 output : 'test_resources2.h',
513 command : [glib_compile_resources,
515 '--sourcedir=' + meson.current_source_dir(),
517 '--c-name', '_g_test2',
521 test_resources_c = custom_target('test_resources.c',
522 input : 'test2.gresource.xml',
523 depends : big_test_resource,
524 output : 'test_resources.c',
525 command : [glib_compile_resources,
527 '--sourcedir=' + meson.current_source_dir(),
528 '--sourcedir=' + meson.current_build_dir(),
530 '--c-name', '_g_test1',
533 digit_test_resources_c = custom_target('digit_test_resources.c',
534 input : '111_digit_test.gresource.xml',
535 output : 'digit_test_resources.c',
536 command : [glib_compile_resources,
538 '--sourcedir=' + meson.current_source_dir(),
539 '--sourcedir=' + meson.current_build_dir(),
544 digit_test_resources_h = custom_target('digit_test_resources.h',
545 input : '111_digit_test.gresource.xml',
546 output : 'digit_test_resources.h',
547 command : [glib_compile_resources,
549 '--sourcedir=' + meson.current_source_dir(),
554 # referenced by test.gresource.xml
555 test_generated_txt = configure_file(input : 'test1.txt',
556 output : 'test-generated.txt',
560 resources_extra_sources = [
565 digit_test_resources_c,
566 digit_test_resources_h,
569 # Create object file containing resource data for testing the --external-data
570 # option. Currently only GNU ld and GNU objcopy support the right options.
571 # Support for --add-symbol was added to LLVM objcopy in 2019
572 # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for
573 # LLVM once that support is in a stable release.
574 if build_machine.system() == 'linux' and cc.get_id() == 'gcc'
575 test_gresource_binary = custom_target('test5.gresource',
576 input : 'test5.gresource.xml',
577 output : 'test5.gresource',
578 command : [glib_compile_resources,
580 '--sourcedir=' + meson.current_source_dir(),
581 '--sourcedir=' + meson.current_build_dir(),
583 install_dir : installed_tests_execdir,
584 install : installed_tests_enabled)
586 # Create resource data file
587 test_resources_binary_c = custom_target('test_resources_binary.c',
588 input : 'test5.gresource.xml',
589 output : 'test_resources_binary.c',
590 command : [glib_compile_resources,
592 '--sourcedir=' + meson.current_source_dir(),
593 '--sourcedir=' + meson.current_build_dir(),
596 '--c-name', '_g_binary_test1',
599 # Create object file containing resource data
600 test_resources_binary = custom_target('test_resources.o',
601 input : test_gresource_binary,
602 output : 'test_resources.o',
609 # Rename symbol to match the one in the C file
610 test_resources_binary2 = custom_target('test_resources2.o',
611 input : test_resources_binary,
612 output : 'test_resources2.o',
613 command : ['objcopy',
614 '--add-symbol','_g_binary_test1_resource_data=.data:0',
618 resources_extra_sources += [
619 test_resources_binary_c,
620 test_resources_binary2,
626 'extra_sources' : resources_extra_sources,
631 foreach test_name, extra_args : gio_tests
632 source = extra_args.get('source', test_name + '.c')
633 extra_sources = extra_args.get('extra_sources', [])
634 install = installed_tests_enabled and extra_args.get('install', true)
635 installed_tests_env = extra_args.get('installed_tests_env', {})
638 test_conf = configuration_data()
639 test_conf.set('installed_tests_dir', installed_tests_execdir)
640 test_conf.set('program', test_name)
641 test_env_override = ''
642 if installed_tests_env != {}
644 foreach var, value : installed_tests_env
645 envs += '@0@=@1@'.format(var, value)
647 test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs))
649 test_conf.set('env', test_env_override)
651 input: installed_tests_template_tap,
652 output: test_name + '.test',
653 install_dir: installed_tests_metadir,
654 configuration: test_conf
658 exe = executable(test_name, [source, extra_sources],
659 c_args : test_c_args + extra_args.get('c_args', []),
660 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
661 install_rpath : extra_args.get('install_rpath', ''),
662 install_dir: installed_tests_execdir,
666 suite = ['gio'] + extra_args.get('suite', [])
667 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
668 local_test_env = test_env
670 foreach var, value : extra_args.get('env', {})
671 local_test_env.append(var, value)
675 env : local_test_env,
679 is_parallel : extra_args.get('is_parallel', true),
680 depends : extra_args.get('depends', []),
684 foreach program_name, extra_args : test_extra_programs
685 source = extra_args.get('source', program_name + '.c')
686 extra_sources = extra_args.get('extra_sources', [])
687 install = installed_tests_enabled and extra_args.get('install', true)
688 executable(program_name, [source, extra_sources],
689 c_args : test_c_args,
690 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
691 install_dir : installed_tests_execdir,
696 # FIXME: subdir('services')