docs: add note about stibp CPU feature for spectre v2
[qemu/ar7.git] / tests / qemu-iotests / 063
blob2d5c0ce9fb4653dc3edb453098f0b2da2f8f8c03
1 #!/usr/bin/env bash
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/>.
22 # creator
23 owner=alex@alex.org.uk
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40 . ./common.pattern
42 _supported_fmt qcow qcow2 vmdk qed raw
43 _supported_proto file
44 _supported_os Linux
45 _unsupported_imgopts "subformat=monolithicFlat" \
46 "subformat=twoGbMaxExtentFlat" \
47 "subformat=twoGbMaxExtentSparse"
49 _make_test_img 4M
51 echo "== Testing conversion with -n fails with no target file =="
52 # check .orig file does not exist
53 rm -f "$TEST_IMG.orig"
54 if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then
55 exit 1
58 echo "== Testing conversion with -n succeeds with a target file =="
59 rm -f "$TEST_IMG.orig"
60 cp "$TEST_IMG" "$TEST_IMG.orig"
61 if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then
62 exit 1
65 echo "== Testing conversion to raw is the same after conversion with -n =="
66 # compare the raw files
67 if ! $QEMU_IMG convert -f $IMGFMT -O raw "$TEST_IMG" "$TEST_IMG.raw1" ; then
68 exit 1
71 if ! $QEMU_IMG convert -f $IMGFMT -O raw "$TEST_IMG.orig" "$TEST_IMG.raw2" ; then
72 exit 1
75 if ! cmp "$TEST_IMG.raw1" "$TEST_IMG.raw2" ; then
76 exit 1
79 echo "== Testing conversion back to original format =="
80 if ! $QEMU_IMG convert -f raw -O $IMGFMT -n "$TEST_IMG.raw2" "$TEST_IMG" ; then
81 exit 1
83 _check_test_img
85 echo "== Testing conversion to a smaller file fails =="
86 rm -f "$TEST_IMG.orig"
87 mv "$TEST_IMG" "$TEST_IMG.orig"
88 _make_test_img 2M
89 if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev/null 2>&1; then
90 exit 1
93 echo "== Regression testing for copy offloading bug =="
95 _make_test_img 1M
96 TEST_IMG="$TEST_IMG.target" _make_test_img 1M
97 $QEMU_IO -c 'write -P 1 0 512k' -c 'write -P 2 512k 512k' "$TEST_IMG" | _filter_qemu_io
98 $QEMU_IO -c 'write -P 4 512k 512k' -c 'write -P 3 0 512k' "$TEST_IMG.target" | _filter_qemu_io
99 $QEMU_IMG convert -n -O $IMGFMT "$TEST_IMG" "$TEST_IMG.target"
100 $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.target"
102 echo "*** done"
103 rm -f $seq.full
104 status=0
105 exit 0