xref: /openbmc/qemu/tests/qemu-iotests/064 (revision 751aec24)
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 ==="
5789e91181SJeff Cody$QEMU_IO -r -c "read -pP 0x00 66M 958M" "$TEST_IMG" | _filter_qemu_io
5889e91181SJeff Cody
59*751aec24SJeff Codyecho
60*751aec24SJeff Codyecho "=== Verify pattern write, 0xc3 99M-157M ==="
61*751aec24SJeff Cody$QEMU_IO -c "write -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io
62*751aec24SJeff Cody# first verify we didn't write where we should not have
63*751aec24SJeff Cody$QEMU_IO -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io
64*751aec24SJeff Cody$QEMU_IO -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io
65*751aec24SJeff Cody$QEMU_IO -c "read -pP 0x00 66M 33M" "$TEST_IMG" | _filter_qemu_io
66*751aec24SJeff Cody$QEMU_IO -c "read -pP 0x00 157MM 867MM" "$TEST_IMG" | _filter_qemu_io
67*751aec24SJeff Cody# now verify what we should have actually written
68*751aec24SJeff Cody$QEMU_IO -c "read -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io
69*751aec24SJeff Cody
7089e91181SJeff Cody# success, all done
7189e91181SJeff Codyecho "*** done"
7289e91181SJeff Codyrm -f $seq.full
7389e91181SJeff Codystatus=0
74