1bf68bcb1SNir Soffer#!/bin/bash 2bf68bcb1SNir Soffer# 3bf68bcb1SNir Soffer# Test that qemu-io fail with non-zero exit code 4bf68bcb1SNir Soffer# 5bf68bcb1SNir Soffer# Copyright (C) 2017 Nir Soffer <nirsof@gmail.com> 6bf68bcb1SNir Soffer# 7bf68bcb1SNir Soffer# This program is free software; you can redistribute it and/or modify 8bf68bcb1SNir Soffer# it under the terms of the GNU General Public License as published by 9bf68bcb1SNir Soffer# the Free Software Foundation; either version 2 of the License, or 10bf68bcb1SNir Soffer# (at your option) any later version. 11bf68bcb1SNir Soffer# 12bf68bcb1SNir Soffer# This program is distributed in the hope that it will be useful, 13bf68bcb1SNir Soffer# but WITHOUT ANY WARRANTY; without even the implied warranty of 14bf68bcb1SNir Soffer# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15bf68bcb1SNir Soffer# GNU General Public License for more details. 16bf68bcb1SNir Soffer# 17bf68bcb1SNir Soffer# You should have received a copy of the GNU General Public License 18bf68bcb1SNir Soffer# along with this program. If not, see <http://www.gnu.org/licenses/>. 19bf68bcb1SNir Soffer# 20bf68bcb1SNir Soffer 21bf68bcb1SNir Soffer# creator 22bf68bcb1SNir Sofferowner=nirsof@gmail.com 23bf68bcb1SNir Soffer 24bf68bcb1SNir Sofferseq=`basename $0` 25bf68bcb1SNir Sofferecho "QA output created by $seq" 26bf68bcb1SNir Soffer 27bf68bcb1SNir Sofferhere=`pwd` 28bf68bcb1SNir Sofferstatus=1 # failure is the default! 29bf68bcb1SNir Soffer 30bf68bcb1SNir Soffer_cleanup() 31bf68bcb1SNir Soffer{ 32bf68bcb1SNir Soffer _cleanup_test_img 33bf68bcb1SNir Soffer} 34bf68bcb1SNir Soffertrap "_cleanup; exit \$status" 0 1 2 3 15 35bf68bcb1SNir Soffer 36bf68bcb1SNir Soffer# get standard environment, filters and checks 37bf68bcb1SNir Soffer. ./common.rc 38bf68bcb1SNir Soffer. ./common.filter 39bf68bcb1SNir Soffer 40bf68bcb1SNir Soffer_unsupported_fmt raw 41bf68bcb1SNir Soffer 42bf68bcb1SNir Soffer 43bf68bcb1SNir Soffersize=256K 44*13a1d4a7SDaniel P. BerrangeIMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt 45bf68bcb1SNir Soffer 46bf68bcb1SNir Sofferecho 47bf68bcb1SNir Sofferecho "== reading wrong format should fail ==" 48bf68bcb1SNir Soffer$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null 49bf68bcb1SNir Soffertest $? -eq 1 || _fail "did not fail" 50bf68bcb1SNir Soffer 51bf68bcb1SNir Sofferecho 52bf68bcb1SNir Sofferecho "== reading missing file should fail ==" 53bf68bcb1SNir Soffer$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null 54bf68bcb1SNir Soffertest $? -eq 1 || _fail "did not fail" 55bf68bcb1SNir Soffer 56bf68bcb1SNir Soffer# success, all done 57bf68bcb1SNir Sofferecho "*** done" 58bf68bcb1SNir Sofferrm -f $seq.full 59bf68bcb1SNir Sofferstatus=0 60