]> Git Repo - qemu.git/blame - tests/qemu-iotests/172
iotests: Drop format-specific in _filter_img_info
[qemu.git] / tests / qemu-iotests / 172
CommitLineData
c9bf278b
KW
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[email protected]
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
28status=1 # failure is the default!
29
30_cleanup()
31{
32 _cleanup_test_img
7ceb4fc1
FZ
33 rm -f "$TEST_IMG.2"
34 rm -f "$TEST_IMG.3"
c9bf278b
KW
35}
36trap "_cleanup; exit \$status" 0 1 2 3 15
37
38# get standard environment, filters and checks
39. ./common.rc
40. ./common.filter
41
42_supported_fmt qcow2
43_supported_proto file
44_supported_os Linux
45
46if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
47 _notrun "Requires a PC machine"
48fi
49
50function do_run_qemu()
51{
52 (
53 if ! test -t 0; then
54 while read cmd; do
55 echo $cmd
56 done
57 fi
58 echo quit
05b4cd5d 59 ) | $QEMU -machine accel=qtest -nographic -monitor stdio -serial none "$@"
c9bf278b
KW
60 echo
61}
62
63function check_floppy_qtree()
64{
65 echo
66 echo Testing: "$@" | _filter_testdir
67
68 # QEMU_OPTIONS contains -nodefaults, we don't want that here because the
69 # defaults are part of what should be checked here.
70 #
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
77}
78
79function check_cache_mode()
80{
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"
84}
85
86
87size=720k
88
89_make_test_img $size
90
7ceb4fc1
FZ
91TEST_IMG="$TEST_IMG.2" _make_test_img $size
92TEST_IMG="$TEST_IMG.3" _make_test_img $size
93
c9bf278b
KW
94# Default drive semantics:
95#
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.
100
101echo
102echo
103echo === Default ===
104
105check_floppy_qtree
106
107echo
108echo
109echo === Using -fda/-fdb options ===
110
111check_floppy_qtree -fda "$TEST_IMG"
112check_floppy_qtree -fdb "$TEST_IMG"
7ceb4fc1 113check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2"
c9bf278b
KW
114
115
116echo
117echo
118echo === Using -drive options ===
119
120check_floppy_qtree -drive if=floppy,file="$TEST_IMG"
121check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
7ceb4fc1 122check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1
c9bf278b
KW
123
124echo
125echo
126echo === Using -drive if=none and -global ===
127
128check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
129check_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
7ceb4fc1 130check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b
KW
131 -global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
132
133echo
134echo
135echo === Using -drive if=none and -device ===
136
137check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
138check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
7ceb4fc1 139check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b
KW
140 -device floppy,drive=none0 -device floppy,drive=none1,unit=1
141
142echo
143echo
144echo === Mixing -fdX and -global ===
145
146# Working
7ceb4fc1
FZ
147check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
148check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
c9bf278b
KW
149
150# Conflicting (-fdX wins)
7ceb4fc1
FZ
151check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
152check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
c9bf278b
KW
153
154echo
155echo
156echo === Mixing -fdX and -device ===
157
158# Working
7ceb4fc1
FZ
159check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
160check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
c9bf278b 161
7ceb4fc1
FZ
162check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
163check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
c9bf278b
KW
164
165# Conflicting
7ceb4fc1
FZ
166check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
167check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
c9bf278b
KW
168
169echo
170echo
171echo === Mixing -drive and -device ===
172
173# Working
7ceb4fc1
FZ
174check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
175check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
c9bf278b
KW
176
177# Conflicting
7ceb4fc1 178check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
c9bf278b
KW
179
180echo
181echo
182echo === Mixing -global and -device ===
183
184# Working
7ceb4fc1 185check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b 186 -global isa-fdc.driveA=none0 -device floppy,drive=none1
7ceb4fc1 187check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b
KW
188 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
189
7ceb4fc1 190check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b 191 -global isa-fdc.driveB=none0 -device floppy,drive=none1
7ceb4fc1 192check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b
KW
193 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
194
195# Conflicting
7ceb4fc1 196check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b 197 -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
7ceb4fc1 198check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
c9bf278b
KW
199 -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
200
201echo
202echo
203echo === Too many floppy drives ===
204
205# Working
206check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
7ceb4fc1
FZ
207 -drive if=none,file="$TEST_IMG.2" \
208 -drive if=none,file="$TEST_IMG.3" \
c9bf278b
KW
209 -global isa-fdc.driveB=none0 \
210 -device floppy,drive=none1
211
212echo
213echo
214echo === Creating an empty drive with anonymous BB ===
215
216check_floppy_qtree -device floppy
217check_floppy_qtree -device floppy,drive-type=120
218check_floppy_qtree -device floppy,drive-type=144
219check_floppy_qtree -device floppy,drive-type=288
220
221echo
222echo
223echo === Try passing different drive size with image ===
224
225check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
226check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
227
228echo
229echo
230echo === Try passing different block sizes ===
231
232# Explicitly setting the default is okay
233check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
234check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
235
236# Changing it is not
237check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
238check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
239
240echo
241echo
242echo === Writethrough caching ===
243
244check_cache_mode -device floppy,drive=none0
245check_cache_mode -device floppy,drive=none0,write-cache=on
246check_cache_mode -device floppy,drive=none0,write-cache=off
247
248# success, all done
249echo "*** done"
250rm -f $seq.full
251status=0
This page took 0.15339 seconds and 4 git commands to generate.