xref: /openbmc/qemu/tests/qemu-iotests/172 (revision 6172e067)
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"
11420171739SMarkus 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
151*6172e067SMarkus Armbruster# Conflicting
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
154*6172e067SMarkus Armbruster# Conflicting, -fdX wins
15502b83f7dSMarkus Armbrustercheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global floppy.drive=none0
156c9bf278bSKevin Wolf
157c9bf278bSKevin Wolfecho
158c9bf278bSKevin Wolfecho
159c9bf278bSKevin Wolfecho === Mixing -fdX and -device ===
160c9bf278bSKevin Wolf
161c9bf278bSKevin Wolf# Working
1627ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1637ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
164c9bf278bSKevin Wolf
1657ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1667ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
167c9bf278bSKevin Wolf
168c9bf278bSKevin Wolf# Conflicting
1697ceb4fc1SFam Zhengcheck_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
1707ceb4fc1SFam Zhengcheck_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
171c9bf278bSKevin Wolf
172c9bf278bSKevin Wolfecho
173c9bf278bSKevin Wolfecho
174c9bf278bSKevin Wolfecho === Mixing -drive and -device ===
175c9bf278bSKevin Wolf
176c9bf278bSKevin Wolf# Working
1777ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0
1787ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1
179c9bf278bSKevin Wolf
180c9bf278bSKevin Wolf# Conflicting
1817ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0
182c9bf278bSKevin Wolf
183c9bf278bSKevin Wolfecho
184c9bf278bSKevin Wolfecho
185c9bf278bSKevin Wolfecho === Mixing -global and -device ===
186c9bf278bSKevin Wolf
187c9bf278bSKevin Wolf# Working
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
1907ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
191c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=1
192c9bf278bSKevin Wolf
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
1957ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
196c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=0
19702b83f7dSMarkus Armbrustercheck_floppy_qtree -drive if=none,file="$TEST_IMG" \
19802b83f7dSMarkus Armbruster                   -global floppy.drive=none0 -device floppy,unit=0
199c9bf278bSKevin Wolf
200c9bf278bSKevin Wolf# Conflicting
2017ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
202c9bf278bSKevin Wolf                   -global isa-fdc.driveA=none0 -device floppy,drive=none1,unit=0
2037ceb4fc1SFam Zhengcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
204c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 -device floppy,drive=none1,unit=1
20502b83f7dSMarkus Armbrustercheck_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \
20602b83f7dSMarkus Armbruster                   -global floppy.drive=none0 -device floppy,drive=none1,unit=0
207c9bf278bSKevin Wolf
208c9bf278bSKevin Wolfecho
209c9bf278bSKevin Wolfecho
21020171739SMarkus Armbrusterecho === Attempt to use drive twice ===
21120171739SMarkus Armbruster
21220171739SMarkus Armbruster# if=none
21320171739SMarkus Armbrustercheck_floppy_qtree -drive if=none -device floppy,drive=none0 -device floppy -device floppy,drive=none0
21402b83f7dSMarkus Armbrustercheck_floppy_qtree -drive if=none -global floppy.drive=none0 -device floppy -device floppy
21520171739SMarkus Armbruster# if=floppy
21620171739SMarkus Armbrustercheck_floppy_qtree -fda "" -device floppy,drive=floppy0
21702b83f7dSMarkus Armbrustercheck_floppy_qtree -fda "" -global floppy.drive=floppy0
21820171739SMarkus Armbruster# default if=floppy (not found, because it's created later)
21920171739SMarkus Armbrustercheck_floppy_qtree -device floppy,drive=floppy0
22020171739SMarkus Armbruster
22120171739SMarkus Armbrusterecho
22220171739SMarkus Armbrusterecho
223c9bf278bSKevin Wolfecho === Too many floppy drives ===
224c9bf278bSKevin Wolf
225c9bf278bSKevin Wolf# Working
226c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=floppy,file="$TEST_IMG" \
2277ceb4fc1SFam Zheng                   -drive if=none,file="$TEST_IMG.2" \
2287ceb4fc1SFam Zheng                   -drive if=none,file="$TEST_IMG.3" \
229c9bf278bSKevin Wolf                   -global isa-fdc.driveB=none0 \
230c9bf278bSKevin Wolf                   -device floppy,drive=none1
231c9bf278bSKevin Wolf
232c9bf278bSKevin Wolfecho
233c9bf278bSKevin Wolfecho
234c9bf278bSKevin Wolfecho === Creating an empty drive with anonymous BB ===
235c9bf278bSKevin Wolf
236c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy
237c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=120
238c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=144
239c9bf278bSKevin Wolfcheck_floppy_qtree -device floppy,drive-type=288
240c9bf278bSKevin Wolf
241c9bf278bSKevin Wolfecho
242c9bf278bSKevin Wolfecho
243c9bf278bSKevin Wolfecho === Try passing different drive size with image ===
244c9bf278bSKevin Wolf
245c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120
246c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288
247c9bf278bSKevin Wolf
248c9bf278bSKevin Wolfecho
249c9bf278bSKevin Wolfecho
250c9bf278bSKevin Wolfecho === Try passing different block sizes ===
251c9bf278bSKevin Wolf
252c9bf278bSKevin Wolf# Explicitly setting the default is okay
253c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512
254c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512
255c9bf278bSKevin Wolf
256c9bf278bSKevin Wolf# Changing it is not
257c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096
258c9bf278bSKevin Wolfcheck_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024
259c9bf278bSKevin Wolf
260c9bf278bSKevin Wolfecho
261c9bf278bSKevin Wolfecho
262c9bf278bSKevin Wolfecho === Writethrough caching ===
263c9bf278bSKevin Wolf
264c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0
265c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0,write-cache=on
266c9bf278bSKevin Wolfcheck_cache_mode -device floppy,drive=none0,write-cache=off
267c9bf278bSKevin Wolf
268c9bf278bSKevin Wolf# success, all done
269c9bf278bSKevin Wolfecho "*** done"
270c9bf278bSKevin Wolfrm -f $seq.full
271c9bf278bSKevin Wolfstatus=0
272