xref: /openbmc/qemu/tests/qemu-iotests/034 (revision fef80ea073c4862bc9eaddb6ddb0ed970b8ad7c4)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto backing quick
3ab3a32adSKevin Wolf#
474021bc4SEric Blake# Test bdrv_pwrite_zeroes with backing files (see also 154)
5ab3a32adSKevin Wolf#
6ab3a32adSKevin Wolf# Copyright (C) 2012 Red Hat, Inc.
7ab3a32adSKevin Wolf#
8ab3a32adSKevin Wolf# This program is free software; you can redistribute it and/or modify
9ab3a32adSKevin Wolf# it under the terms of the GNU General Public License as published by
10ab3a32adSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
11ab3a32adSKevin Wolf# (at your option) any later version.
12ab3a32adSKevin Wolf#
13ab3a32adSKevin Wolf# This program is distributed in the hope that it will be useful,
14ab3a32adSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
15ab3a32adSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16ab3a32adSKevin Wolf# GNU General Public License for more details.
17ab3a32adSKevin Wolf#
18ab3a32adSKevin Wolf# You should have received a copy of the GNU General Public License
19ab3a32adSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20ab3a32adSKevin Wolf#
21ab3a32adSKevin Wolf
22ab3a32adSKevin Wolf# creator
23ab3a32adSKevin Wolfowner=kwolf@redhat.com
24ab3a32adSKevin Wolf
25ab3a32adSKevin Wolfseq=`basename $0`
26ab3a32adSKevin Wolfecho "QA output created by $seq"
27ab3a32adSKevin Wolf
28ab3a32adSKevin Wolfstatus=1	# failure is the default!
29ab3a32adSKevin Wolf
30ab3a32adSKevin Wolf_cleanup()
31ab3a32adSKevin Wolf{
32ab3a32adSKevin Wolf	_cleanup_test_img
33ab3a32adSKevin Wolf}
34ab3a32adSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
35ab3a32adSKevin Wolf
36ab3a32adSKevin Wolf# get standard environment, filters and checks
37ab3a32adSKevin Wolf. ./common.rc
38ab3a32adSKevin Wolf. ./common.filter
39ab3a32adSKevin Wolf
40ab3a32adSKevin Wolf_supported_fmt qcow qcow2 vmdk qed
4157284d2aSMax Reitz_supported_proto file fuse
42ab3a32adSKevin Wolf_supported_os Linux
43d2329f27SFam Zheng_unsupported_imgopts "subformat=monolithicFlat" \
44d2329f27SFam Zheng                     "subformat=twoGbMaxExtentFlat" \
45325dd915SMax Reitz                     "subformat=twoGbMaxExtentSparse" \
46325dd915SMax Reitz                     "subformat=streamOptimized"
47ab3a32adSKevin Wolf
48ab3a32adSKevin WolfCLUSTER_SIZE=4k
49ab3a32adSKevin Wolfsize=128M
50ab3a32adSKevin Wolf
51ab3a32adSKevin Wolfecho
52ab3a32adSKevin Wolfecho "== creating backing file for COW tests =="
53ab3a32adSKevin Wolf
5455810184SFam ZhengTEST_IMG_SAVE="$TEST_IMG"
5555810184SFam ZhengTEST_IMG="$TEST_IMG.base"
5655810184SFam Zheng
57ab3a32adSKevin Wolf_make_test_img $size
58fef9c191SJeff Cody$QEMU_IO -c "write -P 0x55 0 1M" "$TEST_IMG" | _filter_qemu_io
5955810184SFam Zheng
6055810184SFam ZhengTEST_IMG="$TEST_IMG_SAVE"
61ab3a32adSKevin Wolf
62b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 6G
63ab3a32adSKevin Wolf
64ab3a32adSKevin Wolfecho
65ab3a32adSKevin Wolfecho "== zero write with backing file =="
66fef9c191SJeff Cody$QEMU_IO -c "write -z 64k 192k" "$TEST_IMG" | _filter_qemu_io
67fef9c191SJeff Cody$QEMU_IO -c "write -z 513k 13k" "$TEST_IMG" | _filter_qemu_io
68ab3a32adSKevin Wolf
69ab3a32adSKevin Wolf_check_test_img
70ab3a32adSKevin Wolf
71ab3a32adSKevin Wolfecho
72ab3a32adSKevin Wolfecho "== verifying patterns (3) =="
73fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 64k" "$TEST_IMG" | _filter_qemu_io
74fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 64k 192k" "$TEST_IMG" | _filter_qemu_io
75fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 256k 257k" "$TEST_IMG" | _filter_qemu_io
76fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 513k 13k" "$TEST_IMG" | _filter_qemu_io
77fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 526k 498k" "$TEST_IMG" | _filter_qemu_io
78ab3a32adSKevin Wolf
79ab3a32adSKevin Wolfecho
80ab3a32adSKevin Wolfecho "== overwriting zero cluster =="
81fef9c191SJeff Cody$QEMU_IO -c "write -P 0xa 60k 8k" "$TEST_IMG" | _filter_qemu_io
82fef9c191SJeff Cody$QEMU_IO -c "write -P 0xb 64k 8k" "$TEST_IMG" | _filter_qemu_io
83fef9c191SJeff Cody$QEMU_IO -c "write -P 0xc 76k 4k" "$TEST_IMG" | _filter_qemu_io
84fef9c191SJeff Cody$QEMU_IO -c "write -P 0xd 252k 8k" "$TEST_IMG" | _filter_qemu_io
85fef9c191SJeff Cody$QEMU_IO -c "write -P 0xe 248k 8k" "$TEST_IMG" | _filter_qemu_io
86ab3a32adSKevin Wolf
87ab3a32adSKevin Wolf_check_test_img
88ab3a32adSKevin Wolf
89ab3a32adSKevin Wolfecho
90ab3a32adSKevin Wolfecho "== verifying patterns (4) =="
91fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 60k" "$TEST_IMG" | _filter_qemu_io
92fef9c191SJeff Cody$QEMU_IO -c "read -P 0xa 60k 4k" "$TEST_IMG" | _filter_qemu_io
93fef9c191SJeff Cody$QEMU_IO -c "read -P 0xb 64k 8k" "$TEST_IMG" | _filter_qemu_io
94fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 72k 4k" "$TEST_IMG" | _filter_qemu_io
95fef9c191SJeff Cody$QEMU_IO -c "read -P 0xc 76k 4k" "$TEST_IMG" | _filter_qemu_io
96fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 80k 168k" "$TEST_IMG" | _filter_qemu_io
97fef9c191SJeff Cody$QEMU_IO -c "read -P 0xe 248k 8k" "$TEST_IMG" | _filter_qemu_io
98fef9c191SJeff Cody$QEMU_IO -c "read -P 0xd 256k 4k" "$TEST_IMG" | _filter_qemu_io
99fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 260k 64k" "$TEST_IMG" | _filter_qemu_io
100ab3a32adSKevin Wolf
101ab3a32adSKevin Wolfecho
102ab3a32adSKevin Wolfecho "== re-zeroing overwritten area =="
103fef9c191SJeff Cody$QEMU_IO -c "write -z 64k 192k" "$TEST_IMG" | _filter_qemu_io
104ab3a32adSKevin Wolf
105ab3a32adSKevin Wolf_check_test_img
106ab3a32adSKevin Wolf
107ab3a32adSKevin Wolfecho
108ab3a32adSKevin Wolfecho "== verifying patterns (5) =="
109fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 60k" "$TEST_IMG" | _filter_qemu_io
110fef9c191SJeff Cody$QEMU_IO -c "read -P 0xa 60k 4k" "$TEST_IMG" | _filter_qemu_io
111fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 64k 192k" "$TEST_IMG" | _filter_qemu_io
112fef9c191SJeff Cody$QEMU_IO -c "read -P 0xd 256k 4k" "$TEST_IMG" | _filter_qemu_io
113fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 260k 253k" "$TEST_IMG" | _filter_qemu_io
114fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 513k 13k" "$TEST_IMG" | _filter_qemu_io
115fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 526k 498k" "$TEST_IMG" | _filter_qemu_io
116ab3a32adSKevin Wolf
117ab3a32adSKevin Wolf# success, all done
118ab3a32adSKevin Wolfecho "*** done"
119ab3a32adSKevin Wolfrm -f $seq.full
120ab3a32adSKevin Wolfstatus=0
121