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