diff mbox series

[4/4] qemu-iotest: add 311 testcase

Message ID 20201021073355.2499-5-likejun6@huawei.com
State New
Headers show
Series Test qemu-img with different options | expand

Commit Message

likejun6@huawei.com Oct. 21, 2020, 7:33 a.m. UTC
From: likejun <likejun6@huawei.com>

Test backing file is raw

Signed-off-by: likejun <likejun6@huawei.com>
---
 tests/qemu-iotests/311     | 70 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/311.out | 30 ++++++++++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 101 insertions(+)
 create mode 100755 tests/qemu-iotests/311
 create mode 100644 tests/qemu-iotests/311.out
diff mbox series

Patch

diff --git a/tests/qemu-iotests/311 b/tests/qemu-iotests/311
new file mode 100755
index 0000000000..6c2b9f987f
--- /dev/null
+++ b/tests/qemu-iotests/311
@@ -0,0 +1,70 @@ 
+#!/bin/bash
+#
+# Test backing file is raw
+#
+# Copyright (C) 2020 Huawei, Inc
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=zhangshuai13@huawei.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+status=1	# failure is the default!
+
+_cleanup()
+{
+	_cleanup_test_img
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc >/dev/null 2>&1
+. ./common.filter
+
+_supported_fmt qcow2
+_supported_proto file
+_supported_os Linux
+
+echo "=== Check qemu-img info output ==="
+echo
+size=64M
+
+$QEMU_IMG create -f raw $TEST_IMG $size | _filter_img_create
+_img_info | _filter_img_info
+mv "$TEST_IMG" "$TEST_IMG.base"
+
+_make_test_img -b $TEST_IMG.base -F raw
+_img_info --backing-chain | _filter_img_info
+
+echo
+echo "== reading whole image =="
+$QEMU_IO -c "read 0 $size" "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "== rewriting whole image =="
+$QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "== verify pattern =="
+$QEMU_IO -c "read -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
+
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/311.out b/tests/qemu-iotests/311.out
new file mode 100644
index 0000000000..03b8374c04
--- /dev/null
+++ b/tests/qemu-iotests/311.out
@@ -0,0 +1,30 @@ 
+QA output created by 311
+=== Check qemu-img info output ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=raw size=67108864
+image: TEST_DIR/t.IMGFMT
+file format: raw
+virtual size: 64 MiB (67108864 bytes)
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+image: TEST_DIR/t.IMGFMT
+file format: IMGFMT
+virtual size: 64 MiB (67108864 bytes)
+backing file: TEST_DIR/t.IMGFMT.base
+backing file format: raw
+
+image: TEST_DIR/t.IMGFMT.base
+file format: raw
+virtual size: 64 MiB (67108864 bytes)
+
+== reading whole image ==
+read 67108864/67108864 bytes at offset 0
+64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+== rewriting whole image ==
+wrote 67108864/67108864 bytes at offset 0
+64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+== verify pattern ==
+read 67108864/67108864 bytes at offset 0
+64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index e8b6480890..ec57e16f07 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -318,3 +318,4 @@ 
 308 rw auto quick
 309 rw auto quick
 310 rw auto quick
+311 rw auto quick