]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/063
build: Remove --enable-gprof
[mirror_qemu.git] / tests / qemu-iotests / 063
CommitLineData
11a82d14 1#!/usr/bin/env bash
9dd003a9 2# group: rw auto quick
b2e10493
AD
3#
4# test of qemu-img convert -n - convert without creation
5#
6# Copyright (C) 2009 Red Hat, Inc.
7# Copyright (C) 2013 Alex Bligh (alex@alex.org.uk)
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22
23# creator
24owner=alex@alex.org.uk
25
26seq=`basename $0`
27echo "QA output created by $seq"
28
b2e10493
AD
29status=1 # failure is the default!
30
31_cleanup()
32{
f91ecbd7
HR
33 _cleanup_test_img
34 for img in "$TEST_IMG".{orig,raw1,raw2,target}; do
35 _rm_test_img "$img"
36 done
b2e10493
AD
37}
38trap "_cleanup; exit \$status" 0 1 2 3 15
39
40# get standard environment, filters and checks
41. ./common.rc
42. ./common.filter
43. ./common.pattern
44
45_supported_fmt qcow qcow2 vmdk qed raw
1f7bf7d0 46_supported_proto file
d2329f27
FZ
47_unsupported_imgopts "subformat=monolithicFlat" \
48 "subformat=twoGbMaxExtentFlat" \
325dd915
HR
49 "subformat=twoGbMaxExtentSparse" \
50 "subformat=streamOptimized"
b2e10493
AD
51
52_make_test_img 4M
53
54echo "== Testing conversion with -n fails with no target file =="
fef9c191 55if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then
b2e10493
AD
56 exit 1
57fi
58
59echo "== Testing conversion with -n succeeds with a target file =="
d88bef19
HR
60_rm_test_img "$TEST_IMG.orig"
61TEST_IMG="$TEST_IMG.orig" _make_test_img 4M
fef9c191 62if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then
b2e10493
AD
63 exit 1
64fi
65
66echo "== Testing conversion to raw is the same after conversion with -n =="
67# compare the raw files
fef9c191 68if ! $QEMU_IMG convert -f $IMGFMT -O raw "$TEST_IMG" "$TEST_IMG.raw1" ; then
b2e10493
AD
69 exit 1
70fi
71
fef9c191 72if ! $QEMU_IMG convert -f $IMGFMT -O raw "$TEST_IMG.orig" "$TEST_IMG.raw2" ; then
b2e10493
AD
73 exit 1
74fi
75
fef9c191 76if ! cmp "$TEST_IMG.raw1" "$TEST_IMG.raw2" ; then
b2e10493
AD
77 exit 1
78fi
79
80echo "== Testing conversion back to original format =="
fef9c191 81if ! $QEMU_IMG convert -f raw -O $IMGFMT -n "$TEST_IMG.raw2" "$TEST_IMG" ; then
b2e10493
AD
82 exit 1
83fi
84_check_test_img
85
86echo "== Testing conversion to a smaller file fails =="
d88bef19
HR
87TEST_IMG="$TEST_IMG.target" _make_test_img 2M
88if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.target" >/dev/null 2>&1; then
b2e10493
AD
89 exit 1
90fi
91
e06f4639
FZ
92echo "== Regression testing for copy offloading bug =="
93
94_make_test_img 1M
95TEST_IMG="$TEST_IMG.target" _make_test_img 1M
96$QEMU_IO -c 'write -P 1 0 512k' -c 'write -P 2 512k 512k' "$TEST_IMG" | _filter_qemu_io
97$QEMU_IO -c 'write -P 4 512k 512k' -c 'write -P 3 0 512k' "$TEST_IMG.target" | _filter_qemu_io
98$QEMU_IMG convert -n -O $IMGFMT "$TEST_IMG" "$TEST_IMG.target"
99$QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.target"
100
b2e10493
AD
101echo "*** done"
102rm -f $seq.full
103status=0
104exit 0