[libvirt] [RFC PATCH 09/28] tests: qemu: mock pci environment for qemuargv2xmltests

Shivaprasad G Bhat posted 28 patches 6 years, 8 months ago
[libvirt] [RFC PATCH 09/28] tests: qemu: mock pci environment for qemuargv2xmltests
Posted by Shivaprasad G Bhat 6 years, 8 months ago
The upcoming patches verify the sysfs for pci hostdevs.
So, preload the mock library and change the device to
what exists on the mock environment to avoid a failure.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
---
 tests/qemuargv2xmldata/hostdev-pci-address.args |    2 +-
 tests/qemuargv2xmldata/hostdev-pci-address.xml  |    2 +-
 tests/qemuargv2xmltest.c                        |   18 ++++++++++++++++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/tests/qemuargv2xmldata/hostdev-pci-address.args b/tests/qemuargv2xmldata/hostdev-pci-address.args
index 4d24ce3b75..111dff773f 100644
--- a/tests/qemuargv2xmldata/hostdev-pci-address.args
+++ b/tests/qemuargv2xmldata/hostdev-pci-address.args
@@ -20,4 +20,4 @@ QEMU_AUDIO_DRV=none \
 -net none \
 -serial none \
 -parallel none \
--pcidevice host=06:12.5
+-pcidevice host=06:12.1
diff --git a/tests/qemuargv2xmldata/hostdev-pci-address.xml b/tests/qemuargv2xmldata/hostdev-pci-address.xml
index d6b9ce1d25..fd0bff62e6 100644
--- a/tests/qemuargv2xmldata/hostdev-pci-address.xml
+++ b/tests/qemuargv2xmldata/hostdev-pci-address.xml
@@ -31,7 +31,7 @@
     <input type='keyboard' bus='ps2'/>
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <source>
-        <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+        <address domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </hostdev>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index cb010268c4..a68c13fead 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -144,12 +144,25 @@ testCompareXMLToArgvHelper(const void *data)
     return result;
 }
 
-
+# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
 
 static int
 mymain(void)
 {
     int ret = 0;
+    char *fakerootdir;
+
+    if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
+        fprintf(stderr, "Out of memory\n");
+        abort();
+    }
+
+    if (!mkdtemp(fakerootdir)) {
+        fprintf(stderr, "Cannot create fakerootdir");
+        abort();
+    }
+
+    setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
 
     if (qemuTestDriverInit(&driver) < 0)
         return EXIT_FAILURE;
@@ -298,7 +311,8 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-VIR_TEST_MAIN(mymain)
+VIR_TEST_MAIN_PRELOAD(mymain,
+                      abs_builddir "/.libs/virpcimock.so")
 
 #else
 

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