xref: /openbmc/qemu/tests/qemu-iotests/042 (revision ee17f9d5fd44fba950ab2290dd30f38d1cd2b625)
1*ee17f9d5SKevin Wolf#!/bin/bash
2*ee17f9d5SKevin Wolf#
3*ee17f9d5SKevin Wolf# Test qemu-img operation on zero size images
4*ee17f9d5SKevin Wolf#
5*ee17f9d5SKevin Wolf# Copyright (C) 2012 Red Hat, Inc.
6*ee17f9d5SKevin Wolf#
7*ee17f9d5SKevin Wolf# This program is free software; you can redistribute it and/or modify
8*ee17f9d5SKevin Wolf# it under the terms of the GNU General Public License as published by
9*ee17f9d5SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10*ee17f9d5SKevin Wolf# (at your option) any later version.
11*ee17f9d5SKevin Wolf#
12*ee17f9d5SKevin Wolf# This program is distributed in the hope that it will be useful,
13*ee17f9d5SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*ee17f9d5SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*ee17f9d5SKevin Wolf# GNU General Public License for more details.
16*ee17f9d5SKevin Wolf#
17*ee17f9d5SKevin Wolf# You should have received a copy of the GNU General Public License
18*ee17f9d5SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*ee17f9d5SKevin Wolf#
20*ee17f9d5SKevin Wolf
21*ee17f9d5SKevin Wolf# creator
22*ee17f9d5SKevin Wolfowner=kwolf@redhat.com
23*ee17f9d5SKevin Wolf
24*ee17f9d5SKevin Wolfseq=`basename $0`
25*ee17f9d5SKevin Wolfecho "QA output created by $seq"
26*ee17f9d5SKevin Wolf
27*ee17f9d5SKevin Wolfhere=`pwd`
28*ee17f9d5SKevin Wolftmp=/tmp/$$
29*ee17f9d5SKevin Wolfstatus=1	# failure is the default!
30*ee17f9d5SKevin Wolf
31*ee17f9d5SKevin Wolf_cleanup()
32*ee17f9d5SKevin Wolf{
33*ee17f9d5SKevin Wolf	_cleanup_test_img
34*ee17f9d5SKevin Wolf}
35*ee17f9d5SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36*ee17f9d5SKevin Wolf
37*ee17f9d5SKevin Wolf# get standard environment, filters and checks
38*ee17f9d5SKevin Wolf. ./common.rc
39*ee17f9d5SKevin Wolf. ./common.filter
40*ee17f9d5SKevin Wolf
41*ee17f9d5SKevin Wolf_supported_fmt qcow2 qcow qed vmdk
42*ee17f9d5SKevin Wolf_supported_proto file
43*ee17f9d5SKevin Wolf_supported_os Linux
44*ee17f9d5SKevin Wolf
45*ee17f9d5SKevin Wolfecho
46*ee17f9d5SKevin Wolfecho "== Creating zero size image =="
47*ee17f9d5SKevin Wolf
48*ee17f9d5SKevin Wolf_make_test_img 0
49*ee17f9d5SKevin Wolf_check_test_img
50*ee17f9d5SKevin Wolf
51*ee17f9d5SKevin Wolfmv $TEST_IMG $TEST_IMG.orig
52*ee17f9d5SKevin Wolf
53*ee17f9d5SKevin Wolfecho
54*ee17f9d5SKevin Wolfecho "== Converting the image =="
55*ee17f9d5SKevin Wolf
56*ee17f9d5SKevin Wolf$QEMU_IMG convert -O $IMGFMT $TEST_IMG.orig $TEST_IMG
57*ee17f9d5SKevin Wolf_check_test_img
58*ee17f9d5SKevin Wolf
59*ee17f9d5SKevin Wolfecho
60*ee17f9d5SKevin Wolfecho "== Converting the image, compressed =="
61*ee17f9d5SKevin Wolf
62*ee17f9d5SKevin Wolfif [ "$IMGFMT" == "qcow2" ]; then
63*ee17f9d5SKevin Wolf    $QEMU_IMG convert -c -O $IMGFMT $TEST_IMG.orig $TEST_IMG
64*ee17f9d5SKevin Wolffi
65*ee17f9d5SKevin Wolf_check_test_img
66*ee17f9d5SKevin Wolf
67*ee17f9d5SKevin Wolfecho
68*ee17f9d5SKevin Wolfecho "== Rebasing the image =="
69*ee17f9d5SKevin Wolf
70*ee17f9d5SKevin Wolf$QEMU_IMG rebase -u -b $TEST_IMG.orig $TEST_IMG
71*ee17f9d5SKevin Wolf$QEMU_IMG rebase -b $TEST_IMG.orig $TEST_IMG
72*ee17f9d5SKevin Wolf_check_test_img
73*ee17f9d5SKevin Wolf
74*ee17f9d5SKevin Wolf# success, all done
75*ee17f9d5SKevin Wolfecho "*** done"
76*ee17f9d5SKevin Wolfrm -f $seq.full
77*ee17f9d5SKevin Wolfstatus=0
78*ee17f9d5SKevin Wolf
79