cirrus: fix off-by-one in cirrus_bitblt_rop_bkwd_transp_*_16
[qemu.git] / tests / qemu-iotests / 172
1 #!/bin/bash
2 #
3 # Test floppy configuration
4 #
5 # Copyright (C) 2016 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 owner=kwolf@redhat.com
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 status=1        # failure is the default!
29
30 _cleanup()
31 {
32         _cleanup_test_img
33 }
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39
40 _supported_fmt qcow2
41 _supported_proto file
42 _supported_os Linux
43
44 if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
45     _notrun "Requires a PC machine"
46 fi
47
48 function do_run_qemu()
49 {
50     (
51         if ! test -t 0; then
52             while read cmd; do
53                 echo $cmd
54             done
55         fi
56         echo quit
57     ) | $QEMU -nographic -monitor stdio -serial none "$@"
58     echo
59 }
60
61 function check_floppy_qtree()
62 {
63     echo
64     echo Testing: "$@" | _filter_testdir
65
66     # QEMU_OPTIONS contains -nodefaults, we don't want that here because the
67     # defaults are part of what should be checked here.
68     #
69     # Apply the sed filter to stdout only, but keep the stderr output and
70     # filter the qemu program name in it.
71     echo "info qtree" |
72     (QEMU_OPTIONS="" do_run_qemu "$@" |
73         sed -ne '/^          dev: isa-fdc/,/^          dev:/{x;p}' ) 2>&1 |
74     _filter_win32 | _filter_qemu
75 }
76
77 function check_cache_mode()
78 {
79     echo "info block none0" |
80     QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
81     _filter_win32 | _filter_qemu | grep "Cache mode"
82 }
83
84
85 size=720k
86
87 _make_test_img $size
88
89 # Default drive semantics:
90 #
91 # By default you get a single empty floppy drive. You can override it with
92 # -drive and using the same index, but if you use -drive to add a floppy to a
93 # different index, you get both of them. However, as soon as you use any
94 # '-device floppy', even to a different slot, the default drive is disabled.
95
96 echo
97 echo
98 echo === Default ===
99
100 check_floppy_qtree
101
102 echo
103 echo
104 echo === Using -fda/-fdb options ===
105
106 check_floppy_qtree -fda "$TEST_IMG"
107 check_floppy_qtree -fdb "$TEST_IMG"
108 check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG"
109
110
111 echo
112 echo
113 echo === Using -drive options ===
114
115 check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
116 check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
117 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG",index=1
118
119 echo
120 echo
121 echo === Using -drive if=none and -global ===
122
123 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
124 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
125 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
126                    -global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
127
128 echo
129 echo
130 echo === Using -drive if=none and -device ===
131
132 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
133 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
134 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
135                    -device floppy,drive=none0 -device floppy,drive=none1,unit=1
136
137 echo
138 echo
139 echo === Mixing -fdX and -global ===
140
141 # Working
142 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
143 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
144
145 # Conflicting (-fdX wins)
146 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
147 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
148
149 echo
150 echo
151 echo === Mixing -fdX and -device ===
152
153 # Working
154 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
155 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
156
157 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
158 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
159
160 # Conflicting
161 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
162 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
163
164 echo
165 echo
166 echo === Mixing -drive and -device ===
167
168 # Working
169 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
170 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
171
172 # Conflicting
173 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=0
174
175 echo
176 echo
177 echo === Mixing -global and -device ===
178
179 # Working
180 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
181                    -global isa-fdc.driveA=none0 -device floppy,drive=none1
182 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
183                    -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
184
185 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
186                    -global isa-fdc.driveB=none0 -device floppy,drive=none1
187 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
188                    -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
189
190 # Conflicting
191 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
192                    -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
193 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG" \
194                    -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
195
196 echo
197 echo
198 echo === Too many floppy drives ===
199
200 # Working
201 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
202                    -drive if=none,file="$TEST_IMG" \
203                    -drive if=none,file="$TEST_IMG" \
204                    -global isa-fdc.driveB=none0 \
205                    -device floppy,drive=none1
206
207 echo
208 echo
209 echo === Creating an empty drive with anonymous BB ===
210
211 check_floppy_qtree -device floppy
212 check_floppy_qtree -device floppy,drive-type=120
213 check_floppy_qtree -device floppy,drive-type=144
214 check_floppy_qtree -device floppy,drive-type=288
215
216 echo
217 echo
218 echo === Try passing different drive size with image ===
219
220 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
221 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
222
223 echo
224 echo
225 echo === Try passing different block sizes ===
226
227 # Explicitly setting the default is okay
228 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
229 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
230
231 # Changing it is not
232 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
233 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
234
235 echo
236 echo
237 echo === Writethrough caching ===
238
239 check_cache_mode -device floppy,drive=none0
240 check_cache_mode -device floppy,drive=none0,write-cache=on
241 check_cache_mode -device floppy,drive=none0,write-cache=off
242
243 # success, all done
244 echo "*** done"
245 rm -f $seq.full
246 status=0