xref: /qemu/tests/qemu-iotests/078 (revision e3737b820b45e54b059656dc3f914f895ac7a88b)
124f3078aSKevin Wolf#!/bin/bash
224f3078aSKevin Wolf#
324f3078aSKevin Wolf# bochs format input validation tests
424f3078aSKevin Wolf#
524f3078aSKevin Wolf# Copyright (C) 2013 Red Hat, Inc.
624f3078aSKevin Wolf#
724f3078aSKevin Wolf# This program is free software; you can redistribute it and/or modify
824f3078aSKevin Wolf# it under the terms of the GNU General Public License as published by
924f3078aSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
1024f3078aSKevin Wolf# (at your option) any later version.
1124f3078aSKevin Wolf#
1224f3078aSKevin Wolf# This program is distributed in the hope that it will be useful,
1324f3078aSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
1424f3078aSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1524f3078aSKevin Wolf# GNU General Public License for more details.
1624f3078aSKevin Wolf#
1724f3078aSKevin Wolf# You should have received a copy of the GNU General Public License
1824f3078aSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1924f3078aSKevin Wolf#
2024f3078aSKevin Wolf
2124f3078aSKevin Wolf# creator
2224f3078aSKevin Wolfowner=kwolf@redhat.com
2324f3078aSKevin Wolf
2424f3078aSKevin Wolfseq=`basename $0`
2524f3078aSKevin Wolfecho "QA output created by $seq"
2624f3078aSKevin Wolf
2724f3078aSKevin Wolfhere=`pwd`
2824f3078aSKevin Wolftmp=/tmp/$$
2924f3078aSKevin Wolfstatus=1	# failure is the default!
3024f3078aSKevin Wolf
3124f3078aSKevin Wolf_cleanup()
3224f3078aSKevin Wolf{
3324f3078aSKevin Wolf	_cleanup_test_img
3424f3078aSKevin Wolf}
3524f3078aSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
3624f3078aSKevin Wolf
3724f3078aSKevin Wolf# get standard environment, filters and checks
3824f3078aSKevin Wolf. ./common.rc
3924f3078aSKevin Wolf. ./common.filter
4024f3078aSKevin Wolf
4124f3078aSKevin Wolf_supported_fmt bochs
4224f3078aSKevin Wolf_supported_proto generic
4324f3078aSKevin Wolf_supported_os Linux
4424f3078aSKevin Wolf
45246f6583SKevin Wolfcatalog_size_offset=$((0x48))
46*e3737b82SKevin Wolfdisk_size_offset=$((0x58))
47246f6583SKevin Wolf
4824f3078aSKevin Wolfecho
4924f3078aSKevin Wolfecho "== Read from a valid image =="
5024f3078aSKevin Wolf_use_sample_img empty.bochs.bz2
5124f3078aSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
5224f3078aSKevin Wolf
53246f6583SKevin Wolfecho
54246f6583SKevin Wolfecho "== Negative catalog size =="
55246f6583SKevin Wolf_use_sample_img empty.bochs.bz2
56246f6583SKevin Wolfpoke_file "$TEST_IMG" "$catalog_size_offset" "\xff\xff\xff\xff"
57246f6583SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
58246f6583SKevin Wolf
59*e3737b82SKevin Wolfecho
60*e3737b82SKevin Wolfecho "== Overflow for catalog size * sizeof(uint32_t) =="
61*e3737b82SKevin Wolf_use_sample_img empty.bochs.bz2
62*e3737b82SKevin Wolfpoke_file "$TEST_IMG" "$catalog_size_offset" "\x00\x00\x00\x40"
63*e3737b82SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
64*e3737b82SKevin Wolf
65*e3737b82SKevin Wolfecho
66*e3737b82SKevin Wolfecho "== Too small catalog bitmap for image size =="
67*e3737b82SKevin Wolf_use_sample_img empty.bochs.bz2
68*e3737b82SKevin Wolfpoke_file "$TEST_IMG" "$disk_size_offset" "\x00\xc0\x0f\x00\x00\x00\x00\x7f"
69*e3737b82SKevin Wolf{ $QEMU_IO -c "read 2T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
70*e3737b82SKevin Wolf
7124f3078aSKevin Wolf# success, all done
7224f3078aSKevin Wolfecho "*** done"
7324f3078aSKevin Wolfrm -f $seq.full
7424f3078aSKevin Wolfstatus=0
75