1ab3a32adSKevin Wolf#!/bin/bash 2ab3a32adSKevin Wolf# 3ab3a32adSKevin Wolf# Test bdrv_write_zeroes with backing files 4ab3a32adSKevin Wolf# 5ab3a32adSKevin Wolf# Copyright (C) 2012 Red Hat, Inc. 6ab3a32adSKevin Wolf# 7ab3a32adSKevin Wolf# This program is free software; you can redistribute it and/or modify 8ab3a32adSKevin Wolf# it under the terms of the GNU General Public License as published by 9ab3a32adSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10ab3a32adSKevin Wolf# (at your option) any later version. 11ab3a32adSKevin Wolf# 12ab3a32adSKevin Wolf# This program is distributed in the hope that it will be useful, 13ab3a32adSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14ab3a32adSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15ab3a32adSKevin Wolf# GNU General Public License for more details. 16ab3a32adSKevin Wolf# 17ab3a32adSKevin Wolf# You should have received a copy of the GNU General Public License 18ab3a32adSKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19ab3a32adSKevin Wolf# 20ab3a32adSKevin Wolf 21ab3a32adSKevin Wolf# creator 22ab3a32adSKevin Wolfowner=kwolf@redhat.com 23ab3a32adSKevin Wolf 24ab3a32adSKevin Wolfseq=`basename $0` 25ab3a32adSKevin Wolfecho "QA output created by $seq" 26ab3a32adSKevin Wolf 27ab3a32adSKevin Wolfhere=`pwd` 28ab3a32adSKevin Wolftmp=/tmp/$$ 29ab3a32adSKevin Wolfstatus=1 # failure is the default! 30ab3a32adSKevin Wolf 31ab3a32adSKevin Wolf_cleanup() 32ab3a32adSKevin Wolf{ 33ab3a32adSKevin Wolf _cleanup_test_img 34ab3a32adSKevin Wolf} 35ab3a32adSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 36ab3a32adSKevin Wolf 37ab3a32adSKevin Wolf# get standard environment, filters and checks 38ab3a32adSKevin Wolf. ./common.rc 39ab3a32adSKevin Wolf. ./common.filter 40ab3a32adSKevin Wolf 41ab3a32adSKevin Wolf_supported_fmt qcow qcow2 vmdk qed 42ab3a32adSKevin Wolf_supported_proto generic 43ab3a32adSKevin Wolf_supported_os Linux 44ab3a32adSKevin Wolf 45ab3a32adSKevin WolfCLUSTER_SIZE=4k 46ab3a32adSKevin Wolfsize=128M 47ab3a32adSKevin Wolf 48ab3a32adSKevin Wolfecho 49ab3a32adSKevin Wolfecho "== creating backing file for COW tests ==" 50ab3a32adSKevin Wolf 51ab3a32adSKevin Wolf_make_test_img $size 52*fef9c191SJeff Cody$QEMU_IO -c "write -P 0x55 0 1M" "$TEST_IMG" | _filter_qemu_io 53*fef9c191SJeff Codymv "$TEST_IMG" "$TEST_IMG.base" 54ab3a32adSKevin Wolf 55*fef9c191SJeff Cody_make_test_img -b "$TEST_IMG.base" 6G 56ab3a32adSKevin Wolf 57ab3a32adSKevin Wolfecho 58ab3a32adSKevin Wolfecho "== zero write with backing file ==" 59*fef9c191SJeff Cody$QEMU_IO -c "write -z 64k 192k" "$TEST_IMG" | _filter_qemu_io 60*fef9c191SJeff Cody$QEMU_IO -c "write -z 513k 13k" "$TEST_IMG" | _filter_qemu_io 61ab3a32adSKevin Wolf 62ab3a32adSKevin Wolf_check_test_img 63ab3a32adSKevin Wolf 64ab3a32adSKevin Wolfecho 65ab3a32adSKevin Wolfecho "== verifying patterns (3) ==" 66*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 64k" "$TEST_IMG" | _filter_qemu_io 67*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 64k 192k" "$TEST_IMG" | _filter_qemu_io 68*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 256k 257k" "$TEST_IMG" | _filter_qemu_io 69*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 513k 13k" "$TEST_IMG" | _filter_qemu_io 70*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 526k 498k" "$TEST_IMG" | _filter_qemu_io 71ab3a32adSKevin Wolf 72ab3a32adSKevin Wolfecho 73ab3a32adSKevin Wolfecho "== overwriting zero cluster ==" 74*fef9c191SJeff Cody$QEMU_IO -c "write -P 0xa 60k 8k" "$TEST_IMG" | _filter_qemu_io 75*fef9c191SJeff Cody$QEMU_IO -c "write -P 0xb 64k 8k" "$TEST_IMG" | _filter_qemu_io 76*fef9c191SJeff Cody$QEMU_IO -c "write -P 0xc 76k 4k" "$TEST_IMG" | _filter_qemu_io 77*fef9c191SJeff Cody$QEMU_IO -c "write -P 0xd 252k 8k" "$TEST_IMG" | _filter_qemu_io 78*fef9c191SJeff Cody$QEMU_IO -c "write -P 0xe 248k 8k" "$TEST_IMG" | _filter_qemu_io 79ab3a32adSKevin Wolf 80ab3a32adSKevin Wolf_check_test_img 81ab3a32adSKevin Wolf 82ab3a32adSKevin Wolfecho 83ab3a32adSKevin Wolfecho "== verifying patterns (4) ==" 84*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 60k" "$TEST_IMG" | _filter_qemu_io 85*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xa 60k 4k" "$TEST_IMG" | _filter_qemu_io 86*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xb 64k 8k" "$TEST_IMG" | _filter_qemu_io 87*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 72k 4k" "$TEST_IMG" | _filter_qemu_io 88*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xc 76k 4k" "$TEST_IMG" | _filter_qemu_io 89*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 80k 168k" "$TEST_IMG" | _filter_qemu_io 90*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xe 248k 8k" "$TEST_IMG" | _filter_qemu_io 91*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xd 256k 4k" "$TEST_IMG" | _filter_qemu_io 92*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 260k 64k" "$TEST_IMG" | _filter_qemu_io 93ab3a32adSKevin Wolf 94ab3a32adSKevin Wolfecho 95ab3a32adSKevin Wolfecho "== re-zeroing overwritten area ==" 96*fef9c191SJeff Cody$QEMU_IO -c "write -z 64k 192k" "$TEST_IMG" | _filter_qemu_io 97ab3a32adSKevin Wolf 98ab3a32adSKevin Wolf_check_test_img 99ab3a32adSKevin Wolf 100ab3a32adSKevin Wolfecho 101ab3a32adSKevin Wolfecho "== verifying patterns (5) ==" 102*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 0 60k" "$TEST_IMG" | _filter_qemu_io 103*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xa 60k 4k" "$TEST_IMG" | _filter_qemu_io 104*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 64k 192k" "$TEST_IMG" | _filter_qemu_io 105*fef9c191SJeff Cody$QEMU_IO -c "read -P 0xd 256k 4k" "$TEST_IMG" | _filter_qemu_io 106*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 260k 253k" "$TEST_IMG" | _filter_qemu_io 107*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x0 513k 13k" "$TEST_IMG" | _filter_qemu_io 108*fef9c191SJeff Cody$QEMU_IO -c "read -P 0x55 526k 498k" "$TEST_IMG" | _filter_qemu_io 109ab3a32adSKevin Wolf 110ab3a32adSKevin Wolf# success, all done 111ab3a32adSKevin Wolfecho "*** done" 112ab3a32adSKevin Wolfrm -f $seq.full 113ab3a32adSKevin Wolfstatus=0 114