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 <p.fedin@samsung.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Pavel Fedin 2015-09-09 17:03:15 +03:00 committed by Ján Tomko
parent f7dd335749
commit 0636c4a8f6
4 changed files with 36 additions and 8 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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: