xref: /qemu/tests/qemu-iotests/025 (revision 596f4f96)
1*596f4f96SStefan Hajnoczi#!/bin/bash
2*596f4f96SStefan Hajnoczi#
3*596f4f96SStefan Hajnoczi# Resizing images
4*596f4f96SStefan Hajnoczi#
5*596f4f96SStefan Hajnoczi# Copyright (C) 2010 IBM, Corp.
6*596f4f96SStefan Hajnoczi#
7*596f4f96SStefan Hajnoczi# This program is free software; you can redistribute it and/or modify
8*596f4f96SStefan Hajnoczi# it under the terms of the GNU General Public License as published by
9*596f4f96SStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or
10*596f4f96SStefan Hajnoczi# (at your option) any later version.
11*596f4f96SStefan Hajnoczi#
12*596f4f96SStefan Hajnoczi# This program is distributed in the hope that it will be useful,
13*596f4f96SStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*596f4f96SStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*596f4f96SStefan Hajnoczi# GNU General Public License for more details.
16*596f4f96SStefan Hajnoczi#
17*596f4f96SStefan Hajnoczi# You should have received a copy of the GNU General Public License
18*596f4f96SStefan Hajnoczi# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*596f4f96SStefan Hajnoczi#
20*596f4f96SStefan Hajnoczi
21*596f4f96SStefan Hajnoczi# creator
22*596f4f96SStefan Hajnocziowner=stefanha@linux.vnet.ibm.com
23*596f4f96SStefan Hajnoczi
24*596f4f96SStefan Hajnocziseq=`basename $0`
25*596f4f96SStefan Hajnocziecho "QA output created by $seq"
26*596f4f96SStefan Hajnoczi
27*596f4f96SStefan Hajnoczihere=`pwd`
28*596f4f96SStefan Hajnoczitmp=/tmp/$$
29*596f4f96SStefan Hajnoczistatus=1	# failure is the default!
30*596f4f96SStefan Hajnoczi
31*596f4f96SStefan Hajnoczi_cleanup()
32*596f4f96SStefan Hajnoczi{
33*596f4f96SStefan Hajnoczi	_cleanup_test_img
34*596f4f96SStefan Hajnoczi}
35*596f4f96SStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15
36*596f4f96SStefan Hajnoczi
37*596f4f96SStefan Hajnoczi# get standard environment, filters and checks
38*596f4f96SStefan Hajnoczi. ./common.rc
39*596f4f96SStefan Hajnoczi. ./common.filter
40*596f4f96SStefan Hajnoczi. ./common.pattern
41*596f4f96SStefan Hajnoczi
42*596f4f96SStefan Hajnoczi_supported_fmt raw qcow2
43*596f4f96SStefan Hajnoczi_supported_os Linux
44*596f4f96SStefan Hajnoczi
45*596f4f96SStefan Hajnocziecho "=== Creating image"
46*596f4f96SStefan Hajnocziecho
47*596f4f96SStefan Hajnoczismall_size=$((128 * 1024 * 1024))
48*596f4f96SStefan Hajnoczibig_size=$((384 * 1024 * 1024))
49*596f4f96SStefan Hajnoczi_make_test_img $small_size
50*596f4f96SStefan Hajnoczi
51*596f4f96SStefan Hajnocziecho
52*596f4f96SStefan Hajnocziecho "=== Writing whole image"
53*596f4f96SStefan Hajnocziio_pattern write 0 $small_size 0 1 0xc5
54*596f4f96SStefan Hajnoczi_check_test_img
55*596f4f96SStefan Hajnoczi
56*596f4f96SStefan Hajnocziecho
57*596f4f96SStefan Hajnocziecho "=== Resizing image"
58*596f4f96SStefan Hajnoczi$QEMU_IO $TEST_IMG <<EOF
59*596f4f96SStefan Hajnoczilength
60*596f4f96SStefan Hajnoczitruncate $big_size
61*596f4f96SStefan Hajnoczilength
62*596f4f96SStefan HajnocziEOF
63*596f4f96SStefan Hajnoczi_check_test_img
64*596f4f96SStefan Hajnoczi
65*596f4f96SStefan Hajnocziecho
66*596f4f96SStefan Hajnocziecho "=== Verifying image size after reopen"
67*596f4f96SStefan Hajnoczi$QEMU_IO -c "length" $TEST_IMG
68*596f4f96SStefan Hajnoczi
69*596f4f96SStefan Hajnocziecho
70*596f4f96SStefan Hajnocziecho "=== Verifying resized image"
71*596f4f96SStefan Hajnocziio_pattern read 0 $small_size 0 1 0xc5
72*596f4f96SStefan Hajnocziio_pattern read $small_size $(($big_size - $small_size)) 0 1 0
73*596f4f96SStefan Hajnoczi
74*596f4f96SStefan Hajnoczi# success, all done
75*596f4f96SStefan Hajnocziecho "*** done"
76*596f4f96SStefan Hajnoczirm -f $seq.full
77*596f4f96SStefan Hajnoczistatus=0
78