pc-dimm: pass in the machine and to the MemoryHotplugState
[qemu/ar7.git] / tests / qemu-iotests / 172
blob02c5f79bab8582fcf5212148f32314012b922463
1 #!/bin/bash
3 # Test floppy configuration
5 # Copyright (C) 2016 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 here=`pwd`
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 rm -f "$TEST_IMG.2"
34 rm -f "$TEST_IMG.3"
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 qcow2
43 _supported_proto file
44 _supported_os Linux
46 if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
47 _notrun "Requires a PC machine"
50 function do_run_qemu()
53 if ! test -t 0; then
54 while read cmd; do
55 echo $cmd
56 done
58 echo quit
59 ) | $QEMU -machine accel=qtest -nographic -monitor stdio -serial none "$@"
60 echo
63 function check_floppy_qtree()
65 echo
66 echo Testing: "$@" | _filter_testdir
68 # QEMU_OPTIONS contains -nodefaults, we don't want that here because the
69 # defaults are part of what should be checked here.
71 # Apply the sed filter to stdout only, but keep the stderr output and
72 # filter the qemu program name in it.
73 echo "info qtree" |
74 (QEMU_OPTIONS="" do_run_qemu "$@" |
75 sed -ne '/^ dev: isa-fdc/,/^ dev:/{x;p}' ) 2>&1 |
76 _filter_win32 | _filter_qemu
79 function check_cache_mode()
81 echo "info block none0" |
82 QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
83 _filter_win32 | _filter_qemu | grep "Cache mode"
87 size=720k
89 _make_test_img $size
91 TEST_IMG="$TEST_IMG.2" _make_test_img $size
92 TEST_IMG="$TEST_IMG.3" _make_test_img $size
94 # Default drive semantics:
96 # By default you get a single empty floppy drive. You can override it with
97 # -drive and using the same index, but if you use -drive to add a floppy to a
98 # different index, you get both of them. However, as soon as you use any
99 # '-device floppy', even to a different slot, the default drive is disabled.
101 echo
102 echo
103 echo === Default ===
105 check_floppy_qtree
107 echo
108 echo
109 echo === Using -fda/-fdb options ===
111 check_floppy_qtree -fda "$TEST_IMG"
112 check_floppy_qtree -fdb "$TEST_IMG"
113 check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2"
116 echo
117 echo
118 echo === Using -drive options ===
120 check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
121 check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
122 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1
124 echo
125 echo
126 echo === Using -drive if=none and -global ===
128 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
129 check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
130 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
131 -global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
133 echo
134 echo
135 echo === Using -drive if=none and -device ===
137 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
138 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
139 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
140 -device floppy,drive=none0 -device floppy,drive=none1,unit=1
142 echo
143 echo
144 echo === Mixing -fdX and -global ===
146 # Working
147 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
148 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
150 # Conflicting (-fdX wins)
151 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
152 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
154 echo
155 echo
156 echo === Mixing -fdX and -device ===
158 # Working
159 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
160 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
162 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
163 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
165 # Conflicting
166 check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
167 check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
169 echo
170 echo
171 echo === Mixing -drive and -device ===
173 # Working
174 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
175 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
177 # Conflicting
178 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
180 echo
181 echo
182 echo === Mixing -global and -device ===
184 # Working
185 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
186 -global isa-fdc.driveA=none0 -device floppy,drive=none1
187 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
188 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
190 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
191 -global isa-fdc.driveB=none0 -device floppy,drive=none1
192 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
193 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
195 # Conflicting
196 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
197 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
198 check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
199 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
201 echo
202 echo
203 echo === Too many floppy drives ===
205 # Working
206 check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
207 -drive if=none,file="$TEST_IMG.2" \
208 -drive if=none,file="$TEST_IMG.3" \
209 -global isa-fdc.driveB=none0 \
210 -device floppy,drive=none1
212 echo
213 echo
214 echo === Creating an empty drive with anonymous BB ===
216 check_floppy_qtree -device floppy
217 check_floppy_qtree -device floppy,drive-type=120
218 check_floppy_qtree -device floppy,drive-type=144
219 check_floppy_qtree -device floppy,drive-type=288
221 echo
222 echo
223 echo === Try passing different drive size with image ===
225 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
226 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
228 echo
229 echo
230 echo === Try passing different block sizes ===
232 # Explicitly setting the default is okay
233 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
234 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
236 # Changing it is not
237 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
238 check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
240 echo
241 echo
242 echo === Writethrough caching ===
244 check_cache_mode -device floppy,drive=none0
245 check_cache_mode -device floppy,drive=none0,write-cache=on
246 check_cache_mode -device floppy,drive=none0,write-cache=off
248 # success, all done
249 echo "*** done"
250 rm -f $seq.full
251 status=0