[PATCH 2/4] tests: Teach qemuxml2argvtest about spapr-vio addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can't call qemuCapsExtractVersionInfo() from test code, because it
expects to be able to call the emulator, and for testing we have fake
emulators that can't be executed. For that reason qemuxml2argvtest.c
doesn't call qemuDomainAssignPCIAddresses(), instead it open codes its
own version.

That means we can't call qemuDomainAssignAddresses() from the test code,
instead we need to manually call qemuDomainAssignSpaprVioAddresses().

Also add logic to cope with qemuDomainAssignSpaprVioAddresses() failing,
so that we can write a test that checks for a known failure in there.

Signed-off-by: Michael Ellerman <michael@xxxxxxxxxxxxxx>
---
 src/qemu/qemu_command.c  |    2 +-
 src/qemu/qemu_command.h  |    1 +
 tests/qemuxml2argvtest.c |   18 +++++++++++++-----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d051305..4ceb01c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -735,7 +735,7 @@ qemuAssignSpaprVIOAddress(virDomainDefPtr def, virDomainDeviceInfoPtr info,
     return 0;
 }
 
-static int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
+int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
 {
     int i, rc;
 
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index de61cf3..2f8b5ba 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -175,6 +175,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
                                         bool *monJSON);
 
 int qemuDomainAssignAddresses(virDomainDefPtr def);
+int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def);
 
 int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
 qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d87654c..67af27a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -153,6 +153,13 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
         qemuDomainPCIAddressSetPtr pciaddrs;
+
+        if (qemuDomainAssignSpaprVIOAddresses(vmdef)) {
+            if (expectError)
+                goto ok;
+            goto fail;
+        }
+
         if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
             goto fail;
 
@@ -190,11 +197,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
         goto fail;
     }
 
-    if (expectError) {
-        /* need to suppress the errors */
-        virResetLastError();
-    }
-
     if (!(actualargv = virCommandToString(cmd)))
         goto fail;
 
@@ -212,6 +214,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
         goto fail;
     }
 
+ ok:
+    if (expectError) {
+        /* need to suppress the errors */
+        virResetLastError();
+    }
+
     ret = 0;
 
  fail:
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]