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