]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: use mockup cache
authorPavel Fedin <p.fedin@samsung.com>
Wed, 9 Sep 2015 14:03:15 +0000 (17:03 +0300)
committerJán Tomko <jtomko@redhat.com>
Tue, 22 Sep 2015 11:56:59 +0000 (13:56 +0200)
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>
tests/qemuhotplugtest.c
tests/qemuxml2argvtest.c
tests/qemuxmlnstest.c
tests/testutilsqemu.c

index 476dee8be526f9947dc48d85143f83f2ebd78cff..2135b5a9c5906464f3ab2d742ea2e6a1d5398cfa 100644 (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;
     }
 
index cd123560dbff270712cc5b6d953f28c84f7b0204..c021f2f6c2f6a20512b43c337864114f90690a6f 100644 (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);
index 40e32dc5194b0361d9ca7727bc6fb85ac0199c5e..65bf1d30ff528440a0b23fe7721ee4a0ade72fc0 100644 (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);
index de67bbe79f99d388da02f5cf94521a7281d8f791..cec2f6cff9c92db0d411582923e6541593965cb4 100644 (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: