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