xref: /openbmc/qemu/tests/qemu-iotests/017 (revision 2557d8655db1858308142d1a40c02d4917efc3d6)
1*2557d865SKevin Wolf#!/bin/sh
2*2557d865SKevin Wolf#
3*2557d865SKevin Wolf# Simple backing file reads
4*2557d865SKevin Wolf#
5*2557d865SKevin Wolf# Copyright (C) 2009 Red Hat, Inc.
6*2557d865SKevin Wolf#
7*2557d865SKevin Wolf# This program is free software; you can redistribute it and/or modify
8*2557d865SKevin Wolf# it under the terms of the GNU General Public License as published by
9*2557d865SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10*2557d865SKevin Wolf# (at your option) any later version.
11*2557d865SKevin Wolf#
12*2557d865SKevin Wolf# This program is distributed in the hope that it will be useful,
13*2557d865SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*2557d865SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*2557d865SKevin Wolf# GNU General Public License for more details.
16*2557d865SKevin Wolf#
17*2557d865SKevin Wolf# You should have received a copy of the GNU General Public License
18*2557d865SKevin Wolf# along with this program; if not, write to the Free Software
19*2557d865SKevin Wolf# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20*2557d865SKevin Wolf# USA
21*2557d865SKevin Wolf#
22*2557d865SKevin Wolf
23*2557d865SKevin Wolf# creator
24*2557d865SKevin Wolfowner=kwolf@redhat.com
25*2557d865SKevin Wolf
26*2557d865SKevin Wolfseq=`basename $0`
27*2557d865SKevin Wolfecho "QA output created by $seq"
28*2557d865SKevin Wolf
29*2557d865SKevin Wolfhere=`pwd`
30*2557d865SKevin Wolftmp=/tmp/$$
31*2557d865SKevin Wolfstatus=1	# failure is the default!
32*2557d865SKevin Wolf
33*2557d865SKevin Wolf_cleanup()
34*2557d865SKevin Wolf{
35*2557d865SKevin Wolf	_cleanup_test_img
36*2557d865SKevin Wolf}
37*2557d865SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
38*2557d865SKevin Wolf
39*2557d865SKevin Wolf# get standard environment, filters and checks
40*2557d865SKevin Wolf. ./common.rc
41*2557d865SKevin Wolf. ./common.filter
42*2557d865SKevin Wolf. ./common.pattern
43*2557d865SKevin Wolf
44*2557d865SKevin Wolf# Any format supporting backing files
45*2557d865SKevin Wolf_supported_fmt qcow qcow2 vmdk
46*2557d865SKevin Wolf_supported_os Linux
47*2557d865SKevin Wolf
48*2557d865SKevin WolfTEST_OFFSETS="0 4294967296"
49*2557d865SKevin Wolf
50*2557d865SKevin Wolf_make_test_img 6G
51*2557d865SKevin Wolf
52*2557d865SKevin Wolfecho "Filling base image"
53*2557d865SKevin Wolfecho
54*2557d865SKevin Wolf
55*2557d865SKevin Wolffor offset in $TEST_OFFSETS; do
56*2557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
57*2557d865SKevin Wolf    io writev $(( offset )) 512 1024 64
58*2557d865SKevin Wolf
59*2557d865SKevin Wolf    # Complete backing clusters
60*2557d865SKevin Wolf    io writev $(( offset  + 64 * 1024))  65536 65536 1
61*2557d865SKevin Wolfdone
62*2557d865SKevin Wolf_check_test_img
63*2557d865SKevin Wolf
64*2557d865SKevin Wolfecho "Creating test image with backing file"
65*2557d865SKevin Wolfecho
66*2557d865SKevin Wolf
67*2557d865SKevin Wolfmv $TEST_IMG $TEST_IMG.base
68*2557d865SKevin Wolf_make_test_img -b $TEST_IMG.base 6G
69*2557d865SKevin Wolf
70*2557d865SKevin Wolfecho "Filling test image"
71*2557d865SKevin Wolfecho
72*2557d865SKevin Wolf
73*2557d865SKevin Wolffor offset in $TEST_OFFSETS; do
74*2557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
75*2557d865SKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
76*2557d865SKevin Wolf
77*2557d865SKevin Wolf    # Complete test image clusters
78*2557d865SKevin Wolf    io writev $(( offset + 64 * 1024 + 65536))  65536 65536 1
79*2557d865SKevin Wolfdone
80*2557d865SKevin Wolf_check_test_img
81*2557d865SKevin Wolf
82*2557d865SKevin Wolfecho "Reading"
83*2557d865SKevin Wolfecho
84*2557d865SKevin Wolf
85*2557d865SKevin Wolffor offset in $TEST_OFFSETS; do
86*2557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
87*2557d865SKevin Wolf    io readv $(( offset )) 512 1024 64
88*2557d865SKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
89*2557d865SKevin Wolf
90*2557d865SKevin Wolf    # Complete test image clusters
91*2557d865SKevin Wolf    io readv $(( offset  + 64 * 1024))  65536 65536 1
92*2557d865SKevin Wolf    io readv $(( offset + 64 * 1024 + 65536))  65536 65536 1
93*2557d865SKevin Wolf
94*2557d865SKevin Wolf    # Empty sectors
95*2557d865SKevin Wolf    io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1
96*2557d865SKevin Wolfdone
97*2557d865SKevin Wolf_check_test_img
98*2557d865SKevin Wolf
99*2557d865SKevin Wolf# success, all done
100*2557d865SKevin Wolfecho "*** done"
101*2557d865SKevin Wolfrm -f $seq.full
102*2557d865SKevin Wolfstatus=0
103