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