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