1tests_dep = declare_dependency( 2 compile_args: [ 3 '-Dabs_builddir="@0@"'.format(meson.current_build_dir()), 4 '-Dabs_top_builddir="@0@"'.format(meson.build_root()), 5 '-Dabs_srcdir="@0@"'.format(meson.current_source_dir()), 6 '-Dabs_top_srcdir="@0@"'.format(meson.source_root()), 7 ] + coverage_flags + cc_flags_relaxed_frame_limit, 8 dependencies: [ 9 apparmor_dep, 10 dlopen_dep, 11 glib_dep, 12 gnutls_dep, 13 libnl_dep, 14 libxml_dep, 15 rpc_dep, 16 sasl_dep, 17 selinux_dep, 18 xdr_dep, 19 yajl_dep, 20 ], 21 include_directories: [ 22 conf_inc_dir, 23 hypervisor_inc_dir, 24 libvirt_inc, 25 src_inc_dir, 26 top_inc_dir, 27 util_inc_dir, 28 ], 29 link_args: ( 30 libvirt_export_dynamic 31 + coverage_flags 32 ), 33) 34 35tests_env = [ 36 'abs_builddir=@0@'.format(meson.current_build_dir()), 37 'abs_srcdir=@0@'.format(meson.current_source_dir()), 38 'abs_top_builddir=@0@'.format(meson.build_root()), 39 'abs_top_srcdir=@0@'.format(meson.source_root()), 40 'LC_ALL=C', 41 'LIBVIRT_AUTOSTART=0', 42 'G_DEBUG=fatal-warnings', 43] 44 45if use_expensive_tests 46 tests_env += 'VIR_TEST_EXPENSIVE=1' 47else 48 tests_env += 'VIR_TEST_EXPENSIVE=0' 49endif 50 51 52# mock_libs: 53# each entry is a dictionary with following items: 54# * name - mock library name which is also used as default source file name (required) 55# * sources - override default sources based on name (optional, default []) 56# * deps - additional dependencies (optional, default []) 57 58mock_libs = [ 59 { 'name': 'domaincapsmock' }, 60 { 'name': 'shunload', 'sources': [ 'shunloadhelper.c' ] }, 61 { 'name': 'vircgroupmock' }, 62 { 'name': 'virfilecachemock' }, 63 { 'name': 'virfirewallmock' }, 64 { 'name': 'virgdbusmock' }, 65 { 'name': 'virhostcpumock' }, 66 { 'name': 'virhostdevmock' }, 67 { 'name': 'virnetdaemonmock' }, 68 { 'name': 'virnetdevmock' }, 69 { 'name': 'virnetserverclientmock' }, 70 { 'name': 'virpcimock' }, 71 { 'name': 'virportallocatormock' }, 72 { 'name': 'virprocessmock' }, 73 { 'name': 'virrandommock' }, 74] 75 76if host_machine.system() == 'linux' 77 mock_libs += [ 78 { 'name': 'virfilemock' }, 79 { 'name': 'virnetdevbandwidthmock' }, 80 { 'name': 'virnumamock' }, 81 { 'name': 'virtestmock' }, 82 { 'name': 'virusbmock' }, 83 ] 84endif 85 86if conf.has('WITH_BHYVE') 87 mock_libs += [ 88 { 'name': 'bhyveargv2xmlmock' }, 89 { 'name': 'bhyvexml2argvmock' }, 90 ] 91endif 92 93if conf.has('WITH_LIBXL') 94 mock_libs += [ 95 { 'name': 'xlmock', 'sources': [ 'libxlmock.c' ], 'deps': [ libxl_dep ] }, 96 ] 97endif 98 99if conf.has('WITH_NSS') 100 mock_libs += [ 101 { 'name': 'nssmock' }, 102 ] 103endif 104 105if conf.has('WITH_QEMU') 106 mock_libs += [ 107 { 'name': 'qemucaps2xmlmock' }, 108 { 'name': 'qemucpumock' }, 109 { 'name': 'qemuhotplugmock' }, 110 { 'name': 'qemuxml2argvmock' }, 111 { 'name': 'virhostidmock' }, 112 ] 113endif 114 115if conf.has('WITH_SECDRIVER_SELINUX') 116 mock_libs += [ 117 { 'name': 'securityselinuxhelper' }, 118 ] 119endif 120 121 122# build libraries used by tests 123 124test_utils_lib = static_library( 125 'test_utils', 126 [ 'testutils.c' ], 127 dependencies: [ tests_dep ], 128) 129 130if conf.has('WITH_LIBXL') 131 test_utils_xen_lib = static_library( 132 'test_utils_xen', 133 [ 'testutilsxen.c' ], 134 dependencies: [ tests_dep ], 135 ) 136 137 test_xen_driver_lib = shared_library( 138 'test_xen_driver', 139 link_whole: [ libxl_driver_imp ], 140 link_with: [ libvirt_lib ], 141 ) 142else 143 test_utils_xen_lib = [] 144 test_xen_driver_lib = [] 145endif 146 147if conf.has('WITH_LXC') 148 test_utils_lxc_lib = static_library( 149 'test_utils_lxc', 150 [ 'testutilslxc.c' ], 151 dependencies: [ tests_dep ], 152 ) 153else 154 test_utils_lxc_lib = [] 155endif 156 157if conf.has('WITH_QEMU') 158 test_utils_qemu_lib = static_library( 159 'test_utils_qemu', 160 [ 'testutilsqemu.c' ], 161 dependencies: [ tests_dep ], 162 ) 163 164 test_utils_qemu_monitor_lib = static_library( 165 'test_utils_qemu_monitor', 166 [ 'qemumonitortestutils.c', 'testutilsqemuschema.c' ], 167 dependencies: [ tests_dep ], 168 ) 169 170 test_qemu_driver_lib = shared_library( 171 'test_qemu_driver', 172 [ qemu_dtrace_gen_objects ], 173 link_args: [ libvirt_flat_namespace ], 174 link_whole: [ qemu_driver_impl ], 175 link_with: [ libvirt_lib ], 176 ) 177 178 mock_libs += [ 179 { 'name': 'qemucapsprobemock', 'link_with': [ test_qemu_driver_lib ] }, 180 ] 181else 182 test_qemu_driver_lib = [] 183 test_utils_qemu_lib = [] 184 test_utils_qemu_monitor_lib = [] 185endif 186 187test_file_wrapper_lib = static_library( 188 'test_file_wrapper', 189 [ 'virfilewrapper.c' ], 190 dependencies: [ tests_dep ], 191) 192 193foreach mock : mock_libs 194 shared_library( 195 mock['name'], 196 mock.get('sources', [ '@0@.c'.format(mock['name']) ]), 197 override_options: [ 198 'b_asneeded=false', 199 'b_lundef=false', 200 ], 201 dependencies: [ 202 tests_dep, 203 mock.get('deps', []), 204 ], 205 link_with: [ 206 libvirt_lib, 207 mock.get('link_with', []), 208 ], 209 ) 210endforeach 211 212# build helpers used by tests 213 214# Must not link to any libvirt modules - libc only otherwise external 215# libraries might unexpectedly leak file descriptors into commandhelper 216# invalidating the test logic assumptions. 217executable( 218 'commandhelper', 219 [ 'commandhelper.c' ], 220 dependencies: [ 221 tests_dep, 222 ], 223 link_args: [ 224 libvirt_no_indirect, 225 ], 226) 227 228# This is a fake SSH we use from virnetsockettest 229executable( 230 'ssh', 231 [ 'ssh.c' ], 232 dependencies: [ 233 tests_dep, 234 ], 235) 236 237 238# build and define libvirt tests 239 240# tests: 241# each entry is a dictionary with following items: 242# * name - name of the test which is also used as default source file name (required) 243# * sources - override default sources based on name (optional, default [ '$name.c' ]) 244# * c_args - args used by test (optional, default []) 245# * deps - additional dependencies (optional, default []) 246# * include - include_directories (optional, default []) 247# * link_with - compiled libraries to link with (optional, default []) 248# * link_whole - compiled libraries to link whole (optional, default []) 249 250tests = [] 251 252cputest_link_with = [] 253cputest_link_whole = [] 254if conf.has('WITH_QEMU') 255 cputest_link_with += [ test_utils_qemu_monitor_lib, test_qemu_driver_lib ] 256 cputest_link_whole += [ test_utils_qemu_lib ] 257endif 258 259domaincapstest_link_with = [] 260domaincapstest_link_whole = [ test_file_wrapper_lib ] 261if conf.has('WITH_BHYVE') 262 domaincapstest_link_with += [ bhyve_driver_impl ] 263endif 264if conf.has('WITH_LIBXL') 265 domaincapstest_link_with += [ test_xen_driver_lib ] 266 domaincapstest_link_whole += [ test_utils_xen_lib ] 267endif 268if conf.has('WITH_QEMU') 269 domaincapstest_link_with += [ test_qemu_driver_lib ] 270 domaincapstest_link_whole += [ test_utils_qemu_lib ] 271endif 272 273vircapstest_link_with = [] 274vircapstest_link_whole = [] 275vircapstest_sources = [ 'vircapstest.c' ] 276if conf.has('WITH_LXC') 277 vircapstest_link_with += [ lxc_driver_impl_lib ] 278 vircapstest_link_whole += [ test_utils_lxc_lib ] 279endif 280if conf.has('WITH_QEMU') 281 vircapstest_link_with += [ qemu_driver_impl ] 282 vircapstest_link_whole += [ test_utils_qemu_lib ] 283 vircapstest_sources += [ qemu_dtrace_gen_objects ] 284endif 285 286tests += [ 287 { 'name': 'commandtest' }, 288 { 'name': 'cputest', 'link_with': cputest_link_with, 'link_whole': cputest_link_whole }, 289 { 'name': 'domaincapstest', 'link_with': domaincapstest_link_with, 'link_whole': domaincapstest_link_whole }, 290 { 'name': 'domainconftest' }, 291 { 'name': 'genericxml2xmltest' }, 292 { 'name': 'interfacexml2xmltest' }, 293 { 'name': 'metadatatest' }, 294 { 'name': 'networkxml2xmlupdatetest' }, 295 { 'name': 'nodedevxml2xmltest' }, 296 { 'name': 'nwfilterxml2xmltest' }, 297 { 'name': 'objecteventtest' }, 298 { 'name': 'seclabeltest' }, 299 { 'name': 'secretxml2xmltest' }, 300 { 'name': 'shunloadtest', 'deps': [ thread_dep ] }, 301 { 'name': 'sockettest' }, 302 { 'name': 'storagevolxml2xmltest' }, 303 { 'name': 'sysinfotest' }, 304 { 'name': 'utiltest' }, 305 { 'name': 'viralloctest' }, 306 { 'name': 'virauthconfigtest' }, 307 { 'name': 'virbitmaptest' }, 308 { 'name': 'virbuftest' }, 309 { 'name': 'vircapstest', 'sources': vircapstest_sources, 'link_with': vircapstest_link_with, 'link_whole': vircapstest_link_whole }, 310 { 'name': 'vircgrouptest' }, 311 { 'name': 'virconftest' }, 312 { 'name': 'vircryptotest' }, 313 { 'name': 'virendiantest' }, 314 { 'name': 'virerrortest' }, 315 { 'name': 'virfilecachetest' }, 316 { 'name': 'virfiletest' }, 317 { 'name': 'virfirewalltest' }, 318 { 'name': 'virhostcputest', 'link_whole': [ test_file_wrapper_lib ] }, 319 { 'name': 'virhostdevtest' }, 320 { 'name': 'viridentitytest' }, 321 { 'name': 'viriscsitest' }, 322 { 'name': 'virkeycodetest' }, 323 { 'name': 'virkmodtest' }, 324 { 'name': 'virlockspacetest' }, 325 { 'name': 'virlogtest' }, 326 { 'name': 'virnetdevtest' }, 327 { 'name': 'virnetworkportxml2xmltest' }, 328 { 'name': 'virnwfilterbindingxml2xmltest' }, 329 { 'name': 'virpcitest' }, 330 { 'name': 'virportallocatortest' }, 331 { 'name': 'virrotatingfiletest' }, 332 { 'name': 'virschematest' }, 333 { 'name': 'virshtest' }, 334 { 'name': 'virstringtest' }, 335 { 'name': 'virsystemdtest' }, 336 { 'name': 'virtimetest' }, 337 { 'name': 'virtypedparamtest' }, 338 { 'name': 'viruritest' }, 339 { 'name': 'virpcivpdtest' }, 340 { 'name': 'vshtabletest', 'link_with': [ libvirt_shell_lib ] }, 341 { 'name': 'virmigtest' }, 342] 343 344if host_machine.system() == 'linux' 345 tests += [ 346 { 'name': 'fchosttest' }, 347 { 'name': 'scsihosttest' }, 348 { 'name': 'vircaps2xmltest', 'link_whole': [ test_file_wrapper_lib ] }, 349 { 'name': 'virnetdevbandwidthtest' }, 350 { 'name': 'virprocessstattest', 'link_whole': [ test_file_wrapper_lib ] }, 351 { 'name': 'virresctrltest', 'link_whole': [ test_file_wrapper_lib ] }, 352 { 'name': 'virscsitest' }, 353 { 'name': 'virusbtest' }, 354 ] 355 if conf.has('WITH_YAJL') 356 tests += [ 357 { 'name': 'virnetdevopenvswitchtest' }, 358 ] 359 endif 360endif 361 362if conf.has('WITH_BHYVE') 363 tests += [ 364 { 'name': 'bhyveargv2xmltest', 'link_with': [ bhyve_driver_impl ] }, 365 { 'name': 'bhyvexml2argvtest', 'link_with': [ bhyve_driver_impl ] }, 366 { 'name': 'bhyvexml2xmltest', 'link_with': [ bhyve_driver_impl ] }, 367 ] 368endif 369 370if conf.has('WITH_ESX') 371 tests += [ 372 { 'name': 'esxutilstest', 'deps': [ esx_dep ] }, 373 ] 374endif 375 376if conf.has('WITH_LIBVIRTD') 377 tests += [ 378 { 'name': 'eventtest', 'deps': [ thread_dep ] }, 379 { 'name': 'fdstreamtest' }, 380 { 'name': 'virdriverconnvalidatetest' }, 381 { 'name': 'virdrivermoduletest' }, 382 ] 383endif 384 385if conf.has('WITH_LIBXL') 386 tests += [ 387 { 'name': 'libxlxml2domconfigtest', 'link_with': [ test_xen_driver_lib ], 'link_whole': [ test_utils_xen_lib ], 'deps': [ libxl_dep ] }, 388 { 'name': 'xlconfigtest', 'link_with': [ test_xen_driver_lib ], 'link_whole': [ test_utils_xen_lib ] }, 389 { 'name': 'xmconfigtest', 'link_with': [ test_xen_driver_lib ], 'link_whole': [ test_utils_xen_lib ] }, 390 ] 391endif 392 393if conf.has('WITH_LXC') 394 tests += [ 395 { 'name': 'lxcconf2xmltest', 'link_with': [ lxc_driver_impl_lib ], 'link_whole': [ test_utils_lxc_lib ] }, 396 { 'name': 'lxcxml2xmltest', 'link_with': [ lxc_driver_impl_lib ], 'link_whole': [ test_utils_lxc_lib ] }, 397 ] 398endif 399 400if conf.has('WITH_NETWORK') 401 tests += [ 402 { 'name': 'networkxml2conftest', 'link_with': [ network_driver_impl ] }, 403 { 'name': 'networkxml2firewalltest', 'link_with': [ network_driver_impl ] }, 404 { 'name': 'networkxml2xmltest', 'link_with': [ network_driver_impl ] }, 405 ] 406endif 407 408if conf.has('WITH_NODE_DEVICES') 409 tests += [ 410 { 'name': 'nodedevmdevctltest', 'link_with': [ node_device_driver_impl ] }, 411 ] 412endif 413 414if conf.has('WITH_NSS') 415 tests += [ 416 { 417 'name': 'nsstest', 418 'include': [ nss_inc_dir ], 419 'link_with': [ nss_libvirt_impl ], 420 }, 421 { 422 'name': 'nssguesttest', 423 'sources': [ 'nsstest.c' ], 424 'c_args': [ '-DLIBVIRT_NSS_GUEST' ], 425 'include': [ nss_inc_dir ], 426 'link_with': [ nss_libvirt_guest_impl ], 427 }, 428 ] 429endif 430 431if conf.has('WITH_NWFILTER') 432 tests += [ 433 { 'name': 'nwfilterebiptablestest', 'link_with': [ nwfilter_driver_impl ] }, 434 { 'name': 'nwfilterxml2firewalltest', 'link_with': [ nwfilter_driver_impl ] }, 435 ] 436endif 437 438if conf.has('WITH_OPENVZ') 439 tests += [ 440 { 'name': 'openvzutilstest' }, 441 ] 442endif 443 444if conf.has('WITH_POLKIT') 445 tests += [ 446 { 'name': 'virpolkittest' }, 447 ] 448endif 449 450if conf.has('WITH_QEMU') 451 tests += [ 452 { 'name': 'qemuagenttest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 453 { 'name': 'qemublocktest', 'include': [ storage_file_inc_dir ], 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 454 { 'name': 'qemucapabilitiestest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 455 { 'name': 'qemucaps2xmltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 456 { 'name': 'qemucommandutiltest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 457 { 'name': 'qemudomaincheckpointxml2xmltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 458 { 'name': 'qemudomainsnapshotxml2xmltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 459 { 'name': 'qemufirmwaretest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_file_wrapper_lib ] }, 460 { 'name': 'qemuhotplugtest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 461 { 'name': 'qemumemlocktest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 462 { 'name': 'qemumigparamstest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 463 { 'name': 'qemumigrationcookiexmltest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib, test_file_wrapper_lib ] }, 464 { 'name': 'qemumonitorjsontest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 465 { 'name': 'qemusecuritytest', 'sources': [ 'qemusecuritytest.c', 'qemusecuritymock.c' ], 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 466 { 'name': 'qemustatusxml2xmltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib, test_file_wrapper_lib ] }, 467 { 'name': 'qemuvhostusertest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_file_wrapper_lib ] }, 468 { 'name': 'qemuxml2argvtest', 'link_with': [ test_qemu_driver_lib, test_utils_qemu_monitor_lib ], 'link_whole': [ test_utils_qemu_lib, test_file_wrapper_lib ] }, 469 { 'name': 'qemuxml2xmltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib, test_file_wrapper_lib ] }, 470 ] 471endif 472 473if conf.has('WITH_REMOTE') 474 tests += [ 475 { 'name': 'virnetdaemontest' }, 476 { 'name': 'virnetmessagetest' }, 477 { 'name': 'virnetserverclienttest' }, 478 { 'name': 'virnetsockettest' }, 479 ] 480 481 nettls_sources = [ 'virnettlshelpers.c' ] 482 if conf.has('WITH_LIBTASN1_H') 483 nettls_sources += 'pkix_asn1_tab.c' 484 endif 485 486 libtasn1_dep = cc.find_library('tasn1', required: false) 487 488 tests += [ 489 { 'name': 'virnettlscontexttest', 'sources': [ 'virnettlscontexttest.c', nettls_sources ], 'deps': [ libtasn1_dep, ] }, 490 { 'name': 'virnettlssessiontest', 'sources': [ 'virnettlssessiontest.c', nettls_sources ], 'deps': [ libtasn1_dep, ] }, 491 ] 492endif 493 494if conf.has('WITH_SECDRIVER_SELINUX') 495 if conf.has('WITH_LIBATTR') 496 tests += [ 497 { 'name': 'securityselinuxtest' }, 498 ] 499 500 if conf.has('WITH_QEMU') 501 tests += [ 502 { 'name': 'securityselinuxlabeltest', 'link_with': [ test_qemu_driver_lib ], 'link_whole': [ test_utils_qemu_lib ] }, 503 ] 504 endif 505 endif 506endif 507 508if conf.has('WITH_STORAGE') 509 tests += [ 510 { 'name': 'storagepoolcapstest' }, 511 { 'name': 'storagepoolxml2argvtest', 'link_with': [ storage_driver_impl_lib ] }, 512 { 'name': 'storagepoolxml2xmltest', 'link_with': [ storage_driver_impl_lib ] }, 513 { 'name': 'storagevolxml2argvtest', 'link_with': [ storage_driver_impl_lib ] }, 514 { 'name': 'virstorageutiltest', 'link_with': [ storage_driver_impl_lib ] }, 515 ] 516endif 517 518if conf.has('WITH_STORAGE_FS') 519 tests += [ 520 { 'name': 'virstoragetest', 'include': [ storage_file_inc_dir ],'link_with': [ storage_driver_impl_lib ] }, 521 ] 522endif 523 524if conf.has('WITH_STORAGE_SHEEPDOG') 525 tests += [ 526 { 'name': 'storagebackendsheepdogtest', 'link_with': [ storage_driver_impl_lib, storage_backend_sheepdog_priv_lib ] }, 527 ] 528endif 529 530if conf.has('WITH_VBOX') 531 tests += [ 532 { 'name': 'vboxsnapshotxmltest', 'link_with': [ vbox_driver_impl ] }, 533 ] 534endif 535 536if conf.has('WITH_VMWARE') 537 tests += [ 538 { 'name': 'vmwarevertest' }, 539 ] 540endif 541 542if conf.has('WITH_VMX') 543 tests += [ 544 { 'name': 'vmx2xmltest' }, 545 { 'name': 'xml2vmxtest' }, 546 ] 547endif 548 549if conf.has('WITH_YAJL') 550 tests += [ 551 { 'name': 'virjsontest' }, 552 { 'name': 'virmacmaptest' }, 553 ] 554endif 555 556foreach data : tests 557 test_sources = '@0@.c'.format(data['name']) 558 test_bin = executable( 559 data['name'], 560 [ 561 data.get('sources', test_sources), 562 dtrace_gen_objects, 563 ], 564 c_args: [ 565 data.get('c_args', []), 566 ], 567 dependencies: [ 568 tests_dep, 569 data.get('deps', []), 570 ], 571 include_directories: [ 572 data.get('include', []), 573 ], 574 link_args: [ 575 libvirt_no_indirect, 576 ], 577 link_with: [ 578 libvirt_lib, 579 data.get('link_with', []), 580 ], 581 link_whole: [ 582 test_utils_lib, 583 data.get('link_whole', []), 584 ], 585 export_dynamic: true, 586 ) 587 if data['name'] == 'qemuxml2argvtest' 588 timeout = 90 589 else 590 # default meson timeout 591 timeout = 30 592 endif 593 test(data['name'], test_bin, env: tests_env, timeout: timeout) 594endforeach 595 596 597# helpers: 598# each entry is a dictionary with following items: 599# * name - name of the test which is also used as default source file name (required) 600# * sources - override default sources based on name (optional, default [ '$name.c' ]) 601# * c_args - args used by test (optional, default []) 602# * include - include_directories (optional, default []) 603# * link_with - compiled libraries to link with (optional, default []) 604 605helpers = [] 606 607if conf.has('WITH_NSS') 608 helpers += [ 609 # Intentionally not linking with anything else. 610 # See the test source for more detailed explanation. 611 { 612 'name': 'nsslinktest', 613 'include': [ nss_inc_dir ], 614 'link_with': [ nss_libvirt_impl ], 615 }, 616 { 617 'name': 'nssguestlinktest', 618 'sources': [ 'nsslinktest.c' ], 619 'c_args': [ '-DLIBVIRT_NSS_GUEST' ], 620 'include': [ nss_inc_dir ], 621 'link_with': [ nss_libvirt_guest_impl ], 622 }, 623 ] 624endif 625 626if conf.has('WITH_QEMU') 627 helpers += [ 628 { 629 'name': 'qemucapsprobe', 630 'link_with': [ test_qemu_driver_lib, libvirt_lib ], 631 }, 632 ] 633endif 634 635foreach data : helpers 636 helper_sources = '@0@.c'.format(data['name']) 637 helper_bin = executable( 638 data['name'], 639 [ 640 data.get('sources', helper_sources), 641 ], 642 c_args: [ 643 data.get('c_args', []), 644 ], 645 dependencies: [ 646 tests_dep, 647 ], 648 include_directories: [ 649 data.get('include', []), 650 ], 651 link_with: [ 652 data['link_with'], 653 ], 654 export_dynamic: true, 655 ) 656endforeach 657 658 659# test_scripts: 660# list of test scripts to run 661test_scripts = [] 662 663if conf.has('WITH_LIBVIRTD') 664 test_scripts += [ 665 'libvirtd-fail', 666 'libvirtd-pool', 667 'virsh-auth', 668 'virsh-checkpoint', 669 'virsh-cpuset', 670 'virsh-define-dev-segfault', 671 'virsh-int-overflow', 672 'virsh-optparse', 673 'virsh-output', 674 'virsh-read-bufsiz', 675 'virsh-read-non-seekable', 676 'virsh-schedinfo', 677 'virsh-self-test', 678 'virsh-snapshot', 679 'virsh-start', 680 'virsh-undefine', 681 'virsh-uriprecedence', 682 'virsh-vcpupin', 683 'virt-admin-self-test', 684 ] 685 686 if conf.has('WITH_SECDRIVER_APPARMOR') 687 test_scripts += 'virt-aa-helper-test' 688 endif 689endif 690 691foreach name : test_scripts 692 script = find_program(name) 693 test(name, script, env: tests_env) 694endforeach 695 696testenv = runutf8 697testenv += 'VIR_TEST_FILE_ACCESS=1' 698 699add_test_setup( 700 'access', 701 env: testenv, 702 exe_wrapper: [ python3_prog, check_file_access_prog.path() ], 703) 704 705add_test_setup( 706 'valgrind', 707 exe_wrapper: [ 708 'valgrind', '--quiet', '--leak-check=full', '--trace-children=yes', 709 '--trace-children-skip="*/tools/virsh,*/tests/commandhelper,/usr/bin/*"', 710 '--suppressions=@0@'.format(meson.current_source_dir() / '.valgrind.supp'), 711 '--error-exitcode=1', 712 ], 713 # default timeout in meson is 30s 714 timeout_multiplier: 4, 715) 716