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