xref: /openbmc/qemu/tests/qemu-iotests/017 (revision e8c212d6824fbe5660b8653463f7a3b46fb34b80)
12557d865SKevin Wolf#!/bin/sh
22557d865SKevin Wolf#
32557d865SKevin Wolf# Simple backing file reads
42557d865SKevin Wolf#
52557d865SKevin Wolf# Copyright (C) 2009 Red Hat, Inc.
62557d865SKevin Wolf#
72557d865SKevin Wolf# This program is free software; you can redistribute it and/or modify
82557d865SKevin Wolf# it under the terms of the GNU General Public License as published by
92557d865SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
102557d865SKevin Wolf# (at your option) any later version.
112557d865SKevin Wolf#
122557d865SKevin Wolf# This program is distributed in the hope that it will be useful,
132557d865SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
142557d865SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
152557d865SKevin Wolf# GNU General Public License for more details.
162557d865SKevin Wolf#
172557d865SKevin Wolf# You should have received a copy of the GNU General Public License
18*e8c212d6SChristoph Hellwig# along with this program.  If not, see <http://www.gnu.org/licenses/>.
192557d865SKevin Wolf#
202557d865SKevin Wolf
212557d865SKevin Wolf# creator
222557d865SKevin Wolfowner=kwolf@redhat.com
232557d865SKevin Wolf
242557d865SKevin Wolfseq=`basename $0`
252557d865SKevin Wolfecho "QA output created by $seq"
262557d865SKevin Wolf
272557d865SKevin Wolfhere=`pwd`
282557d865SKevin Wolftmp=/tmp/$$
292557d865SKevin Wolfstatus=1	# failure is the default!
302557d865SKevin Wolf
312557d865SKevin Wolf_cleanup()
322557d865SKevin Wolf{
332557d865SKevin Wolf	_cleanup_test_img
342557d865SKevin Wolf}
352557d865SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
362557d865SKevin Wolf
372557d865SKevin Wolf# get standard environment, filters and checks
382557d865SKevin Wolf. ./common.rc
392557d865SKevin Wolf. ./common.filter
402557d865SKevin Wolf. ./common.pattern
412557d865SKevin Wolf
422557d865SKevin Wolf# Any format supporting backing files
432557d865SKevin Wolf_supported_fmt qcow qcow2 vmdk
442557d865SKevin Wolf_supported_os Linux
452557d865SKevin Wolf
462557d865SKevin WolfTEST_OFFSETS="0 4294967296"
472557d865SKevin Wolf
482557d865SKevin Wolf_make_test_img 6G
492557d865SKevin Wolf
502557d865SKevin Wolfecho "Filling base image"
512557d865SKevin Wolfecho
522557d865SKevin Wolf
532557d865SKevin Wolffor offset in $TEST_OFFSETS; do
542557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
552557d865SKevin Wolf    io writev $(( offset )) 512 1024 64
562557d865SKevin Wolf
572557d865SKevin Wolf    # Complete backing clusters
582557d865SKevin Wolf    io writev $(( offset  + 64 * 1024))  65536 65536 1
592557d865SKevin Wolfdone
602557d865SKevin Wolf_check_test_img
612557d865SKevin Wolf
622557d865SKevin Wolfecho "Creating test image with backing file"
632557d865SKevin Wolfecho
642557d865SKevin Wolf
652557d865SKevin Wolfmv $TEST_IMG $TEST_IMG.base
662557d865SKevin Wolf_make_test_img -b $TEST_IMG.base 6G
672557d865SKevin Wolf
682557d865SKevin Wolfecho "Filling test image"
692557d865SKevin Wolfecho
702557d865SKevin Wolf
712557d865SKevin Wolffor offset in $TEST_OFFSETS; do
722557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
732557d865SKevin Wolf    io writev $(( offset + 512 )) 512 1024 64
742557d865SKevin Wolf
752557d865SKevin Wolf    # Complete test image clusters
762557d865SKevin Wolf    io writev $(( offset + 64 * 1024 + 65536))  65536 65536 1
772557d865SKevin Wolfdone
782557d865SKevin Wolf_check_test_img
792557d865SKevin Wolf
802557d865SKevin Wolfecho "Reading"
812557d865SKevin Wolfecho
822557d865SKevin Wolf
832557d865SKevin Wolffor offset in $TEST_OFFSETS; do
842557d865SKevin Wolf    # Some clusters with alternating backing file/image file reads
852557d865SKevin Wolf    io readv $(( offset )) 512 1024 64
862557d865SKevin Wolf    io readv $(( offset + 512 )) 512 1024 64
872557d865SKevin Wolf
882557d865SKevin Wolf    # Complete test image clusters
892557d865SKevin Wolf    io readv $(( offset  + 64 * 1024))  65536 65536 1
902557d865SKevin Wolf    io readv $(( offset + 64 * 1024 + 65536))  65536 65536 1
912557d865SKevin Wolf
922557d865SKevin Wolf    # Empty sectors
932557d865SKevin Wolf    io_zero readv $(( offset + 64 * 1024 + 65536 * 4 )) 65536 65536 1
942557d865SKevin Wolfdone
952557d865SKevin Wolf_check_test_img
962557d865SKevin Wolf
972557d865SKevin Wolf# success, all done
982557d865SKevin Wolfecho "*** done"
992557d865SKevin Wolfrm -f $seq.full
1002557d865SKevin Wolfstatus=0
101