3 # test of qemu-img convert -n - convert without creation
5 # Copyright (C) 2009 Red Hat, Inc.
6 # Copyright (C) 2013 Alex Bligh (alex@alex.org.uk)
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 owner
=alex@alex.org.uk
26 echo "QA output created by $seq"
29 status
=1 # failure is the default!
34 rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2"
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
43 _supported_fmt qcow qcow2 vmdk qed raw
46 _unsupported_imgopts
"subformat=monolithicFlat" \
47 "subformat=twoGbMaxExtentFlat" \
48 "subformat=twoGbMaxExtentSparse"
52 echo "== Testing conversion with -n fails with no target file =="
53 # check .orig file does not exist
54 rm -f "$TEST_IMG.orig"
55 if $QEMU_IMG convert
-f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev
/null
2>&1; then
59 echo "== Testing conversion with -n succeeds with a target file =="
60 rm -f "$TEST_IMG.orig"
61 cp "$TEST_IMG" "$TEST_IMG.orig"
62 if ! $QEMU_IMG convert
-f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then
66 echo "== Testing conversion to raw is the same after conversion with -n =="
67 # compare the raw files
68 if ! $QEMU_IMG convert
-f $IMGFMT -O raw
"$TEST_IMG" "$TEST_IMG.raw1" ; then
72 if ! $QEMU_IMG convert
-f $IMGFMT -O raw
"$TEST_IMG.orig" "$TEST_IMG.raw2" ; then
76 if ! cmp "$TEST_IMG.raw1" "$TEST_IMG.raw2" ; then
80 echo "== Testing conversion back to original format =="
81 if ! $QEMU_IMG convert
-f raw
-O $IMGFMT -n "$TEST_IMG.raw2" "$TEST_IMG" ; then
86 echo "== Testing conversion to a smaller file fails =="
87 rm -f "$TEST_IMG.orig"
88 mv "$TEST_IMG" "$TEST_IMG.orig"
90 if $QEMU_IMG convert
-f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev
/null
2>&1; then