1*2fa4c042SKevin Wolf#!/bin/bash 2*2fa4c042SKevin Wolf# 3*2fa4c042SKevin Wolf# Test qemu-img progress output 4*2fa4c042SKevin Wolf# 5*2fa4c042SKevin Wolf# Copyright (C) 2014 Red Hat, Inc. 6*2fa4c042SKevin Wolf# 7*2fa4c042SKevin Wolf# This program is free software; you can redistribute it and/or modify 8*2fa4c042SKevin Wolf# it under the terms of the GNU General Public License as published by 9*2fa4c042SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*2fa4c042SKevin Wolf# (at your option) any later version. 11*2fa4c042SKevin Wolf# 12*2fa4c042SKevin Wolf# This program is distributed in the hope that it will be useful, 13*2fa4c042SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*2fa4c042SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*2fa4c042SKevin Wolf# GNU General Public License for more details. 16*2fa4c042SKevin Wolf# 17*2fa4c042SKevin Wolf# You should have received a copy of the GNU General Public License 18*2fa4c042SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*2fa4c042SKevin Wolf# 20*2fa4c042SKevin Wolf 21*2fa4c042SKevin Wolf# creator 22*2fa4c042SKevin Wolfowner=kwolf@redhat.com 23*2fa4c042SKevin Wolf 24*2fa4c042SKevin Wolfseq=`basename $0` 25*2fa4c042SKevin Wolfecho "QA output created by $seq" 26*2fa4c042SKevin Wolf 27*2fa4c042SKevin Wolfhere=`pwd` 28*2fa4c042SKevin Wolftmp=/tmp/$$ 29*2fa4c042SKevin Wolfstatus=1 # failure is the default! 30*2fa4c042SKevin Wolf 31*2fa4c042SKevin Wolf_cleanup() 32*2fa4c042SKevin Wolf{ 33*2fa4c042SKevin Wolf _cleanup_test_img 34*2fa4c042SKevin Wolf} 35*2fa4c042SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36*2fa4c042SKevin Wolf 37*2fa4c042SKevin Wolf# get standard environment, filters and checks 38*2fa4c042SKevin Wolf. ./common.rc 39*2fa4c042SKevin Wolf. ./common.filter 40*2fa4c042SKevin Wolf 41*2fa4c042SKevin Wolf_supported_fmt qcow2 42*2fa4c042SKevin Wolf_supported_proto file 43*2fa4c042SKevin Wolf_supported_os Linux 44*2fa4c042SKevin Wolf 45*2fa4c042SKevin Wolffunction run_qemu_img() 46*2fa4c042SKevin Wolf{ 47*2fa4c042SKevin Wolf echo 48*2fa4c042SKevin Wolf echo Testing: "$@" | _filter_testdir 49*2fa4c042SKevin Wolf} 50*2fa4c042SKevin Wolf 51*2fa4c042SKevin Wolfsize=128M 52*2fa4c042SKevin Wolf 53*2fa4c042SKevin Wolf_make_test_img $size 54*2fa4c042SKevin Wolf$QEMU_IO -c 'write 0 1M' $TEST_IMG | _filter_qemu_io 55*2fa4c042SKevin Wolf$QEMU_IO -c 'write 2M 1M' $TEST_IMG | _filter_qemu_io 56*2fa4c042SKevin Wolf$QEMU_IO -c 'write 4M 1M' $TEST_IMG | _filter_qemu_io 57*2fa4c042SKevin Wolf$QEMU_IO -c 'write 32M 1M' $TEST_IMG | _filter_qemu_io 58*2fa4c042SKevin Wolf 59*2fa4c042SKevin Wolf$QEMU_IMG convert -p -O $IMGFMT -f $IMGFMT "$TEST_IMG" "$TEST_IMG".base 2>&1 |\ 60*2fa4c042SKevin Wolf _filter_testdir | sed -e 's/\r/\n/g' 61*2fa4c042SKevin Wolf 62*2fa4c042SKevin Wolf# success, all done 63*2fa4c042SKevin Wolfecho "*** done" 64*2fa4c042SKevin Wolfrm -f $seq.full 65*2fa4c042SKevin Wolfstatus=0 66