From 002daa184d9f565529bcfc1b7d591e2ae98baab6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Sat, 16 Dec 2023 08:48:21 +0100 Subject: [PATCH] qemuxml2argvtest: Setup fake driver only once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/qemuxml2argvtest.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) 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