[libvirt] [RFC PATCH 7/9] tests: qemucapabilities: Test commands used to query capabilities

Peter Krempa pkrempa at redhat.com
Fri Jun 1 08:19:59 UTC 2018


Use qemuMonitorTestNewFromFileFull which allows to test commands used
along with providing replies. This has two advantages:

1) It's easier to see which command was used when looking at the files
2) We check that the used commands are actually in the correct order

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tests/qemucapabilitiestest.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 5a42a35c11..cf94bc9d36 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -30,7 +30,7 @@
 typedef struct _testQemuData testQemuData;
 typedef testQemuData *testQemuDataPtr;
 struct _testQemuData {
-    virDomainXMLOptionPtr xmlopt;
+    virQEMUDriver driver;
     const char *archName;
     const char *base;
 };
@@ -40,7 +40,7 @@ static int
 testQemuCaps(const void *opaque)
 {
     int ret = -1;
-    const testQemuData *data = opaque;
+    testQemuData *data = (void *) opaque;
     char *repliesFile = NULL;
     char *capsFile = NULL;
     qemuMonitorTestPtr mon = NULL;
@@ -53,7 +53,7 @@ testQemuCaps(const void *opaque)
                     abs_srcdir, data->base, data->archName) < 0)
         goto cleanup;

-    if (!(mon = qemuMonitorTestNewFromFile(repliesFile, data->xmlopt, false)))
+    if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL)))
         goto cleanup;

     if (!(capsActual = virQEMUCapsNew()) ||
@@ -136,7 +136,6 @@ static int
 mymain(void)
 {
     int ret = 0;
-    virQEMUDriver driver;
     testQemuData data;

 #if !WITH_YAJL
@@ -145,13 +144,11 @@ mymain(void)
 #endif

     if (virThreadInitialize() < 0 ||
-        qemuTestDriverInit(&driver) < 0)
+        qemuTestDriverInit(&data.driver) < 0)
         return EXIT_FAILURE;

     virEventRegisterDefaultImpl();

-    data.xmlopt = driver.xmlopt;
-
 #define DO_TEST(arch, name) \
     do { \
         data.archName = arch; \
@@ -197,7 +194,7 @@ mymain(void)
      * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
      */

-    qemuTestDriverFree(&driver);
+    qemuTestDriverFree(&data.driver);

     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.16.2




More information about the libvir-list mailing list