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