Debian Codegraph @

glib/gio/tests/meson.build

raw
1 common_gio_tests_deps = [
2 libglib_dep,
3 libgmodule_dep,
4 libgobject_dep,
5 libgio_dep,
6 ]
7
8 test_c_args = [
9 '-DG_LOG_DOMAIN="GLib-GIO"',
10 '-DGLIB_MKENUMS="@0@"'.format(glib_mkenums),
11 '-DGLIB_COMPILE_SCHEMAS="@0@"'.format(glib_compile_schemas.full_path()),
12 '-UG_DISABLE_ASSERT',
13 ]
14
15 libutil_dep = dependency('', required : false)
16
17 if cc.has_header('pty.h')
18 have_openpty = cc.has_function('openpty', prefix : '#include <pty.h>')
19
20 if host_machine.system() == 'linux' and not have_openpty
21 libutil_dep = cc.find_library('util', required : false)
22 have_openpty = cc.has_function('openpty', dependencies : libutil_dep, prefix : '#include <pty.h>')
23 endif
24
25 if have_openpty
26 test_c_args += '-DHAVE_OPENPTY'
27 endif
28 endif
29
30 test_cpp_args = test_c_args
31
32 if host_machine.system() == 'windows'
33 common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')]
34 endif
35
36 subdir('gdbus-object-manager-example')
37
38 gengiotypefuncs_prog = find_program('gengiotypefuncs.py')
39 giotypefuncs_inc = custom_target(
40 'giotypefuncs.inc',
41 output : 'giotypefuncs.inc',
42 input : gio_headers + [gioenumtypes_h] + gobject_install_headers,
43 command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@'])
44
45 if glib_build_shared
46 subdir('modules')
47 endif
48
49 # Test programs buildable on all platforms
50 gio_tests = {
51 'application-command-line': {},
52 'appmonitor' : {
53 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
54 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
55 'can_fail' : host_system in ['darwin', 'gnu'],
56 },
57 'async-close-output-stream' : {},
58 'async-splice-output-stream' : {},
59 'buffered-input-stream' : {},
60 'buffered-output-stream' : {},
61 'cancellable' : {},
62 'contexts' : {},
63 'contenttype' : {
64 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392 / https://gitlab.gnome.org/GNOME/glib/-/issues/1251
65 'can_fail' : host_system == 'darwin',
66 },
67 'converter-stream' : {
68 # musl: charset tests fail due to missing collation support in musl libc
69 # From https://wiki.musl-libc.org/roadmap#Open_future_goals
70 # "LC_COLLATE support for collation orders other than simple codepoint order"
71 'can_fail' : linux_libc == 'musl',
72 },
73 'credentials' : {},
74 'data-input-stream' : {},
75 'data-output-stream' : {},
76 'error': {},
77 'file-thumbnail' : {},
78 'fileattributematcher' : {},
79 'filter-streams' : {},
80 'giomodule' : {
81 'depends' : glib_build_shared ? [libtestmodulea, libtestmoduleb] : [],
82 },
83 'gsubprocess' : {
84 'suite': host_system == 'windows' ? ['flaky'] : [],
85 'extra_programs': ['gsubprocess-testprog'],
86 },
87 'g-file' : {},
88 'g-file-info' : {
89 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3070
90 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
91 'can_fail' : host_system in ['darwin', 'gnu'] or host_system == 'windows' and cc.get_id() != 'gcc',
92 },
93 'g-icon' : {},
94 'gdbus-addresses' : {},
95 'gdbus-message' : {},
96 'gdbus-peer' : {
97 'dependencies' : [libgdbus_example_objectmanager_dep],
98 'install_rpath' : installed_tests_execdir,
99 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
100 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
101 'can_fail' : host_system in ['darwin', 'windows', 'gnu'],
102 },
103 'inet-address' : {},
104 'io-stream' : {},
105 'max-version' : {'install' : false},
106 'memory-input-stream' : {},
107 'memory-monitor' : {},
108 'memory-output-stream' : {},
109 'memory-settings-backend' : {},
110 'mount-operation' : {},
111 'network-address' : {'extra_sources': ['mock-resolver.c']},
112 'network-monitor' : {},
113 'network-monitor-race' : {},
114 'null-settings-backend' : {},
115 'permission' : {},
116 'pollable' : {'dependencies' : [libutil_dep]},
117 'power-profile-monitor' : {},
118 'proxy-test' : {},
119 'readwrite' : {},
120 'sandbox' : {
121 'extra_sources': ['../gsandbox.c', 'portal-support-utils.c'],
122 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
123 },
124 'simple-async-result' : {},
125 'simple-proxy' : {},
126 'sleepy-stream' : {},
127 'socket' : {
128 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
129 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
130 'can_fail' : host_system in ['darwin', 'gnu'],
131 },
132 'socket-listener' : {},
133 'socket-service' : {},
134 'srvtarget' : {},
135 'task' : {},
136 'vfs' : {},
137 'volumemonitor' : {},
138 'glistmodel' : {},
139 'testfilemonitor' : {'suite' : ['slow', 'flaky']},
140 'thumbnail-verification' : {},
141 'tls-certificate' : {'extra_sources' : ['gtesttlsbackend.c']},
142 'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']},
143 'tls-database' : {'extra_sources' : ['gtesttlsbackend.c']},
144 'tls-bindings' : {'extra_sources' : ['gtesttlsbackend.c']},
145 'unix-fd' : {},
146 'gdbus-address-get-session' : {
147 'extra_programs': host_system != 'windows' ? ['dbus-launch'] : [],
148 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/1392
149 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
150 'can_fail' : host_system in ['darwin', 'gnu'],
151 },
152 'win32-appinfo' : {},
153 }
154
155 if have_cxx
156 gio_tests += {
157 'cxx' : {
158 'protocol': 'exitcode',
159 'source' : ['cxx.cpp'],
160 'suite': ['cpp'],
161 },
162 }
163
164 foreach std, arg: cxx_standards
165 gio_tests += {
166 'cxx-@0@'.format(std) : {
167 'protocol': 'exitcode',
168 'source' : ['cxx.cpp'],
169 'suite' : ['cpp'],
170 'cpp_args' : [arg],
171 },
172 }
173 endforeach
174 endif
175
176 test_extra_programs = {
177 'gdbus-connection-flush-helper' : {},
178 'gdbus-testserver' : {},
179 'gsubprocess-testprog' : {},
180 }
181
182 python_tests = {
183 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/2764
184 'codegen.py' : {
185 'can_fail' : host_system == 'freebsd',
186 'suite': ['gdbus-codegen', 'slow'],
187 'timeout': 90,
188 },
189 'gio-tool.py' : {
190 'depends' : gio_tool,
191 'can_fail' : host_system == 'windows',
192 },
193 }
194
195 test_env = environment()
196 test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
197 test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
198 test_env.set('GIO_MODULE_DIR', '')
199
200 if host_system != 'windows' and not glib_have_cocoa
201 test_env.set('GIO_LAUNCH_DESKTOP', gio_launch_desktop.full_path())
202 endif
203
204 # Check for libdbus1 - Optional - is only used in the GDBus test cases
205 # 1.2.14 required for dbus_message_set_serial
206 dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14')
207 if not dbus1_dep.found()
208 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
209 # MSVC: Search for the DBus library by the configuration, which corresponds
210 # to the output of CMake builds of DBus. Note that debugoptimized
211 # is really a Release build with .PDB files.
212 if vs_crt == 'debug'
213 dbus1_dep = cc.find_library('dbus-1d', required : false)
214 else
215 dbus1_dep = cc.find_library('dbus-1', required : false)
216 endif
217 endif
218 endif
219 if dbus1_dep.found()
220 glib_conf.set('HAVE_DBUS1', 1)
221
222 gio_tests += {
223 'gdbus-serialization' : {
224 'extra_sources' : ['gdbus-tests.c'],
225 'dependencies' : [dbus1_dep],
226 },
227 'gdbus-server-auth' : {
228 'dependencies' : [dbus1_dep],
229 },
230 }
231 else
232 # We can build a cut-down version of this test without libdbus
233 gio_tests += {
234 'gdbus-server-auth' : {},
235 }
236 endif
237
238 have_dbus_daemon = find_program('dbus-daemon', required : false).found()
239 if have_dbus_daemon
240 gio_tests += {
241 'debugcontroller' : {},
242 'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
243 }
244 endif
245
246 # Test programs buildable on UNIX only
247 if host_machine.system() != 'windows'
248 gio_tests += {
249 'file' : {
250 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
251 'can_fail' : host_system == 'gnu',
252 },
253 'gdbus-peer-object-manager' : {},
254 'gdbus-sasl' : {},
255 'live-g-file' : {},
256 'portal-support-flatpak-none' : {
257 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
258 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
259 'suite': ['portal-support'],
260 },
261 'portal-support-flatpak-full' : {
262 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
263 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
264 'suite': ['portal-support'],
265 },
266 'portal-support-flatpak-network-only' : {
267 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
268 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
269 'suite': ['portal-support'],
270 },
271 'portal-support-flatpak-gsettings-only' : {
272 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
273 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
274 'suite': ['portal-support'],
275 },
276 'portal-support-none' : {
277 'extra_sources': ['../gportalsupport.c', '../gsandbox.c'],
278 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
279 'suite': ['portal-support'],
280 },
281 'portal-support-env-var' : {
282 'extra_sources': ['../gportalsupport.c', '../gsandbox.c'],
283 'suite': ['portal-support'],
284 },
285 'portal-support-snap' : {
286 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
287 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
288 'suite': ['portal-support'],
289 },
290 'portal-support-snap-classic' : {
291 'extra_sources': ['../gportalsupport.c', '../gsandbox.c', 'portal-support-utils.c'],
292 'c_args': ['-DG_PORTAL_SUPPORT_TEST'],
293 'suite': ['portal-support'],
294 },
295 'resolver-parsing' : {'dependencies' : [network_libs]},
296 'socket-address' : {},
297 'stream-rw_all' : {
298 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
299 'can_fail' : host_system == 'gnu',
300 },
301 'unix-mounts' : {},
302 'unix-streams' : {},
303 'g-file-info-filesystem-readonly' : {},
304 'gschema-compile' : {'install' : false},
305 'trash' : {
306 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3069
307 'can_fail' : host_system == 'darwin',
308 },
309 }
310
311 # LD_PRELOAD modules don't work so well with AddressSanitizer
312 if have_rtld_next and glib_build_shared and get_option('b_sanitize') == 'none'
313 gio_tests += {
314 'gsocketclient-slow' : {
315 'depends' : [
316 shared_library('slow-connect-preload',
317 'slow-connect-preload.c',
318 name_prefix : '',
319 dependencies: libdl_dep,
320 install_dir : installed_tests_execdir,
321 install_tag : 'tests',
322 install: installed_tests_enabled,
323 )
324 ],
325 'env' : {
326 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir())
327 },
328 'installed_tests_env' : {
329 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir),
330 },
331 },
332 }
333 endif
334
335 # Uninstalled because of the check-for-executable logic in DesktopAppInfo
336 # unable to find the installed executable
337 if not glib_have_cocoa
338 gio_tests += {
339 'appinfo' : {
340 'install' : false,
341 'extra_programs' : ['appinfo-test'],
342 },
343 'desktop-app-info' : {
344 'install' : false,
345 'depends' : gio_launch_desktop,
346 'extra_programs' : ['apps', 'appinfo-test'],
347 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
348 'can_fail' : host_system == 'gnu',
349 },
350 }
351 endif
352
353 test_extra_programs += {
354 'basic-application' : {},
355 'dbus-launch' : {},
356 'appinfo-test' : {},
357 }
358
359 if not glib_have_cocoa
360 test_extra_programs += {
361 'apps' : {},
362 }
363 gio_tests += {
364 'mimeapps' : {},
365 }
366 endif
367
368 if have_dbus_daemon
369 annotate_args = [
370 '--annotate', 'org.project.Bar', 'Key1', 'Value1',
371 '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
372 '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
373 '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
374 '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
375 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
376 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
377 '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
378 ]
379 # Generate gdbus-test-codegen-generated.{c,h}
380 gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
381 input : ['test-codegen.xml'],
382 output : ['gdbus-test-codegen-generated.h',
383 'gdbus-test-codegen-generated.c'],
384 depend_files : gdbus_codegen_built_files,
385 depends : gdbus_codegen_built_targets,
386 command : [python, gdbus_codegen,
387 '--interface-prefix', 'org.project.',
388 '--output-directory', '@OUTDIR@',
389 '--generate-c-code', 'gdbus-test-codegen-generated',
390 '--c-generate-object-manager',
391 '--c-generate-autocleanup', 'all',
392 '--c-namespace', 'Foo_iGen',
393 '--generate-docbook', 'gdbus-test-codegen-generated-doc',
394 annotate_args,
395 '@INPUT@'])
396 # Generate gdbus-test-codegen-generated-min-required-2-64.{c,h}
397 gdbus_test_codegen_generated_min_required_2_64 = custom_target('gdbus-test-codegen-generated-min-required-2-64',
398 input : ['test-codegen.xml'],
399 output : ['gdbus-test-codegen-generated-min-required-2-64.h',
400 'gdbus-test-codegen-generated-min-required-2-64.c'],
401 depend_files : gdbus_codegen_built_files,
402 depends : gdbus_codegen_built_targets,
403 command : [python, gdbus_codegen,
404 '--glib-min-required', '2.64',
405 '--interface-prefix', 'org.project.',
406 '--output-directory', '@OUTDIR@',
407 '--generate-c-code', 'gdbus-test-codegen-generated-min-required-2-64',
408 '--c-generate-object-manager',
409 '--c-generate-autocleanup', 'all',
410 '--c-namespace', 'Foo_iGen',
411 '--generate-docbook', 'gdbus-test-codegen-generated-doc',
412 annotate_args,
413 '@INPUT@'])
414 gdbus_test_codegen_generated_interface_info = [
415 custom_target('gdbus-test-codegen-generated-interface-info-h',
416 input : ['test-codegen.xml'],
417 output : ['gdbus-test-codegen-generated-interface-info.h'],
418 depend_files : gdbus_codegen_built_files,
419 depends : gdbus_codegen_built_targets,
420 command : [python, gdbus_codegen,
421 '--interface-info-header',
422 annotate_args,
423 '--output', '@OUTPUT@',
424 '@INPUT@']),
425 custom_target('gdbus-test-codegen-generated-interface-info-c',
426 input : ['test-codegen.xml'],
427 output : ['gdbus-test-codegen-generated-interface-info.c'],
428 depend_files : gdbus_codegen_built_files,
429 depends : gdbus_codegen_built_targets,
430 command : [python, gdbus_codegen,
431 '--interface-info-body',
432 annotate_args,
433 '--output', '@OUTPUT@',
434 '@INPUT@']),
435 ]
436
437 extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
438 extra_programs = ['gdbus-testserver']
439
440 gio_tests += {
441 'actions' : {
442 'extra_sources' : extra_sources,
443 'suite' : ['slow'],
444 },
445 'fdo-notification-backend': {},
446 'gdbus-auth' : {'extra_sources' : extra_sources},
447 'gdbus-bz627724' : {'extra_sources' : extra_sources},
448 'gdbus-close-pending' : {'extra_sources' : extra_sources},
449 'gdbus-connection' : {
450 'extra_sources' : extra_sources,
451 'extra_programs': extra_programs,
452 },
453 'gdbus-connection-loss' : {
454 'extra_sources' : extra_sources,
455 'extra_programs': extra_programs,
456 },
457 'gdbus-connection-slow' : {
458 'extra_sources' : extra_sources,
459 'extra_programs': extra_programs + ['gdbus-connection-flush-helper'],
460 },
461 'gdbus-error' : {'extra_sources' : extra_sources},
462 'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
463 'gdbus-export' : {
464 'extra_sources' : extra_sources,
465 'suite' : ['slow'],
466 },
467 'gdbus-introspection' : {
468 'extra_sources' : extra_sources,
469 'extra_programs': extra_programs,
470 },
471 'gdbus-method-invocation' : {'extra_sources' : extra_sources},
472 'gdbus-names' : {
473 'extra_sources' : extra_sources,
474 'extra_programs' : ['fake-service-name'],
475 },
476 'gdbus-proxy' : {
477 'extra_sources' : extra_sources,
478 'extra_programs': extra_programs,
479 },
480 'gdbus-proxy-threads' : {
481 'extra_sources' : extra_sources,
482 'dependencies' : [dbus1_dep],
483 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
484 'can_fail' : host_system == 'gnu',
485 },
486 'gdbus-proxy-unique-name' : {
487 'extra_sources' : extra_sources,
488 'extra_programs': extra_programs,
489 },
490 'gdbus-proxy-well-known-name' : {
491 'extra_sources' : extra_sources,
492 'extra_programs': extra_programs,
493 },
494 'gdbus-test-codegen' : {
495 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
496 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32'],
497 'suite': ['gdbus-codegen'],
498 },
499 'gdbus-threading' : {
500 'extra_sources' : extra_sources,
501 'extra_programs': extra_programs,
502 'suite' : ['slow'],
503 },
504 'gmenumodel' : {
505 'extra_sources' : extra_sources,
506 'suite' : ['slow'],
507 },
508 'gnotification' : {
509 'extra_sources' : [extra_sources, 'gnotification-server.c'],
510 },
511 'gdbus-test-codegen-old' : {
512 'source' : 'gdbus-test-codegen.c',
513 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
514 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
515 '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
516 'suite': ['gdbus-codegen'],
517 },
518 'gdbus-test-codegen-min-required-2-64' : {
519 'source' : 'gdbus-test-codegen.c',
520 'extra_sources' : [extra_sources, gdbus_test_codegen_generated_min_required_2_64, gdbus_test_codegen_generated_interface_info],
521 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_64'],
522 'suite': ['gdbus-codegen'],
523 },
524 'gapplication' : {
525 'extra_sources' : extra_sources,
526 'extra_programs': ['basic-application'],
527 },
528 }
529
530 if not glib_have_cocoa
531 gio_tests += {
532 'dbus-appinfo' : {
533 'extra_sources' : extra_sources,
534 'extra_programs' : ['fake-document-portal'],
535 },
536 }
537 endif
538
539 fake_document_portal_generated = custom_target('fake-document-portal-generated',
540 input : ['../org.freedesktop.portal.Documents.xml'],
541 output : ['fake-document-portal-generated.h',
542 'fake-document-portal-generated.c'],
543 depend_files : gdbus_codegen_built_files,
544 depends : gdbus_codegen_built_targets,
545 command : [python, gdbus_codegen,
546 '--interface-prefix', 'org.freedesktop.portal.',
547 '--output-directory', '@OUTDIR@',
548 '--generate-c-code', 'fake-document-portal-generated',
549 '--c-namespace', 'Fake',
550 '@INPUT@'])
551
552 test_extra_programs += {
553 'fake-document-portal' : {
554 'extra_sources': fake_document_portal_generated,
555 },
556 'fake-service-name' : {}
557 }
558 endif # have_dbus_daemon
559
560 # This test is currently unreliable
561 executable('gdbus-overflow', 'gdbus-overflow.c',
562 c_args : test_c_args,
563 dependencies : common_gio_tests_deps,
564 install_dir : installed_tests_execdir,
565 install_tag : 'tests',
566 install : installed_tests_enabled)
567
568 gio_tests += {
569 'gdbus-connection-flush' : {
570 'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
571 },
572 'gdbus-non-socket' : {
573 'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
574 },
575 }
576
577 # Generate test.mo from de.po using msgfmt
578 msgfmt = find_program('msgfmt', required : false)
579 if msgfmt.found()
580 subdir('de/LC_MESSAGES')
581 gio_tests += {
582 'gsettings' : {
583 'extra_sources' : [test_mo],
584 'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()),
585 '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)],
586 'install' : false,
587 'depends' : glib_compile_schemas,
588 # FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/3148
589 'can_fail' : host_system == 'gnu',
590 },
591 }
592 endif
593 endif # unix
594
595 # Test programs buildable on Windows only
596 if host_machine.system() == 'windows'
597 gio_tests += {'win32-streams' : {}}
598 endif
599
600 if cc.get_id() != 'msvc'
601 gio_tests += {
602 'autoptr-gio' : {
603 'source' : 'autoptr.c',
604 },
605 }
606 endif
607
608 test_extra_programs += {
609 'gio-du' : {'install' : false},
610 'echo-server' : {'install' : false},
611 'filter-cat' : {'install' : false},
612 'gapplication-example-actions' : {'install' : false},
613 'gapplication-example-cmdline' : {'install' : false},
614 'gapplication-example-cmdline2' : {'install' : false},
615 'gapplication-example-cmdline3' : {'install' : false},
616 'gapplication-example-cmdline4' : {'install' : false},
617 'gapplication-example-dbushooks' : {'install' : false},
618 'gapplication-example-open' : {'install' : false},
619 'gdbus-daemon' : {
620 'extra_sources' : gdbus_daemon_sources,
621 'install' : false,
622 },
623 'gdbus-example-export' : {'install' : false},
624 'gdbus-example-own-name' : {'install' : false},
625 'gdbus-example-peer' : {'install' : false},
626 'gdbus-example-proxy-subclass' : {'install' : false},
627 'gdbus-example-server' : {'install' : false},
628 'gdbus-example-subtree' : {'install' : false},
629 'gdbus-example-watch-name' : {'install' : false},
630 'gdbus-example-watch-proxy' : {'install' : false},
631 'httpd' : {'install' : false},
632 'proxy' : {'install' : false},
633 'resolver' : {'install' : false},
634 'send-data' : {'install' : false},
635 'socket-testserver' : {'install' : false},
636 'socket-testclient' : {
637 'extra_sources' : ['gtlsconsoleinteraction.c'],
638 'install' : false,
639 },
640 }
641
642 gdbus_example_objectmanager_sources = files(
643 'gdbus-example-objectmanager-client.c',
644 'gdbus-example-objectmanager-server.c',
645 )
646
647 if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
648 test_extra_programs += {
649 # These three are manual-run tests because they need a session bus but don't bring one up themselves
650 # FIXME: these build but don't seem to work!
651 'gdbus-example-objectmanager-client' : {
652 'dependencies' : [libgdbus_example_objectmanager_dep],
653 'install' : false,
654 },
655 'gdbus-example-objectmanager-server' : {
656 'dependencies' : [libgdbus_example_objectmanager_dep],
657 'install' : false,
658 },
659 'gdbus-test-fixture' : {
660 'dependencies' : [libgdbus_example_objectmanager_dep],
661 'install' : false,
662 },
663 }
664 endif
665
666 if host_machine.system() != 'windows'
667 test_extra_programs += {
668 'gdbus-example-unix-fd-client' : {
669 'install' : false,
670 },
671 }
672 endif
673
674 appinfo_test_desktop_files = [
675 'appinfo-test-gnome',
676 'appinfo-test-notgnome',
677 'appinfo-test-path',
678 'appinfo-test',
679 'appinfo-test2',
680 ]
681
682 foreach appinfo_test_desktop_file : appinfo_test_desktop_files
683 input_desktop_file = appinfo_test_desktop_file + '.desktop.in'
684 output_desktop_file = appinfo_test_desktop_file + '.desktop'
685 configure_file(
686 input: input_desktop_file,
687 output: output_desktop_file,
688 configuration: {
689 'installed_tests_dir' : meson.current_build_dir(),
690 },
691 )
692
693 if installed_tests_enabled
694 installed_desktop = configure_file(
695 input: input_desktop_file,
696 output: appinfo_test_desktop_file + '-installed.desktop',
697 configuration: {
698 'installed_tests_dir' : installed_tests_execdir,
699 },
700 )
701
702 install_data(installed_desktop,
703 install_dir: installed_tests_execdir,
704 install_tag: 'tests',
705 rename: output_desktop_file,
706 )
707 endif
708 endforeach
709
710 if installed_tests_enabled
711 install_data(
712 'contexts.c',
713 'g-icon.c',
714 'appinfo-test-actions.desktop',
715 'appinfo-test-static.desktop',
716 'file.c',
717 'org.gtk.test.dbusappinfo.desktop',
718 'org.gtk.test.dbusappinfo.flatpak.desktop',
719 'test1.overlay',
720 install_dir : installed_tests_execdir,
721 install_tag : 'tests',
722 )
723 install_subdir('x-content',
724 install_dir : installed_tests_execdir,
725 install_tag : 'tests',
726 )
727 install_subdir('desktop-files',
728 install_dir : installed_tests_execdir,
729 install_tag : 'tests',
730 )
731 install_subdir('thumbnails',
732 install_dir : installed_tests_execdir,
733 install_tag : 'tests',
734 )
735 install_subdir('cert-tests',
736 install_dir : installed_tests_execdir,
737 install_tag : 'tests',
738 )
739
740 cdata = configuration_data()
741 cdata.set('installed_tests_dir', installed_tests_execdir)
742 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir)
743 configure_file(
744 input: installed_tests_template,
745 output: 'static-link.test',
746 install_dir: installed_tests_metadir,
747 install_tag: 'tests',
748 configuration: cdata
749 )
750 install_subdir('static-link',
751 install_dir : installed_tests_execdir,
752 install_tag : 'tests',
753 )
754 install_data('static-link.py',
755 install_dir : installed_tests_execdir,
756 install_tag : 'tests',
757 )
758
759 monitor_tests = [
760 'memory-monitor-dbus',
761 'memory-monitor-portal',
762 'power-profile-monitor-dbus',
763 'power-profile-monitor-portal'
764 ]
765
766 foreach monitor_test : monitor_tests
767 cdata = configuration_data()
768 cdata.set('installed_tests_dir', installed_tests_execdir)
769 cdata.set('program', monitor_test + '.py')
770 cdata.set('env', '')
771 configure_file(
772 input: installed_tests_template_tap,
773 output: monitor_test + '.test',
774 install_dir: installed_tests_metadir,
775 install_tag: 'tests',
776 configuration: cdata
777 )
778 cdata = configuration_data()
779 cdata.set('libexecdir', join_paths(glib_prefix, get_option('libexecdir')))
780 configure_file(
781 input: monitor_test + '.py.in',
782 output: monitor_test + '.py',
783 install_dir : installed_tests_execdir,
784 install_tag : 'tests',
785 configuration: cdata,
786 )
787 endforeach
788 endif
789
790 # FIXME: Work around Meson not automatically using exe_wrapper around glib_compile_resources
791 # https://github.com/mesonbuild/meson/issues/11029
792 if not meson.is_cross_build()
793
794 resource_plugin = []
795 compiler_type = '--compiler=@0@'.format(cc.get_id())
796
797 if glib_build_shared
798 plugin_resources_c = custom_target('plugin-resources.c',
799 input : 'test4.gresource.xml',
800 output : 'plugin-resources.c',
801 command : [glib_compile_resources,
802 compiler_type,
803 '--target=@OUTPUT@',
804 '--sourcedir=' + meson.current_source_dir(),
805 '--internal',
806 '--generate-source',
807 '--c-name', '_g_plugin',
808 '@INPUT@'])
809
810 resource_plugin += shared_module('resourceplugin',
811 sources: ['resourceplugin.c', plugin_resources_c],
812 link_args : export_dynamic_ldflags,
813 dependencies : common_gio_tests_deps,
814 install_dir : installed_tests_execdir,
815 install_tag : 'tests',
816 install : installed_tests_enabled
817 )
818 endif
819
820 # referenced by test2.gresource.xml
821 big_test_resource = custom_target(
822 'gresource-big-test.txt',
823 input : ['gen-big-test-resource.py'],
824 output : ['gresource-big-test.txt'],
825 command : [python, '@INPUT0@', '@OUTPUT@'])
826
827 # referenced by test.gresource.xml
828 test_generated_txt = fs.copyfile('test1.txt', 'test-generated.txt')
829
830 test_gresource = custom_target('test.gresource',
831 input : 'test.gresource.xml',
832 depends : test_generated_txt,
833 output : 'test.gresource',
834 command : [glib_compile_resources,
835 compiler_type,
836 '--target=@OUTPUT@',
837 '--sourcedir=' + meson.current_source_dir(),
838 '--sourcedir=' + meson.current_build_dir(),
839 '--internal',
840 '@INPUT@'],
841 install_dir : installed_tests_execdir,
842 install_tag : 'tests',
843 install : installed_tests_enabled)
844
845 test_resources2_c = custom_target('test_resources2.c',
846 input : 'test3.gresource.xml',
847 output : 'test_resources2.c',
848 command : [glib_compile_resources,
849 compiler_type,
850 '--target=@OUTPUT@',
851 '--sourcedir=' + meson.current_source_dir(),
852 '--internal',
853 '--generate',
854 '--c-name', '_g_test2',
855 '--manual-register',
856 '@INPUT@'])
857
858 test_resources2_h = custom_target('test_resources2.h',
859 input : 'test3.gresource.xml',
860 output : 'test_resources2.h',
861 command : [glib_compile_resources,
862 compiler_type,
863 '--target=@OUTPUT@',
864 '--sourcedir=' + meson.current_source_dir(),
865 '--internal',
866 '--generate',
867 '--c-name', '_g_test2',
868 '--manual-register',
869 '@INPUT@'])
870
871 test_resources_c = custom_target('test_resources.c',
872 input : 'test2.gresource.xml',
873 depends : big_test_resource,
874 output : 'test_resources.c',
875 command : [glib_compile_resources,
876 compiler_type,
877 '--target=@OUTPUT@',
878 '--sourcedir=' + meson.current_source_dir(),
879 '--sourcedir=' + meson.current_build_dir(),
880 '--internal',
881 '--generate-source',
882 '--c-name', '_g_test1',
883 '@INPUT@'])
884
885 digit_test_resources_c = custom_target('digit_test_resources.c',
886 input : '111_digit_test.gresource.xml',
887 output : 'digit_test_resources.c',
888 command : [glib_compile_resources,
889 compiler_type,
890 '--target=@OUTPUT@',
891 '--sourcedir=' + meson.current_source_dir(),
892 '--sourcedir=' + meson.current_build_dir(),
893 '--internal',
894 '--generate-source',
895 '--manual-register',
896 '@INPUT@'])
897
898 digit_test_resources_h = custom_target('digit_test_resources.h',
899 input : '111_digit_test.gresource.xml',
900 output : 'digit_test_resources.h',
901 command : [glib_compile_resources,
902 compiler_type,
903 '--target=@OUTPUT@',
904 '--sourcedir=' + meson.current_source_dir(),
905 '--internal',
906 '--generate',
907 '--manual-register',
908 '@INPUT@'])
909
910 resources_extra_sources = [
911 test_gresource,
912 test_resources_c,
913 test_resources2_c,
914 test_resources2_h,
915 digit_test_resources_c,
916 digit_test_resources_h,
917 ]
918
919 # Create object file containing resource data for testing the --external-data
920 # option. Currently only GNU ld and objcopy, or (as of 2019) LLVM ld and
921 # objcopy, support the right options.
922 objcopy_supports_add_symbol = false
923 objcopy = find_program('objcopy', required : false)
924 if objcopy.found()
925 # FIXME: This should be `check: true` because we never really expect
926 # `objcopy --help` to fail, given that `objcopy` exists. However, it does
927 # fail on FreeBSD because ELF Tool Chain has
928 # [a bug](https://sourceforge.net/p/elftoolchain/code/3950/).
929 # This can be changed back to `check: true` once our CI uses a FreeBSD
930 # version which includes the fix.
931 # See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2360#note_1318608
932 objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
933 endif
934
935 ld = find_program('ld', required : false)
936
937 if build_machine.system() != 'linux'
938 why_no_external_data = 'only works on Linux'
939 elif not objcopy.found()
940 why_no_external_data = 'objcopy not found'
941 elif not objcopy_supports_add_symbol
942 why_no_external_data = 'objcopy does not support --add-symbol'
943 elif not ld.found()
944 why_no_external_data = 'ld not found'
945 elif build_machine.cpu_family() in ['mips', 'mips64']
946 why_no_external_data = 'cc -r can produce a mismatched MIPS ABI family, see GNOME/glib!3640'
947 else
948 why_no_external_data = ''
949
950 test_gresource_binary = custom_target('test5.gresource',
951 input : 'test5.gresource.xml',
952 output : 'test5.gresource',
953 command : [glib_compile_resources,
954 compiler_type,
955 '--target=@OUTPUT@',
956 '--sourcedir=' + meson.current_source_dir(),
957 '--sourcedir=' + meson.current_build_dir(),
958 '--internal',
959 '@INPUT@'],
960 install_dir : installed_tests_execdir,
961 install_tag : 'tests',
962 install : installed_tests_enabled)
963
964 # Create resource data file
965 test_resources_binary_c = custom_target('test_resources_binary.c',
966 input : 'test5.gresource.xml',
967 output : 'test_resources_binary.c',
968 command : [glib_compile_resources,
969 compiler_type,
970 '--target=@OUTPUT@',
971 '--sourcedir=' + meson.current_source_dir(),
972 '--sourcedir=' + meson.current_build_dir(),
973 '--internal',
974 '--generate-source',
975 '--external-data',
976 '--c-name', '_g_binary_test1',
977 '@INPUT@'])
978
979 # Create object file containing resource data
980 test_resources_binary = custom_target('test_resources.o',
981 input : test_gresource_binary,
982 output : 'test_resources.o',
983 command : cc.cmd_array() + ['-Wl,-z,noexecstack', '-r', '-Wl,-b,binary',
984 '-nostdlib', '@INPUT@', '-o','@OUTPUT@'])
985
986 # Rename symbol to match the one in the C file
987 if cc.get_id() == 'gcc' and host_system == 'windows'
988 underscore = '_'
989 else
990 underscore = ''
991 endif
992 test_resources_binary2 = custom_target('test_resources2.o',
993 input : test_resources_binary,
994 output : 'test_resources2.o',
995 command : [objcopy,
996 '--strip-debug',
997 '--add-symbol', underscore + '_g_binary_test1_resource_data=.data:0',
998 '@INPUT@',
999 '@OUTPUT@'])
1000
1001 resources_extra_sources += [
1002 test_resources_binary_c,
1003 test_resources_binary2,
1004 ]
1005 endif
1006
1007 resources_c_args = []
1008
1009 if why_no_external_data != ''
1010 resources_c_args += '-DNO_EXTERNAL_DATA="@0@"'.format(why_no_external_data)
1011 endif
1012
1013 gio_tests += {
1014 'resources' : {
1015 'c_args' : resources_c_args,
1016 'extra_sources' : resources_extra_sources,
1017 'depends' : resource_plugin,
1018 # FIXME: musl: https://gitlab.gnome.org/GNOME/glib/-/issues/3160
1019 'can_fail' : linux_libc == 'musl',
1020 },
1021 }
1022 endif
1023
1024 test_extra_programs_targets = {}
1025 foreach program_name, extra_args : test_extra_programs
1026 source = extra_args.get('source', program_name + '.c')
1027 extra_sources = extra_args.get('extra_sources', [])
1028 install = installed_tests_enabled and extra_args.get('install', true)
1029 test_extra_programs_targets += {
1030 program_name : executable(program_name,
1031 sources: [source, extra_sources],
1032 c_args : test_c_args,
1033 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
1034 install_dir : installed_tests_execdir,
1035 install_tag : 'tests',
1036 install : install,
1037 )
1038 }
1039 endforeach
1040
1041 foreach test_name, extra_args : gio_tests
1042 source = extra_args.get('source', test_name + '.c')
1043 extra_sources = extra_args.get('extra_sources', [])
1044 install = installed_tests_enabled and extra_args.get('install', true)
1045 installed_tests_env = extra_args.get('installed_tests_env', {})
1046
1047 if install
1048 test_conf = configuration_data()
1049 test_conf.set('installed_tests_dir', installed_tests_execdir)
1050 test_conf.set('program', test_name)
1051 test_env_override = ''
1052 if installed_tests_env != {}
1053 envs = []
1054 foreach var, value : installed_tests_env
1055 envs += '@0@=@1@'.format(var, value)
1056 endforeach
1057 test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs))
1058 endif
1059 test_conf.set('env', test_env_override)
1060 configure_file(
1061 input: installed_tests_template_tap,
1062 output: test_name + '.test',
1063 install_dir: installed_tests_metadir,
1064 install_tag: 'tests',
1065 configuration: test_conf
1066 )
1067 endif
1068
1069 exe = executable(test_name, [source, extra_sources],
1070 c_args : test_c_args + extra_args.get('c_args', []),
1071 cpp_args : test_cpp_args + extra_args.get('cpp_args', []),
1072 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
1073 install_rpath : extra_args.get('install_rpath', ''),
1074 install_dir: installed_tests_execdir,
1075 install_tag: 'tests',
1076 install: install,
1077 )
1078
1079 suite = ['gio'] + extra_args.get('suite', [])
1080 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
1081 local_test_env = test_env
1082 depends = [extra_args.get('depends', [])]
1083
1084 foreach program : extra_args.get('extra_programs', [])
1085 depends += test_extra_programs_targets[program]
1086 endforeach
1087
1088 foreach var, value : extra_args.get('env', {})
1089 local_test_env.append(var, value)
1090 endforeach
1091
1092 if extra_args.get('can_fail', false)
1093 suite += 'failing'
1094 endif
1095
1096 test(test_name, exe,
1097 protocol : extra_args.get('protocol', test_protocol),
1098 env : local_test_env,
1099 timeout : timeout,
1100 suite : suite,
1101 is_parallel : extra_args.get('is_parallel', true),
1102 depends : depends,
1103 should_fail : extra_args.get('should_fail', false),
1104 )
1105 endforeach
1106
1107 foreach test_name, extra_args : python_tests
1108 depends = [extra_args.get('depends', [])]
1109 suite = ['gio', 'no-valgrind'] + extra_args.get('suite', [])
1110 timeout = extra_args.get('timeout', test_timeout)
1111
1112 if extra_args.get('can_fail', false)
1113 suite += 'failing'
1114 endif
1115
1116 foreach program : extra_args.get('extra_programs', [])
1117 depends += test_extra_programs_targets[program]
1118 endforeach
1119
1120 test(
1121 test_name,
1122 python,
1123 protocol : extra_args.get('protocol', test_protocol),
1124 depends: depends,
1125 args: ['-B', files(test_name)],
1126 env: test_env,
1127 timeout: timeout,
1128 suite: suite,
1129 )
1130
1131 if installed_tests_enabled
1132 install_data(
1133 files(test_name),
1134 install_dir: installed_tests_execdir,
1135 install_tag: 'tests',
1136 install_mode: 'rwxr-xr-x',
1137 )
1138
1139 test_conf = configuration_data()
1140 test_conf.set('installed_tests_dir', installed_tests_execdir)
1141 test_conf.set('program', test_name)
1142 test_conf.set('env', '')
1143 configure_file(
1144 input: installed_tests_template_tap,
1145 output: test_name + '.test',
1146 install_dir: installed_tests_metadir,
1147 install_tag: 'tests',
1148 configuration: test_conf,
1149 )
1150 endif
1151 endforeach
1152
1153 # TAP test runner for Python tests
1154 if installed_tests_enabled
1155 install_data(
1156 files('taptestrunner.py'),
1157 install_dir: installed_tests_execdir,
1158 install_tag: 'tests',
1159 )
1160 endif
1161
1162 if have_bash and have_pkg_config
1163 prefix = get_option('prefix')
1164 if prefix.endswith(':/')
1165 prefix += '/'
1166 endif
1167
1168 pkg_config_tests = [
1169 'pkg-config --validate gio-2.0',
1170 'test "$(pkg-config --modversion gio-2.0)" = "@0@"'.format(glib_version),
1171 'test "$(pkg-config --variable=prefix gio-2.0)" = "@0@"'.format(
1172 get_option('prefix')),
1173 'test "$(pkg-config --variable=datadir gio-2.0)" = "@0@"'.format(
1174 prefix / get_option('datadir')),
1175 'test "$(pkg-config --variable=schemasdir gio-2.0)" = "@0@"'.format(
1176 prefix / get_option('datadir') / schemas_subdir),
1177 'test "$(pkg-config --variable=giomoduledir gio-2.0)" = "@0@"'.format(
1178 get_option('gio_module_dir') != '' ?
1179 prefix / get_option('gio_module_dir') :
1180 prefix / get_option('libdir') / 'gio' / 'modules'),
1181 ]
1182
1183 gio_binaries = [
1184 'gio',
1185 'glib-compile-resources',
1186 'gdbus',
1187 'gdbus-codegen',
1188 'gresource',
1189 'gsettings',
1190 ]
1191 gio_multiarch_binaries = [
1192 'gio-querymodules',
1193 'glib-compile-schemas',
1194 ]
1195
1196 foreach binary: gio_binaries
1197 pkg_config_tests += [
1198 'test "$(pkg-config --variable=@0@ gio-2.0)" = "@1@"'.format(
1199 binary.underscorify(),
1200 prefix / get_option('bindir') / binary)
1201 ]
1202 endforeach
1203
1204 foreach binary: gio_multiarch_binaries
1205 pkg_config_tests += [
1206 'test "$(pkg-config --variable=@0@ gio-2.0)" = "@1@"'.format(
1207 binary.underscorify(),
1208 prefix / multiarch_bindir / binary)
1209 ]
1210 endforeach
1211
1212 test('gio-2.0-pkg-config',
1213 bash,
1214 args: [ '-xe', '-c', '\n'.join(pkg_config_tests) ],
1215 suite: ['gio', 'no-valgrind', 'pkg-config'],
1216 env: {
1217 'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
1218 },
1219 )
1220
1221 platform_module = host_system == 'windows' ? 'gio-windows-2.0' : 'gio-unix-2.0'
1222 pkg_config_tests = [
1223 'pkg-config --validate ' + platform_module,
1224 'test "$(pkg-config --modversion @0@)" = "@1@"'.format(platform_module,
1225 glib_version),
1226 'test "$(pkg-config --variable=prefix @0@)" = "@1@"'.format(platform_module,
1227 get_option('prefix')),
1228 ]
1229
1230 test(platform_module + '-pkg-config',
1231 bash,
1232 args: [ '-xe', '-c', '\n'.join(pkg_config_tests) ],
1233 suite: ['gio', 'no-valgrind', 'pkg-config'],
1234 env: {
1235 'PKG_CONFIG_PATH': meson.project_build_root() / 'meson-private',
1236 },
1237 )
1238 endif
1239
1240 subdir('services')