xref: /openbmc/qemu/tests/qemu-iotests/072 (revision 42a5009d)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick
391f84f65SMax Reitz#
491f84f65SMax Reitz# Test case for nested image formats
591f84f65SMax Reitz#
691f84f65SMax Reitz# Copyright (C) 2013 Red Hat, Inc.
791f84f65SMax Reitz#
891f84f65SMax Reitz# This program is free software; you can redistribute it and/or modify
991f84f65SMax Reitz# it under the terms of the GNU General Public License as published by
1091f84f65SMax Reitz# the Free Software Foundation; either version 2 of the License, or
1191f84f65SMax Reitz# (at your option) any later version.
1291f84f65SMax Reitz#
1391f84f65SMax Reitz# This program is distributed in the hope that it will be useful,
1491f84f65SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
1591f84f65SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1691f84f65SMax Reitz# GNU General Public License for more details.
1791f84f65SMax Reitz#
1891f84f65SMax Reitz# You should have received a copy of the GNU General Public License
1991f84f65SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2091f84f65SMax Reitz#
2191f84f65SMax Reitz
2291f84f65SMax Reitz# creator
23*42a5009dSJohn Snowowner=hreitz@redhat.com
2491f84f65SMax Reitz
2591f84f65SMax Reitzseq="$(basename $0)"
2691f84f65SMax Reitzecho "QA output created by $seq"
2791f84f65SMax Reitz
2891f84f65SMax Reitzstatus=1	# failure is the default!
2991f84f65SMax Reitz
3091f84f65SMax Reitz_cleanup()
3191f84f65SMax Reitz{
3291f84f65SMax Reitz	_cleanup_test_img
3391f84f65SMax Reitz}
3491f84f65SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
3591f84f65SMax Reitz
3691f84f65SMax Reitz# get standard environment, filters and checks
3791f84f65SMax Reitz. ./common.rc
3891f84f65SMax Reitz. ./common.filter
3991f84f65SMax Reitz
40550830f9SStefan Hajnoczi_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
411f7bf7d0SPeter Lieven_supported_proto file
42325dd915SMax Reitz_unsupported_imgopts "subformat=streamOptimized"
4391f84f65SMax Reitz
4491f84f65SMax ReitzIMG_SIZE=64M
4591f84f65SMax Reitz
4691f84f65SMax Reitzecho
4791f84f65SMax Reitzecho "=== Testing nested image formats ==="
4891f84f65SMax Reitzecho
4991f84f65SMax Reitz
5091f84f65SMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
5191f84f65SMax Reitz
5291f84f65SMax Reitz$QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \
5391f84f65SMax Reitz         -c 'write -P 66 1024 512' "$TEST_IMG.base" | _filter_qemu_io
5491f84f65SMax Reitz
5591f84f65SMax Reitz$QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG"
5691f84f65SMax Reitz
5791f84f65SMax Reitz$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=$IMGFMT,file.file.filename=$TEST_IMG" \
5891f84f65SMax Reitz         -c 'read -P 42 0 512' -c 'read -P 23 512 512' \
5991f84f65SMax Reitz         -c 'read -P 66 1024 512' | _filter_qemu_io
6091f84f65SMax Reitz
6191f84f65SMax Reitz# When not giving any format, qemu should open only one "layer". Therefore, this
6291f84f65SMax Reitz# should not work for any image formats with a header.
6391f84f65SMax Reitz$QEMU_IO -c 'read -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
6491f84f65SMax Reitz
6591f84f65SMax Reitz# success, all done
6691f84f65SMax Reitzecho "*** done"
6791f84f65SMax Reitzrm -f $seq.full
6891f84f65SMax Reitzstatus=0
69