1ee3a315eSPaolo Bonzini#!/bin/bash 2ee3a315eSPaolo Bonzini# 3ee3a315eSPaolo Bonzini# Test aligned and misaligned write zeroes operations. 4ee3a315eSPaolo Bonzini# 5ee3a315eSPaolo Bonzini# Copyright (C) 2012 Red Hat, Inc. 6ee3a315eSPaolo Bonzini# 7ee3a315eSPaolo Bonzini# This program is free software; you can redistribute it and/or modify 8ee3a315eSPaolo Bonzini# it under the terms of the GNU General Public License as published by 9ee3a315eSPaolo Bonzini# the Free Software Foundation; either version 2 of the License, or 10ee3a315eSPaolo Bonzini# (at your option) any later version. 11ee3a315eSPaolo Bonzini# 12ee3a315eSPaolo Bonzini# This program is distributed in the hope that it will be useful, 13ee3a315eSPaolo Bonzini# but WITHOUT ANY WARRANTY; without even the implied warranty of 14ee3a315eSPaolo Bonzini# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15ee3a315eSPaolo Bonzini# GNU General Public License for more details. 16ee3a315eSPaolo Bonzini# 17ee3a315eSPaolo Bonzini# You should have received a copy of the GNU General Public License 18ee3a315eSPaolo Bonzini# along with this program. If not, see <http://www.gnu.org/licenses/>. 19ee3a315eSPaolo Bonzini# 20ee3a315eSPaolo Bonzini 21ee3a315eSPaolo Bonzini# creator 22ee3a315eSPaolo Bonziniowner=pbonzini@redhat.com 23ee3a315eSPaolo Bonzini 24ee3a315eSPaolo Bonziniseq=`basename $0` 25ee3a315eSPaolo Bonziniecho "QA output created by $seq" 26ee3a315eSPaolo Bonzini 27ee3a315eSPaolo Bonzinihere=`pwd` 28ee3a315eSPaolo Bonzinitmp=/tmp/$$ 29ee3a315eSPaolo Bonzinistatus=1 # failure is the default! 30ee3a315eSPaolo Bonzini 31ee3a315eSPaolo Bonzini_cleanup() 32ee3a315eSPaolo Bonzini{ 33ee3a315eSPaolo Bonzini _cleanup_test_img 34ee3a315eSPaolo Bonzini} 35ee3a315eSPaolo Bonzinitrap "_cleanup; exit \$status" 0 1 2 3 15 36ee3a315eSPaolo Bonzini 37ee3a315eSPaolo Bonzini# get standard environment, filters and checks 38ee3a315eSPaolo Bonzini. ./common.rc 39ee3a315eSPaolo Bonzini. ./common.filter 40ee3a315eSPaolo Bonzini 41ee3a315eSPaolo Bonzini_supported_fmt generic 42ee3a315eSPaolo Bonzini_supported_proto generic 43ee3a315eSPaolo Bonzini_supported_os Linux 44ee3a315eSPaolo Bonzini 45ee3a315eSPaolo Bonzini 46ee3a315eSPaolo Bonzinisize=128M 47ee3a315eSPaolo Bonzini_make_test_img $size 48ee3a315eSPaolo Bonzini 4961815d6eSFam Zhengdo_test() 5061815d6eSFam Zheng{ 5161815d6eSFam Zheng local align=$1 5261815d6eSFam Zheng local iocmd=$2 5361815d6eSFam Zheng local img=$3 5461815d6eSFam Zheng { 5561815d6eSFam Zheng echo "open -o driver=$IMGFMT,file.align=$align blkdebug::$img" 5661815d6eSFam Zheng echo $iocmd 5761815d6eSFam Zheng } | $QEMU_IO 5861815d6eSFam Zheng} 5961815d6eSFam Zheng 60*7fa84cd8SKevin Wolffor write_zero_cmd in "write -z" "aio_write -z"; do 6161815d6eSFam Zhengfor align in 512 4k; do 62ee3a315eSPaolo Bonzini echo 63ee3a315eSPaolo Bonzini echo "== preparing image ==" 6461815d6eSFam Zheng do_test $align "write -P 0xa 0x200 0x400" "$TEST_IMG" | _filter_qemu_io 6561815d6eSFam Zheng do_test $align "write -P 0xa 0x20000 0x600" "$TEST_IMG" | _filter_qemu_io 66*7fa84cd8SKevin Wolf do_test $align "$write_zero_cmd 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io 67ee3a315eSPaolo Bonzini 68ee3a315eSPaolo Bonzini echo 69ee3a315eSPaolo Bonzini echo "== verifying patterns (1) ==" 7061815d6eSFam Zheng do_test $align "read -P 0xa 0x200 0x200" "$TEST_IMG" | _filter_qemu_io 7161815d6eSFam Zheng do_test $align "read -P 0x0 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io 7261815d6eSFam Zheng do_test $align "read -P 0xa 0x20400 0x200" "$TEST_IMG" | _filter_qemu_io 73ee3a315eSPaolo Bonzini 74ee3a315eSPaolo Bonzini echo 75ee3a315eSPaolo Bonzini echo "== rewriting zeroes ==" 7661815d6eSFam Zheng do_test $align "write -P 0xb 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io 77*7fa84cd8SKevin Wolf do_test $align "$write_zero_cmd 0x10000 0x10000" "$TEST_IMG" | _filter_qemu_io 78ee3a315eSPaolo Bonzini 79ee3a315eSPaolo Bonzini echo 80ee3a315eSPaolo Bonzini echo "== verifying patterns (2) ==" 8161815d6eSFam Zheng do_test $align "read -P 0x0 0x400 0x20000" "$TEST_IMG" | _filter_qemu_io 82ab53c447SFam Zheng 83ab53c447SFam Zheng echo 84ab53c447SFam Zheng echo "== rewriting unaligned zeroes ==" 85ab53c447SFam Zheng do_test $align "write -P 0xb 0x0 0x1000" "$TEST_IMG" | _filter_qemu_io 86*7fa84cd8SKevin Wolf do_test $align "$write_zero_cmd 0x200 0x200" "$TEST_IMG" | _filter_qemu_io 87ab53c447SFam Zheng 88ab53c447SFam Zheng echo 89ab53c447SFam Zheng echo "== verifying patterns (3) ==" 90ab53c447SFam Zheng do_test $align "read -P 0xb 0x0 0x200" "$TEST_IMG" | _filter_qemu_io 91ab53c447SFam Zheng do_test $align "read -P 0x0 0x200 0x200" "$TEST_IMG" | _filter_qemu_io 92ab53c447SFam Zheng do_test $align "read -P 0xb 0x400 0xc00" "$TEST_IMG" | _filter_qemu_io 93ab53c447SFam Zheng 94ab53c447SFam Zheng echo 9561815d6eSFam Zhengdone 96*7fa84cd8SKevin Wolfdone 97ee3a315eSPaolo Bonzini 98ee3a315eSPaolo Bonzini# success, all done 99ee3a315eSPaolo Bonziniecho "*** done" 100ee3a315eSPaolo Bonzinirm -f $seq.full 101ee3a315eSPaolo Bonzinistatus=0 102