1*afbcc40bSKevin Wolf#!/bin/bash 2*afbcc40bSKevin Wolf# 3*afbcc40bSKevin Wolf# parallels format input validation tests 4*afbcc40bSKevin Wolf# 5*afbcc40bSKevin Wolf# Copyright (C) 2013 Red Hat, Inc. 6*afbcc40bSKevin Wolf# 7*afbcc40bSKevin Wolf# This program is free software; you can redistribute it and/or modify 8*afbcc40bSKevin Wolf# it under the terms of the GNU General Public License as published by 9*afbcc40bSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*afbcc40bSKevin Wolf# (at your option) any later version. 11*afbcc40bSKevin Wolf# 12*afbcc40bSKevin Wolf# This program is distributed in the hope that it will be useful, 13*afbcc40bSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*afbcc40bSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*afbcc40bSKevin Wolf# GNU General Public License for more details. 16*afbcc40bSKevin Wolf# 17*afbcc40bSKevin Wolf# You should have received a copy of the GNU General Public License 18*afbcc40bSKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*afbcc40bSKevin Wolf# 20*afbcc40bSKevin Wolf 21*afbcc40bSKevin Wolf# creator 22*afbcc40bSKevin Wolfowner=kwolf@redhat.com 23*afbcc40bSKevin Wolf 24*afbcc40bSKevin Wolfseq=`basename $0` 25*afbcc40bSKevin Wolfecho "QA output created by $seq" 26*afbcc40bSKevin Wolf 27*afbcc40bSKevin Wolfhere=`pwd` 28*afbcc40bSKevin Wolftmp=/tmp/$$ 29*afbcc40bSKevin Wolfstatus=1 # failure is the default! 30*afbcc40bSKevin Wolf 31*afbcc40bSKevin Wolf_cleanup() 32*afbcc40bSKevin Wolf{ 33*afbcc40bSKevin Wolf _cleanup_test_img 34*afbcc40bSKevin Wolf} 35*afbcc40bSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36*afbcc40bSKevin Wolf 37*afbcc40bSKevin Wolf# get standard environment, filters and checks 38*afbcc40bSKevin Wolf. ./common.rc 39*afbcc40bSKevin Wolf. ./common.filter 40*afbcc40bSKevin Wolf 41*afbcc40bSKevin Wolf_supported_fmt parallels 42*afbcc40bSKevin Wolf_supported_proto generic 43*afbcc40bSKevin Wolf_supported_os Linux 44*afbcc40bSKevin Wolf 45*afbcc40bSKevin Wolfcatalog_entries_offset=$((0x20)) 46*afbcc40bSKevin Wolfnb_sectors_offset=$((0x24)) 47*afbcc40bSKevin Wolf 48*afbcc40bSKevin Wolfecho 49*afbcc40bSKevin Wolfecho "== Read from a valid (enough) image ==" 50*afbcc40bSKevin Wolf_use_sample_img fake.parallels.bz2 51*afbcc40bSKevin Wolf{ $QEMU_IO -c "read -P 0x11 0 64k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir 52*afbcc40bSKevin Wolf 53*afbcc40bSKevin Wolfecho 54*afbcc40bSKevin Wolfecho "== Negative catalog size ==" 55*afbcc40bSKevin Wolf_use_sample_img fake.parallels.bz2 56*afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$catalog_entries_offset" "\xff\xff\xff\xff" 57*afbcc40bSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir 58*afbcc40bSKevin Wolf 59*afbcc40bSKevin Wolfecho 60*afbcc40bSKevin Wolfecho "== Overflow in catalog allocation ==" 61*afbcc40bSKevin Wolf_use_sample_img fake.parallels.bz2 62*afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$nb_sectors_offset" "\xff\xff\xff\xff" 63*afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$catalog_entries_offset" "\x01\x00\x00\x40" 64*afbcc40bSKevin Wolf{ $QEMU_IO -c "read 64M 64M" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir 65*afbcc40bSKevin Wolf 66*afbcc40bSKevin Wolf# success, all done 67*afbcc40bSKevin Wolfecho "*** done" 68*afbcc40bSKevin Wolfrm -f $seq.full 69*afbcc40bSKevin Wolfstatus=0 70