111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick 389e91181SJeff Cody# 489e91181SJeff Cody# Test VHDX read/write from a sample image created with Hyper-V 589e91181SJeff Cody# 689e91181SJeff Cody# Copyright (C) 2013 Red Hat, Inc. 789e91181SJeff Cody# 889e91181SJeff Cody# This program is free software; you can redistribute it and/or modify 989e91181SJeff Cody# it under the terms of the GNU General Public License as published by 1089e91181SJeff Cody# the Free Software Foundation; either version 2 of the License, or 1189e91181SJeff Cody# (at your option) any later version. 1289e91181SJeff Cody# 1389e91181SJeff Cody# This program is distributed in the hope that it will be useful, 1489e91181SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of 1589e91181SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1689e91181SJeff Cody# GNU General Public License for more details. 1789e91181SJeff Cody# 1889e91181SJeff Cody# You should have received a copy of the GNU General Public License 1989e91181SJeff Cody# along with this program. If not, see <http://www.gnu.org/licenses/>. 2089e91181SJeff Cody# 2189e91181SJeff Cody 2289e91181SJeff Cody# creator 23*42a5009dSJohn Snowowner=codyprime@gmail.com 2489e91181SJeff Cody 2589e91181SJeff Codyseq=`basename $0` 2689e91181SJeff Codyecho "QA output created by $seq" 2789e91181SJeff Cody 2889e91181SJeff Codystatus=1 # failure is the default! 2989e91181SJeff Cody 3089e91181SJeff Cody_cleanup() 3189e91181SJeff Cody{ 3289e91181SJeff Cody _cleanup_test_img 3389e91181SJeff Cody} 3489e91181SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 3589e91181SJeff Cody 3689e91181SJeff Cody# get standard environment, filters and checks 3789e91181SJeff Cody. ./common.rc 3889e91181SJeff Cody. ./common.filter 3989e91181SJeff Cody 4089e91181SJeff Cody_supported_fmt vhdx 4189e91181SJeff Cody_supported_proto generic 4289e91181SJeff Cody_supported_os Linux 4389e91181SJeff Cody 4489e91181SJeff Cody_use_sample_img iotest-dynamic-1G.vhdx.bz2 4589e91181SJeff Cody 4689e91181SJeff Codyecho 4789e91181SJeff Codyecho "=== Verify pattern 0xa5, 0 - 33MB ===" 4889e91181SJeff Cody$QEMU_IO -r -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io 4989e91181SJeff Cody 5089e91181SJeff Codyecho 5189e91181SJeff Codyecho "=== Verify pattern 0x96, 33M - 66M ===" 5289e91181SJeff Cody$QEMU_IO -r -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io 5389e91181SJeff Cody 5489e91181SJeff Codyecho 5589e91181SJeff Codyecho "=== Verify pattern 0x00, 66M - 1024M ===" 56e35053b2SMax Reitz$QEMU_IO -r -c "read -pP 0x00 66M 62M" \ 57e35053b2SMax Reitz -c "read -pP 0x00 128M 128M" \ 58e35053b2SMax Reitz -c "read -pP 0x00 256M 128M" \ 59e35053b2SMax Reitz -c "read -pP 0x00 384M 128M" \ 60e35053b2SMax Reitz -c "read -pP 0x00 512M 128M" \ 61e35053b2SMax Reitz -c "read -pP 0x00 640M 128M" \ 62e35053b2SMax Reitz -c "read -pP 0x00 768M 128M" \ 63e35053b2SMax Reitz -c "read -pP 0x00 896M 128M" \ 64e35053b2SMax Reitz "$TEST_IMG" | _filter_qemu_io 6589e91181SJeff Cody 66751aec24SJeff Codyecho 67751aec24SJeff Codyecho "=== Verify pattern write, 0xc3 99M-157M ===" 68751aec24SJeff Cody$QEMU_IO -c "write -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io 69751aec24SJeff Cody# first verify we didn't write where we should not have 70751aec24SJeff Cody$QEMU_IO -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io 71751aec24SJeff Cody$QEMU_IO -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io 72751aec24SJeff Cody$QEMU_IO -c "read -pP 0x00 66M 33M" "$TEST_IMG" | _filter_qemu_io 73e35053b2SMax Reitz$QEMU_IO -c "read -pP 0x00 157M 99M" \ 74e35053b2SMax Reitz -c "read -pP 0x00 256M 128M" \ 75e35053b2SMax Reitz -c "read -pP 0x00 384M 128M" \ 76e35053b2SMax Reitz -c "read -pP 0x00 512M 128M" \ 77e35053b2SMax Reitz -c "read -pP 0x00 640M 128M" \ 78e35053b2SMax Reitz -c "read -pP 0x00 768M 128M" \ 79e35053b2SMax Reitz -c "read -pP 0x00 896M 128M" \ 80e35053b2SMax Reitz "$TEST_IMG" | _filter_qemu_io 81751aec24SJeff Cody# now verify what we should have actually written 82751aec24SJeff Cody$QEMU_IO -c "read -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io 83751aec24SJeff Cody 8489e91181SJeff Cody# success, all done 8589e91181SJeff Codyecho "*** done" 8689e91181SJeff Codyrm -f $seq.full 8789e91181SJeff Codystatus=0 88