xref: /openbmc/qemu/tests/qemu-iotests/052 (revision 755c5fe79d88717600356d3edf04835bba43dcb6)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2f95e26ddSStefan Hajnoczi#
3f95e26ddSStefan Hajnoczi# Test bdrv_read/bdrv_write using BDRV_O_SNAPSHOT
4f95e26ddSStefan Hajnoczi#
5f95e26ddSStefan Hajnoczi# Copyright (C) 2013 Red Hat, Inc.
6f95e26ddSStefan Hajnoczi#
7f95e26ddSStefan Hajnoczi# This program is free software; you can redistribute it and/or modify
8f95e26ddSStefan Hajnoczi# it under the terms of the GNU General Public License as published by
9f95e26ddSStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or
10f95e26ddSStefan Hajnoczi# (at your option) any later version.
11f95e26ddSStefan Hajnoczi#
12f95e26ddSStefan Hajnoczi# This program is distributed in the hope that it will be useful,
13f95e26ddSStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of
14f95e26ddSStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f95e26ddSStefan Hajnoczi# GNU General Public License for more details.
16f95e26ddSStefan Hajnoczi#
17f95e26ddSStefan Hajnoczi# You should have received a copy of the GNU General Public License
18f95e26ddSStefan Hajnoczi# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19f95e26ddSStefan Hajnoczi#
20f95e26ddSStefan Hajnoczi
21f95e26ddSStefan Hajnoczi# creator
22f95e26ddSStefan Hajnocziowner=stefanha@redhat.com
23f95e26ddSStefan Hajnoczi
24f95e26ddSStefan Hajnocziseq=`basename $0`
25f95e26ddSStefan Hajnocziecho "QA output created by $seq"
26f95e26ddSStefan Hajnoczi
27f95e26ddSStefan Hajnoczistatus=1	# failure is the default!
28f95e26ddSStefan Hajnoczi
29f95e26ddSStefan Hajnoczi_cleanup()
30f95e26ddSStefan Hajnoczi{
31f95e26ddSStefan Hajnoczi	_cleanup_test_img
32f95e26ddSStefan Hajnoczi}
33f95e26ddSStefan Hajnoczitrap "_cleanup; exit \$status" 0 1 2 3 15
34f95e26ddSStefan Hajnoczi
35f95e26ddSStefan Hajnoczi# get standard environment, filters and checks
36f95e26ddSStefan Hajnoczi. ./common.rc
37f95e26ddSStefan Hajnoczi. ./common.filter
38f95e26ddSStefan Hajnoczi
39f95e26ddSStefan Hajnoczi_supported_fmt generic
401f7bf7d0SPeter Lieven_supported_proto file
41cf77b2d2SKevin Wolf
42cf77b2d2SKevin Wolf# Don't do O_DIRECT on tmpfs
43*755c5fe7SNir Soffer_supported_cache_modes writeback writethrough unsafe
44f95e26ddSStefan Hajnoczi
45f95e26ddSStefan Hajnoczisize=128M
46f95e26ddSStefan Hajnoczi_make_test_img $size
47f95e26ddSStefan Hajnoczi
48f95e26ddSStefan Hajnocziecho
494e9b25fbSDaniel P. Berrangeecho "== initializing whole image =="
504e9b25fbSDaniel P. Berrange$QEMU_IO -c "write -z 0 $size" "$TEST_IMG" | _filter_qemu_io
514e9b25fbSDaniel P. Berrange
524e9b25fbSDaniel P. Berrangeecho
53f95e26ddSStefan Hajnocziecho "== reading whole image =="
54fef9c191SJeff Cody$QEMU_IO -s -c "read 0 $size" "$TEST_IMG" | _filter_qemu_io
55f95e26ddSStefan Hajnoczi
56f95e26ddSStefan Hajnocziecho
57f95e26ddSStefan Hajnocziecho "== writing whole image does not modify image =="
58fef9c191SJeff Cody$QEMU_IO -s -c "write -P 0xa 0 $size" "$TEST_IMG" | _filter_qemu_io
59fef9c191SJeff Cody$QEMU_IO -c "read -P 0 0 $size" "$TEST_IMG" | _filter_qemu_io
60f95e26ddSStefan Hajnoczi
61f95e26ddSStefan Hajnoczi# success, all done
62f95e26ddSStefan Hajnocziecho "*** done"
63f95e26ddSStefan Hajnoczirm -f $seq.full
64f95e26ddSStefan Hajnoczistatus=0
65