qapi/error: Check format string argument in error_*prepend()
[qemu/armbru.git] / tests / qemu-iotests / 232
blob685356ac3bae6da1bb80a3365373abf53f043872
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 for img in "$TEST_IMG".[01234]; do
33 _rm_test_img "$img"
34 done
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
42 _supported_fmt generic
43 _supported_proto file
44 _supported_os Linux
46 do_run_qemu()
48 echo Testing: "$@"
50 if ! test -t 0; then
51 while read cmd; do
52 echo $cmd
53 done
55 echo quit
56 ) | $QEMU -nographic -monitor stdio -nodefaults "$@"
57 echo
60 run_qemu()
62 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_hmp |
63 _filter_generated_node_ids | _filter_imgfmt
66 run_qemu_info_block()
68 echo "info block -n" | run_qemu "$@" | grep -e "(file" -e "QEMU_PROG"
71 size=128M
73 _make_test_img $size
75 if [ -n "$TEST_IMG_FILE" ]; then
76 TEST_IMG=$TEST_IMG_FILE
79 chmod a-w $TEST_IMG
80 (echo test > $TEST_IMG) 2>/dev/null && \
81 _notrun "Readonly attribute is ignored, probably you run this test as" \
82 "root, which is unsupported."
83 chmod a+w $TEST_IMG
85 echo
86 echo "=== -drive with read-write image: read-only/auto-read-only combinations ==="
87 echo
89 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
90 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
91 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
92 echo
93 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
94 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
95 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
96 echo
97 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
98 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
99 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
101 echo
102 echo "=== -drive with read-only image: read-only/auto-read-only combinations ==="
103 echo
105 chmod a-w $TEST_IMG
107 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=off
108 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on,auto-read-only=on
109 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=on
110 echo
111 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=off
112 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off,auto-read-only=on
113 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,read-only=off
114 echo
115 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=off
116 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none,auto-read-only=on
117 run_qemu_info_block -drive driver=file,file="$TEST_IMG",if=none
119 echo
120 echo "=== -blockdev with read-write image: read-only/auto-read-only combinations ==="
121 echo
123 chmod a+w $TEST_IMG
125 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
126 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
127 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
128 echo
129 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
130 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
131 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
132 echo
133 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
134 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
135 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
137 echo
138 echo "=== -blockdev with read-only image: read-only/auto-read-only combinations ==="
139 echo
141 chmod a-w $TEST_IMG
143 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=off
144 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on,auto-read-only=on
145 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=on
146 echo
147 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=off
148 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off,auto-read-only=on
149 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,read-only=off
150 echo
151 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=off
152 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0,auto-read-only=on
153 run_qemu_info_block -blockdev driver=file,filename="$TEST_IMG",node-name=node0
155 # success, all done
156 echo "*** done"
157 rm -f $seq.full
158 status=0