111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 26bf19c94SChristoph Hellwig# 36bf19c94SChristoph Hellwig# Test simple read/write using plain bdrv_pread/bdrv_pwrite 46bf19c94SChristoph Hellwig# 56bf19c94SChristoph Hellwig# Copyright (C) 2009 Red Hat, Inc. 66bf19c94SChristoph Hellwig# 76bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or modify 86bf19c94SChristoph Hellwig# it under the terms of the GNU General Public License as published by 96bf19c94SChristoph Hellwig# the Free Software Foundation; either version 2 of the License, or 106bf19c94SChristoph Hellwig# (at your option) any later version. 116bf19c94SChristoph Hellwig# 126bf19c94SChristoph Hellwig# This program is distributed in the hope that it will be useful, 136bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of 146bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 156bf19c94SChristoph Hellwig# GNU General Public License for more details. 166bf19c94SChristoph Hellwig# 176bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License 18e8c212d6SChristoph Hellwig# along with this program. If not, see <http://www.gnu.org/licenses/>. 196bf19c94SChristoph Hellwig# 206bf19c94SChristoph Hellwig 216bf19c94SChristoph Hellwig# creator 226bf19c94SChristoph Hellwigowner=hch@lst.de 236bf19c94SChristoph Hellwig 246bf19c94SChristoph Hellwigseq=`basename $0` 256bf19c94SChristoph Hellwigecho "QA output created by $seq" 266bf19c94SChristoph Hellwig 276bf19c94SChristoph Hellwigstatus=1 # failure is the default! 286bf19c94SChristoph Hellwig 296bf19c94SChristoph Hellwig_cleanup() 306bf19c94SChristoph Hellwig{ 316bf19c94SChristoph Hellwig _cleanup_test_img 326bf19c94SChristoph Hellwig} 336bf19c94SChristoph Hellwigtrap "_cleanup; exit \$status" 0 1 2 3 15 346bf19c94SChristoph Hellwig 356bf19c94SChristoph Hellwig# get standard environment, filters and checks 366bf19c94SChristoph Hellwig. ./common.rc 376bf19c94SChristoph Hellwig. ./common.filter 386bf19c94SChristoph Hellwig 396bf19c94SChristoph Hellwig_supported_fmt generic 409cdfa1b3SMORITA Kazutaka_supported_proto generic 41*325dd915SMax Reitz_unsupported_imgopts "subformat=streamOptimized" 426bf19c94SChristoph Hellwig 436bf19c94SChristoph Hellwig 446bf19c94SChristoph Hellwigsize=128M 456bf19c94SChristoph Hellwig_make_test_img $size 466bf19c94SChristoph Hellwig 476bf19c94SChristoph Hellwigecho 486bf19c94SChristoph Hellwigecho "== reading whole image ==" 49fef9c191SJeff Cody$QEMU_IO -c "read -p 0 $size" "$TEST_IMG" | _filter_qemu_io 506bf19c94SChristoph Hellwig 516bf19c94SChristoph Hellwigecho 526bf19c94SChristoph Hellwigecho "== rewriting whole image ==" 53fef9c191SJeff Cody$QEMU_IO -c "write -pP 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io 546bf19c94SChristoph Hellwig 556bf19c94SChristoph Hellwigecho 566bf19c94SChristoph Hellwigecho "== verify pattern ==" 57fef9c191SJeff Cody$QEMU_IO -c "read -pP 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io 586bf19c94SChristoph Hellwig 596bf19c94SChristoph Hellwigecho 606bf19c94SChristoph Hellwigecho "unaligned pwrite" 61fef9c191SJeff Cody$QEMU_IO -c 'write -pP 0xab 66 42' "$TEST_IMG" | _filter_qemu_io 62fef9c191SJeff Cody$QEMU_IO -c 'write -pP 0xac 512 288' "$TEST_IMG" | _filter_qemu_io 63fef9c191SJeff Cody$QEMU_IO -c 'write -pP 0xad 800 224' "$TEST_IMG" | _filter_qemu_io 64fef9c191SJeff Cody$QEMU_IO -c 'write -pP 0xae 66000 128k' "$TEST_IMG" | _filter_qemu_io 65fef9c191SJeff Cody$QEMU_IO -c 'write -pP 0xaf 256k 42' "$TEST_IMG" | _filter_qemu_io 666bf19c94SChristoph Hellwig 676bf19c94SChristoph Hellwigecho 686bf19c94SChristoph Hellwigecho "verify pattern" 69fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xa 0 66' "$TEST_IMG" | _filter_qemu_io 70fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xab 66 42' "$TEST_IMG" | _filter_qemu_io 71fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xa 108 404' "$TEST_IMG" | _filter_qemu_io 72fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xac 512 288' "$TEST_IMG" | _filter_qemu_io 73fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xad 800 224' "$TEST_IMG" | _filter_qemu_io 74fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xa 1k 64976' "$TEST_IMG" | _filter_qemu_io 75fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xae 66000 128k' "$TEST_IMG" | _filter_qemu_io 76fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xa 197072 65072' "$TEST_IMG" | _filter_qemu_io 77fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xaf 256k 42' "$TEST_IMG" | _filter_qemu_io 78fef9c191SJeff Cody$QEMU_IO -c 'read -pP 0xa 262186 470' "$TEST_IMG" | _filter_qemu_io 796bf19c94SChristoph Hellwig 806bf19c94SChristoph Hellwig# success, all done 816bf19c94SChristoph Hellwigecho "*** done" 826bf19c94SChristoph Hellwigrm -f $seq.full 836bf19c94SChristoph Hellwigstatus=0 84