xref: /openbmc/qemu/tests/qemu-iotests/172 (revision 20171739)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2c9bf278bSKevin Wolf#
3c9bf278bSKevin Wolf# Test floppy configuration
4c9bf278bSKevin Wolf#
5c9bf278bSKevin Wolf# Copyright (C) 2016 Red Hat, Inc.
6c9bf278bSKevin Wolf#
7c9bf278bSKevin Wolf# This program is free software; you can redistribute it and/or modify
8c9bf278bSKevin Wolf# it under the terms of the GNU General Public License as published by
9c9bf278bSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10c9bf278bSKevin Wolf# (at your option) any later version.
11c9bf278bSKevin Wolf#
12c9bf278bSKevin Wolf# This program is distributed in the hope that it will be useful,
13c9bf278bSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14c9bf278bSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15c9bf278bSKevin Wolf# GNU General Public License for more details.
16c9bf278bSKevin Wolf#
17c9bf278bSKevin Wolf# You should have received a copy of the GNU General Public License
18c9bf278bSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19c9bf278bSKevin Wolf#
20c9bf278bSKevin Wolf
21c9bf278bSKevin Wolf# creator
22c9bf278bSKevin Wolfowner=kwolf@redhat.com
23c9bf278bSKevin Wolf
24c9bf278bSKevin Wolfseq=`basename $0`
25c9bf278bSKevin Wolfecho "QA output created by $seq"
26c9bf278bSKevin Wolf
27c9bf278bSKevin Wolfstatus=1	# failure is the default!
28c9bf278bSKevin Wolf
29c9bf278bSKevin Wolf_cleanup()
30c9bf278bSKevin Wolf{
31c9bf278bSKevin Wolf    _cleanup_test_img
32f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.2"
33f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.3"
34c9bf278bSKevin Wolf}
35c9bf278bSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36c9bf278bSKevin Wolf
37c9bf278bSKevin Wolf# get standard environment, filters and checks
38c9bf278bSKevin Wolf. ./common.rc
39c9bf278bSKevin Wolf. ./common.filter
40c9bf278bSKevin Wolf
41c9bf278bSKevin Wolf_supported_fmt qcow2
42c9bf278bSKevin Wolf_supported_proto file
43c9bf278bSKevin Wolf_supported_os Linux
44c9bf278bSKevin Wolf
45c9bf278bSKevin Wolfif [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
46c9bf278bSKevin Wolf    _notrun "Requires a PC machine"
47c9bf278bSKevin Wolffi
48c9bf278bSKevin Wolf
498cedcffdSEric Blakedo_run_qemu()
50c9bf278bSKevin Wolf{
51c9bf278bSKevin Wolf    (
52c9bf278bSKevin Wolf        if ! test -t 0; then
53c9bf278bSKevin Wolf            while read cmd; do
54c9bf278bSKevin Wolf                echo $cmd
55c9bf278bSKevin Wolf            done
56c9bf278bSKevin Wolf        fi
57c9bf278bSKevin Wolf        echo quit
58976e8c54SThomas Huth    ) | $QEMU -accel qtest -nographic -monitor stdio -serial none "$@"
59c9bf278bSKevin Wolf    echo
60c9bf278bSKevin Wolf}
61c9bf278bSKevin Wolf
628cedcffdSEric Blakecheck_floppy_qtree()
63c9bf278bSKevin Wolf{
64c9bf278bSKevin Wolf    echo
65c9bf278bSKevin Wolf    echo Testing: "$@" | _filter_testdir
66c9bf278bSKevin Wolf
67c9bf278bSKevin Wolf    # QEMU_OPTIONS contains -nodefaults, we don't want that here because the
68c9bf278bSKevin Wolf    # defaults are part of what should be checked here.
69c9bf278bSKevin Wolf    #
70c9bf278bSKevin Wolf    # Apply the sed filter to stdout only, but keep the stderr output and
71c9bf278bSKevin Wolf    # filter the qemu program name in it.
726a1a6433SMarkus Armbruster    printf "info qtree\ninfo block\n" |
73c9bf278bSKevin Wolf    (QEMU_OPTIONS="" do_run_qemu "$@" |
746a1a6433SMarkus Armbruster	_filter_testdir |_filter_generated_node_ids | _filter_hmp |
756a1a6433SMarkus Armbruster        sed -ne '/^          dev: isa-fdc/,/^          dev:/{x;p};/^[a-z][^ ]* (NODE_NAME):* /,/^(qemu)$/{p}') 2>&1 |
76c9bf278bSKevin Wolf    _filter_win32 | _filter_qemu
77c9bf278bSKevin Wolf}
78c9bf278bSKevin Wolf
798cedcffdSEric Blakecheck_cache_mode()
80c9bf278bSKevin Wolf{
81c9bf278bSKevin Wolf    echo "info block none0" |
82c9bf278bSKevin Wolf    QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" |
83c9bf278bSKevin Wolf    _filter_win32 | _filter_qemu | grep "Cache mode"
84c9bf278bSKevin Wolf}
85c9bf278bSKevin Wolf
86c9bf278bSKevin Wolf
87c9bf278bSKevin Wolfsize=720k
88c9bf278bSKevin Wolf
89c9bf278bSKevin Wolf_make_test_img $size
90c9bf278bSKevin Wolf
917ceb4fc1SFam ZhengTEST_IMG="$TEST_IMG.2" _make_test_img $size
927ceb4fc1SFam ZhengTEST_IMG="$TEST_IMG.3" _make_test_img $size
937ceb4fc1SFam Zheng
94c9bf278bSKevin Wolf# Default drive semantics:
95c9bf278bSKevin Wolf#
96c9bf278bSKevin Wolf# By default you get a single empty floppy drive. You can override it with
97c9bf278bSKevin Wolf# -drive and using the same index, but if you use -drive to add a floppy to a
98c9bf278bSKevin Wolf# different index, you get both of them. However, as soon as you use any
99c9bf278bSKevin Wolf# '-device floppy', even to a different slot, the default drive is disabled.
100c9bf278bSKevin Wolf
101c9bf278bSKevin Wolfecho
102c9bf278bSKevin Wolfecho
103c9bf278bSKevin Wolfecho === Default ===
104c9bf278bSKevin Wolf
105c9bf278bSKevin Wolfcheck_floppy_qtree
106c9bf278bSKevin Wolf
107c9bf278bSKevin Wolfecho
108c9bf278bSKevin Wolfecho
109c9bf278bSKevin Wolfecho === Using -fda/-fdb options ===
110c9bf278bSKevin Wolf
111c9bf278bSKevin Wolfcheck_floppy_qtree -fda "$TEST_IMG"
112c9bf278bSKevin Wolfcheck_floppy_qtree -fdb "$TEST_IMG"
1137ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2"
114*20171739SMarkus Armbrustercheck_floppy_qtree -fdb ""
115c9bf278bSKevin Wolf
116c9bf278bSKevin Wolf
117c9bf278bSKevin Wolfecho
118c9bf278bSKevin Wolfecho
119c9bf278bSKevin Wolfecho === Using -drive options ===
120c9bf278bSKevin Wolf
121c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG"
122c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1
1237ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1
124c9bf278bSKevin Wolf
125c9bf278bSKevin Wolfecho
126c9bf278bSKevin Wolfecho
127c9bf278bSKevin Wolfecho === Using -drive if=none and -global ===
128c9bf278bSKevin Wolf
129c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveA=none0
130c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -global isa-fdc.driveB=none0
1317ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
132c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -global isa-fdc.driveB=none1
133c9bf278bSKevin Wolf
134c9bf278bSKevin Wolfecho
135c9bf278bSKevin Wolfecho
136c9bf278bSKevin Wolfecho === Using -drive if=none and -device ===
137c9bf278bSKevin Wolf
138c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0
139c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1
1407ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
141c9bf278bSKevin Wolf                   -device floppy,drive=none0 -device floppy,drive=none1,unit=1
142c9bf278bSKevin Wolf
143c9bf278bSKevin Wolfecho
144c9bf278bSKevin Wolfecho
145c9bf278bSKevin Wolfecho === Mixing -fdX and -global ===
146c9bf278bSKevin Wolf
147c9bf278bSKevin Wolf# Working
1487ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
1497ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
150c9bf278bSKevin Wolf
151c9bf278bSKevin Wolf# Conflicting (-fdX wins)
1527ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveA=none0
1537ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global isa-fdc.driveB=none0
154c9bf278bSKevin Wolf
155c9bf278bSKevin Wolfecho
156c9bf278bSKevin Wolfecho
157c9bf278bSKevin Wolfecho === Mixing -fdX and -device ===
158c9bf278bSKevin Wolf
159c9bf278bSKevin Wolf# Working
1607ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1617ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
162c9bf278bSKevin Wolf
1637ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1647ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
165c9bf278bSKevin Wolf
166c9bf278bSKevin Wolf# Conflicting
1677ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
1687ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
169c9bf278bSKevin Wolf
170c9bf278bSKevin Wolfecho
171c9bf278bSKevin Wolfecho
172c9bf278bSKevin Wolfecho === Mixing -drive and -device ===
173c9bf278bSKevin Wolf
174c9bf278bSKevin Wolf# Working
1757ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1767ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
177c9bf278bSKevin Wolf
178c9bf278bSKevin Wolf# Conflicting
1797ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
180c9bf278bSKevin Wolf
181c9bf278bSKevin Wolfecho
182c9bf278bSKevin Wolfecho
183c9bf278bSKevin Wolfecho === Mixing -global and -device ===
184c9bf278bSKevin Wolf
185c9bf278bSKevin Wolf# Working
1867ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
187c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -device floppy,drive=none1
1887ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
189c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
190c9bf278bSKevin Wolf
1917ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
192c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 -device floppy,drive=none1
1937ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
194c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
195c9bf278bSKevin Wolf
196c9bf278bSKevin Wolf# Conflicting
1977ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
198c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
1997ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
200c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
201c9bf278bSKevin Wolf
202c9bf278bSKevin Wolfecho
203c9bf278bSKevin Wolfecho
204*20171739SMarkus Armbrusterecho === Attempt to use drive twice ===
205*20171739SMarkus Armbruster
206*20171739SMarkus Armbruster# if=none
207*20171739SMarkus Armbrustercheck_floppy_qtree -drive if=none -device floppy,drive=none0 -device floppy -device floppy,drive=none0
208*20171739SMarkus Armbruster# if=floppy
209*20171739SMarkus Armbrustercheck_floppy_qtree -fda "" -device floppy,drive=floppy0
210*20171739SMarkus Armbruster# default if=floppy (not found, because it's created later)
211*20171739SMarkus Armbrustercheck_floppy_qtree -device floppy,drive=floppy0
212*20171739SMarkus Armbruster
213*20171739SMarkus Armbrusterecho
214*20171739SMarkus Armbrusterecho
215c9bf278bSKevin Wolfecho === Too many floppy drives ===
216c9bf278bSKevin Wolf
217c9bf278bSKevin Wolf# Working
218c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
2197ceb4fc1SFam Zheng                   -drive if=none,file="$TEST_IMG.2" \
2207ceb4fc1SFam Zheng                   -drive if=none,file="$TEST_IMG.3" \
221c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 \
222c9bf278bSKevin Wolf                   -device floppy,drive=none1
223c9bf278bSKevin Wolf
224c9bf278bSKevin Wolfecho
225c9bf278bSKevin Wolfecho
226c9bf278bSKevin Wolfecho === Creating an empty drive with anonymous BB ===
227c9bf278bSKevin Wolf
228c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy
229c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=120
230c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=144
231c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=288
232c9bf278bSKevin Wolf
233c9bf278bSKevin Wolfecho
234c9bf278bSKevin Wolfecho
235c9bf278bSKevin Wolfecho === Try passing different drive size with image ===
236c9bf278bSKevin Wolf
237c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
238c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
239c9bf278bSKevin Wolf
240c9bf278bSKevin Wolfecho
241c9bf278bSKevin Wolfecho
242c9bf278bSKevin Wolfecho === Try passing different block sizes ===
243c9bf278bSKevin Wolf
244c9bf278bSKevin Wolf# Explicitly setting the default is okay
245c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
246c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
247c9bf278bSKevin Wolf
248c9bf278bSKevin Wolf# Changing it is not
249c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
250c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
251c9bf278bSKevin Wolf
252c9bf278bSKevin Wolfecho
253c9bf278bSKevin Wolfecho
254c9bf278bSKevin Wolfecho === Writethrough caching ===
255c9bf278bSKevin Wolf
256c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0
257c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0,write-cache=on
258c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0,write-cache=off
259c9bf278bSKevin Wolf
260c9bf278bSKevin Wolf# success, all done
261c9bf278bSKevin Wolfecho "*** done"
262c9bf278bSKevin Wolfrm -f $seq.full
263c9bf278bSKevin Wolfstatus=0
264