Blame SOURCES/kvm-iotests-Add-test-for-rebasing-with-relative-paths.patch

357786
From f5f8208d1e759b789da9f2ae03b2320c355dbf89 Mon Sep 17 00:00:00 2001
357786
From: Max Reitz <mreitz@redhat.com>
357786
Date: Mon, 18 Jun 2018 17:48:33 +0200
357786
Subject: [PATCH 11/89] iotests: Add test for rebasing with relative paths
357786
357786
RH-Author: Max Reitz <mreitz@redhat.com>
357786
Message-id: <20180618174833.19439-3-mreitz@redhat.com>
357786
Patchwork-id: 80789
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/2] iotests: Add test for rebasing with relative paths
357786
Bugzilla: 1569835
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
357786
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
Reviewed-by: Eric Blake <eblake@redhat.com>
357786
Message-id: 20180509182002.8044-3-mreitz@redhat.com
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
(cherry picked from commit 28036a7f7044fddb79819e3c8fcb4ae5605c60e0)
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/qemu-iotests/024     | 82 ++++++++++++++++++++++++++++++++++++++++++++--
357786
 tests/qemu-iotests/024.out | 30 +++++++++++++++++
357786
 2 files changed, 109 insertions(+), 3 deletions(-)
357786
357786
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
357786
index e0d77ce..4071ed6 100755
357786
--- a/tests/qemu-iotests/024
357786
+++ b/tests/qemu-iotests/024
357786
@@ -29,9 +29,14 @@ status=1	# failure is the default!
357786
 
357786
 _cleanup()
357786
 {
357786
-	_cleanup_test_img
357786
-	rm -f "$TEST_DIR/t.$IMGFMT.base_old"
357786
-	rm -f "$TEST_DIR/t.$IMGFMT.base_new"
357786
+    _cleanup_test_img
357786
+    rm -f "$TEST_DIR/t.$IMGFMT.base_old"
357786
+    rm -f "$TEST_DIR/t.$IMGFMT.base_new"
357786
+
357786
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT"
357786
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old"
357786
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new"
357786
+    rmdir "$TEST_DIR/subdir" 2> /dev/null
357786
 }
357786
 trap "_cleanup; exit \$status" 0 1 2 3 15
357786
 
357786
@@ -123,6 +128,77 @@ io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
357786
 io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
357786
 io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
357786
 
357786
+echo
357786
+echo "=== Test rebase in a subdirectory of the working directory ==="
357786
+echo
357786
+
357786
+# Clean up the old images beforehand so they do not interfere with
357786
+# this test
357786
+_cleanup
357786
+
357786
+mkdir "$TEST_DIR/subdir"
357786
+
357786
+# Relative to the overlay
357786
+BASE_OLD_OREL="t.$IMGFMT.base_old"
357786
+BASE_NEW_OREL="t.$IMGFMT.base_new"
357786
+
357786
+# Relative to $TEST_DIR (which is going to be our working directory)
357786
+OVERLAY_WREL="subdir/t.$IMGFMT"
357786
+
357786
+BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL"
357786
+BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL"
357786
+OVERLAY="$TEST_DIR/$OVERLAY_WREL"
357786
+
357786
+# Test done here:
357786
+#
357786
+# Backing (old): 11 11 -- 11
357786
+# Backing (new): -- 22 22 11
357786
+# Overlay:       -- -- -- --
357786
+#
357786
+# Rebasing works, we have verified that above.  Here, we just want to
357786
+# see that rebasing is done for the correct target backing file.
357786
+
357786
+TEST_IMG=$BASE_OLD _make_test_img 1M
357786
+TEST_IMG=$BASE_NEW _make_test_img 1M
357786
+TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" 1M
357786
+
357786
+echo
357786
+
357786
+$QEMU_IO "$BASE_OLD" \
357786
+    -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
357786
+    -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
357786
+    | _filter_qemu_io
357786
+
357786
+$QEMU_IO "$BASE_NEW" \
357786
+    -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
357786
+    -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
357786
+    | _filter_qemu_io
357786
+
357786
+echo
357786
+
357786
+pushd "$TEST_DIR" >/dev/null
357786
+$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" "$OVERLAY_WREL"
357786
+popd >/dev/null
357786
+
357786
+# Verify the backing path is correct
357786
+TEST_IMG=$OVERLAY _img_info | grep '^backing file'
357786
+
357786
+echo
357786
+
357786
+# Verify the data is correct
357786
+$QEMU_IO "$OVERLAY" \
357786
+    -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
357786
+    -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
357786
+    -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
357786
+    -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
357786
+    | _filter_qemu_io
357786
+
357786
+echo
357786
+
357786
+# Verify that cluster #3 is not allocated (because it is the same in
357786
+# $BASE_OLD and $BASE_NEW)
357786
+$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map
357786
+
357786
 
357786
 # success, all done
357786
 echo "*** done"
357786
diff --git a/tests/qemu-iotests/024.out b/tests/qemu-iotests/024.out
357786
index 33cfaf5..024dc78 100644
357786
--- a/tests/qemu-iotests/024.out
357786
+++ b/tests/qemu-iotests/024.out
357786
@@ -141,4 +141,34 @@ read 65536/65536 bytes at offset 917504
357786
 === IO: pattern 0x00
357786
 read 65536/65536 bytes at offset 983040
357786
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+
357786
+=== Test rebase in a subdirectory of the working directory ===
357786
+
357786
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=1048576
357786
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=1048576
357786
+Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.base_old
357786
+
357786
+wrote 131072/131072 bytes at offset 0
357786
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+wrote 65536/65536 bytes at offset 196608
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+wrote 131072/131072 bytes at offset 65536
357786
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+wrote 65536/65536 bytes at offset 196608
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+
357786
+backing file: t.IMGFMT.base_new (actual path: TEST_DIR/subdir/t.IMGFMT.base_new)
357786
+
357786
+read 65536/65536 bytes at offset 0
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+read 65536/65536 bytes at offset 65536
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+read 65536/65536 bytes at offset 131072
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+read 65536/65536 bytes at offset 196608
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+
357786
+Offset          Length          File
357786
+0               0x30000         TEST_DIR/subdir/t.IMGFMT
357786
+0x30000         0x10000         TEST_DIR/subdir/t.IMGFMT.base_new
357786
 *** done
357786
-- 
357786
1.8.3.1
357786