xref: /openbmc/qemu/tests/qemu-iotests/090 (revision cffb12051a26e5494ed009c99db7858b2aab7099)
1*cffb1205SMax Reitz#!/bin/bash
2*cffb1205SMax Reitz#
3*cffb1205SMax Reitz# Test for discarding compressed clusters on qcow2 images
4*cffb1205SMax Reitz#
5*cffb1205SMax Reitz# Copyright (C) 2014 Red Hat, Inc.
6*cffb1205SMax Reitz#
7*cffb1205SMax Reitz# This program is free software; you can redistribute it and/or modify
8*cffb1205SMax Reitz# it under the terms of the GNU General Public License as published by
9*cffb1205SMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*cffb1205SMax Reitz# (at your option) any later version.
11*cffb1205SMax Reitz#
12*cffb1205SMax Reitz# This program is distributed in the hope that it will be useful,
13*cffb1205SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*cffb1205SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*cffb1205SMax Reitz# GNU General Public License for more details.
16*cffb1205SMax Reitz#
17*cffb1205SMax Reitz# You should have received a copy of the GNU General Public License
18*cffb1205SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*cffb1205SMax Reitz#
20*cffb1205SMax Reitz
21*cffb1205SMax Reitz# creator
22*cffb1205SMax Reitzowner=mreitz@redhat.com
23*cffb1205SMax Reitz
24*cffb1205SMax Reitzseq="$(basename $0)"
25*cffb1205SMax Reitzecho "QA output created by $seq"
26*cffb1205SMax Reitz
27*cffb1205SMax Reitzhere="$PWD"
28*cffb1205SMax Reitztmp=/tmp/$$
29*cffb1205SMax Reitzstatus=1	# failure is the default!
30*cffb1205SMax Reitz
31*cffb1205SMax Reitz_cleanup()
32*cffb1205SMax Reitz{
33*cffb1205SMax Reitz	_cleanup_test_img
34*cffb1205SMax Reitz}
35*cffb1205SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36*cffb1205SMax Reitz
37*cffb1205SMax Reitz# get standard environment, filters and checks
38*cffb1205SMax Reitz. ./common.rc
39*cffb1205SMax Reitz. ./common.filter
40*cffb1205SMax Reitz
41*cffb1205SMax Reitz_supported_fmt qcow2
42*cffb1205SMax Reitz_supported_proto file
43*cffb1205SMax Reitz_supported_os Linux
44*cffb1205SMax Reitz
45*cffb1205SMax ReitzIMG_SIZE=128K
46*cffb1205SMax Reitz
47*cffb1205SMax Reitz_make_test_img $IMG_SIZE
48*cffb1205SMax Reitz
49*cffb1205SMax Reitz$QEMU_IO -c 'write -c -P 42 0 64k' \
50*cffb1205SMax Reitz         -c 'write -c -P 23 64k 64k' \
51*cffb1205SMax Reitz         -c 'discard 64k 64k' \
52*cffb1205SMax Reitz         "$TEST_IMG" | _filter_qemu_io
53*cffb1205SMax Reitz
54*cffb1205SMax Reitz$QEMU_IO -c 'read -P 0 64k 64k' "$TEST_IMG" | _filter_qemu_io
55*cffb1205SMax Reitz
56*cffb1205SMax Reitz_check_test_img
57*cffb1205SMax Reitz
58*cffb1205SMax Reitz# success, all done
59*cffb1205SMax Reitzecho "*** done"
60*cffb1205SMax Reitzrm -f $seq.full
61*cffb1205SMax Reitzstatus=0
62