xref: /openbmc/qemu/tests/qemu-iotests/076 (revision 0e324626)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: io
3afbcc40bSKevin Wolf#
4afbcc40bSKevin Wolf# parallels format input validation tests
5afbcc40bSKevin Wolf#
6afbcc40bSKevin Wolf# Copyright (C) 2013 Red Hat, Inc.
7afbcc40bSKevin Wolf#
8afbcc40bSKevin Wolf# This program is free software; you can redistribute it and/or modify
9afbcc40bSKevin Wolf# it under the terms of the GNU General Public License as published by
10afbcc40bSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
11afbcc40bSKevin Wolf# (at your option) any later version.
12afbcc40bSKevin Wolf#
13afbcc40bSKevin Wolf# This program is distributed in the hope that it will be useful,
14afbcc40bSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
15afbcc40bSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16afbcc40bSKevin Wolf# GNU General Public License for more details.
17afbcc40bSKevin Wolf#
18afbcc40bSKevin Wolf# You should have received a copy of the GNU General Public License
19afbcc40bSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20afbcc40bSKevin Wolf#
21afbcc40bSKevin Wolf
22afbcc40bSKevin Wolf# creator
23afbcc40bSKevin Wolfowner=kwolf@redhat.com
24afbcc40bSKevin Wolf
25afbcc40bSKevin Wolfseq=`basename $0`
26afbcc40bSKevin Wolfecho "QA output created by $seq"
27afbcc40bSKevin Wolf
28afbcc40bSKevin Wolfstatus=1	# failure is the default!
29afbcc40bSKevin Wolf
30afbcc40bSKevin Wolf_cleanup()
31afbcc40bSKevin Wolf{
32afbcc40bSKevin Wolf	_cleanup_test_img
33afbcc40bSKevin Wolf}
34afbcc40bSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
35afbcc40bSKevin Wolf
36afbcc40bSKevin Wolf# get standard environment, filters and checks
37afbcc40bSKevin Wolf. ./common.rc
38afbcc40bSKevin Wolf. ./common.filter
39afbcc40bSKevin Wolf
40afbcc40bSKevin Wolf_supported_fmt parallels
41c5f7c0afSPeter Lieven_supported_proto file
42afbcc40bSKevin Wolf_supported_os Linux
43afbcc40bSKevin Wolf
449302e863SKevin Wolftracks_offset=$((0x1c))
45afbcc40bSKevin Wolfcatalog_entries_offset=$((0x20))
46afbcc40bSKevin Wolfnb_sectors_offset=$((0x24))
47afbcc40bSKevin Wolf
48afbcc40bSKevin Wolfecho
49285030b0SDenis V. Lunevecho "== Read from a valid v1 image =="
50285030b0SDenis V. Lunev_use_sample_img parallels-v1.bz2
51d134cf73SDenis V. Lunev{ $QEMU_IO -c "read -P 0x11 0 64k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
52afbcc40bSKevin Wolf
53afbcc40bSKevin Wolfecho
54afbcc40bSKevin Wolfecho "== Negative catalog size =="
55285030b0SDenis V. Lunev_use_sample_img parallels-v1.bz2
56afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$catalog_entries_offset" "\xff\xff\xff\xff"
57d134cf73SDenis V. Lunev{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
58afbcc40bSKevin Wolf
59afbcc40bSKevin Wolfecho
60afbcc40bSKevin Wolfecho "== Overflow in catalog allocation =="
61285030b0SDenis V. Lunev_use_sample_img parallels-v1.bz2
62afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$nb_sectors_offset" "\xff\xff\xff\xff"
63afbcc40bSKevin Wolfpoke_file "$TEST_IMG" "$catalog_entries_offset" "\x01\x00\x00\x40"
64d134cf73SDenis V. Lunev{ $QEMU_IO -c "read 64M 64M" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
65afbcc40bSKevin Wolf
669302e863SKevin Wolfecho
679302e863SKevin Wolfecho "== Zero sectors per track =="
68285030b0SDenis V. Lunev_use_sample_img parallels-v1.bz2
699302e863SKevin Wolfpoke_file "$TEST_IMG" "$tracks_offset" "\x00\x00\x00\x00"
70d134cf73SDenis V. Lunev{ $QEMU_IO -c "read 0 512" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
719302e863SKevin Wolf
7276823c6eSDenis V. Lunevecho
7376823c6eSDenis V. Lunevecho "== Read from a valid v2 image =="
7476823c6eSDenis V. Lunev_use_sample_img parallels-v2.bz2
75d134cf73SDenis V. Lunev{ $QEMU_IO -c "read -P 0x11 0 64k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
7650ffd8fdSDenis V. Lunev{ $QEMU_IO -c "write -P 0x21 1024k 1k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
7750ffd8fdSDenis V. Lunev{ $QEMU_IO -c "write -P 0x22 1025k 1k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
7850ffd8fdSDenis V. Lunev{ $QEMU_IO -c "read -P 0x21 1024k 1k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
7950ffd8fdSDenis V. Lunev{ $QEMU_IO -c "read -P 0x22 1025k 1k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
8050ffd8fdSDenis V. Lunev{ $QEMU_IO -c "read -P 0 1026k 62k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir
8176823c6eSDenis V. Lunev
82afbcc40bSKevin Wolf# success, all done
83afbcc40bSKevin Wolfecho "*** done"
84afbcc40bSKevin Wolfrm -f $seq.full
85afbcc40bSKevin Wolfstatus=0
86