From: Pavel Fedin
Date: Wed, 9 Sep 2015 14:03:15 +0000 (+0300)
Subject: tests: use mockup cache
X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0636c4a8f68951b013006cede5917aacb0e0908a;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git
tests: use mockup cache
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
---
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 476dee8be..2135b5a9c 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 cd123560d..c021f2f6c 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 40e32dc51..65bf1d30f 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 de67bbe79..cec2f6cff 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: