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