Make callers use virFileCacheClear to clear the cache before populating
it rather than trying to overwrite what's in it.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/qemusecuritytest.c | 2 ++
tests/qemustatusxml2xmltest.c | 2 ++
tests/qemuxml2argvtest.c | 2 ++
tests/qemuxml2xmltest.c | 2 ++
tests/testutilsqemu.c | 25 ++++++-------------------
5 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c
index 0596783b6c..e2989c05aa 100644
--- a/tests/qemusecuritytest.c
+++ b/tests/qemusecuritytest.c
@@ -64,6 +64,8 @@ prepareObjects(virQEMUDriver *driver,
if (!(priv->qemuCaps = qemuTestParseCapabilitiesArch(VIR_ARCH_X86_64,
latestCapsFile)))
return -1;
+ virFileCacheClear(driver->qemuCapsCache);
+
if (qemuTestCapsCacheInsert(driver->qemuCapsCache, priv->qemuCaps) < 0)
return -1;
diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c
index db82a1a980..c69ff5e5e1 100644
--- a/tests/qemustatusxml2xmltest.c
+++ b/tests/qemustatusxml2xmltest.c
@@ -26,6 +26,8 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
if (testQemuInfoInitArgs((struct testQemuInfo *) data) < 0)
return -1;
+ virFileCacheClear(driver.qemuCapsCache);
+
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, data->qemuCaps) < 0)
return -1;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fa60028cf0..4aecbe57f6 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -664,6 +664,8 @@ testCompareXMLToArgv(const void *data)
goto cleanup;
}
+ virFileCacheClear(driver.qemuCapsCache);
+
if (info->args.hostOS == HOST_OS_MACOS)
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
else
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 9c7d6c6b2b..787e51956f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -44,6 +44,8 @@ testXML2XMLCommon(const struct testQemuInfo *info)
if (!(info->flags & FLAG_REAL_CAPS))
virQEMUCapsInitQMPBasicArch(info->qemuCaps);
+ virFileCacheClear(driver.qemuCapsCache);
+
if (info->args.hostOS == HOST_OS_MACOS)
rc = qemuTestCapsCacheInsertMacOS(driver.qemuCapsCache, info->qemuCaps);
else
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 396803c40b..9d7bc2ed51 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -524,17 +524,16 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
size_t i;
if (caps && virQEMUCapsGetArch(caps) != VIR_ARCH_NONE) {
- /* for capabilities which have architecture set we populate only the
- * given architecture and poison all other so that the test doesn't
- * accidentally test a weird combination */
+ /* all tests using real caps or arcitecture are expected to call:
+ *
+ * virFileCacheClear(driver.qemuCapsCache);
+ *
+ * before populating the cache;
+ */
virArch arch = virQEMUCapsGetArch(caps);
- g_autoptr(virQEMUCaps) emptyCaps = virQEMUCapsNew();
g_autoptr(virQEMUCaps) copyCaps = NULL;
virQEMUCaps *effCaps = caps;
- if (!emptyCaps)
- return -1;
-
if (arch_alias[arch] != VIR_ARCH_NONE)
arch = arch_alias[arch];
@@ -550,18 +549,6 @@ qemuTestCapsCacheInsertImpl(virFileCache *cache,
if (qemuTestCapsCacheInsertData(cache, qemu_emulators[arch], effCaps) <
0)
return -1;
}
-
-
- for (i = 0; i < G_N_ELEMENTS(qemu_emulators); i++) {
- if (!qemu_emulators[i])
- continue;
-
- if (i == arch)
- continue;
-
- if (qemuTestCapsCacheInsertData(cache, qemu_emulators[i], emptyCaps) < 0)
- return -1;
- }
} else {
/* in case when caps are missing or are missing architecture, we populate
* everything */
--
2.39.2