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