]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: testQemuCapsIterate: Pass suffix to callback
authorAndrea Bolognani <abologna@redhat.com>
Tue, 22 Oct 2019 13:44:37 +0000 (15:44 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 24 Oct 2019 15:21:12 +0000 (17:21 +0200)
Right now users need to hardcode the suffix, which is not a big
deal since they're the ones who passed it to testQemuCapsIterate()
in the first place; however, since we're already passing most of
the information to the callback and we're going to add more later
on, it makes sense to be consistent and pass the suffix too.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
tests/qemucapabilitiestest.c
tests/qemucaps2xmltest.c
tests/testutilsqemu.c
tests/testutilsqemu.h

index 6b8d2676e319bda2b414041ea7a1a0f0be1424dc..cc2242df50497651ed159041bed2c9f4aa450a7d 100644 (file)
@@ -38,6 +38,7 @@ struct _testQemuData {
     const char *inputDir;
     const char *outputDir;
     const char *archName;
+    const char *suffix;
     const char *base;
     int ret;
 };
@@ -77,8 +78,9 @@ testQemuCaps(const void *opaque)
     unsigned int fakeMicrocodeVersion = 0;
     const char *p;
 
-    if (virAsprintf(&repliesFile, "%s/%s.%s.replies",
-                    data->inputDir, data->base, data->archName) < 0 ||
+    if (virAsprintf(&repliesFile, "%s/%s.%s.%s",
+                    data->inputDir, data->base,
+                    data->archName, data->suffix) < 0 ||
         virAsprintf(&capsFile, "%s/%s.%s.xml",
                     data->outputDir, data->base, data->archName) < 0)
         goto cleanup;
@@ -182,6 +184,7 @@ static int
 doCapsTest(const char *inputDir,
            const char *base,
            const char *archName,
+           const char *suffix,
            void *opaque)
 {
     testQemuDataPtr data = (testQemuDataPtr) opaque;
@@ -196,6 +199,7 @@ doCapsTest(const char *inputDir,
     data->inputDir = inputDir;
     data->base = base;
     data->archName = archName;
+    data->suffix = suffix;
 
     if (virTestRun(title, testQemuCaps, data) < 0)
         data->ret = -1;
index 8985b20ac65dc7c852958d29c7a260f469167b33..7a41e9cdd3e679d9adbae4dd45ddcfdcee57469e 100644 (file)
@@ -33,6 +33,7 @@ struct _testQemuData {
     const char *outputDir;
     const char *base;
     const char *archName;
+    const char *suffix;
     int ret;
 };
 
@@ -145,8 +146,9 @@ testQemuCapsXML(const void *opaque)
                     data->outputDir, data->archName) < 0)
         goto cleanup;
 
-    if (virAsprintf(&capsFile, "%s/%s.%s.xml",
-                    data->inputDir, data->base, data->archName) < 0)
+    if (virAsprintf(&capsFile, "%s/%s.%s.%s",
+                    data->inputDir, data->base,
+                    data->archName, data->suffix) < 0)
         goto cleanup;
 
     if (virTestLoadFile(capsFile, &capsData) < 0)
@@ -176,6 +178,7 @@ static int
 doCapsTest(const char *inputDir,
            const char *base,
            const char *archName,
+           const char *suffix,
            void *opaque)
 {
     testQemuDataPtr data = (testQemuDataPtr) opaque;
@@ -187,6 +190,7 @@ doCapsTest(const char *inputDir,
     data->inputDir = inputDir;
     data->base = base;
     data->archName = archName;
+    data->suffix = suffix;
 
     if (virTestRun(title, testQemuCapsXML, data) < 0)
         data->ret = -1;
index 75c8180c7a5eb5ae9b83464e6f47f402a790c89b..1f0270f488fc187fa83736cbb84e0ff133e3de9e 100644 (file)
@@ -936,9 +936,16 @@ testQemuCapsIterate(const char *suffix,
         archName[0] = '\0';
         archName++;
 
-        /* Run the user-provided callback */
-        if (callback(TEST_QEMU_CAPS_PATH, base, archName, opaque) < 0)
+        /* Run the user-provided callback.
+         *
+         * We skip the dot that, as verified earlier, starts the suffix
+         * to make it nicer to rebuild the original file name from inside
+         * the callback.
+         */
+        if (callback(TEST_QEMU_CAPS_PATH, base,
+                     archName, suffix + 1, opaque) < 0) {
             goto cleanup;
+        }
     }
 
     if (rc < 0)
index 07373f8ce65878d06bc0ce3563069ddcf318783c..2c8c4960e97831ac29e6fee6cfa5e705498d86f7 100644 (file)
@@ -99,6 +99,7 @@ virHashTablePtr testQemuGetLatestCaps(void);
 typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
                                            const char *base,
                                            const char *archName,
+                                           const char *suffix,
                                            void *opaque);
 int testQemuCapsIterate(const char *suffix,
                         testQemuCapsIterateCallback callback,