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