105560fceSStefan Hajnoczi#!/bin/bash 205560fceSStefan Hajnoczi# 305560fceSStefan Hajnoczi# cloop format input validation tests 405560fceSStefan Hajnoczi# 505560fceSStefan Hajnoczi# Copyright (C) 2013 Red Hat, Inc. 605560fceSStefan Hajnoczi# 705560fceSStefan Hajnoczi# This program is free software; you can redistribute it and/or modify 805560fceSStefan Hajnoczi# it under the terms of the GNU General Public License as published by 905560fceSStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or 1005560fceSStefan Hajnoczi# (at your option) any later version. 1105560fceSStefan Hajnoczi# 1205560fceSStefan Hajnoczi# This program is distributed in the hope that it will be useful, 1305560fceSStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of 1405560fceSStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1505560fceSStefan Hajnoczi# GNU General Public License for more details. 1605560fceSStefan Hajnoczi# 1705560fceSStefan Hajnoczi# You should have received a copy of the GNU General Public License 1805560fceSStefan Hajnoczi# along with this program. If not, see <http://www.gnu.org/licenses/>. 1905560fceSStefan Hajnoczi# 2005560fceSStefan Hajnoczi 2105560fceSStefan Hajnoczi# creator 2205560fceSStefan Hajnocziowner=stefanha@redhat.com 2305560fceSStefan Hajnoczi 2405560fceSStefan Hajnocziseq=`basename $0` 2505560fceSStefan Hajnocziecho "QA output created by $seq" 2605560fceSStefan Hajnoczi 2705560fceSStefan Hajnoczihere=`pwd` 2805560fceSStefan Hajnoczitmp=/tmp/$$ 2905560fceSStefan Hajnoczistatus=1 # failure is the default! 3005560fceSStefan Hajnoczi 3105560fceSStefan Hajnoczi_cleanup() 3205560fceSStefan Hajnoczi{ 3305560fceSStefan Hajnoczi _cleanup_test_img 3405560fceSStefan Hajnoczi} 3505560fceSStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15 3605560fceSStefan Hajnoczi 3705560fceSStefan Hajnoczi# get standard environment, filters and checks 3805560fceSStefan Hajnoczi. ./common.rc 3905560fceSStefan Hajnoczi. ./common.filter 4005560fceSStefan Hajnoczi 4105560fceSStefan Hajnoczi_supported_fmt cloop 4205560fceSStefan Hajnoczi_supported_proto generic 4305560fceSStefan Hajnoczi_supported_os Linux 4405560fceSStefan Hajnoczi 45d65f97a8SStefan Hajnocziblock_size_offset=128 46*509a41baSStefan Hajnoczin_blocks_offset=132 47d65f97a8SStefan Hajnoczi 4805560fceSStefan Hajnocziecho 4905560fceSStefan Hajnocziecho "== check that the first sector can be read ==" 5005560fceSStefan Hajnoczi_use_sample_img simple-pattern.cloop.bz2 5105560fceSStefan Hajnoczi$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir 5205560fceSStefan Hajnoczi 53d65f97a8SStefan Hajnocziecho 54d65f97a8SStefan Hajnocziecho "== block_size must be a multiple of 512 ==" 55d65f97a8SStefan Hajnoczi_use_sample_img simple-pattern.cloop.bz2 56d65f97a8SStefan Hajnoczipoke_file "$TEST_IMG" "$block_size_offset" "\x00\x00\x02\x01" 57d65f97a8SStefan Hajnoczi$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir 58d65f97a8SStefan Hajnoczi 59d65f97a8SStefan Hajnocziecho 60d65f97a8SStefan Hajnocziecho "== block_size cannot be zero ==" 61d65f97a8SStefan Hajnoczi_use_sample_img simple-pattern.cloop.bz2 62d65f97a8SStefan Hajnoczipoke_file "$TEST_IMG" "$block_size_offset" "\x00\x00\x00\x00" 63d65f97a8SStefan Hajnoczi$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir 64d65f97a8SStefan Hajnoczi 65d65f97a8SStefan Hajnocziecho 66d65f97a8SStefan Hajnocziecho "== huge block_size ===" 67d65f97a8SStefan Hajnoczi_use_sample_img simple-pattern.cloop.bz2 68d65f97a8SStefan Hajnoczipoke_file "$TEST_IMG" "$block_size_offset" "\xff\xff\xfe\x00" 69d65f97a8SStefan Hajnoczi$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir 70d65f97a8SStefan Hajnoczi 71*509a41baSStefan Hajnocziecho 72*509a41baSStefan Hajnocziecho "== offsets_size overflow ===" 73*509a41baSStefan Hajnoczi_use_sample_img simple-pattern.cloop.bz2 74*509a41baSStefan Hajnoczipoke_file "$TEST_IMG" "$n_blocks_offset" "\xff\xff\xff\xff" 75*509a41baSStefan Hajnoczi$QEMU_IO -c "read 0 512" $TEST_IMG 2>&1 | _filter_qemu_io | _filter_testdir 76*509a41baSStefan Hajnoczi 7705560fceSStefan Hajnoczi# success, all done 7805560fceSStefan Hajnocziecho "*** done" 7905560fceSStefan Hajnoczirm -f $seq.full 8005560fceSStefan Hajnoczistatus=0 81