diff mbox series

[4/7] iotests: filter img create backing_file when IMGPROTO is modified

Message ID 20230725141915.386364-5-stefanha@redhat.com
State New
Headers show
Series iotests: add -io_uring support | expand

Commit Message

Stefan Hajnoczi July 25, 2023, 2:19 p.m. UTC
197 and 215 modify IMGPROTO, IMGFMT, etc temporarily while creating an
additional image file after the main test image. The backing file name
still has the old IMGPROTO, IMGFMT, etc. This means _filter_img_create
will not filter the backing_file= output from qemu-img.

Add a helper that filters backing_file= output so these test cases are
more robust. This will be necessary in order to enable the io_uring
protocol driver in qemu-iotests.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 tests/qemu-iotests/197           | 4 +++-
 tests/qemu-iotests/197.out       | 2 +-
 tests/qemu-iotests/215           | 4 +++-
 tests/qemu-iotests/215.out       | 2 +-
 tests/qemu-iotests/common.filter | 8 ++++++++
 5 files changed, 16 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
index a2547bc280..756603b19e 100755
--- a/tests/qemu-iotests/197
+++ b/tests/qemu-iotests/197
@@ -68,7 +68,9 @@  fi
 _make_test_img 4G
 $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io
 IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \
-    _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create
+    _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | \
+    _filter_img_create_backing_file | \
+    _filter_img_create
 $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io
 
 # Ensure that a read of two clusters, but where one is already allocated,
diff --git a/tests/qemu-iotests/197.out b/tests/qemu-iotests/197.out
index ad414c3b0e..bbfb3413e4 100644
--- a/tests/qemu-iotests/197.out
+++ b/tests/qemu-iotests/197.out
@@ -5,7 +5,7 @@  QA output created by 197
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
 wrote 1024/1024 bytes at offset 3221225472
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT
+Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=BACKING_FILE backing_fmt=IMGFMT
 wrote 65536/65536 bytes at offset 1048576
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 131072/131072 bytes at offset 1048576
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
index d464596f14..145f2bb3eb 100755
--- a/tests/qemu-iotests/215
+++ b/tests/qemu-iotests/215
@@ -65,7 +65,9 @@  fi
 _make_test_img 4G
 $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io
 IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \
-    _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create
+    _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | \
+    _filter_img_create_backing_file | \
+    _filter_img_create
 $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io
 
 # Ensure that a read of two clusters, but where one is already allocated,
diff --git a/tests/qemu-iotests/215.out b/tests/qemu-iotests/215.out
index 5a2fe40d03..d10cce71bc 100644
--- a/tests/qemu-iotests/215.out
+++ b/tests/qemu-iotests/215.out
@@ -5,7 +5,7 @@  QA output created by 215
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
 wrote 1024/1024 bytes at offset 3221225472
 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT
+Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=BACKING_FILE backing_fmt=IMGFMT
 wrote 65536/65536 bytes at offset 1048576
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 read 131072/131072 bytes at offset 1048576
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 4acac16c52..b047fe43a0 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -206,6 +206,14 @@  _filter_img_create()
     done
 }
 
+# When creating additional images with different IMGPROTO, IMGFMT, etc than the
+# main test image, _filter_img_create cannot filter backing_file since it
+# contains different IMGPROTO, IMGFMT, etc values than currently in use.
+_filter_img_create_backing_file()
+{
+    sed -e "s/ backing_file=[^ ]*/ backing_file=BACKING_FILE/g"
+}
+
 _filter_img_create_size()
 {
     gsed -e "s# size=[0-9]\\+# size=SIZE#g"