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