xref: /qemu/tests/qemu-iotests/098 (revision 7d90030196d8e08fb13ff9c081fb6343d7bcb8c5)
1*7d900301SMax Reitz#!/bin/bash
2*7d900301SMax Reitz#
3*7d900301SMax Reitz# Test qcow2's bdrv_make_empty for images without internal snapshots
4*7d900301SMax Reitz#
5*7d900301SMax Reitz# Copyright (C) 2014 Red Hat, Inc.
6*7d900301SMax Reitz#
7*7d900301SMax Reitz# This program is free software; you can redistribute it and/or modify
8*7d900301SMax Reitz# it under the terms of the GNU General Public License as published by
9*7d900301SMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*7d900301SMax Reitz# (at your option) any later version.
11*7d900301SMax Reitz#
12*7d900301SMax Reitz# This program is distributed in the hope that it will be useful,
13*7d900301SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*7d900301SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*7d900301SMax Reitz# GNU General Public License for more details.
16*7d900301SMax Reitz#
17*7d900301SMax Reitz# You should have received a copy of the GNU General Public License
18*7d900301SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*7d900301SMax Reitz#
20*7d900301SMax Reitz
21*7d900301SMax Reitz# creator
22*7d900301SMax Reitzowner=mreitz@redhat.com
23*7d900301SMax Reitz
24*7d900301SMax Reitzseq="$(basename $0)"
25*7d900301SMax Reitzecho "QA output created by $seq"
26*7d900301SMax Reitz
27*7d900301SMax Reitzhere="$PWD"
28*7d900301SMax Reitztmp=/tmp/$$
29*7d900301SMax Reitzstatus=1	# failure is the default!
30*7d900301SMax Reitz
31*7d900301SMax Reitz_cleanup()
32*7d900301SMax Reitz{
33*7d900301SMax Reitz    _cleanup_test_img
34*7d900301SMax Reitz    rm -f "$TEST_DIR/blkdebug.conf"
35*7d900301SMax Reitz}
36*7d900301SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
37*7d900301SMax Reitz
38*7d900301SMax Reitz# get standard environment, filters and checks
39*7d900301SMax Reitz. ./common.rc
40*7d900301SMax Reitz. ./common.filter
41*7d900301SMax Reitz. ./common.pattern
42*7d900301SMax Reitz
43*7d900301SMax Reitz_supported_fmt qcow2
44*7d900301SMax Reitz_supported_proto file
45*7d900301SMax Reitz_supported_os Linux
46*7d900301SMax Reitz
47*7d900301SMax ReitzIMGOPTS="compat=1.1"
48*7d900301SMax Reitz
49*7d900301SMax Reitzfor event in l1_update empty_image_prepare reftable_update refblock_alloc; do
50*7d900301SMax Reitz
51*7d900301SMax Reitzecho
52*7d900301SMax Reitzecho "=== $event ==="
53*7d900301SMax Reitzecho
54*7d900301SMax Reitz
55*7d900301SMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 64M
56*7d900301SMax Reitz_make_test_img -b "$TEST_IMG.base" 64M
57*7d900301SMax Reitz
58*7d900301SMax Reitz# Some data that can be leaked when emptying the top image
59*7d900301SMax Reitz$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
60*7d900301SMax Reitz
61*7d900301SMax Reitzcat > "$TEST_DIR/blkdebug.conf" <<EOF
62*7d900301SMax Reitz[inject-error]
63*7d900301SMax Reitzevent = "$event"
64*7d900301SMax ReitzEOF
65*7d900301SMax Reitz
66*7d900301SMax Reitz$QEMU_IMG commit "blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" 2>&1 \
67*7d900301SMax Reitz    | _filter_testdir | _filter_imgfmt
68*7d900301SMax Reitz
69*7d900301SMax Reitz# There may be errors, but they should be fixed by opening the image
70*7d900301SMax Reitz$QEMU_IO -c close "$TEST_IMG"
71*7d900301SMax Reitz
72*7d900301SMax Reitz_check_test_img
73*7d900301SMax Reitz
74*7d900301SMax Reitzdone
75*7d900301SMax Reitz
76*7d900301SMax Reitz
77*7d900301SMax Reitzrm -f "$TEST_DIR/blkdebug.conf"
78*7d900301SMax Reitz
79*7d900301SMax Reitz# success, all done
80*7d900301SMax Reitzecho "*** done"
81*7d900301SMax Reitzrm -f $seq.full
82*7d900301SMax Reitzstatus=0
83