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