Message ID | 1503493480-21691-3-git-send-email-chugh.ishani@research.iiit.ac.in |
---|---|
State | New |
Headers | show |
On Wed, Aug 23, 2017 at 06:34:39PM +0530, Ishani Chugh wrote: > +CONFIG_FILE=$TEST_DIR/backup-config > +SOCKET=unix:$TEST_DIR/backup_socket > +size=128M > + > +_make_test_img $size > +export QEMU_BACKUP_CONFIG=$CONFIG_FILE > +qemu_comm_method="monitor" > +echo > +_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait I tend to put doublequotes around any variable expansion unless the variable is trivially guaranteed to contain no spaces. Imagine TEST_DIR="a b", then your command expands to: '-qmp' 'unix:a' 'b/backup_socket,server,nowait' QEMU will think the option is -qmp unix:a only. If you use doublequotes then the space will not split the argument into multiple arguments: -qmp "$SOCKET",server,nowait expands to: '-qmp' 'unix:a b/backup_socket,server,nowait' Please use doublequotes around all variable expansion. > +$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp $SOCKET > +$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad --target $TEST_DIR/virtio0 > +echo > +echo "== Creating backup ==" > +$PYTHON ../../contrib/backup/qemu-backup.py backup --guest adad > +_send_qemu_cmd $QEMU_HANDLE 'quit' '' > +wait=1 _cleanup_qemu > +echo > +echo "== Comparing images ==" > +$QEMU_IMG compare $TEST_DIR/virtio0 $TEST_IMG > +rm $TEST_DIR/virtio0 > + > +_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp $SOCKET,server,nowait > +echo > +echo "== Writing Pattern ==" > +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io > +echo > +echo "== Creating backup ==" > +$PYTHON ../../contrib/backup/qemu-backup.py backup --guest adad > +_send_qemu_cmd $QEMU_HANDLE 'quit' '' > +wait=1 _cleanup_qemu > +echo > +echo "== Comparing images ==" > +$QEMU_IMG compare $TEST_DIR/virtio0 $TEST_IMG > +rm $TEST_DIR/virtio0 > +rm $CONFIG_FILE All cleanup should be done from a trap handler function. This way the cleanup happens even if the process terminates early: _cleanup() { rm -f "$TEST_DIR"/virtio0 rm -f "$CONFIG_FILE" _cleanup_test_img } trap "_cleanup; exit \$status" 0 1 2 3 15
On 23 August 2017 at 14:04, Ishani Chugh <chugh.ishani@research.iiit.ac.in> wrote: > This patch is the test for full backup implementation in Backup tool. > The test employs two basic substests: > 1) Backing up an empty guest and comparing it with base image. > 2) Writing a pattern to the guest, creating backup and comparing > with the base image. > > Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in> > --- > tests/qemu-iotests/191 | 78 ++++++++++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/191.out | 33 ++++++++++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 112 insertions(+) > create mode 100755 tests/qemu-iotests/191 > create mode 100644 tests/qemu-iotests/191.out > > diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 > new file mode 100755 > index 0000000..fb4cde9 > --- /dev/null > +++ b/tests/qemu-iotests/191 > @@ -0,0 +1,78 @@ > +#!/bin/bash > +# > +# Test full backup functionality of qemu-backup tool > +# > +# Copyright (C) 2009 Red Hat, Inc. Should this perhaps have a different copyright owner and date? thanks -- PMM
On 08/25/2017 10:36 AM, Peter Maydell wrote: > On 23 August 2017 at 14:04, Ishani Chugh > <chugh.ishani@research.iiit.ac.in> wrote: >> This patch is the test for full backup implementation in Backup tool. >> The test employs two basic substests: >> 1) Backing up an empty guest and comparing it with base image. >> 2) Writing a pattern to the guest, creating backup and comparing >> with the base image. >> >> Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in> >> --- >> tests/qemu-iotests/191 | 78 ++++++++++++++++++++++++++++++++++++++++++++++ >> tests/qemu-iotests/191.out | 33 ++++++++++++++++++++ >> tests/qemu-iotests/group | 1 + >> 3 files changed, 112 insertions(+) >> create mode 100755 tests/qemu-iotests/191 >> create mode 100644 tests/qemu-iotests/191.out >> >> diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 >> new file mode 100755 >> index 0000000..fb4cde9 >> --- /dev/null >> +++ b/tests/qemu-iotests/191 >> @@ -0,0 +1,78 @@ >> +#!/bin/bash >> +# >> +# Test full backup functionality of qemu-backup tool >> +# >> +# Copyright (C) 2009 Red Hat, Inc. > > Should this perhaps have a different copyright owner and date? > > thanks > -- PMM > Yes! Ishani, please take credit for your own work! :)
diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 new file mode 100755 index 0000000..fb4cde9 --- /dev/null +++ b/tests/qemu-iotests/191 @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Test full backup functionality of qemu-backup tool +# +# Copyright (C) 2009 Red Hat, 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=chugh.ishani@research.iiit.ac.in + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt generic +_supported_proto generic +_supported_os Linux + + +CONFIG_FILE=$TEST_DIR/backup-config +SOCKET=unix:$TEST_DIR/backup_socket +size=128M + +_make_test_img $size +export QEMU_BACKUP_CONFIG=$CONFIG_FILE +qemu_comm_method="monitor" +echo +_launch_qemu -drive if=virtio,file=$TEST_IMG -qmp $SOCKET,server,nowait +$PYTHON ../../contrib/backup/qemu-backup.py guest add --guest adad --qmp $SOCKET +$PYTHON ../../contrib/backup/qemu-backup.py drive add --id virtio0 --guest adad --target $TEST_DIR/virtio0 +echo +echo "== Creating backup ==" +$PYTHON ../../contrib/backup/qemu-backup.py backup --guest adad +_send_qemu_cmd $QEMU_HANDLE 'quit' '' +wait=1 _cleanup_qemu +echo +echo "== Comparing images ==" +$QEMU_IMG compare $TEST_DIR/virtio0 $TEST_IMG +rm $TEST_DIR/virtio0 + +_launch_qemu -drive if=virtio,id=virtio0,file=$TEST_IMG -qmp $SOCKET,server,nowait +echo +echo "== Writing Pattern ==" +_send_qemu_cmd $QEMU_HANDLE 'qemu-io virtio0 "write -P 0x22 0 1M"' "(qemu)" | _filter_qemu_io +echo +echo "== Creating backup ==" +$PYTHON ../../contrib/backup/qemu-backup.py backup --guest adad +_send_qemu_cmd $QEMU_HANDLE 'quit' '' +wait=1 _cleanup_qemu +echo +echo "== Comparing images ==" +$QEMU_IMG compare $TEST_DIR/virtio0 $TEST_IMG +rm $TEST_DIR/virtio0 +rm $CONFIG_FILE + +echo "*** done" +status=0 \ No newline at end of file diff --git a/tests/qemu-iotests/191.out b/tests/qemu-iotests/191.out new file mode 100644 index 0000000..a8b0dbb --- /dev/null +++ b/tests/qemu-iotests/191.out @@ -0,0 +1,33 @@ +QA output created by 191 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 + +Successfully Added Guest +Successfully Added Drive + +== Creating backup == +Backup Started +*virtio0 +Backup Complete +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) Formatting 'TEST_DIR/virtio0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 +quit + +== Comparing images == +Images are identical. + +== Writing Pattern == +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) qemu-io virtio0 "write -P 0x22 0 1M" + +== Creating backup == +Backup Started +*virtio0 +Backup Complete +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +(qemu) Formatting 'TEST_DIR/virtio0', fmt=qcow2 size=134217728 cluster_size=65536 lazy_refcounts=off refcount_bits=16 +quit + +== Comparing images == +Images are identical. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index afbdc42..bfff383 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -187,3 +187,4 @@ 189 rw auto 190 rw auto quick 192 rw auto quick +193 rw auto
This patch is the test for full backup implementation in Backup tool. The test employs two basic substests: 1) Backing up an empty guest and comparing it with base image. 2) Writing a pattern to the guest, creating backup and comparing with the base image. Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in> --- tests/qemu-iotests/191 | 78 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/191.out | 33 ++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 112 insertions(+) create mode 100755 tests/qemu-iotests/191 create mode 100644 tests/qemu-iotests/191.out