From: Peter Krempa Date: Sat, 16 Dec 2023 07:48:21 +0000 (+0100) Subject: qemuxml2argvtest: Setup fake driver only once X-Git-Tag: v10.1.0-rc1~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=002daa184d9f565529bcfc1b7d591e2ae98baab6;p=thirdparty%2Flibvirt.git qemuxml2argvtest: Setup fake driver only once Move the setup of the fake driver from testCompareXMLToArgv to 'mymain'. With this we also won't need to reset the fake drivers which was done only partially. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 92808af9dc..66367ff79c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -611,7 +611,6 @@ testCompareXMLToArgv(const void *data) int ret = -1; virDomainObj *vm = NULL; virDomainChrSourceDef monitor_chr = { 0 }; - g_autoptr(virConnect) conn = NULL; virError *err = NULL; g_autofree char *log = NULL; g_autoptr(virCommand) cmd = NULL; @@ -646,21 +645,6 @@ testCompareXMLToArgv(const void *data) testUpdateQEMUCapsHostCPUModel(info->qemuCaps, driver.hostarch); } - if (!(conn = virGetConnect())) - goto cleanup; - - conn->secretDriver = &fakeSecretDriver; - conn->storageDriver = &fakeStorageDriver; - conn->nwfilterDriver = &fakeNWFilterDriver; - conn->networkDriver = &fakeNetworkDriver; - - virSetConnectInterface(conn); - virSetConnectNetwork(conn); - virSetConnectNWFilter(conn); - virSetConnectNodeDev(conn); - virSetConnectSecret(conn); - virSetConnectStorage(conn); - if (virIdentitySetCurrent(sysident) < 0) goto cleanup; @@ -788,8 +772,6 @@ testCompareXMLToArgv(const void *data) virDomainChrSourceDefClear(&monitor_chr); virObjectUnref(vm); virIdentitySetCurrent(NULL); - virSetConnectSecret(NULL); - virSetConnectStorage(NULL); if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64) qemuTestSetHostArch(&driver, VIR_ARCH_NONE); @@ -873,6 +855,7 @@ static int mymain(void) { int ret = 0; + g_autoptr(virConnect) conn = NULL; g_autoptr(GHashTable) duplicateTests = virHashNew(NULL); g_autoptr(GHashTable) existingTestCases = virHashNew(NULL); g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps(); @@ -924,6 +907,21 @@ mymain(void) virFileWrapperAddPrefix("/usr/libexec/qemu/vhost-user", abs_srcdir "/qemuvhostuserdata/usr/libexec/qemu/vhost-user"); + if (!(conn = virGetConnect())) + return EXIT_FAILURE; + + conn->secretDriver = &fakeSecretDriver; + conn->storageDriver = &fakeStorageDriver; + conn->nwfilterDriver = &fakeNWFilterDriver; + conn->networkDriver = &fakeNetworkDriver; + + virSetConnectInterface(conn); + virSetConnectNetwork(conn); + virSetConnectNWFilter(conn); + virSetConnectNodeDev(conn); + virSetConnectSecret(conn); + virSetConnectStorage(conn); + /** * The following set of macros allows testing of XML -> argv conversion with a * real set of capabilities gathered from a real qemu copy. It is desired to use