1*ae6ef019SMax Reitz#!/usr/bin/env bash 2*ae6ef019SMax Reitz# 3*ae6ef019SMax Reitz# Test reverse-ordered qcow2 writes on a sub-cluster level 4*ae6ef019SMax Reitz# 5*ae6ef019SMax Reitz# Copyright (C) 2019 Red Hat, Inc. 6*ae6ef019SMax Reitz# 7*ae6ef019SMax Reitz# This program is free software; you can redistribute it and/or modify 8*ae6ef019SMax Reitz# it under the terms of the GNU General Public License as published by 9*ae6ef019SMax Reitz# the Free Software Foundation; either version 2 of the License, or 10*ae6ef019SMax Reitz# (at your option) any later version. 11*ae6ef019SMax Reitz# 12*ae6ef019SMax Reitz# This program is distributed in the hope that it will be useful, 13*ae6ef019SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*ae6ef019SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*ae6ef019SMax Reitz# GNU General Public License for more details. 16*ae6ef019SMax Reitz# 17*ae6ef019SMax Reitz# You should have received a copy of the GNU General Public License 18*ae6ef019SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*ae6ef019SMax Reitz# 20*ae6ef019SMax Reitz 21*ae6ef019SMax Reitzseq=$(basename $0) 22*ae6ef019SMax Reitzecho "QA output created by $seq" 23*ae6ef019SMax Reitz 24*ae6ef019SMax Reitzstatus=1 # failure is the default! 25*ae6ef019SMax Reitz 26*ae6ef019SMax Reitz_cleanup() 27*ae6ef019SMax Reitz{ 28*ae6ef019SMax Reitz _cleanup_test_img 29*ae6ef019SMax Reitz} 30*ae6ef019SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 31*ae6ef019SMax Reitz 32*ae6ef019SMax Reitz# get standard environment, filters and checks 33*ae6ef019SMax Reitz. ./common.rc 34*ae6ef019SMax Reitz. ./common.filter 35*ae6ef019SMax Reitz 36*ae6ef019SMax Reitz# qcow2-specific test 37*ae6ef019SMax Reitz_supported_fmt qcow2 38*ae6ef019SMax Reitz_supported_proto file 39*ae6ef019SMax Reitz_supported_os Linux 40*ae6ef019SMax Reitz 41*ae6ef019SMax Reitzecho '--- Writing to the image ---' 42*ae6ef019SMax Reitz 43*ae6ef019SMax Reitz# Reduce cluster size so we get more and quicker I/O 44*ae6ef019SMax ReitzIMGOPTS='cluster_size=4096' _make_test_img 1M 45*ae6ef019SMax Reitz(for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ 46*ae6ef019SMax Reitz echo "aio_write -P 42 $((kb + 1))k 2k"; \ 47*ae6ef019SMax Reitz done) \ 48*ae6ef019SMax Reitz | $QEMU_IO "$TEST_IMG" > /dev/null 49*ae6ef019SMax Reitz 50*ae6ef019SMax Reitzecho '--- Verifying its content ---' 51*ae6ef019SMax Reitz 52*ae6ef019SMax Reitz(for ((kb = 0; kb < 1024; kb += 4)); do \ 53*ae6ef019SMax Reitz echo "read -P 0 ${kb}k 1k"; \ 54*ae6ef019SMax Reitz echo "read -P 42 $((kb + 1))k 2k"; \ 55*ae6ef019SMax Reitz echo "read -P 0 $((kb + 3))k 1k"; \ 56*ae6ef019SMax Reitz done) \ 57*ae6ef019SMax Reitz | $QEMU_IO "$TEST_IMG" | _filter_qemu_io | grep 'verification' 58*ae6ef019SMax Reitz 59*ae6ef019SMax Reitz# Status of qemu-io 60*ae6ef019SMax Reitzif [ ${PIPESTATUS[1]} = 0 ]; then 61*ae6ef019SMax Reitz echo 'Content verified.' 62*ae6ef019SMax Reitzfi 63*ae6ef019SMax Reitz 64*ae6ef019SMax Reitz# success, all done 65*ae6ef019SMax Reitzecho "*** done" 66*ae6ef019SMax Reitzrm -f $seq.full 67*ae6ef019SMax Reitzstatus=0 68