Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2019-11-04-tag' into staging
[qemu/ar7.git] / tests / qemu-iotests / 232
blob65b0e420632bddd01a6bcdc5c503e392319af278
1 #!/usr/bin/env bash
3 # Test for auto-read-only
5 # Copyright (C) 2018 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 _cleanup()
31 _cleanup_test_img
32 rm -f $TEST_IMG.[01234]
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 _supported_fmt generic
41 _supported_proto file
42 _supported_os Linux
44 do_run_qemu()
46 echo Testing: "$@"
48 if ! test -t 0; then
49 while read cmd; do
50 echo $cmd
51 done
53 echo quit
54 ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
55 echo
58 run_qemu()
60 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
61 _filter_generated_node_ids | _filter_imgfmt
64 run_qemu_info_block()
66 echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
69 size=128M
71 _make_test_img $size
73 if [ -n "$TEST_IMG_FILE" ]; then
74 TEST_IMG=$TEST_IMG_FILE
77 chmod a-w $TEST_IMG
78 (echo test > $TEST_IMG) 2>/dev/null && \
79 _notrun "Readonly attribute is ignored, probably you run this test as" \
80 "root, which is unsupported."
81 chmod a+w $TEST_IMG
83 echo
84 echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
85 echo
87 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
88 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
89 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
90 echo
91 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
92 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
93 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
94 echo
95 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
96 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
97 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
99 echo
100 echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
101 echo
103 chmod a-w $TEST_IMG
105 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
106 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
107 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
108 echo
109 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
110 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
111 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
112 echo
113 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
114 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
115 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
117 echo
118 echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
119 echo
121 chmod a+w $TEST_IMG
123 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
124 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
125 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
126 echo
127 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
128 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
129 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
130 echo
131 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
132 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
133 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
135 echo
136 echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
137 echo
139 chmod a-w $TEST_IMG
141 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
142 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
143 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
144 echo
145 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
146 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
147 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
148 echo
149 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
150 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
151 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
153 # success, all done
154 echo "*** done"
155 rm -f $seq.full
156 status=0