Message ID | 1414336849-21179-4-git-send-email-junmuzi@gmail.com |
---|---|
State | New |
Headers | show |
On 2014-10-26 at 16:20, Jun Li wrote: > Add qemu-iotests for qcow2 shrinking. > e.g: > $ ./check -qcow2 110 > > Signed-off-by: Jun Li <junmuzi@gmail.com> > --- > tests/qemu-iotests/110 | 76 ++++++++++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/110.out | 13 ++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 90 insertions(+) > create mode 100755 tests/qemu-iotests/110 > create mode 100644 tests/qemu-iotests/110.out > > diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 > new file mode 100755 > index 0000000..c2145a2 > --- /dev/null > +++ b/tests/qemu-iotests/110 > @@ -0,0 +1,76 @@ > +#!/bin/bash > +# > +# Tests qcow2 shrinking > +# > +# Copyright (C) 2014 Jun Li (junmuzi@gmail.com) > +# > +# 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=junmuzi@gmail.com > + > +seq="$(basename $0)" > +echo "QA output created by $seq" > + > +here="$PWD" > +tmp=/tmp/$$ > +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 > +. ./common.filter > +. ./common.pattern > + > +_supported_fmt qcow2 > +_supported_proto file > +_supported_os Linux > + > + > +# Setup test basic parameters > +IMG_SIZE=500M > +CLUSTER_SIZE=64k > + > +echo > +echo '=== Test qcow2 shrinking ===' > +echo > + > +_make_test_img $IMG_SIZE > +io_pattern write 0 500M 65536 1 110 > +#cp $TEST_IMG /tmp/before-resized.img This line should be removed. > + > +# shrinking image > +$QEMU_IMG resize "$TEST_IMG" -10M > + > +_check_test_img Just testing whether the image is consistent is not enough. Please try to read the pattern back ("io_pattern read 0 490M 65536 1 110") to compare whether the data is still there. > + > +# shrinking image > +$QEMU_IMG resize "$TEST_IMG" -100M > +#cp $TEST_IMG /tmp/resized.img This line should be removed, too. > + > +_check_test_img And here should be another "io_pattern read 0 390M 65536 1 110". Max > + > +# success, all done > +echo "*** done" > + > +# Cleanup > +_cleanup_test_img > + > +status=0 > diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out > new file mode 100644 > index 0000000..e54388b > --- /dev/null > +++ b/tests/qemu-iotests/110.out > @@ -0,0 +1,13 @@ > +QA output created by 110 > + > +=== Test qcow2 shrinking === > + > +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288000 > +=== IO: pattern 110 > +wrote 524288000/524288000 bytes at offset 0 > +500 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > +Image resized. > +No errors were found on the image. > +Image resized. > +No errors were found on the image. > +*** done > diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group > index 9bbd5d3..de467ff 100644 > --- a/tests/qemu-iotests/group > +++ b/tests/qemu-iotests/group > @@ -109,3 +109,4 @@ > 105 rw auto quick > 107 rw auto quick > 108 rw auto quick > +110 rw auto quick
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 new file mode 100755 index 0000000..c2145a2 --- /dev/null +++ b/tests/qemu-iotests/110 @@ -0,0 +1,76 @@ +#!/bin/bash +# +# Tests qcow2 shrinking +# +# Copyright (C) 2014 Jun Li (junmuzi@gmail.com) +# +# 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=junmuzi@gmail.com + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +tmp=/tmp/$$ +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 +. ./common.filter +. ./common.pattern + +_supported_fmt qcow2 +_supported_proto file +_supported_os Linux + + +# Setup test basic parameters +IMG_SIZE=500M +CLUSTER_SIZE=64k + +echo +echo '=== Test qcow2 shrinking ===' +echo + +_make_test_img $IMG_SIZE +io_pattern write 0 500M 65536 1 110 +#cp $TEST_IMG /tmp/before-resized.img + +# shrinking image +$QEMU_IMG resize "$TEST_IMG" -10M + +_check_test_img + +# shrinking image +$QEMU_IMG resize "$TEST_IMG" -100M +#cp $TEST_IMG /tmp/resized.img + +_check_test_img + +# success, all done +echo "*** done" + +# Cleanup +_cleanup_test_img + +status=0 diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out new file mode 100644 index 0000000..e54388b --- /dev/null +++ b/tests/qemu-iotests/110.out @@ -0,0 +1,13 @@ +QA output created by 110 + +=== Test qcow2 shrinking === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288000 +=== IO: pattern 110 +wrote 524288000/524288000 bytes at offset 0 +500 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image resized. +No errors were found on the image. +Image resized. +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 9bbd5d3..de467ff 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -109,3 +109,4 @@ 105 rw auto quick 107 rw auto quick 108 rw auto quick +110 rw auto quick
Add qemu-iotests for qcow2 shrinking. e.g: $ ./check -qcow2 110 Signed-off-by: Jun Li <junmuzi@gmail.com> --- tests/qemu-iotests/110 | 76 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/110.out | 13 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 90 insertions(+) create mode 100755 tests/qemu-iotests/110 create mode 100644 tests/qemu-iotests/110.out