xref: /openbmc/qemu/tests/qemu-iotests/092 (revision 42eb5817)
17159a45bSKevin Wolf#!/bin/bash
27159a45bSKevin Wolf#
37159a45bSKevin Wolf# qcow1 format input validation tests
47159a45bSKevin Wolf#
57159a45bSKevin Wolf# Copyright (C) 2014 Red Hat, Inc.
67159a45bSKevin Wolf#
77159a45bSKevin Wolf# This program is free software; you can redistribute it and/or modify
87159a45bSKevin Wolf# it under the terms of the GNU General Public License as published by
97159a45bSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
107159a45bSKevin Wolf# (at your option) any later version.
117159a45bSKevin Wolf#
127159a45bSKevin Wolf# This program is distributed in the hope that it will be useful,
137159a45bSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
147159a45bSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
157159a45bSKevin Wolf# GNU General Public License for more details.
167159a45bSKevin Wolf#
177159a45bSKevin Wolf# You should have received a copy of the GNU General Public License
187159a45bSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
197159a45bSKevin Wolf#
207159a45bSKevin Wolf
217159a45bSKevin Wolf# creator
227159a45bSKevin Wolfowner=kwolf@redhat.com
237159a45bSKevin Wolf
247159a45bSKevin Wolfseq=`basename $0`
257159a45bSKevin Wolfecho "QA output created by $seq"
267159a45bSKevin Wolf
277159a45bSKevin Wolfhere=`pwd`
287159a45bSKevin Wolftmp=/tmp/$$
297159a45bSKevin Wolfstatus=1	# failure is the default!
307159a45bSKevin Wolf
317159a45bSKevin Wolf_cleanup()
327159a45bSKevin Wolf{
337159a45bSKevin Wolf    rm -f $TEST_IMG.snap
347159a45bSKevin Wolf    _cleanup_test_img
357159a45bSKevin Wolf}
367159a45bSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
377159a45bSKevin Wolf
387159a45bSKevin Wolf# get standard environment, filters and checks
397159a45bSKevin Wolf. ./common.rc
407159a45bSKevin Wolf. ./common.filter
417159a45bSKevin Wolf
427159a45bSKevin Wolf_supported_fmt qcow
437159a45bSKevin Wolf_supported_proto generic
447159a45bSKevin Wolf_supported_os Linux
457159a45bSKevin Wolf
467159a45bSKevin Wolfoffset_cluster_bits=32
47*42eb5817SKevin Wolfoffset_l2_bits=33
487159a45bSKevin Wolf
497159a45bSKevin Wolfecho
507159a45bSKevin Wolfecho "== Invalid cluster size =="
517159a45bSKevin Wolf_make_test_img 64M
527159a45bSKevin Wolfpoke_file "$TEST_IMG" "$offset_cluster_bits" "\xff"
537159a45bSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
547159a45bSKevin Wolfpoke_file "$TEST_IMG" "$offset_cluster_bits" "\x1f"
557159a45bSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
567159a45bSKevin Wolfpoke_file "$TEST_IMG" "$offset_cluster_bits" "\x08"
577159a45bSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
587159a45bSKevin Wolfpoke_file "$TEST_IMG" "$offset_cluster_bits" "\x11"
597159a45bSKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
607159a45bSKevin Wolf
61*42eb5817SKevin Wolfecho
62*42eb5817SKevin Wolfecho "== Invalid L2 table size =="
63*42eb5817SKevin Wolf_make_test_img 64M
64*42eb5817SKevin Wolfpoke_file "$TEST_IMG" "$offset_l2_bits" "\xff"
65*42eb5817SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
66*42eb5817SKevin Wolfpoke_file "$TEST_IMG" "$offset_l2_bits" "\x05"
67*42eb5817SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
68*42eb5817SKevin Wolfpoke_file "$TEST_IMG" "$offset_l2_bits" "\x0e"
69*42eb5817SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
70*42eb5817SKevin Wolf
71*42eb5817SKevin Wolf# 1 << 0x1b = 2^31 / L2_CACHE_SIZE
72*42eb5817SKevin Wolfpoke_file "$TEST_IMG" "$offset_l2_bits" "\x1b"
73*42eb5817SKevin Wolf{ $QEMU_IO -c "read 0 512" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
74*42eb5817SKevin Wolf
757159a45bSKevin Wolf# success, all done
767159a45bSKevin Wolfecho "*** done"
777159a45bSKevin Wolfrm -f $seq.full
787159a45bSKevin Wolfstatus=0
79