xref: /qemu/tests/qemu-iotests/072 (revision 91f84f652de14329d5ad0666499a78fd0db0f1c7)
1*91f84f65SMax Reitz#!/bin/bash
2*91f84f65SMax Reitz#
3*91f84f65SMax Reitz# Test case for nested image formats
4*91f84f65SMax Reitz#
5*91f84f65SMax Reitz# Copyright (C) 2013 Red Hat, Inc.
6*91f84f65SMax Reitz#
7*91f84f65SMax Reitz# This program is free software; you can redistribute it and/or modify
8*91f84f65SMax Reitz# it under the terms of the GNU General Public License as published by
9*91f84f65SMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*91f84f65SMax Reitz# (at your option) any later version.
11*91f84f65SMax Reitz#
12*91f84f65SMax Reitz# This program is distributed in the hope that it will be useful,
13*91f84f65SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*91f84f65SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*91f84f65SMax Reitz# GNU General Public License for more details.
16*91f84f65SMax Reitz#
17*91f84f65SMax Reitz# You should have received a copy of the GNU General Public License
18*91f84f65SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*91f84f65SMax Reitz#
20*91f84f65SMax Reitz
21*91f84f65SMax Reitz# creator
22*91f84f65SMax Reitzowner=mreitz@redhat.com
23*91f84f65SMax Reitz
24*91f84f65SMax Reitzseq="$(basename $0)"
25*91f84f65SMax Reitzecho "QA output created by $seq"
26*91f84f65SMax Reitz
27*91f84f65SMax Reitzhere="$PWD"
28*91f84f65SMax Reitztmp=/tmp/$$
29*91f84f65SMax Reitzstatus=1	# failure is the default!
30*91f84f65SMax Reitz
31*91f84f65SMax Reitz_cleanup()
32*91f84f65SMax Reitz{
33*91f84f65SMax Reitz	_cleanup_test_img
34*91f84f65SMax Reitz}
35*91f84f65SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36*91f84f65SMax Reitz
37*91f84f65SMax Reitz# get standard environment, filters and checks
38*91f84f65SMax Reitz. ./common.rc
39*91f84f65SMax Reitz. ./common.filter
40*91f84f65SMax Reitz
41*91f84f65SMax Reitz_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow cow
42*91f84f65SMax Reitz_supported_proto generic
43*91f84f65SMax Reitz_supported_os Linux
44*91f84f65SMax Reitz
45*91f84f65SMax ReitzIMG_SIZE=64M
46*91f84f65SMax Reitz
47*91f84f65SMax Reitzecho
48*91f84f65SMax Reitzecho "=== Testing nested image formats ==="
49*91f84f65SMax Reitzecho
50*91f84f65SMax Reitz
51*91f84f65SMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
52*91f84f65SMax Reitz
53*91f84f65SMax Reitz$QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \
54*91f84f65SMax Reitz         -c 'write -P 66 1024 512' "$TEST_IMG.base" | _filter_qemu_io
55*91f84f65SMax Reitz
56*91f84f65SMax Reitz$QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG"
57*91f84f65SMax Reitz
58*91f84f65SMax Reitz$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST_IMG" \
59*91f84f65SMax Reitz         -c 'read -P 42 0 512' -c 'read -P 23 512 512' \
60*91f84f65SMax Reitz         -c 'read -P 66 1024 512' | _filter_qemu_io
61*91f84f65SMax Reitz
62*91f84f65SMax Reitz# When not giving any format, qemu should open only one "layer". Therefore, this
63*91f84f65SMax Reitz# should not work for any image formats with a header.
64*91f84f65SMax Reitz$QEMU_IO -c 'read -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
65*91f84f65SMax Reitz
66*91f84f65SMax Reitz# success, all done
67*91f84f65SMax Reitzecho "*** done"
68*91f84f65SMax Reitzrm -f $seq.full
69*91f84f65SMax Reitzstatus=0
70