[PATCH 07/32] qemublocktest: Add 'empty' case for checkpoint deletion

Peter Krempa posted 32 patches 5 years, 6 months ago
[PATCH 07/32] qemublocktest: Add 'empty' case for checkpoint deletion
Posted by Peter Krempa 5 years, 6 months ago
Use the new test data for checkpoint deletion testing. This test also
requires modification of the internals to allow checking for test
failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemublocktest.c                               | 13 +++++++------
 .../checkpointdelete/empty-out.json                 |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)
 create mode 100644 tests/qemublocktestdata/checkpointdelete/empty-out.json

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 9e54c254e8..1821c227d5 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -851,14 +851,13 @@ testQemuCheckpointDeleteMerge(const void *opaque)
                                          data->parentbitmap,
                                          actions,
                                          "testdisk",
-                                         &reopenimages) < 0) {
-        VIR_TEST_VERBOSE("failed to generate checkpoint delete transaction\n");
-        return -1;
+                                         &reopenimages) >= 0) {
+        if (virJSONValueToBuffer(actions, &buf, true) < 0)
+            return -1;
+    } else {
+        virBufferAddLit(&buf, "NULL\n");
     }

-    if (virJSONValueToBuffer(actions, &buf, true) < 0)
-        return -1;
-
     if (reopenimages) {
         virBufferAddLit(&buf, "reopen nodes:\n");

@@ -1333,6 +1332,8 @@ mymain(void)
         ret = -1; \
     } while (0)

+    TEST_CHECKPOINT_DELETE_MERGE("empty", "a", NULL, "empty");
+
     TEST_CHECKPOINT_DELETE_MERGE("basic-noparent", "a", NULL, "basic");
     TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate1", "b", "a", "basic");
     TEST_CHECKPOINT_DELETE_MERGE("basic-intermediate2", "c", "b", "basic");
diff --git a/tests/qemublocktestdata/checkpointdelete/empty-out.json b/tests/qemublocktestdata/checkpointdelete/empty-out.json
new file mode 100644
index 0000000000..7951defec1
--- /dev/null
+++ b/tests/qemublocktestdata/checkpointdelete/empty-out.json
@@ -0,0 +1 @@
+NULL
-- 
2.26.2

Re: [PATCH 07/32] qemublocktest: Add 'empty' case for checkpoint deletion
Posted by Eric Blake 5 years, 6 months ago
On 6/15/20 12:09 PM, Peter Krempa wrote:
> Use the new test data for checkpoint deletion testing. This test also
> requires modification of the internals to allow checking for test
> failure.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   tests/qemublocktest.c                               | 13 +++++++------
>   .../checkpointdelete/empty-out.json                 |  1 +
>   2 files changed, 8 insertions(+), 6 deletions(-)
>   create mode 100644 tests/qemublocktestdata/checkpointdelete/empty-out.json
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org