xref: /openbmc/qemu/tests/qemu-iotests/004 (revision 0e324626)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick
36bf19c94SChristoph Hellwig#
46bf19c94SChristoph Hellwig# Make sure we can't read and write outside of the image size.
56bf19c94SChristoph Hellwig#
66bf19c94SChristoph Hellwig# Copyright (C) 2009 Red Hat, Inc.
76bf19c94SChristoph Hellwig#
86bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or modify
96bf19c94SChristoph Hellwig# it under the terms of the GNU General Public License as published by
106bf19c94SChristoph Hellwig# the Free Software Foundation; either version 2 of the License, or
116bf19c94SChristoph Hellwig# (at your option) any later version.
126bf19c94SChristoph Hellwig#
136bf19c94SChristoph Hellwig# This program is distributed in the hope that it will be useful,
146bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of
156bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
166bf19c94SChristoph Hellwig# GNU General Public License for more details.
176bf19c94SChristoph Hellwig#
186bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License
19e8c212d6SChristoph Hellwig# along with this program.  If not, see <http://www.gnu.org/licenses/>.
206bf19c94SChristoph Hellwig#
216bf19c94SChristoph Hellwig
226bf19c94SChristoph Hellwig# creator
236bf19c94SChristoph Hellwigowner=hch@lst.de
246bf19c94SChristoph Hellwig
256bf19c94SChristoph Hellwigseq=`basename $0`
266bf19c94SChristoph Hellwigecho "QA output created by $seq"
276bf19c94SChristoph Hellwig
286bf19c94SChristoph Hellwigstatus=1	# failure is the default!
296bf19c94SChristoph Hellwig
306bf19c94SChristoph Hellwig_cleanup()
316bf19c94SChristoph Hellwig{
326bf19c94SChristoph Hellwig	_cleanup_test_img
336bf19c94SChristoph Hellwig}
346bf19c94SChristoph Hellwigtrap "_cleanup; exit \$status" 0 1 2 3 15
356bf19c94SChristoph Hellwig
366bf19c94SChristoph Hellwig# get standard environment, filters and checks
376bf19c94SChristoph Hellwig. ./common.rc
386bf19c94SChristoph Hellwig. ./common.filter
396bf19c94SChristoph Hellwig
404e9b25fbSDaniel P. Berrange_supported_fmt raw qcow qcow2 qed vdi vmdk vhdx luks
419cdfa1b3SMORITA Kazutaka_supported_proto generic
426bf19c94SChristoph Hellwig
436bf19c94SChristoph Hellwig
446bf19c94SChristoph Hellwigsize=128M
456bf19c94SChristoph Hellwigpre_offset=127M
466bf19c94SChristoph Hellwigpast_offset=140M
476bf19c94SChristoph Hellwig
486bf19c94SChristoph Hellwig_make_test_img $size
496bf19c94SChristoph Hellwig
506bf19c94SChristoph Hellwigecho
516bf19c94SChristoph Hellwigecho "write before image boundary"
52fef9c191SJeff Cody$QEMU_IO -c "write $pre_offset 1M" "$TEST_IMG" | _filter_qemu_io
536bf19c94SChristoph Hellwig
546bf19c94SChristoph Hellwigecho
556bf19c94SChristoph Hellwigecho "write into image boundary"
56fef9c191SJeff Cody$QEMU_IO -c "write $pre_offset 4M" "$TEST_IMG"
576bf19c94SChristoph Hellwig
586bf19c94SChristoph Hellwigecho
596bf19c94SChristoph Hellwigecho "write at image boundary"
60fef9c191SJeff Cody$QEMU_IO -c "write $size 4096" "$TEST_IMG"
616bf19c94SChristoph Hellwig
626bf19c94SChristoph Hellwigecho
636bf19c94SChristoph Hellwigecho "write past image boundary"
64fef9c191SJeff Cody$QEMU_IO -c "write $past_offset 4096" "$TEST_IMG"
656bf19c94SChristoph Hellwig
666bf19c94SChristoph Hellwigecho
676bf19c94SChristoph Hellwigecho "pwrite past image boundary"
68fef9c191SJeff Cody$QEMU_IO -c "write -p $past_offset 4096" "$TEST_IMG"
696bf19c94SChristoph Hellwig
706bf19c94SChristoph Hellwigecho
716bf19c94SChristoph Hellwigecho "writev past image boundary"
72fef9c191SJeff Cody$QEMU_IO -c "writev $past_offset 4096" "$TEST_IMG"
736bf19c94SChristoph Hellwig
746bf19c94SChristoph Hellwigecho
756bf19c94SChristoph Hellwigecho "read before image boundary"
76fef9c191SJeff Cody$QEMU_IO -c "read $pre_offset 1M" "$TEST_IMG" | _filter_qemu_io
776bf19c94SChristoph Hellwig
786bf19c94SChristoph Hellwigecho
796bf19c94SChristoph Hellwigecho "read into image boundary"
80fef9c191SJeff Cody$QEMU_IO -c "read $pre_offset 4M" "$TEST_IMG"
816bf19c94SChristoph Hellwig
826bf19c94SChristoph Hellwigecho
836bf19c94SChristoph Hellwigecho "read at image boundary"
84fef9c191SJeff Cody$QEMU_IO -c "read $size 4096" "$TEST_IMG"
856bf19c94SChristoph Hellwig
866bf19c94SChristoph Hellwigecho
876bf19c94SChristoph Hellwigecho "read past image boundary"
88fef9c191SJeff Cody$QEMU_IO -c "read $past_offset 4096" "$TEST_IMG"
896bf19c94SChristoph Hellwig
906bf19c94SChristoph Hellwigecho
916bf19c94SChristoph Hellwigecho "pread past image boundary"
92fef9c191SJeff Cody$QEMU_IO -c "read -p $past_offset 4096" "$TEST_IMG"
936bf19c94SChristoph Hellwig
946bf19c94SChristoph Hellwigecho
956bf19c94SChristoph Hellwigecho "readv past image boundary"
96fef9c191SJeff Cody$QEMU_IO -c "readv $past_offset 4096" "$TEST_IMG"
976bf19c94SChristoph Hellwig
986bf19c94SChristoph Hellwig
996bf19c94SChristoph Hellwig# success, all done
1006bf19c94SChristoph Hellwigecho "*** done"
1016bf19c94SChristoph Hellwigrm -f $seq.full
1026bf19c94SChristoph Hellwigstatus=0
103