]> Git Repo - qemu.git/blame - tests/qemu-iotests/033
iotests: Disallow compat=0.10 in 223
[qemu.git] / tests / qemu-iotests / 033
CommitLineData
ee3a315e
PB
1#!/bin/bash
2#
3# Test aligned and misaligned write zeroes operations.
4#
5# Copyright (C) 2012 Red Hat, Inc.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21# creator
22[email protected]
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
ee3a315e
PB
28status=1 # failure is the default!
29
30_cleanup()
31{
32 _cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39
40_supported_fmt generic
41_supported_proto generic
42_supported_os Linux
43
44
45size=128M
46_make_test_img $size
47
61815d6e
FZ
48do_test()
49{
50 local align=$1
51 local iocmd=$2
52 local img=$3
13a1d4a7
DB
53 if [ "$IMGOPTSSYNTAX" = "true" ]
54 then
55 IO_OPEN_ARG="$img"
56 IO_EXTRA_ARGS="--image-opts"
57 else
58 IO_OPEN_ARG="-o driver=$IMGFMT,file.align=$align blkdebug::$img"
59 IO_EXTRA_ARGS=""
60 fi
61815d6e 61 {
13a1d4a7 62 echo "open $IO_OPEN_ARG"
61815d6e 63 echo $iocmd
13a1d4a7 64 } | $QEMU_IO $IO_EXTRA_ARGS
61815d6e
FZ
65}
66
afe35cde
AN
67echo
68echo "=== Test aligned and misaligned write zeroes operations ==="
69
7fa84cd8 70for write_zero_cmd in "write -z" "aio_write -z"; do
61815d6e
FZ
71for align in 512 4k; do
72 echo
73 echo "== preparing image =="
74 do_test $align "write -P 0xa 0x200 0x400" "$TEST_IMG" | _filter_qemu_io
75 do_test $align "write -P 0xa 0x20000 0x600" "$TEST_IMG" | _filter_qemu_io
7fa84cd8 76 do_test $align "$write_zero_cmd 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io
ee3a315e 77
61815d6e
FZ
78 echo
79 echo "== verifying patterns (1) =="
80 do_test $align "read -P 0xa 0x200 0x200" "$TEST_IMG" | _filter_qemu_io
81 do_test $align "read -P 0x0 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io
82 do_test $align "read -P 0xa 0x20400 0x200" "$TEST_IMG" | _filter_qemu_io
ee3a315e 83
61815d6e
FZ
84 echo
85 echo "== rewriting zeroes =="
86 do_test $align "write -P 0xb 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io
7fa84cd8 87 do_test $align "$write_zero_cmd 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io
ee3a315e 88
61815d6e
FZ
89 echo
90 echo "== verifying patterns (2) =="
91 do_test $align "read -P 0x0 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io
ab53c447
FZ
92
93 echo
94 echo "== rewriting unaligned zeroes =="
95 do_test $align "write -P 0xb 0x0 0x1000" "$TEST_IMG" | _filter_qemu_io
7fa84cd8 96 do_test $align "$write_zero_cmd 0x200 0x200" "$TEST_IMG" | _filter_qemu_io
ab53c447
FZ
97
98 echo
99 echo "== verifying patterns (3) =="
100 do_test $align "read -P 0xb 0x0 0x200" "$TEST_IMG" | _filter_qemu_io
101 do_test $align "read -P 0x0 0x200 0x200" "$TEST_IMG" | _filter_qemu_io
102 do_test $align "read -P 0xb 0x400 0xc00" "$TEST_IMG" | _filter_qemu_io
103
104 echo
61815d6e 105done
7fa84cd8 106done
ee3a315e 107
6eba9f01 108_cleanup_test_img
afe35cde
AN
109
110# Trigger truncate that would shrink qcow2 L1 table, which is done by
111# clearing one entry (8 bytes) with bdrv_co_pwrite_zeroes()
112
113echo
114echo "=== Test misaligned write zeroes via truncate ==="
115echo
116
117# any size will do, but the smaller the size the smaller the required image
118CLUSTER_SIZE=$((4 * 1024))
119L2_COVERAGE=$(($CLUSTER_SIZE * $CLUSTER_SIZE / 8))
120_make_test_img $(($L2_COVERAGE * 2))
121
122do_test 512 "write -P 1 0 0x200" "$TEST_IMG" | _filter_qemu_io
123# next L2 table
124do_test 512 "write -P 1 $L2_COVERAGE 0x200" "$TEST_IMG" | _filter_qemu_io
125
126# only interested in qcow2 here; also other formats might respond with
127# "not supported" error message
128if [ $IMGFMT = "qcow2" ]; then
129 do_test 512 "truncate $L2_COVERAGE" "$TEST_IMG" | _filter_qemu_io
130fi
131
132do_test 512 "read -P 1 0 0x200" "$TEST_IMG" | _filter_qemu_io
133
ee3a315e 134# success, all done
afe35cde 135echo
ee3a315e
PB
136echo "*** done"
137rm -f $seq.full
138status=0
This page took 0.392928 seconds and 4 git commands to generate.