Test qemu-img with different options
PATCH 1/4 qemu-iotest: add 308 testcase
In reply to [email protected]From: likejun <[email protected]>
Test thick image creation, size and rw
--- tests/qemu-iotests/308 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/308.out | 21 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 126 insertions(+) create mode 100755 tests/qemu-iotests/308 create mode 100644 tests/qemu-iotests/308.out
tests/qemu-iotests/308 new file +104 -0
@@ -0,0 +1,104 @@ +#!/bin/bash +# +# Test thick image creation, size and rw +# +# 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 [email protected] + +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 + +_img_info_tmp() +{ + if [[ "$1" == "--format-specific" ]]; then + local format_specific=1 + shift + else + local format_specific=0 + fi + + discard=0 + regex_json_spec_start='^ *"format-specific": \{' + $QEMU_IMG info "$@" "$TEST_IMG" 2>&1 | \ + sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ + -e "s#$TEST_DIR#TEST_DIR#g" \ + -e "s#$IMGFMT#IMGFMT#g" \ + -e "/actual-size/ D" | \ + while IFS='' read line; do + if [[ $format_specific == 1 ]]; then + discard=0 + elif [[ $line == "Format specific information:" ]]; then + discard=1 + elif [[ $line =~ $regex_json_spec_start ]]; then + discard=2 + regex_json_spec_end="^${line%%[^ ]*}\\},? *$" + fi + if [[ $discard == 0 ]]; then + echo "$line" + elif [[ $discard == 1 && ! $line ]]; then + echo + discard=0 + elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then + discard=0 + fi + done +} + +IMGOPTS="preallocation=full" + +echo "=== Check qemu-img info output ===" +echo +size=64M + +_make_test_img $size +_img_info_tmp | _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
tests/qemu-iotests/308.out new file +21 -0
@@ -0,0 +1,21 @@ +QA output created by 308 +=== Check qemu-img info output === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=full +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64 MiB (67108864 bytes) +disk size: 64.3 MiB + +== 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
tests/qemu-iotests/group +1 -0
@@ -315,3 +315,4 @@ 304 rw quick 305 rw quick 307 rw quick export +308 rw auto quick
Signature · 1 line
2.19.1
PATCH 2/4 qemu-iotest: add 309 testcase
In reply to [email protected]From: likejun <[email protected]>
Test raw thin provisioned image creation, size and rw
--- tests/qemu-iotests/309 | 102 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/309.out | 21 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 124 insertions(+) create mode 100755 tests/qemu-iotests/309 create mode 100644 tests/qemu-iotests/309.out
tests/qemu-iotests/309 new file +102 -0
@@ -0,0 +1,102 @@ +#!/bin/bash +# +# Test raw thin provisioned image creation, size and rw +# +# 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 [email protected] + +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 + +_img_info_tmp() +{ + if [[ "$1" == "--format-specific" ]]; then + local format_specific=1 + shift + else + local format_specific=0 + fi + + discard=0 + regex_json_spec_start='^ *"format-specific": \{' + $QEMU_IMG info "$@" "$TEST_IMG" 2>&1 | \ + sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ + -e "s#$TEST_DIR#TEST_DIR#g" \ + -e "s#$IMGFMT#IMGFMT#g" \ + -e "/actual-size/ D" | \ + while IFS='' read line; do + if [[ $format_specific == 1 ]]; then + discard=0 + elif [[ $line == "Format specific information:" ]]; then + discard=1 + elif [[ $line =~ $regex_json_spec_start ]]; then + discard=2 + regex_json_spec_end="^${line%%[^ ]*}\\},? *$" + fi + if [[ $discard == 0 ]]; then + echo "$line" + elif [[ $discard == 1 && ! $line ]]; then + echo + discard=0 + elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then + discard=0 + fi + done +} + +echo "=== Check qemu-img info output ===" +echo +size=64M + +_make_test_img $size +_img_info_tmp | _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
tests/qemu-iotests/309.out new file +21 -0
@@ -0,0 +1,21 @@ +QA output created by 309 +=== Check qemu-img info output === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64 MiB (67108864 bytes) +disk size: 196 KiB + +== 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
tests/qemu-iotests/group +1 -0
@@ -316,3 +316,4 @@ 305 rw quick 307 rw quick export 308 rw auto quick +309 rw auto quick
Signature · 1 line
2.19.1
PATCH 3/4 qemu-iotest: add 310 testcase
In reply to [email protected]From: likejun <[email protected]>
Test falloc image creation, size and rw
--- tests/qemu-iotests/310 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/310.out | 21 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 126 insertions(+) create mode 100755 tests/qemu-iotests/310 create mode 100644 tests/qemu-iotests/310.out
tests/qemu-iotests/310 new file +104 -0
@@ -0,0 +1,104 @@ +#!/bin/bash +# +# Test falloc image creation, size and rw +# +# 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 [email protected] + +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 + +_img_info_tmp() +{ + if [[ "$1" == "--format-specific" ]]; then + local format_specific=1 + shift + else + local format_specific=0 + fi + + discard=0 + regex_json_spec_start='^ *"format-specific": \{' + $QEMU_IMG info "$@" "$TEST_IMG" 2>&1 | \ + sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ + -e "s#$TEST_DIR#TEST_DIR#g" \ + -e "s#$IMGFMT#IMGFMT#g" \ + -e "/actual-size/ D" | \ + while IFS='' read line; do + if [[ $format_specific == 1 ]]; then + discard=0 + elif [[ $line == "Format specific information:" ]]; then + discard=1 + elif [[ $line =~ $regex_json_spec_start ]]; then + discard=2 + regex_json_spec_end="^${line%%[^ ]*}\\},? *$" + fi + if [[ $discard == 0 ]]; then + echo "$line" + elif [[ $discard == 1 && ! $line ]]; then + echo + discard=0 + elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then + discard=0 + fi + done +} + +IMGOPTS="preallocation=falloc" + +echo "=== Check qemu-img info output ===" +echo +size=64M + +_make_test_img $size +_img_info_tmp | _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
tests/qemu-iotests/310.out new file +21 -0
@@ -0,0 +1,21 @@ +QA output created by 310 +=== Check qemu-img info output === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 preallocation=falloc +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 64 MiB (67108864 bytes) +disk size: 64.3 MiB + +== 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
tests/qemu-iotests/group +1 -0
@@ -317,3 +317,4 @@ 307 rw quick export 308 rw auto quick 309 rw auto quick +310 rw auto quick
Signature · 1 line
2.19.1
cover Test qemu-img with different options
From: likejun <[email protected]>
This patch set add those iotests:
308: Test thick image creation, size and rw;
309: Test raw thin provisioned image creation, size and rw; 310: Test falloc image creation, size and rw;
311: Test backing file is raw;
likejun (4):
qemu-iotest: add 308 testcase
qemu-iotest: add 309 testcase
qemu-iotest: add 310 testcase
qemu-iotest: add 311 testcase
tests/qemu-iotests/308 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/308.out | 21 ++++++++ tests/qemu-iotests/309 | 102 ++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/309.out | 21 ++++++++ tests/qemu-iotests/310 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/310.out | 21 ++++++++ tests/qemu-iotests/311 | 70 +++++++++++++++++++++++++ tests/qemu-iotests/311.out | 30 +++++++++++ tests/qemu-iotests/group | 4 ++ 9 files changed, 477 insertions(+) create mode 100755 tests/qemu-iotests/308 create mode 100644 tests/qemu-iotests/308.out create mode 100755 tests/qemu-iotests/309 create mode 100644 tests/qemu-iotests/309.out create mode 100755 tests/qemu-iotests/310 create mode 100644 tests/qemu-iotests/310.out create mode 100755 tests/qemu-iotests/311 create mode 100644 tests/qemu-iotests/311.out
Signature · 1 line
2.19.1
PATCH 4/4 qemu-iotest: add 311 testcase
From: likejun <[email protected]>
Test backing file is raw
--- 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
tests/qemu-iotests/311 new file +70 -0
@@ -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 [email protected] + +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
tests/qemu-iotests/311.out new file +30 -0
@@ -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
tests/qemu-iotests/group +1 -0
@@ -318,3 +318,4 @@ 308 rw auto quick 309 rw auto quick 310 rw auto quick +311 rw auto quick
Signature · 1 line
2.19.1