Statistics
| Branch: | Revision:

root / tests / qemu-iotests / 002 @ 30bd6a4d

History | View | Annotate | Download (2.5 kB)

1 908eaf68 Stefan Hajnoczi
#!/bin/bash
2 6bf19c94 Christoph Hellwig
#
3 6bf19c94 Christoph Hellwig
# Test simple read/write using plain bdrv_pread/bdrv_pwrite
4 6bf19c94 Christoph Hellwig
#
5 6bf19c94 Christoph Hellwig
# Copyright (C) 2009 Red Hat, Inc.
6 6bf19c94 Christoph Hellwig
#
7 6bf19c94 Christoph Hellwig
# This program is free software; you can redistribute it and/or modify
8 6bf19c94 Christoph Hellwig
# it under the terms of the GNU General Public License as published by
9 6bf19c94 Christoph Hellwig
# the Free Software Foundation; either version 2 of the License, or
10 6bf19c94 Christoph Hellwig
# (at your option) any later version.
11 6bf19c94 Christoph Hellwig
#
12 6bf19c94 Christoph Hellwig
# This program is distributed in the hope that it will be useful,
13 6bf19c94 Christoph Hellwig
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14 6bf19c94 Christoph Hellwig
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 6bf19c94 Christoph Hellwig
# GNU General Public License for more details.
16 6bf19c94 Christoph Hellwig
#
17 6bf19c94 Christoph Hellwig
# You should have received a copy of the GNU General Public License
18 e8c212d6 Christoph Hellwig
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 6bf19c94 Christoph Hellwig
#
20 6bf19c94 Christoph Hellwig
21 6bf19c94 Christoph Hellwig
# creator
22 6bf19c94 Christoph Hellwig
owner=hch@lst.de
23 6bf19c94 Christoph Hellwig
24 6bf19c94 Christoph Hellwig
seq=`basename $0`
25 6bf19c94 Christoph Hellwig
echo "QA output created by $seq"
26 6bf19c94 Christoph Hellwig
27 6bf19c94 Christoph Hellwig
here=`pwd`
28 6bf19c94 Christoph Hellwig
tmp=/tmp/$$
29 6bf19c94 Christoph Hellwig
status=1	# failure is the default!
30 6bf19c94 Christoph Hellwig
31 6bf19c94 Christoph Hellwig
_cleanup()
32 6bf19c94 Christoph Hellwig
{
33 6bf19c94 Christoph Hellwig
	_cleanup_test_img
34 6bf19c94 Christoph Hellwig
}
35 6bf19c94 Christoph Hellwig
trap "_cleanup; exit \$status" 0 1 2 3 15
36 6bf19c94 Christoph Hellwig
37 6bf19c94 Christoph Hellwig
# get standard environment, filters and checks
38 6bf19c94 Christoph Hellwig
. ./common.rc
39 6bf19c94 Christoph Hellwig
. ./common.filter
40 6bf19c94 Christoph Hellwig
41 6bf19c94 Christoph Hellwig
_supported_fmt generic
42 9cdfa1b3 MORITA Kazutaka
_supported_proto generic
43 6bf19c94 Christoph Hellwig
_supported_os Linux
44 6bf19c94 Christoph Hellwig
45 6bf19c94 Christoph Hellwig
46 6bf19c94 Christoph Hellwig
size=128M
47 6bf19c94 Christoph Hellwig
_make_test_img $size
48 6bf19c94 Christoph Hellwig
49 6bf19c94 Christoph Hellwig
echo
50 6bf19c94 Christoph Hellwig
echo "== reading whole image =="
51 fef9c191 Jeff Cody
$QEMU_IO -c "read -p 0 $size" "$TEST_IMG" | _filter_qemu_io
52 6bf19c94 Christoph Hellwig
53 6bf19c94 Christoph Hellwig
echo
54 6bf19c94 Christoph Hellwig
echo "== rewriting whole image =="
55 fef9c191 Jeff Cody
$QEMU_IO -c "write -pP 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
56 6bf19c94 Christoph Hellwig
57 6bf19c94 Christoph Hellwig
echo
58 6bf19c94 Christoph Hellwig
echo "== verify pattern =="
59 fef9c191 Jeff Cody
$QEMU_IO -c "read -pP 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
60 6bf19c94 Christoph Hellwig
61 6bf19c94 Christoph Hellwig
echo
62 6bf19c94 Christoph Hellwig
echo "unaligned pwrite"
63 fef9c191 Jeff Cody
$QEMU_IO -c 'write -pP 0xab 66 42' "$TEST_IMG" | _filter_qemu_io
64 fef9c191 Jeff Cody
$QEMU_IO -c 'write -pP 0xac 512 288' "$TEST_IMG" | _filter_qemu_io
65 fef9c191 Jeff Cody
$QEMU_IO -c 'write -pP 0xad 800 224' "$TEST_IMG" | _filter_qemu_io
66 fef9c191 Jeff Cody
$QEMU_IO -c 'write -pP 0xae 66000 128k' "$TEST_IMG" | _filter_qemu_io
67 fef9c191 Jeff Cody
$QEMU_IO -c 'write -pP 0xaf 256k 42' "$TEST_IMG" | _filter_qemu_io
68 6bf19c94 Christoph Hellwig
69 6bf19c94 Christoph Hellwig
echo
70 6bf19c94 Christoph Hellwig
echo "verify pattern"
71 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xa 0 66' "$TEST_IMG" | _filter_qemu_io
72 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xab 66 42' "$TEST_IMG" | _filter_qemu_io
73 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xa 108 404' "$TEST_IMG" | _filter_qemu_io
74 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xac 512 288' "$TEST_IMG" | _filter_qemu_io
75 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xad 800 224' "$TEST_IMG" | _filter_qemu_io
76 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xa 1k 64976' "$TEST_IMG" | _filter_qemu_io
77 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xae 66000 128k' "$TEST_IMG" | _filter_qemu_io
78 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xa 197072 65072' "$TEST_IMG" | _filter_qemu_io
79 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xaf 256k 42' "$TEST_IMG" | _filter_qemu_io
80 fef9c191 Jeff Cody
$QEMU_IO -c 'read -pP 0xa 262186 470' "$TEST_IMG" | _filter_qemu_io
81 6bf19c94 Christoph Hellwig
82 6bf19c94 Christoph Hellwig
# success, all done
83 6bf19c94 Christoph Hellwig
echo "*** done"
84 6bf19c94 Christoph Hellwig
rm -f $seq.full
85 6bf19c94 Christoph Hellwig
status=0