[libvirt] [PATCH] tests: make domaincapstest less anoying to debug

Peter Krempa posted 1 patch 36 weeks ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/4ebfab0dd63c2abd2933d0a97b94bf40ada111f3.1572009552.git.pkrempa@redhat.com
tests/domaincapstest.c | 36 +++++++++++++++++++++---------------
tests/testutilsqemu.c  |  8 ++++----
2 files changed, 25 insertions(+), 19 deletions(-)

[libvirt] [PATCH] tests: make domaincapstest less anoying to debug

Posted by Peter Krempa 36 weeks ago
Since 6a077cf2b3 domaincapstest does not run through all cases on
failure but terminates right away. This makes it super annoying to debug
or use in combination with VIR_TEST_REGNERATE_OUTPUT.

Fix it by remembering failure and still running through all cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/domaincapstest.c | 36 +++++++++++++++++++++---------------
 tests/testutilsqemu.c  |  8 ++++----
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index f77accdb76..e4e13c8bb3 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -313,6 +313,8 @@ doTestQemu(const char *inputDir G_GNUC_UNUSED,
            const char *suffix G_GNUC_UNUSED,
            void *opaque)
 {
+    int ret = 0;
+
     if (STREQ(arch, "x86_64")) {
         /* For x86_64 we test three combinations:
          *
@@ -321,13 +323,16 @@ doTestQemu(const char *inputDir G_GNUC_UNUSED,
          *   - TCG with default machine
          */
         if (doTestQemuInternal(version, NULL, arch,
-                               VIR_DOMAIN_VIRT_KVM, opaque) < 0 ||
-            doTestQemuInternal(version, "q35", arch,
-                               VIR_DOMAIN_VIRT_KVM, opaque) < 0 ||
-            doTestQemuInternal(version, NULL, arch,
-                               VIR_DOMAIN_VIRT_QEMU, opaque) < 0) {
-            return -1;
-        }
+                               VIR_DOMAIN_VIRT_KVM, opaque) < 0)
+            ret = -1;
+
+        if (doTestQemuInternal(version, "q35", arch,
+                               VIR_DOMAIN_VIRT_KVM, opaque) < 0)
+            ret = -1;
+
+        if (doTestQemuInternal(version, NULL, arch,
+                               VIR_DOMAIN_VIRT_QEMU, opaque) < 0)
+            ret = -1;
     } else if (STREQ(arch, "aarch64")) {
         /* For aarch64 we test two combinations:
          *
@@ -335,21 +340,22 @@ doTestQemu(const char *inputDir G_GNUC_UNUSED,
          *   - KVM with virt machine
          */
         if (doTestQemuInternal(version, NULL, arch,
-                               VIR_DOMAIN_VIRT_KVM, opaque) < 0 ||
-            doTestQemuInternal(version, "virt", arch,
-                               VIR_DOMAIN_VIRT_KVM, opaque) < 0) {
-            return -1;
-        }
+                               VIR_DOMAIN_VIRT_KVM, opaque) < 0)
+            ret = -1;
+
+        if (doTestQemuInternal(version, "virt", arch,
+                               VIR_DOMAIN_VIRT_KVM, opaque) < 0)
+            ret = -1;
     } else if (STRPREFIX(arch, "riscv")) {
         /* Unfortunately we have to skip RISC-V at the moment */
         return 0;
     } else {
         if (doTestQemuInternal(version, NULL, arch,
                                VIR_DOMAIN_VIRT_KVM, opaque) < 0)
-            return -1;
+            ret = -1;
     }

-    return 0;
+    return ret;
 }

 #endif
@@ -431,7 +437,7 @@ mymain(void)
                             abs_srcdir "/qemufirmwaredata/home/user/.config/qemu/firmware");

     if (testQemuCapsIterate(".xml", doTestQemu, cfg) < 0)
-        return EXIT_FAILURE;
+        ret = -1;

     /*
      * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies"
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 54d6b1a0ac..34a6bd2653 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -902,6 +902,7 @@ testQemuCapsIterate(const char *suffix,
     DIR *dir = NULL;
     int rc;
     int ret = -1;
+    bool fail = false;

     if (!callback)
         return 0;
@@ -949,12 +950,11 @@ testQemuCapsIterate(const char *suffix,
          * the callback.
          */
         if (callback(TEST_QEMU_CAPS_PATH, "caps", version,
-                     archName, suffix + 1, opaque) < 0) {
-            goto cleanup;
-        }
+                     archName, suffix + 1, opaque) < 0)
+            fail = true;
     }

-    if (rc < 0)
+    if (rc < 0 || fail)
         goto cleanup;

     ret = 0;
-- 
2.21.0

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

Re: [libvirt] [PATCH] tests: make domaincapstest less anoying to debug

Posted by Daniel Henrique Barboza 36 weeks ago

On 10/25/19 10:19 AM, Peter Krempa wrote:
> Since 6a077cf2b3 domaincapstest does not run through all cases on
> failure but terminates right away. This makes it super annoying to debug
> or use in combination with VIR_TEST_REGNERATE_OUTPUT.

I believe the flag is called VIR_TEST_REGENERATE_OUTPUT

> 
> Fix it by remembering failure and still running through all cases.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>

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