Philippe Mathieu-Daudé | 11a82d1 | 2019-03-07 15:58:38 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Vladimir Sementsov-Ogievskiy | 9dd003a | 2021-01-16 16:44:19 +0300 | [diff] [blame] | 2 | # group: auto |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 3 | # |
| 4 | # Test floppy configuration |
| 5 | # |
| 6 | # Copyright (C) 2016 Red Hat, Inc. |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # This program is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | # |
| 21 | |
| 22 | # creator |
| 23 | owner=kwolf@redhat.com |
| 24 | |
| 25 | seq=`basename $0` |
| 26 | echo "QA output created by $seq" |
| 27 | |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 28 | status=1 # failure is the default! |
| 29 | |
| 30 | _cleanup() |
| 31 | { |
Max Reitz | f91ecbd | 2019-11-07 17:37:01 +0100 | [diff] [blame] | 32 | _cleanup_test_img |
| 33 | _rm_test_img "$TEST_IMG.2" |
| 34 | _rm_test_img "$TEST_IMG.3" |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 35 | } |
| 36 | trap "_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 | |
| 46 | if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then |
| 47 | _notrun "Requires a PC machine" |
| 48 | fi |
| 49 | |
Eric Blake | 8cedcff | 2018-11-16 15:50:02 -0600 | [diff] [blame] | 50 | do_run_qemu() |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 51 | { |
| 52 | ( |
| 53 | if ! test -t 0; then |
| 54 | while read cmd; do |
| 55 | echo $cmd |
| 56 | done |
| 57 | fi |
| 58 | echo quit |
Thomas Huth | 2feae89 | 2023-05-12 09:49:37 +0200 | [diff] [blame] | 59 | ) | $QEMU -accel qtest -nographic -monitor stdio -serial none -vga none -nic none "$@" |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 60 | echo |
| 61 | } |
| 62 | |
Eric Blake | 8cedcff | 2018-11-16 15:50:02 -0600 | [diff] [blame] | 63 | check_floppy_qtree() |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 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. |
Markus Armbruster | 6a1a643 | 2020-06-22 11:42:12 +0200 | [diff] [blame] | 73 | printf "info qtree\ninfo block\n" | |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 74 | (QEMU_OPTIONS="" do_run_qemu "$@" | |
Markus Armbruster | 6a1a643 | 2020-06-22 11:42:12 +0200 | [diff] [blame] | 75 | _filter_testdir |_filter_generated_node_ids | _filter_hmp | |
| 76 | sed -ne '/^ dev: isa-fdc/,/^ dev:/{x;p};/^[a-z][^ ]* (NODE_NAME):* /,/^(qemu)$/{p}') 2>&1 | |
Vladimir Sementsov-Ogievskiy | 1a35110 | 2020-12-16 12:52:05 +0300 | [diff] [blame] | 77 | _filter_win32 | _filter_qemu | _filter_qom_path |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 78 | } |
| 79 | |
Eric Blake | 8cedcff | 2018-11-16 15:50:02 -0600 | [diff] [blame] | 80 | check_cache_mode() |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 81 | { |
| 82 | echo "info block none0" | |
| 83 | QEMU_OPTIONS="" do_run_qemu -drive if=none,file="$TEST_IMG" "$@" | |
| 84 | _filter_win32 | _filter_qemu | grep "Cache mode" |
| 85 | } |
| 86 | |
| 87 | |
| 88 | size=720k |
| 89 | |
| 90 | _make_test_img $size |
| 91 | |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 92 | TEST_IMG="$TEST_IMG.2" _make_test_img $size |
| 93 | TEST_IMG="$TEST_IMG.3" _make_test_img $size |
| 94 | |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 95 | # Default drive semantics: |
| 96 | # |
| 97 | # By default you get a single empty floppy drive. You can override it with |
| 98 | # -drive and using the same index, but if you use -drive to add a floppy to a |
| 99 | # different index, you get both of them. However, as soon as you use any |
| 100 | # '-device floppy', even to a different slot, the default drive is disabled. |
| 101 | |
| 102 | echo |
| 103 | echo |
| 104 | echo === Default === |
| 105 | |
| 106 | check_floppy_qtree |
| 107 | |
| 108 | echo |
| 109 | echo |
| 110 | echo === Using -fda/-fdb options === |
| 111 | |
| 112 | check_floppy_qtree -fda "$TEST_IMG" |
| 113 | check_floppy_qtree -fdb "$TEST_IMG" |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 114 | check_floppy_qtree -fda "$TEST_IMG" -fdb "$TEST_IMG.2" |
Markus Armbruster | 2017173 | 2020-06-22 11:42:13 +0200 | [diff] [blame] | 115 | check_floppy_qtree -fdb "" |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 116 | |
| 117 | |
| 118 | echo |
| 119 | echo |
| 120 | echo === Using -drive options === |
| 121 | |
| 122 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" |
| 123 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG",index=1 |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 124 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=floppy,file="$TEST_IMG.2",index=1 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 125 | |
| 126 | echo |
| 127 | echo |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 128 | echo === Using -drive if=none and -device === |
| 129 | |
| 130 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0 |
| 131 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,unit=1 |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 132 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \ |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 133 | -device floppy,drive=none0 -device floppy,drive=none1,unit=1 |
| 134 | |
| 135 | echo |
| 136 | echo |
| 137 | echo === Mixing -fdX and -global === |
| 138 | |
Markus Armbruster | 6172e06 | 2020-06-22 11:42:15 +0200 | [diff] [blame] | 139 | # Conflicting, -fdX wins |
Markus Armbruster | 02b83f7 | 2020-06-22 11:42:14 +0200 | [diff] [blame] | 140 | check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -global floppy.drive=none0 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 141 | |
| 142 | echo |
| 143 | echo |
| 144 | echo === Mixing -fdX and -device === |
| 145 | |
| 146 | # Working |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 147 | check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0 |
| 148 | check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 149 | |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 150 | check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0 |
| 151 | check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 152 | |
| 153 | # Conflicting |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 154 | check_floppy_qtree -fda "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0 |
| 155 | check_floppy_qtree -fdb "$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 156 | |
| 157 | echo |
| 158 | echo |
| 159 | echo === Mixing -drive and -device === |
| 160 | |
| 161 | # Working |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 162 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0 |
| 163 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=1 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 164 | |
| 165 | # Conflicting |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 166 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" -device floppy,drive=none0,unit=0 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 167 | |
| 168 | echo |
| 169 | echo |
| 170 | echo === Mixing -global and -device === |
| 171 | |
| 172 | # Working |
Markus Armbruster | 02b83f7 | 2020-06-22 11:42:14 +0200 | [diff] [blame] | 173 | check_floppy_qtree -drive if=none,file="$TEST_IMG" \ |
| 174 | -global floppy.drive=none0 -device floppy,unit=0 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 175 | |
| 176 | # Conflicting |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 177 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -drive if=none,file="$TEST_IMG.2" \ |
Markus Armbruster | 02b83f7 | 2020-06-22 11:42:14 +0200 | [diff] [blame] | 178 | -global floppy.drive=none0 -device floppy,drive=none1,unit=0 |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 179 | |
| 180 | echo |
| 181 | echo |
Markus Armbruster | 2017173 | 2020-06-22 11:42:13 +0200 | [diff] [blame] | 182 | echo === Attempt to use drive twice === |
| 183 | |
| 184 | # if=none |
| 185 | check_floppy_qtree -drive if=none -device floppy,drive=none0 -device floppy -device floppy,drive=none0 |
Markus Armbruster | 02b83f7 | 2020-06-22 11:42:14 +0200 | [diff] [blame] | 186 | check_floppy_qtree -drive if=none -global floppy.drive=none0 -device floppy -device floppy |
Markus Armbruster | 2017173 | 2020-06-22 11:42:13 +0200 | [diff] [blame] | 187 | # if=floppy |
| 188 | check_floppy_qtree -fda "" -device floppy,drive=floppy0 |
Markus Armbruster | 02b83f7 | 2020-06-22 11:42:14 +0200 | [diff] [blame] | 189 | check_floppy_qtree -fda "" -global floppy.drive=floppy0 |
Markus Armbruster | 2017173 | 2020-06-22 11:42:13 +0200 | [diff] [blame] | 190 | # default if=floppy (not found, because it's created later) |
| 191 | check_floppy_qtree -device floppy,drive=floppy0 |
| 192 | |
| 193 | echo |
| 194 | echo |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 195 | echo === Too many floppy drives === |
| 196 | |
| 197 | # Working |
| 198 | check_floppy_qtree -drive if=floppy,file="$TEST_IMG" \ |
Fam Zheng | 7ceb4fc | 2017-05-03 00:35:48 +0800 | [diff] [blame] | 199 | -drive if=none,file="$TEST_IMG.2" \ |
| 200 | -drive if=none,file="$TEST_IMG.3" \ |
Markus Armbruster | 36585e2 | 2021-03-09 17:12:11 +0100 | [diff] [blame] | 201 | -device floppy,drive=none0 \ |
Kevin Wolf | c9bf278 | 2016-10-27 16:29:14 -0400 | [diff] [blame] | 202 | -device floppy,drive=none1 |
| 203 | |
| 204 | echo |
| 205 | echo |
| 206 | echo === Creating an empty drive with anonymous BB === |
| 207 | |
| 208 | check_floppy_qtree -device floppy |
| 209 | check_floppy_qtree -device floppy,drive-type=120 |
| 210 | check_floppy_qtree -device floppy,drive-type=144 |
| 211 | check_floppy_qtree -device floppy,drive-type=288 |
| 212 | |
| 213 | echo |
| 214 | echo |
| 215 | echo === Try passing different drive size with image === |
| 216 | |
| 217 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=120 |
| 218 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,drive-type=288 |
| 219 | |
| 220 | echo |
| 221 | echo |
| 222 | echo === Try passing different block sizes === |
| 223 | |
| 224 | # Explicitly setting the default is okay |
| 225 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=512 |
| 226 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=512 |
| 227 | |
| 228 | # Changing it is not |
| 229 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,logical_block_size=4096 |
| 230 | check_floppy_qtree -drive if=none,file="$TEST_IMG" -device floppy,drive=none0,physical_block_size=1024 |
| 231 | |
| 232 | echo |
| 233 | echo |
| 234 | echo === Writethrough caching === |
| 235 | |
| 236 | check_cache_mode -device floppy,drive=none0 |
| 237 | check_cache_mode -device floppy,drive=none0,write-cache=on |
| 238 | check_cache_mode -device floppy,drive=none0,write-cache=off |
| 239 | |
| 240 | # success, all done |
| 241 | echo "*** done" |
| 242 | rm -f $seq.full |
| 243 | status=0 |