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