xref: /openbmc/qemu/tests/qemu-iotests/064 (revision 11a82d14)
1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Codystatus=1	# failure is the default!
2889e91181SJeff Cody
2989e91181SJeff Cody_cleanup()
3089e91181SJeff Cody{
3189e91181SJeff Cody    _cleanup_test_img
3289e91181SJeff Cody}
3389e91181SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
3489e91181SJeff Cody
3589e91181SJeff Cody# get standard environment, filters and checks
3689e91181SJeff Cody. ./common.rc
3789e91181SJeff Cody. ./common.filter
3889e91181SJeff Cody
3989e91181SJeff Cody_supported_fmt vhdx
4089e91181SJeff Cody_supported_proto generic
4189e91181SJeff Cody_supported_os Linux
4289e91181SJeff Cody
4389e91181SJeff Cody_use_sample_img iotest-dynamic-1G.vhdx.bz2
4489e91181SJeff Cody
4589e91181SJeff Codyecho
4689e91181SJeff Codyecho "=== Verify pattern 0xa5, 0 - 33MB ==="
4789e91181SJeff Cody$QEMU_IO -r -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io
4889e91181SJeff Cody
4989e91181SJeff Codyecho
5089e91181SJeff Codyecho "=== Verify pattern 0x96, 33M - 66M ==="
5189e91181SJeff Cody$QEMU_IO -r -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io
5289e91181SJeff Cody
5389e91181SJeff Codyecho
5489e91181SJeff Codyecho "=== Verify pattern 0x00, 66M - 1024M ==="
55e35053b2SMax Reitz$QEMU_IO -r -c "read -pP 0x00 66M 62M" \
56e35053b2SMax Reitz            -c "read -pP 0x00 128M 128M" \
57e35053b2SMax Reitz            -c "read -pP 0x00 256M 128M" \
58e35053b2SMax Reitz            -c "read -pP 0x00 384M 128M" \
59e35053b2SMax Reitz            -c "read -pP 0x00 512M 128M" \
60e35053b2SMax Reitz            -c "read -pP 0x00 640M 128M" \
61e35053b2SMax Reitz            -c "read -pP 0x00 768M 128M" \
62e35053b2SMax Reitz            -c "read -pP 0x00 896M 128M" \
63e35053b2SMax Reitz            "$TEST_IMG" | _filter_qemu_io
6489e91181SJeff Cody
65751aec24SJeff Codyecho
66751aec24SJeff Codyecho "=== Verify pattern write, 0xc3 99M-157M ==="
67751aec24SJeff Cody$QEMU_IO -c "write -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io
68751aec24SJeff Cody# first verify we didn't write where we should not have
69751aec24SJeff Cody$QEMU_IO -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io
70751aec24SJeff Cody$QEMU_IO -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io
71751aec24SJeff Cody$QEMU_IO -c "read -pP 0x00 66M 33M" "$TEST_IMG" | _filter_qemu_io
72e35053b2SMax Reitz$QEMU_IO -c "read -pP 0x00 157M 99M" \
73e35053b2SMax Reitz         -c "read -pP 0x00 256M 128M" \
74e35053b2SMax Reitz         -c "read -pP 0x00 384M 128M" \
75e35053b2SMax Reitz         -c "read -pP 0x00 512M 128M" \
76e35053b2SMax Reitz         -c "read -pP 0x00 640M 128M" \
77e35053b2SMax Reitz         -c "read -pP 0x00 768M 128M" \
78e35053b2SMax Reitz         -c "read -pP 0x00 896M 128M" \
79e35053b2SMax Reitz         "$TEST_IMG" | _filter_qemu_io
80751aec24SJeff Cody# now verify what we should have actually written
81751aec24SJeff Cody$QEMU_IO -c "read -pP 0xc3 99M 58M" "$TEST_IMG" | _filter_qemu_io
82751aec24SJeff Cody
8389e91181SJeff Cody# success, all done
8489e91181SJeff Codyecho "*** done"
8589e91181SJeff Codyrm -f $seq.full
8689e91181SJeff Codystatus=0
87