111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick 3cffb1205SMax Reitz# 4cffb1205SMax Reitz# Test for discarding compressed clusters on qcow2 images 5cffb1205SMax Reitz# 6cffb1205SMax Reitz# Copyright (C) 2014 Red Hat, Inc. 7cffb1205SMax Reitz# 8cffb1205SMax Reitz# This program is free software; you can redistribute it and/or modify 9cffb1205SMax Reitz# it under the terms of the GNU General Public License as published by 10cffb1205SMax Reitz# the Free Software Foundation; either version 2 of the License, or 11cffb1205SMax Reitz# (at your option) any later version. 12cffb1205SMax Reitz# 13cffb1205SMax Reitz# This program is distributed in the hope that it will be useful, 14cffb1205SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 15cffb1205SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16cffb1205SMax Reitz# GNU General Public License for more details. 17cffb1205SMax Reitz# 18cffb1205SMax Reitz# You should have received a copy of the GNU General Public License 19cffb1205SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 20cffb1205SMax Reitz# 21cffb1205SMax Reitz 22cffb1205SMax Reitz# creator 23*42a5009dSJohn Snowowner=hreitz@redhat.com 24cffb1205SMax Reitz 25cffb1205SMax Reitzseq="$(basename $0)" 26cffb1205SMax Reitzecho "QA output created by $seq" 27cffb1205SMax Reitz 28cffb1205SMax Reitzstatus=1 # failure is the default! 29cffb1205SMax Reitz 30cffb1205SMax Reitz_cleanup() 31cffb1205SMax Reitz{ 32cffb1205SMax Reitz _cleanup_test_img 33cffb1205SMax Reitz} 34cffb1205SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 35cffb1205SMax Reitz 36cffb1205SMax Reitz# get standard environment, filters and checks 37cffb1205SMax Reitz. ./common.rc 38cffb1205SMax Reitz. ./common.filter 39cffb1205SMax Reitz 40cffb1205SMax Reitz_supported_fmt qcow2 4157284d2aSMax Reitz_supported_proto file nfs fuse 423be2024aSMax Reitz# External data files do not support compressed clusters 433be2024aSMax Reitz_unsupported_imgopts data_file 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