fbe740
From 60c3e3fd52b1d2fe5fbab42d762248a02b5143f6 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <60c3e3fd52b1d2fe5fbab42d762248a02b5143f6@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Tue, 23 Jun 2020 12:23:40 +0200
fbe740
Subject: [PATCH] qemublocktest: Add 'empty' case for incremental backup test
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Use the new test data when calculating incremental backup operations. As
fbe740
incremental backup fails with no bitmap the test code is modified to
fbe740
allow testing this case too.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Eric Blake <eblake@redhat.com>
fbe740
(cherry picked from commit 218d00f443a5e211ea3664996c610f62b18425f7)
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1804593
fbe740
Message-Id: <45ec7a3b4dce5f583d2864991e16cdc090b8dfce.1592906423.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 tests/qemublocktest.c                         | 19 ++++++++++---------
fbe740
 .../backupmerge/empty-out.json                |  1 +
fbe740
 2 files changed, 11 insertions(+), 9 deletions(-)
fbe740
 create mode 100644 tests/qemublocktestdata/backupmerge/empty-out.json
fbe740
fbe740
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
fbe740
index 2063ca0be7..3ef6ccec9b 100644
fbe740
--- a/tests/qemublocktest.c
fbe740
+++ b/tests/qemublocktest.c
fbe740
@@ -793,17 +793,16 @@ testQemuBackupIncrementalBitmapCalculate(const void *opaque)
fbe740
 
fbe740
     incremental = testQemuBackupGetIncremental(data->incremental);
fbe740
 
fbe740
-    if (!(mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental,
fbe740
-                                                              data->chain,
fbe740
-                                                              nodedata,
fbe740
-                                                              "testdisk"))) {
fbe740
-        VIR_TEST_VERBOSE("failed to calculate merged bitmaps");
fbe740
-        return -1;
fbe740
+    if ((mergebitmaps = qemuBackupDiskPrepareOneBitmapsChain(incremental,
fbe740
+                                                             data->chain,
fbe740
+                                                             nodedata,
fbe740
+                                                             "testdisk"))) {
fbe740
+        if (!(actual = virJSONValueToString(mergebitmaps, true)))
fbe740
+            return -1;
fbe740
+    } else {
fbe740
+        actual = g_strdup("NULL\n");
fbe740
     }
fbe740
 
fbe740
-    if (!(actual = virJSONValueToString(mergebitmaps, true)))
fbe740
-        return -1;
fbe740
-
fbe740
     return virTestCompareToFile(actual, expectpath);
fbe740
 }
fbe740
 
fbe740
@@ -1311,6 +1310,8 @@ mymain(void)
fbe740
             ret = -1; \
fbe740
     } while (0)
fbe740
 
fbe740
+    TEST_BACKUP_BITMAP_CALCULATE("empty", bitmapSourceChain, "a", "empty");
fbe740
+
fbe740
     TEST_BACKUP_BITMAP_CALCULATE("basic-flat", bitmapSourceChain, "current", "basic");
fbe740
     TEST_BACKUP_BITMAP_CALCULATE("basic-intermediate", bitmapSourceChain, "d", "basic");
fbe740
     TEST_BACKUP_BITMAP_CALCULATE("basic-deep", bitmapSourceChain, "a", "basic");
fbe740
diff --git a/tests/qemublocktestdata/backupmerge/empty-out.json b/tests/qemublocktestdata/backupmerge/empty-out.json
fbe740
new file mode 100644
fbe740
index 0000000000..7951defec1
fbe740
--- /dev/null
fbe740
+++ b/tests/qemublocktestdata/backupmerge/empty-out.json
fbe740
@@ -0,0 +1 @@
fbe740
+NULL
fbe740
-- 
fbe740
2.27.0
fbe740