[PATCH 06/32] qemublocktest: Add 'empty' case for incremental backup test

Peter Krempa posted 32 patches 5 years, 6 months ago
[PATCH 06/32] qemublocktest: Add 'empty' case for incremental backup test
Posted by Peter Krempa 5 years, 6 months ago
Use the new test data when calculating incremental backup operations. As
incremental backup fails with no bitmap the test code is modified to
allow testing this case too.

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

diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 8d613d7cac..9e54c254e8 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -793,17 +793,16 @@ testQemuBackupIncrementalBitmapCalculate(const void *opaque)

     incremental = testQemuBackupGetIncremental(data->incremental);

-    if (!(mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental,
-                                                              data->chain,
-                                                              nodedata,
-                                                              "testdisk"))) {
-        VIR_TEST_VERBOSE("failed to calculate merged bitmaps");
-        return -1;
+    if ((mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental,
+                                                             data->chain,
+                                                             nodedata,
+                                                             "testdisk"))) {
+        if (!(actual = virJSONValueToString(mergebitmaps, true)))
+            return -1;
+    } else {
+        actual = g_strdup("NULL\n");
     }

-    if (!(actual = virJSONValueToString(mergebitmaps, true)))
-        return -1;
-
     return virTestCompareToFile(actual, expectpath);
 }

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

+    TEST_BACKUP_BITMAP_CALCULATE("empty", bitmapSourceChain, "a", "empty");
+
     TEST_BACKUP_BITMAP_CALCULATE("basic-flat", bitmapSourceChain, "current", "basic");
     TEST_BACKUP_BITMAP_CALCULATE("basic-intermediate", bitmapSourceChain, "d", "basic");
     TEST_BACKUP_BITMAP_CALCULATE("basic-deep", bitmapSourceChain, "a", "basic");
diff --git a/tests/qemublocktestdata/backupmerge/empty-out.json b/tests/qemublocktestdata/backupmerge/empty-out.json
new file mode 100644
index 0000000000..7951defec1
--- /dev/null
+++ b/tests/qemublocktestdata/backupmerge/empty-out.json
@@ -0,0 +1 @@
+NULL
-- 
2.26.2

Re: [PATCH 06/32] qemublocktest: Add 'empty' case for incremental backup test
Posted by Eric Blake 5 years, 6 months ago
On 6/15/20 12:09 PM, Peter Krempa wrote:
> Use the new test data when calculating incremental backup operations. As
> incremental backup fails with no bitmap the test code is modified to
> allow testing this case too.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   tests/qemublocktest.c                         | 19 ++++++++++---------
>   .../backupmerge/empty-out.json                |  1 +
>   2 files changed, 11 insertions(+), 9 deletions(-)
>   create mode 100644 tests/qemublocktestdata/backupmerge/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