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