xref: /openbmc/qemu/tests/qemu-iotests/187 (revision 0e324626)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto
3ea22b7a2SKevin Wolf#
4ea22b7a2SKevin Wolf# Test switching between read-only and read-write
5ea22b7a2SKevin Wolf#
6ea22b7a2SKevin Wolf# Copyright (C) 2017 Red Hat, Inc.
7ea22b7a2SKevin Wolf#
8ea22b7a2SKevin Wolf# This program is free software; you can redistribute it and/or modify
9ea22b7a2SKevin Wolf# it under the terms of the GNU General Public License as published by
10ea22b7a2SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
11ea22b7a2SKevin Wolf# (at your option) any later version.
12ea22b7a2SKevin Wolf#
13ea22b7a2SKevin Wolf# This program is distributed in the hope that it will be useful,
14ea22b7a2SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
15ea22b7a2SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16ea22b7a2SKevin Wolf# GNU General Public License for more details.
17ea22b7a2SKevin Wolf#
18ea22b7a2SKevin Wolf# You should have received a copy of the GNU General Public License
19ea22b7a2SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20ea22b7a2SKevin Wolf#
21ea22b7a2SKevin Wolf
22ea22b7a2SKevin Wolf# creator
23ea22b7a2SKevin Wolfowner=kwolf@redhat.com
24ea22b7a2SKevin Wolf
25ea22b7a2SKevin Wolfseq=`basename $0`
26ea22b7a2SKevin Wolfecho "QA output created by $seq"
27ea22b7a2SKevin Wolf
28ea22b7a2SKevin Wolfstatus=1	# failure is the default!
29ea22b7a2SKevin Wolf
30ea22b7a2SKevin Wolf_cleanup()
31ea22b7a2SKevin Wolf{
32ea22b7a2SKevin Wolf    _cleanup_test_img
33f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.2"
34f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.3"
35ea22b7a2SKevin Wolf}
36ea22b7a2SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
37ea22b7a2SKevin Wolf
38ea22b7a2SKevin Wolf# get standard environment, filters and checks
39ea22b7a2SKevin Wolf. ./common.rc
40ea22b7a2SKevin Wolf. ./common.filter
41ea22b7a2SKevin Wolf
42ea22b7a2SKevin Wolf_supported_fmt qcow2
4357284d2aSMax Reitz_supported_proto file fuse
44ea22b7a2SKevin Wolf
45ea22b7a2SKevin Wolfsize=64M
46ea22b7a2SKevin Wolf_make_test_img $size
47ea22b7a2SKevin Wolf
48ea22b7a2SKevin Wolfecho
49ea22b7a2SKevin Wolfecho "Start from read-only"
50ea22b7a2SKevin Wolfecho
51ea22b7a2SKevin Wolf
52ea22b7a2SKevin Wolf$QEMU_IO -r -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
53ea22b7a2SKevin Wolf$QEMU_IO -r -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
54ea22b7a2SKevin Wolf$QEMU_IO -r -c 'reopen -w' -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
55ea22b7a2SKevin Wolf
56ea22b7a2SKevin Wolfecho
57ea22b7a2SKevin Wolfecho "Start from read-write"
58ea22b7a2SKevin Wolfecho
59ea22b7a2SKevin Wolf
60ea22b7a2SKevin Wolf$QEMU_IO -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
61ea22b7a2SKevin Wolf$QEMU_IO -c 'reopen -r' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
62ea22b7a2SKevin Wolf$QEMU_IO -c 'reopen -r' -c 'reopen -w' -c 'write 0 64k' $TEST_IMG | _filter_qemu_io
63ea22b7a2SKevin Wolf
64ea22b7a2SKevin Wolf
65ea22b7a2SKevin Wolf# success, all done
66ea22b7a2SKevin Wolfecho "*** done"
67ea22b7a2SKevin Wolfrm -f $seq.full
68ea22b7a2SKevin Wolfstatus=0
69