1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Sofferstatus=1 # failure is the default! 28bf68bcb1SNir Soffer 29bf68bcb1SNir Soffer_cleanup() 30bf68bcb1SNir Soffer{ 31bf68bcb1SNir Soffer _cleanup_test_img 32bf68bcb1SNir Soffer} 33bf68bcb1SNir Soffertrap "_cleanup; exit \$status" 0 1 2 3 15 34bf68bcb1SNir Soffer 35bf68bcb1SNir Soffer# get standard environment, filters and checks 36bf68bcb1SNir Soffer. ./common.rc 37bf68bcb1SNir Soffer. ./common.filter 38bf68bcb1SNir Soffer 39bf68bcb1SNir Soffer_unsupported_fmt raw 40bf68bcb1SNir Soffer 41bf68bcb1SNir Soffer 42bf68bcb1SNir Soffersize=256K 4313a1d4a7SDaniel P. BerrangeIMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt 44bf68bcb1SNir Soffer 45bf68bcb1SNir Sofferecho 46bf68bcb1SNir Sofferecho "== reading wrong format should fail ==" 47bf68bcb1SNir Soffer$QEMU_IO -f $IMGFMT -c "read 0 $size" "$TEST_IMG" 2>/dev/null 48bf68bcb1SNir Soffertest $? -eq 1 || _fail "did not fail" 49bf68bcb1SNir Soffer 50bf68bcb1SNir Sofferecho 51bf68bcb1SNir Sofferecho "== reading missing file should fail ==" 52bf68bcb1SNir Soffer$QEMU_IO -c "read 0 $size" "$TEST_DIR/missing" 2>/dev/null 53bf68bcb1SNir Soffertest $? -eq 1 || _fail "did not fail" 54bf68bcb1SNir Soffer 55bf68bcb1SNir Soffer# success, all done 56bf68bcb1SNir Sofferecho "*** done" 57bf68bcb1SNir Sofferrm -f $seq.full 58bf68bcb1SNir Sofferstatus=0 59