tests: fix tests when test driver is disabled

Various tests try to open a connection to 'test:///default' and
must be skipped when the test driver is disabled.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-05-07 10:40:15 +01:00
parent 20acd5b1be
commit 67ac2cd590
2 changed files with 30 additions and 16 deletions

View File

@ -33,6 +33,7 @@ static char *fchost_prefix;
#define TEST_FC_HOST_NUM 5
#define TEST_FC_HOST_NUM_NO_FAB 6
#ifdef WITH_TEST
/* virNodeDeviceCreateXML using "<parent>" to find the vport capable HBA */
static const char test7_xml[] =
"<device>"
@ -85,7 +86,7 @@ static const char test11_xml[] =
" <path>/dev/disk/by-path</path>"
" </target>"
"</pool>";
#endif /* WITH_TEST */
/* Test virIsVHBACapable */
static int
@ -222,7 +223,7 @@ test6(const void *data G_GNUC_UNUSED)
}
#ifdef WITH_TEST
/* Test manageVHBAByNodeDevice
* - Test both virNodeDeviceCreateXML and virNodeDeviceDestroy
* - Create a node device vHBA allowing usage of various different
@ -313,7 +314,7 @@ manageVHBAByStoragePool(const void *data)
virConnectClose(conn);
return ret;
}
#endif
static int
mymain(void)
@ -334,6 +335,7 @@ mymain(void)
ret = -1;
if (virTestRun("virVHBAGetConfig-empty-fabric_wwn", test6, NULL) < 0)
ret = -1;
#ifdef WITH_TEST
if (virTestRun("manageVHBAByNodeDevice-by-parent", manageVHBAByNodeDevice,
test7_xml) < 0)
ret = -1;
@ -349,6 +351,7 @@ mymain(void)
if (virTestRun("manageVHBAByStoragePool-by-parent", manageVHBAByStoragePool,
test11_xml) < 0)
ret = -1;
#endif
VIR_FREE(fchost_prefix);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;

View File

@ -74,7 +74,6 @@ endif
mock_libs = [
{ 'name': 'domaincapsmock' },
{ 'name': 'shunload', 'sources': [ 'shunloadhelper.c' ] },
{ 'name': 'vircgroupmock' },
{ 'name': 'virdnsmasqmock' },
{ 'name': 'virfilecachemock' },
@ -106,6 +105,11 @@ if host_machine.system() != 'windows'
]
endif
if conf.has('WITH_TEST')
mock_libs += [
{ 'name': 'shunload', 'sources': [ 'shunloadhelper.c' ] },
]
endif
# build libraries used by tests
@ -258,15 +262,11 @@ tests += [
{ 'name': 'domainconftest' },
{ 'name': 'genericxml2xmltest' },
{ 'name': 'interfacexml2xmltest' },
{ 'name': 'metadatatest' },
{ 'name': 'networkmetadatatest' },
{ 'name': 'networkxml2xmlupdatetest' },
{ 'name': 'nodedevxml2xmltest' },
{ 'name': 'nwfilterxml2xmltest' },
{ 'name': 'objecteventtest' },
{ 'name': 'seclabeltest' },
{ 'name': 'secretxml2xmltest' },
{ 'name': 'shunloadtest', 'deps': [ thread_dep ] },
{ 'name': 'sockettest' },
{ 'name': 'storagevolxml2xmltest' },
{ 'name': 'sysinfotest' },
@ -298,7 +298,6 @@ tests += [
{ 'name': 'virportallocatortest' },
{ 'name': 'virrotatingfiletest' },
{ 'name': 'virschematest' },
{ 'name': 'virshtest', 'depends': [ virsh_prog ] },
{ 'name': 'virstringtest' },
{ 'name': 'virsystemdtest' },
{ 'name': 'virtimetest' },
@ -333,6 +332,17 @@ if host_machine.system() == 'linux'
endif
endif
if conf.has('WITH_TEST')
tests += [
{ 'name': 'fdstreamtest' },
{ 'name': 'metadatatest' },
{ 'name': 'networkmetadatatest' },
{ 'name': 'objecteventtest' },
{ 'name': 'shunloadtest', 'deps': [ thread_dep ] },
{ 'name': 'virshtest', 'depends': [ virsh_prog ] },
]
endif
if conf.has('WITH_BHYVE')
tests += [
{ 'name': 'bhyveargv2xmltest', 'link_with': [ bhyve_driver_impl ] },
@ -364,7 +374,6 @@ endif
if conf.has('WITH_LIBVIRTD')
tests += [
{ 'name': 'eventtest', 'deps': [ thread_dep ] },
{ 'name': 'fdstreamtest' },
{ 'name': 'virdriverconnvalidatetest' },
{ 'name': 'virdrivermoduletest' },
]
@ -619,12 +628,14 @@ test(
suite: 'script',
)
# vsh based client self-test, which can be run directly from meson
test('virsh self-test',
if conf.has('WITH_TEST')
# vsh based client self-test, which can be run directly from meson
test('virsh self-test',
virsh_prog,
args: [ '-q', '-c', 'test:///default', 'self-test' ],
suite: 'bin',
)
)
endif
if conf.has('WITH_REMOTE')
test('virt-admin self-test',