1*925bb323SMax Reitz#!/bin/bash 2*925bb323SMax Reitz# 3*925bb323SMax Reitz# Test case for qemu-io -c map and qemu-img map 4*925bb323SMax Reitz# 5*925bb323SMax Reitz# Copyright (C) 2014 Red Hat, Inc. 6*925bb323SMax Reitz# 7*925bb323SMax Reitz# This program is free software; you can redistribute it and/or modify 8*925bb323SMax Reitz# it under the terms of the GNU General Public License as published by 9*925bb323SMax Reitz# the Free Software Foundation; either version 2 of the License, or 10*925bb323SMax Reitz# (at your option) any later version. 11*925bb323SMax Reitz# 12*925bb323SMax Reitz# This program is distributed in the hope that it will be useful, 13*925bb323SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*925bb323SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*925bb323SMax Reitz# GNU General Public License for more details. 16*925bb323SMax Reitz# 17*925bb323SMax Reitz# You should have received a copy of the GNU General Public License 18*925bb323SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*925bb323SMax Reitz# 20*925bb323SMax Reitz 21*925bb323SMax Reitz# creator 22*925bb323SMax Reitzowner=mreitz@redhat.com 23*925bb323SMax Reitz 24*925bb323SMax Reitzseq=$(basename $0) 25*925bb323SMax Reitzecho "QA output created by $seq" 26*925bb323SMax Reitz 27*925bb323SMax Reitzhere=$PWD 28*925bb323SMax Reitztmp=/tmp/$$ 29*925bb323SMax Reitzstatus=1 # failure is the default! 30*925bb323SMax Reitz 31*925bb323SMax Reitz_cleanup() 32*925bb323SMax Reitz{ 33*925bb323SMax Reitz _cleanup_test_img 34*925bb323SMax Reitz} 35*925bb323SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 36*925bb323SMax Reitz 37*925bb323SMax Reitz# get standard environment, filters and checks 38*925bb323SMax Reitz. ./common.rc 39*925bb323SMax Reitz. ./common.filter 40*925bb323SMax Reitz 41*925bb323SMax Reitz_supported_fmt qcow2 42*925bb323SMax Reitz_supported_proto file 43*925bb323SMax Reitz_supported_os Linux 44*925bb323SMax Reitz 45*925bb323SMax ReitzIMG_SIZE=64K 46*925bb323SMax Reitz 47*925bb323SMax Reitzecho 48*925bb323SMax Reitzecho '=== Testing map command on truncated image ===' 49*925bb323SMax Reitzecho 50*925bb323SMax Reitz 51*925bb323SMax Reitz_make_test_img $IMG_SIZE 52*925bb323SMax Reitz# Create cluster 53*925bb323SMax Reitz$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io 54*925bb323SMax Reitz# Remove data cluster from image (first cluster: image header, second: reftable, 55*925bb323SMax Reitz# third: refblock, fourth: L1 table, fifth: L2 table) 56*925bb323SMax Reitztruncate -s $((5 * 64 * 1024)) "$TEST_IMG" 57*925bb323SMax Reitz 58*925bb323SMax Reitz$QEMU_IO -c map "$TEST_IMG" 59*925bb323SMax Reitz$QEMU_IMG map "$TEST_IMG" 60*925bb323SMax Reitz 61*925bb323SMax Reitz# success, all done 62*925bb323SMax Reitzecho '*** done' 63*925bb323SMax Reitzrm -f $seq.full 64*925bb323SMax Reitzstatus=0 65