From 0636c4a8f68951b013006cede5917aacb0e0908a Mon Sep 17 00:00:00 2001
From: Pavel Fedin
Date: Wed, 9 Sep 2015 17:03:15 +0300
Subject: [PATCH] tests: use mockup cache
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
Use the new API in order to correctly add capability sets to the cache
before parsing XML files
Signed-off-by: Pavel Fedin
Signed-off-by: Ján Tomko
---
tests/qemuhotplugtest.c | 22 ++++++++++++++--------
tests/qemuxml2argvtest.c | 5 +++++
tests/qemuxmlnstest.c | 6 ++++++
tests/testutilsqemu.c | 11 +++++++++++
4 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 476dee8be5..2135b5a9c5 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -57,7 +57,7 @@ static int
qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr *vm,
const char *domxml,
- bool event)
+ bool event, const char *testname)
{
int ret = -1;
qemuDomainObjPrivatePtr priv = NULL;
@@ -65,12 +65,6 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
if (!(*vm = virDomainObjNew(xmlopt)))
goto cleanup;
- if (!((*vm)->def = virDomainDefParseString(domxml,
- driver.caps,
- driver.xmlopt,
- VIR_DOMAIN_DEF_PARSE_INACTIVE)))
- goto cleanup;
-
priv = (*vm)->privateData;
if (!(priv->qemuCaps = virQEMUCapsNew()))
@@ -85,6 +79,17 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
if (event)
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
+ ret = qemuTestCapsCacheInsert(driver.qemuCapsCache, testname,
+ priv->qemuCaps);
+ if (ret < 0)
+ goto cleanup;
+
+ if (!((*vm)->def = virDomainDefParseString(domxml,
+ driver.caps,
+ driver.xmlopt,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE)))
+ goto cleanup;
+
if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0)
goto cleanup;
@@ -243,7 +248,8 @@ testQemuHotplug(const void *data)
vm = test->vm;
} else {
if (qemuHotplugCreateObjects(driver.xmlopt, &vm, domain_xml,
- test->deviceDeletedEvent) < 0)
+ test->deviceDeletedEvent,
+ test->domain_filename) < 0)
goto cleanup;
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index cd123560db..c021f2f6c2 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -423,6 +423,11 @@ testCompareXMLToArgvHelper(const void *data)
if (virQEMUCapsGet(info->extraFlags, QEMU_CAPS_ENABLE_FIPS))
flags |= FLAG_FIPS;
+ result = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name,
+ info->extraFlags);
+ if (result < 0)
+ goto cleanup;
+
result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
info->migrateFrom, info->migrateFd,
flags);
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 40e32dc519..65bf1d30ff 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -179,6 +179,12 @@ testCompareXMLToArgvHelper(const void *data)
abs_srcdir, info->name) < 0)
goto cleanup;
+ qemuTestCapsName = info->name;
+ result = qemuTestCapsCacheInsert(driver.qemuCapsCache, info->name,
+ info->extraFlags);
+ if (result < 0)
+ goto cleanup;
+
result = testCompareXMLToArgvFiles(xml, args, info->extraFlags,
info->migrateFrom, info->migrateFd,
info->json, info->expectError);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index de67bbe79f..cec2f6cff9 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -559,6 +559,8 @@ int qemuTestCapsCacheInsert(virQEMUCapsCachePtr cache, const char *binary,
ret = virHashAddEntry(cache->binaries, binary, caps);
if (ret < 0)
virObjectUnref(caps);
+ else
+ qemuTestCapsName = binary;
return ret;
}
@@ -573,10 +575,19 @@ int qemuTestDriverInit(virQEMUDriver *driver)
if (!driver->caps)
goto error;
+ /* Using /dev/null for libDir and cacheDir automatically produces errors
+ * upon attempt to use any of them */
+ driver->qemuCapsCache = virQEMUCapsCacheNew("/dev/null", "/dev/null", 0, 0);
+ if (!driver->qemuCapsCache)
+ goto error;
+
driver->xmlopt = virQEMUDriverCreateXMLConf(driver);
if (!driver->xmlopt)
goto error;
+ if (qemuTestCapsCacheInsert(driver->qemuCapsCache, "empty", NULL) < 0)
+ goto error;
+
return 0;
error:
--
2.39.5