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

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