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