Statistics
| Branch: | Revision:

root / tests / qemu-iotests / 034 @ 08e4ed6c

History | View | Annotate | Download (3.4 kB)

1 ab3a32ad Kevin Wolf
#!/bin/bash
2 ab3a32ad Kevin Wolf
#
3 ab3a32ad Kevin Wolf
# Test bdrv_write_zeroes with backing files
4 ab3a32ad Kevin Wolf
#
5 ab3a32ad Kevin Wolf
# Copyright (C) 2012 Red Hat, Inc.
6 ab3a32ad Kevin Wolf
#
7 ab3a32ad Kevin Wolf
# This program is free software; you can redistribute it and/or modify
8 ab3a32ad Kevin Wolf
# it under the terms of the GNU General Public License as published by
9 ab3a32ad Kevin Wolf
# the Free Software Foundation; either version 2 of the License, or
10 ab3a32ad Kevin Wolf
# (at your option) any later version.
11 ab3a32ad Kevin Wolf
#
12 ab3a32ad Kevin Wolf
# This program is distributed in the hope that it will be useful,
13 ab3a32ad Kevin Wolf
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ab3a32ad Kevin Wolf
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ab3a32ad Kevin Wolf
# GNU General Public License for more details.
16 ab3a32ad Kevin Wolf
#
17 ab3a32ad Kevin Wolf
# You should have received a copy of the GNU General Public License
18 ab3a32ad Kevin Wolf
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 ab3a32ad Kevin Wolf
#
20 ab3a32ad Kevin Wolf
21 ab3a32ad Kevin Wolf
# creator
22 ab3a32ad Kevin Wolf
owner=kwolf@redhat.com
23 ab3a32ad Kevin Wolf
24 ab3a32ad Kevin Wolf
seq=`basename $0`
25 ab3a32ad Kevin Wolf
echo "QA output created by $seq"
26 ab3a32ad Kevin Wolf
27 ab3a32ad Kevin Wolf
here=`pwd`
28 ab3a32ad Kevin Wolf
tmp=/tmp/$$
29 ab3a32ad Kevin Wolf
status=1	# failure is the default!
30 ab3a32ad Kevin Wolf
31 ab3a32ad Kevin Wolf
_cleanup()
32 ab3a32ad Kevin Wolf
{
33 ab3a32ad Kevin Wolf
	_cleanup_test_img
34 ab3a32ad Kevin Wolf
}
35 ab3a32ad Kevin Wolf
trap "_cleanup; exit \$status" 0 1 2 3 15
36 ab3a32ad Kevin Wolf
37 ab3a32ad Kevin Wolf
# get standard environment, filters and checks
38 ab3a32ad Kevin Wolf
. ./common.rc
39 ab3a32ad Kevin Wolf
. ./common.filter
40 ab3a32ad Kevin Wolf
41 ab3a32ad Kevin Wolf
_supported_fmt qcow qcow2 vmdk qed
42 ab3a32ad Kevin Wolf
_supported_proto generic
43 ab3a32ad Kevin Wolf
_supported_os Linux
44 ab3a32ad Kevin Wolf
45 ab3a32ad Kevin Wolf
CLUSTER_SIZE=4k
46 ab3a32ad Kevin Wolf
size=128M
47 ab3a32ad Kevin Wolf
48 ab3a32ad Kevin Wolf
echo
49 ab3a32ad Kevin Wolf
echo "== creating backing file for COW tests =="
50 ab3a32ad Kevin Wolf
51 ab3a32ad Kevin Wolf
_make_test_img $size
52 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0x55 0 1M" $TEST_IMG | _filter_qemu_io
53 ab3a32ad Kevin Wolf
mv $TEST_IMG $TEST_IMG.base
54 ab3a32ad Kevin Wolf
55 ab3a32ad Kevin Wolf
_make_test_img -b $TEST_IMG.base 6G
56 ab3a32ad Kevin Wolf
57 ab3a32ad Kevin Wolf
echo
58 ab3a32ad Kevin Wolf
echo "== zero write with backing file =="
59 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -z 64k 192k" $TEST_IMG | _filter_qemu_io
60 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -z 513k 13k" $TEST_IMG | _filter_qemu_io
61 ab3a32ad Kevin Wolf
62 ab3a32ad Kevin Wolf
_check_test_img
63 ab3a32ad Kevin Wolf
64 ab3a32ad Kevin Wolf
echo
65 ab3a32ad Kevin Wolf
echo "== verifying patterns (3) =="
66 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 0 64k" $TEST_IMG | _filter_qemu_io
67 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 64k 192k" $TEST_IMG | _filter_qemu_io
68 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 256k 257k" $TEST_IMG | _filter_qemu_io
69 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 513k 13k" $TEST_IMG | _filter_qemu_io
70 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 526k 498k" $TEST_IMG | _filter_qemu_io
71 ab3a32ad Kevin Wolf
72 ab3a32ad Kevin Wolf
echo
73 ab3a32ad Kevin Wolf
echo "== overwriting zero cluster =="
74 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0xa 60k 8k" $TEST_IMG | _filter_qemu_io
75 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0xb 64k 8k" $TEST_IMG | _filter_qemu_io
76 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0xc 76k 4k" $TEST_IMG | _filter_qemu_io
77 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0xd 252k 8k" $TEST_IMG | _filter_qemu_io
78 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -P 0xe 248k 8k" $TEST_IMG | _filter_qemu_io
79 ab3a32ad Kevin Wolf
80 ab3a32ad Kevin Wolf
_check_test_img
81 ab3a32ad Kevin Wolf
82 ab3a32ad Kevin Wolf
echo
83 ab3a32ad Kevin Wolf
echo "== verifying patterns (4) =="
84 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 0 60k" $TEST_IMG | _filter_qemu_io
85 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xa 60k 4k" $TEST_IMG | _filter_qemu_io
86 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xb 64k 8k" $TEST_IMG | _filter_qemu_io
87 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 72k 4k" $TEST_IMG | _filter_qemu_io
88 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xc 76k 4k" $TEST_IMG | _filter_qemu_io
89 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 80k 168k" $TEST_IMG | _filter_qemu_io
90 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xe 248k 8k" $TEST_IMG | _filter_qemu_io
91 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xd 256k 4k" $TEST_IMG | _filter_qemu_io
92 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 260k 64k" $TEST_IMG | _filter_qemu_io
93 ab3a32ad Kevin Wolf
94 ab3a32ad Kevin Wolf
echo
95 ab3a32ad Kevin Wolf
echo "== re-zeroing overwritten area =="
96 ab3a32ad Kevin Wolf
$QEMU_IO -c "write -z 64k 192k" $TEST_IMG | _filter_qemu_io
97 ab3a32ad Kevin Wolf
98 ab3a32ad Kevin Wolf
_check_test_img
99 ab3a32ad Kevin Wolf
100 ab3a32ad Kevin Wolf
echo
101 ab3a32ad Kevin Wolf
echo "== verifying patterns (5) =="
102 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 0 60k" $TEST_IMG | _filter_qemu_io
103 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xa 60k 4k" $TEST_IMG | _filter_qemu_io
104 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 64k 192k" $TEST_IMG | _filter_qemu_io
105 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0xd 256k 4k" $TEST_IMG | _filter_qemu_io
106 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 260k 253k" $TEST_IMG | _filter_qemu_io
107 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x0 513k 13k" $TEST_IMG | _filter_qemu_io
108 ab3a32ad Kevin Wolf
$QEMU_IO -c "read -P 0x55 526k 498k" $TEST_IMG | _filter_qemu_io
109 ab3a32ad Kevin Wolf
110 ab3a32ad Kevin Wolf
# success, all done
111 ab3a32ad Kevin Wolf
echo "*** done"
112 ab3a32ad Kevin Wolf
rm -f $seq.full
113 ab3a32ad Kevin Wolf
status=0