1common_gio_tests_deps = [ 2 libglib_dep, 3 libgmodule_dep, 4 libgobject_dep, 5 libgio_dep, 6] 7 8test_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# workaround for https://github.com/mesonbuild/meson/issues/6880 16if build_machine.system() == 'linux' 17 libutil_name = 'libutil' 18 libutil = run_command('sh', '-c', 19 '''ldconfig -p | grep -o "[[:space:]]@0@\.so\(\.[0-9]\+\)\?\b"''' 20 .format(libutil_name)).stdout().strip().split('\n') 21 22 if libutil.length() > 0 23 message('Found libutil as @0@'.format(libutil[0])) 24 test_c_args += '-DLIBUTIL_SONAME="@0@"'.format(libutil[0]) 25 else 26 warning('libutil not found') 27 endif # libutil.length() > 0 28endif # build_machine.system() == 'linux' 29 30if host_machine.system() == 'windows' 31 common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')] 32endif 33 34subdir('gdbus-object-manager-example') 35 36gengiotypefuncs_prog = find_program('gengiotypefuncs.py') 37giotypefuncs_inc = custom_target( 38 'giotypefuncs.inc', 39 output : 'giotypefuncs.inc', 40 input : gio_headers + [gioenumtypes_h] + gobject_install_headers, 41 command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@']) 42 43# Test programs buildable on all platforms 44gio_tests = { 45 'appmonitor' : {}, 46 'async-close-output-stream' : {}, 47 'async-splice-output-stream' : {}, 48 'buffered-input-stream' : {}, 49 'buffered-output-stream' : {}, 50 'cancellable' : {}, 51 'contexts' : {}, 52 'contenttype' : {}, 53 'converter-stream' : {}, 54 'credentials' : {}, 55 'data-input-stream' : {}, 56 'data-output-stream' : {}, 57 'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]}, 58 'fileattributematcher' : {}, 59 'filter-streams' : {}, 60 'giomodule' : {}, 61 'gsubprocess' : {}, 62 'g-file' : {}, 63 'g-file-info' : {}, 64 'g-icon' : {}, 65 'gdbus-addresses' : {}, 66 'gdbus-message' : {}, 67 'inet-address' : {}, 68 'io-stream' : {}, 69 'memory-input-stream' : {}, 70 'memory-monitor' : {}, 71 'memory-output-stream' : {}, 72 'mount-operation' : {}, 73 'network-address' : {'extra_sources': ['mock-resolver.c']}, 74 'network-monitor' : {}, 75 'network-monitor-race' : {}, 76 'permission' : {}, 77 'pollable' : {'dependencies' : [libdl_dep]}, 78 'proxy-test' : {}, 79 'readwrite' : {}, 80 'simple-async-result' : {}, 81 'simple-proxy' : {}, 82 'sleepy-stream' : {}, 83 'socket' : {}, 84 'socket-listener' : {}, 85 'socket-service' : {}, 86 'srvtarget' : {}, 87 'task' : {}, 88 'vfs' : {}, 89 'volumemonitor' : {}, 90 'glistmodel' : {}, 91 'testfilemonitor' : {'suite' : ['slow', 'flaky']}, 92 'thumbnail-verification' : {}, 93 'tls-certificate' : {'extra_sources' : ['gtesttlsbackend.c']}, 94 'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']}, 95 'tls-database' : {'extra_sources' : ['gtesttlsbackend.c']}, 96 'tls-bindings' : {'extra_sources' : ['gtesttlsbackend.c']}, 97 'gdbus-address-get-session' : {}, 98 'win32-appinfo' : {}, 99} 100 101test_extra_programs = { 102 'gdbus-connection-flush-helper' : {}, 103 'gdbus-testserver' : {}, 104 'gsubprocess-testprog' : {}, 105} 106 107python_tests = [ 108 'codegen.py', 109] 110 111test_env = environment() 112test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) 113test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) 114test_env.set('GIO_MODULE_DIR', '') 115 116# Check for libdbus1 - Optional - is only used in the GDBus test cases 117# 1.2.14 required for dbus_message_set_serial 118dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14') 119if not dbus1_dep.found() 120 if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' 121 # MSVC: Search for the DBus library by the configuration, which corresponds 122 # to the output of CMake builds of DBus. Note that debugoptimized 123 # is really a Release build with .PDB files. 124 if vs_crt == 'debug' 125 dbus1_dep = cc.find_library('dbus-1d', required : false) 126 else 127 dbus1_dep = cc.find_library('dbus-1', required : false) 128 endif 129 endif 130endif 131if dbus1_dep.found() 132 glib_conf.set('HAVE_DBUS1', 1) 133 134 gio_tests += { 135 'gdbus-serialization' : { 136 'extra_sources' : ['gdbus-tests.c'], 137 'dependencies' : [dbus1_dep], 138 }, 139 'gdbus-server-auth' : { 140 'dependencies' : [dbus1_dep], 141 }, 142 } 143else 144 # We can build a cut-down version of this test without libdbus 145 gio_tests += { 146 'gdbus-server-auth' : {}, 147 } 148endif 149 150# Test programs buildable on UNIX only 151if host_machine.system() != 'windows' 152 gio_tests += { 153 'file' : {}, 154 'gdbus-peer' : { 155 'dependencies' : [libgdbus_example_objectmanager_dep], 156 'install_rpath' : installed_tests_execdir 157 }, 158 'gdbus-peer-object-manager' : {}, 159 'live-g-file' : {}, 160 'socket-address' : {}, 161 'stream-rw_all' : {}, 162 'unix-fd' : {}, 163 'unix-mounts' : {}, 164 'unix-streams' : {}, 165 'g-file-info-filesystem-readonly' : {}, 166 'gschema-compile' : {'install' : false}, 167 'trash' : {}, 168 } 169 170 # LD_PRELOAD modules don't work so well with AddressSanitizer 171 if have_rtld_next and get_option('b_sanitize') == 'none' 172 gio_tests += { 173 'gsocketclient-slow' : { 174 'depends' : [ 175 shared_library('slow-connect-preload', 176 'slow-connect-preload.c', 177 name_prefix : '', 178 dependencies: libdl_dep, 179 install_dir : installed_tests_execdir, 180 install: installed_tests_enabled, 181 ) 182 ], 183 'env' : { 184 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir()) 185 }, 186 'installed_tests_env' : { 187 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir), 188 }, 189 }, 190 } 191 endif 192 193 # Uninstalled because of the check-for-executable logic in DesktopAppInfo 194 # unable to find the installed executable 195 if not glib_have_cocoa 196 gio_tests += { 197 'appinfo' : { 198 'install' : false, 199 }, 200 'desktop-app-info' : { 201 'install' : false, 202 }, 203 } 204 endif 205 206 test_extra_programs += { 207 'basic-application' : {}, 208 'dbus-launch' : {}, 209 'appinfo-test' : {}, 210 } 211 212 if not glib_have_cocoa 213 test_extra_programs += { 214 'apps' : {}, 215 } 216 gio_tests += { 217 'mimeapps' : {}, 218 } 219 endif 220 221 # Test programs that need to bring up a session bus (requires dbus-daemon) 222 have_dbus_daemon = find_program('dbus-daemon', required : false).found() 223 if have_dbus_daemon 224 annotate_args = [ 225 '--annotate', 'org.project.Bar', 'Key1', 'Value1', 226 '--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2', 227 '--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3', 228 '--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4', 229 '--annotate', 'org.project.Bar:ay', 'Key5', 'Value5', 230 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6', 231 '--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7', 232 '--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8', 233 ] 234 # Generate gdbus-test-codegen-generated.{c,h} 235 gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated', 236 input : ['test-codegen.xml'], 237 output : ['gdbus-test-codegen-generated.h', 238 'gdbus-test-codegen-generated.c'], 239 depend_files : gdbus_codegen_built_files, 240 command : [python, gdbus_codegen, 241 '--interface-prefix', 'org.project.', 242 '--output-directory', '@OUTDIR@', 243 '--generate-c-code', 'gdbus-test-codegen-generated', 244 '--c-generate-object-manager', 245 '--c-generate-autocleanup', 'all', 246 '--c-namespace', 'Foo_iGen', 247 '--generate-docbook', 'gdbus-test-codegen-generated-doc', 248 annotate_args, 249 '@INPUT@']) 250 # Generate gdbus-test-codegen-generated-min-required-2-64.{c,h} 251 gdbus_test_codegen_generated_min_required_2_64 = custom_target('gdbus-test-codegen-generated-min-required-2-64', 252 input : ['test-codegen.xml'], 253 output : ['gdbus-test-codegen-generated-min-required-2-64.h', 254 'gdbus-test-codegen-generated-min-required-2-64.c'], 255 depend_files : gdbus_codegen_built_files, 256 command : [python, gdbus_codegen, 257 '--glib-min-required', '2.64', 258 '--interface-prefix', 'org.project.', 259 '--output-directory', '@OUTDIR@', 260 '--generate-c-code', 'gdbus-test-codegen-generated-min-required-2-64', 261 '--c-generate-object-manager', 262 '--c-generate-autocleanup', 'all', 263 '--c-namespace', 'Foo_iGen', 264 '--generate-docbook', 'gdbus-test-codegen-generated-doc', 265 annotate_args, 266 '@INPUT@']) 267 gdbus_test_codegen_generated_interface_info = [ 268 custom_target('gdbus-test-codegen-generated-interface-info-h', 269 input : ['test-codegen.xml'], 270 output : ['gdbus-test-codegen-generated-interface-info.h'], 271 depend_files : gdbus_codegen_built_files, 272 command : [python, gdbus_codegen, 273 '--interface-info-header', 274 annotate_args, 275 '--output', '@OUTPUT@', 276 '@INPUT@']), 277 custom_target('gdbus-test-codegen-generated-interface-info-c', 278 input : ['test-codegen.xml'], 279 output : ['gdbus-test-codegen-generated-interface-info.c'], 280 depend_files : gdbus_codegen_built_files, 281 command : [python, gdbus_codegen, 282 '--interface-info-body', 283 annotate_args, 284 '--output', '@OUTPUT@', 285 '@INPUT@']), 286 ] 287 288 extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c'] 289 290 gio_tests += { 291 'actions' : { 292 'extra_sources' : extra_sources, 293 'suite' : ['slow'], 294 }, 295 'gdbus-auth' : {'extra_sources' : extra_sources}, 296 'gdbus-bz627724' : {'extra_sources' : extra_sources}, 297 'gdbus-close-pending' : {'extra_sources' : extra_sources}, 298 'gdbus-connection' : {'extra_sources' : extra_sources}, 299 'gdbus-connection-loss' : {'extra_sources' : extra_sources}, 300 'gdbus-connection-slow' : {'extra_sources' : extra_sources}, 301 'gdbus-error' : {'extra_sources' : extra_sources}, 302 'gdbus-exit-on-close' : {'extra_sources' : extra_sources}, 303 'gdbus-export' : { 304 'extra_sources' : extra_sources, 305 'suite' : ['slow'], 306 }, 307 'gdbus-introspection' : {'extra_sources' : extra_sources}, 308 'gdbus-names' : {'extra_sources' : extra_sources}, 309 'gdbus-proxy' : {'extra_sources' : extra_sources}, 310 'gdbus-proxy-threads' : { 311 'extra_sources' : extra_sources, 312 'dependencies' : [dbus1_dep], 313 }, 314 'gdbus-proxy-unique-name' : {'extra_sources' : extra_sources}, 315 'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources}, 316 'gdbus-test-codegen' : { 317 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info], 318 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32'], 319 }, 320 'gdbus-threading' : { 321 'extra_sources' : extra_sources, 322 'suite' : ['slow'], 323 }, 324 'gmenumodel' : { 325 'extra_sources' : extra_sources, 326 'suite' : ['slow'], 327 }, 328 'gnotification' : { 329 'extra_sources' : [extra_sources, 'gnotification-server.c'], 330 }, 331 'gdbus-test-codegen-old' : { 332 'source' : 'gdbus-test-codegen.c', 333 'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info], 334 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36', 335 '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'], 336 }, 337 'gdbus-test-codegen-min-required-2-64' : { 338 'source' : 'gdbus-test-codegen.c', 339 'extra_sources' : [extra_sources, gdbus_test_codegen_generated_min_required_2_64, gdbus_test_codegen_generated_interface_info], 340 'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_64'], 341 }, 342 'gapplication' : {'extra_sources' : extra_sources}, 343 } 344 345 if not glib_have_cocoa 346 gio_tests += { 347 'dbus-appinfo' : { 348 'extra_sources' : extra_sources, 349 }, 350 } 351 endif 352 353 fake_document_portal_generated = custom_target('fake-document-portal-generated', 354 input : ['../org.freedesktop.portal.Documents.xml'], 355 output : ['fake-document-portal-generated.h', 356 'fake-document-portal-generated.c'], 357 depend_files : gdbus_codegen_built_files, 358 command : [python, gdbus_codegen, 359 '--interface-prefix', 'org.freedesktop.portal.', 360 '--output-directory', '@OUTDIR@', 361 '--generate-c-code', 'fake-document-portal-generated', 362 '--c-namespace', 'Fake', 363 '@INPUT@']) 364 365 test_extra_programs += { 366 'fake-document-portal' : { 367 'extra_sources': fake_document_portal_generated, 368 }, 369 'fake-service-name' : {} 370 } 371 endif # have_dbus_daemon 372 373 # This test is currently unreliable 374 executable('gdbus-overflow', 'gdbus-overflow.c', 375 c_args : test_c_args, 376 dependencies : common_gio_tests_deps, 377 install_dir : installed_tests_execdir, 378 install : installed_tests_enabled) 379 380 gio_tests += { 381 'gdbus-connection-flush' : { 382 'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'], 383 }, 384 'gdbus-non-socket' : { 385 'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'], 386 }, 387 } 388 389 # Generate test.mo from de.po using msgfmt 390 msgfmt = find_program('msgfmt', required : false) 391 if msgfmt.found() 392 subdir('de/LC_MESSAGES') 393 gio_tests += { 394 'gsettings' : { 395 'extra_sources' : [test_mo], 396 'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()), 397 '-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)], 398 'install' : false, 399 }, 400 } 401 endif 402endif # unix 403 404# Test programs buildable on Windows only 405if host_machine.system() == 'windows' 406 gio_tests += {'win32-streams' : {}} 407endif 408 409if cc.get_id() != 'msvc' 410 gio_tests += { 411 'autoptr-gio' : { 412 'source' : 'autoptr.c', 413 }, 414 } 415endif 416 417test_extra_programs += { 418 'gio-du' : {'install' : false}, 419 'echo-server' : {'install' : false}, 420 'filter-cat' : {'install' : false}, 421 'gapplication-example-actions' : {'install' : false}, 422 'gapplication-example-cmdline' : {'install' : false}, 423 'gapplication-example-cmdline2' : {'install' : false}, 424 'gapplication-example-cmdline3' : {'install' : false}, 425 'gapplication-example-cmdline4' : {'install' : false}, 426 'gapplication-example-dbushooks' : {'install' : false}, 427 'gapplication-example-open' : {'install' : false}, 428 'gdbus-daemon' : { 429 'extra_sources' : gdbus_daemon_sources, 430 'install' : false, 431 }, 432 'gdbus-example-export' : {'install' : false}, 433 'gdbus-example-own-name' : {'install' : false}, 434 'gdbus-example-peer' : {'install' : false}, 435 'gdbus-example-proxy-subclass' : {'install' : false}, 436 'gdbus-example-server' : {'install' : false}, 437 'gdbus-example-subtree' : {'install' : false}, 438 'gdbus-example-watch-name' : {'install' : false}, 439 'gdbus-example-watch-proxy' : {'install' : false}, 440 'httpd' : {'install' : false}, 441 'proxy' : {'install' : false}, 442 'resolver' : {'install' : false}, 443 'send-data' : {'install' : false}, 444 'socket-server' : {'install' : false}, 445 'socket-client' : { 446 'extra_sources' : ['gtlsconsoleinteraction.c'], 447 'install' : false, 448 }, 449} 450 451gdbus_example_objectmanager_sources = files( 452 'gdbus-example-objectmanager-client.c', 453 'gdbus-example-objectmanager-server.c', 454) 455 456if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl' 457 test_extra_programs += { 458 # These three are manual-run tests because they need a session bus but don't bring one up themselves 459 # FIXME: these build but don't seem to work! 460 'gdbus-example-objectmanager-client' : { 461 'dependencies' : [libgdbus_example_objectmanager_dep], 462 'install' : false, 463 }, 464 'gdbus-example-objectmanager-server' : { 465 'dependencies' : [libgdbus_example_objectmanager_dep], 466 'install' : false, 467 }, 468 'gdbus-test-fixture' : { 469 'dependencies' : [libgdbus_example_objectmanager_dep], 470 'install' : false, 471 }, 472 } 473endif 474 475if host_machine.system() != 'windows' 476 test_extra_programs += { 477 'gdbus-example-unix-fd-client' : { 478 'install' : false, 479 }, 480 } 481endif 482 483appinfo_test_desktop_files = [ 484 'appinfo-test-gnome.desktop', 485 'appinfo-test-notgnome.desktop', 486 'appinfo-test.desktop', 487 'appinfo-test2.desktop', 488] 489 490cdata = configuration_data() 491if installed_tests_enabled 492 cdata.set('installed_tests_dir', installed_tests_execdir) 493else 494 cdata.set('installed_tests_dir', meson.current_build_dir()) 495endif 496 497foreach appinfo_test_desktop_file : appinfo_test_desktop_files 498 if installed_tests_enabled 499 configure_file( 500 input: appinfo_test_desktop_file + '.in', 501 output: appinfo_test_desktop_file, 502 install_dir: installed_tests_execdir, 503 configuration: cdata, 504 ) 505 else 506 configure_file( 507 input: appinfo_test_desktop_file + '.in', 508 output: appinfo_test_desktop_file, 509 configuration: cdata, 510 ) 511 endif 512endforeach 513 514if installed_tests_enabled 515 install_data( 516 'contexts.c', 517 'g-icon.c', 518 'appinfo-test-actions.desktop', 519 'appinfo-test-static.desktop', 520 'file.c', 521 'org.gtk.test.dbusappinfo.desktop', 522 'org.gtk.test.dbusappinfo.flatpak.desktop', 523 'test1.overlay', 524 install_dir : installed_tests_execdir, 525 ) 526 install_subdir('x-content', install_dir : installed_tests_execdir) 527 install_subdir('desktop-files', install_dir : installed_tests_execdir) 528 install_subdir('thumbnails', install_dir : installed_tests_execdir) 529 install_subdir('cert-tests', install_dir : installed_tests_execdir) 530 531 cdata = configuration_data() 532 cdata.set('installed_tests_dir', installed_tests_execdir) 533 cdata.set('program', 'static-link.py ' + glib_pkgconfigreldir) 534 configure_file( 535 input: installed_tests_template, 536 output: 'static-link.test', 537 install_dir: installed_tests_metadir, 538 configuration: cdata 539 ) 540 install_subdir('static-link', install_dir : installed_tests_execdir) 541 install_data('static-link.py', install_dir : installed_tests_execdir) 542 543 memory_monitor_tests = [ 544 'memory-monitor-dbus', 545 'memory-monitor-portal', 546 ] 547 548 foreach memory_monitor_test : memory_monitor_tests 549 cdata = configuration_data() 550 cdata.set('installed_tests_dir', installed_tests_execdir) 551 cdata.set('program', memory_monitor_test + '.py') 552 cdata.set('env', '') 553 configure_file( 554 input: installed_tests_template_tap, 555 output: memory_monitor_test + '.test', 556 install_dir: installed_tests_metadir, 557 configuration: cdata 558 ) 559 cdata = configuration_data() 560 cdata.set('libexecdir', join_paths(glib_prefix, get_option('libexecdir'))) 561 configure_file( 562 input: memory_monitor_test + '.py.in', 563 output: memory_monitor_test + '.py', 564 install_dir : installed_tests_execdir, 565 configuration: cdata, 566 ) 567 endforeach 568endif 569 570if not meson.is_cross_build() or meson.has_exe_wrapper() 571 572 plugin_resources_c = custom_target('plugin-resources.c', 573 input : 'test4.gresource.xml', 574 output : 'plugin-resources.c', 575 command : [glib_compile_resources, 576 '--target=@OUTPUT@', 577 '--sourcedir=' + meson.current_source_dir(), 578 '--generate-source', 579 '--c-name', '_g_plugin', 580 '@INPUT@']) 581 582 shared_module('resourceplugin', 'resourceplugin.c', plugin_resources_c, 583 link_args : export_dynamic_ldflags, 584 dependencies : common_gio_tests_deps, 585 install_dir : installed_tests_execdir, 586 install : installed_tests_enabled 587 ) 588 589 # referenced by test2.gresource.xml 590 big_test_resource = custom_target( 591 'gresource-big-test.txt', 592 input : ['gen-big-test-resource.py'], 593 output : ['gresource-big-test.txt'], 594 command : [python, '@INPUT0@', '@OUTPUT@']) 595 596 test_gresource = custom_target('test.gresource', 597 input : 'test.gresource.xml', 598 output : 'test.gresource', 599 command : [glib_compile_resources, 600 '--target=@OUTPUT@', 601 '--sourcedir=' + meson.current_source_dir(), 602 '--sourcedir=' + meson.current_build_dir(), 603 '@INPUT@'], 604 install_dir : installed_tests_execdir, 605 install : installed_tests_enabled) 606 607 test_resources2_c = custom_target('test_resources2.c', 608 input : 'test3.gresource.xml', 609 output : 'test_resources2.c', 610 command : [glib_compile_resources, 611 '--target=@OUTPUT@', 612 '--sourcedir=' + meson.current_source_dir(), 613 '--generate', 614 '--c-name', '_g_test2', 615 '--manual-register', 616 '@INPUT@']) 617 618 test_resources2_h = custom_target('test_resources2.h', 619 input : 'test3.gresource.xml', 620 output : 'test_resources2.h', 621 command : [glib_compile_resources, 622 '--target=@OUTPUT@', 623 '--sourcedir=' + meson.current_source_dir(), 624 '--generate', 625 '--c-name', '_g_test2', 626 '--manual-register', 627 '@INPUT@']) 628 629 test_resources_c = custom_target('test_resources.c', 630 input : 'test2.gresource.xml', 631 depends : big_test_resource, 632 output : 'test_resources.c', 633 command : [glib_compile_resources, 634 '--target=@OUTPUT@', 635 '--sourcedir=' + meson.current_source_dir(), 636 '--sourcedir=' + meson.current_build_dir(), 637 '--generate-source', 638 '--c-name', '_g_test1', 639 '@INPUT@']) 640 641 digit_test_resources_c = custom_target('digit_test_resources.c', 642 input : '111_digit_test.gresource.xml', 643 output : 'digit_test_resources.c', 644 command : [glib_compile_resources, 645 '--target=@OUTPUT@', 646 '--sourcedir=' + meson.current_source_dir(), 647 '--sourcedir=' + meson.current_build_dir(), 648 '--generate-source', 649 '--manual-register', 650 '@INPUT@']) 651 652 digit_test_resources_h = custom_target('digit_test_resources.h', 653 input : '111_digit_test.gresource.xml', 654 output : 'digit_test_resources.h', 655 command : [glib_compile_resources, 656 '--target=@OUTPUT@', 657 '--sourcedir=' + meson.current_source_dir(), 658 '--generate', 659 '--manual-register', 660 '@INPUT@']) 661 662 # referenced by test.gresource.xml 663 test_generated_txt = configure_file(input : 'test1.txt', 664 output : 'test-generated.txt', 665 copy : true, 666 ) 667 668 resources_extra_sources = [ 669 test_gresource, 670 test_resources_c, 671 test_resources2_c, 672 test_resources2_h, 673 digit_test_resources_c, 674 digit_test_resources_h, 675 ] 676 677 # Create object file containing resource data for testing the --external-data 678 # option. Currently only GNU ld and GNU objcopy support the right options. 679 # Support for --add-symbol was added to LLVM objcopy in 2019 680 # (https://reviews.llvm.org/D58234). FIXME: This test could be enabled for 681 # LLVM once that support is in a stable release. 682 objcopy_supports_add_symbol = false 683 objcopy = find_program('objcopy', required : false) 684 if objcopy.found() 685 objcopy_supports_add_symbol = run_command(objcopy, '--help').stdout().contains('--add-symbol') 686 endif 687 688 ld = find_program('ld', required : false) 689 690 if build_machine.system() == 'linux' and cc.get_id() == 'gcc' and objcopy.found() and objcopy_supports_add_symbol and ld.found() 691 test_gresource_binary = custom_target('test5.gresource', 692 input : 'test5.gresource.xml', 693 output : 'test5.gresource', 694 command : [glib_compile_resources, 695 '--target=@OUTPUT@', 696 '--sourcedir=' + meson.current_source_dir(), 697 '--sourcedir=' + meson.current_build_dir(), 698 '@INPUT@'], 699 install_dir : installed_tests_execdir, 700 install : installed_tests_enabled) 701 702 # Create resource data file 703 test_resources_binary_c = custom_target('test_resources_binary.c', 704 input : 'test5.gresource.xml', 705 output : 'test_resources_binary.c', 706 command : [glib_compile_resources, 707 '--target=@OUTPUT@', 708 '--sourcedir=' + meson.current_source_dir(), 709 '--sourcedir=' + meson.current_build_dir(), 710 '--generate-source', 711 '--external-data', 712 '--c-name', '_g_binary_test1', 713 '@INPUT@']) 714 715 # Create object file containing resource data 716 test_resources_binary = custom_target('test_resources.o', 717 input : test_gresource_binary, 718 output : 'test_resources.o', 719 command : [ld, 720 '-r', 721 '-b','binary', 722 '@INPUT@', 723 '-o','@OUTPUT@']) 724 725 # Rename symbol to match the one in the C file 726 test_resources_binary2 = custom_target('test_resources2.o', 727 input : test_resources_binary, 728 output : 'test_resources2.o', 729 command : [objcopy, 730 '--add-symbol','_g_binary_test1_resource_data=.data:0', 731 '@INPUT@', 732 '@OUTPUT@']) 733 734 resources_extra_sources += [ 735 test_resources_binary_c, 736 test_resources_binary2, 737 ] 738 endif 739 740 gio_tests += { 741 'resources' : { 742 'extra_sources' : resources_extra_sources, 743 }, 744 } 745endif 746 747foreach test_name, extra_args : gio_tests 748 source = extra_args.get('source', test_name + '.c') 749 extra_sources = extra_args.get('extra_sources', []) 750 install = installed_tests_enabled and extra_args.get('install', true) 751 installed_tests_env = extra_args.get('installed_tests_env', {}) 752 753 if install 754 test_conf = configuration_data() 755 test_conf.set('installed_tests_dir', installed_tests_execdir) 756 test_conf.set('program', test_name) 757 test_env_override = '' 758 if installed_tests_env != {} 759 envs = [] 760 foreach var, value : installed_tests_env 761 envs += '@0@=@1@'.format(var, value) 762 endforeach 763 test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs)) 764 endif 765 test_conf.set('env', test_env_override) 766 configure_file( 767 input: installed_tests_template_tap, 768 output: test_name + '.test', 769 install_dir: installed_tests_metadir, 770 configuration: test_conf 771 ) 772 endif 773 774 exe = executable(test_name, [source, extra_sources], 775 c_args : test_c_args + extra_args.get('c_args', []), 776 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []), 777 install_rpath : extra_args.get('install_rpath', ''), 778 install_dir: installed_tests_execdir, 779 install: install, 780 ) 781 782 suite = ['gio'] + extra_args.get('suite', []) 783 timeout = suite.contains('slow') ? test_timeout_slow : test_timeout 784 local_test_env = test_env 785 786 foreach var, value : extra_args.get('env', {}) 787 local_test_env.append(var, value) 788 endforeach 789 790 test(test_name, exe, 791 env : local_test_env, 792 timeout : timeout, 793 suite : suite, 794 is_parallel : extra_args.get('is_parallel', true), 795 depends : extra_args.get('depends', []), 796 ) 797endforeach 798 799foreach program_name, extra_args : test_extra_programs 800 source = extra_args.get('source', program_name + '.c') 801 extra_sources = extra_args.get('extra_sources', []) 802 install = installed_tests_enabled and extra_args.get('install', true) 803 executable(program_name, [source, extra_sources], 804 c_args : test_c_args, 805 dependencies : common_gio_tests_deps + extra_args.get('dependencies', []), 806 install_dir : installed_tests_execdir, 807 install : install, 808 ) 809endforeach 810 811foreach test_name : python_tests 812 test( 813 test_name, 814 python, 815 args: ['-B', files(test_name)], 816 env: test_env, 817 suite: ['gio', 'no-valgrind'], 818 ) 819 820 if installed_tests_enabled 821 install_data( 822 files(test_name), 823 install_dir: installed_tests_execdir, 824 install_mode: 'rwxr-xr-x', 825 ) 826 827 test_conf = configuration_data() 828 test_conf.set('installed_tests_dir', installed_tests_execdir) 829 test_conf.set('program', test_name) 830 test_conf.set('env', '') 831 configure_file( 832 input: installed_tests_template_tap, 833 output: test_name + '.test', 834 install_dir: installed_tests_metadir, 835 configuration: test_conf, 836 ) 837 endif 838endforeach 839 840# TAP test runner for Python tests 841if installed_tests_enabled 842 install_data( 843 files('taptestrunner.py'), 844 install_dir: installed_tests_execdir, 845 ) 846endif 847 848subdir('services') 849subdir('modules') 850