111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Reitzstatus=1 # failure is the default! 28cffb1205SMax Reitz 29cffb1205SMax Reitz_cleanup() 30cffb1205SMax Reitz{ 31cffb1205SMax Reitz _cleanup_test_img 32cffb1205SMax Reitz} 33cffb1205SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 34cffb1205SMax Reitz 35cffb1205SMax Reitz# get standard environment, filters and checks 36cffb1205SMax Reitz. ./common.rc 37cffb1205SMax Reitz. ./common.filter 38cffb1205SMax Reitz 39cffb1205SMax Reitz_supported_fmt qcow2 40c5f7c0afSPeter Lieven_supported_proto file nfs 41*3be2024aSMax Reitz# External data files do not support compressed clusters 42*3be2024aSMax Reitz_unsupported_imgopts data_file 43cffb1205SMax Reitz 44cffb1205SMax ReitzIMG_SIZE=128K 45cffb1205SMax Reitz 46cffb1205SMax Reitz_make_test_img $IMG_SIZE 47cffb1205SMax Reitz 48cffb1205SMax Reitz$QEMU_IO -c 'write -c -P 42 0 64k' \ 49cffb1205SMax Reitz -c 'write -c -P 23 64k 64k' \ 50cffb1205SMax Reitz -c 'discard 64k 64k' \ 51cffb1205SMax Reitz "$TEST_IMG" | _filter_qemu_io 52cffb1205SMax Reitz 53cffb1205SMax Reitz$QEMU_IO -c 'read -P 0 64k 64k' "$TEST_IMG" | _filter_qemu_io 54cffb1205SMax Reitz 55cffb1205SMax Reitz_check_test_img 56cffb1205SMax Reitz 57cffb1205SMax Reitz# success, all done 58cffb1205SMax Reitzecho "*** done" 59cffb1205SMax Reitzrm -f $seq.full 60cffb1205SMax Reitzstatus=0 61