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

View File

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