1#!/usr/bin/env bash 2 3if [ -z "$KUT_STANDALONE" ]; then 4 if [ ! -f config.mak ]; then 5 echo "run ./configure && make first. See ./configure -h" 6 exit 2 7 fi 8 source config.mak 9 source scripts/arch-run.bash 10fi 11 12ACCEL=$(get_qemu_accelerator) || 13 exit $? 14 15qemu=$(search_qemu_binary) || 16 exit $? 17 18if ! ${qemu} -device '?' 2>&1 | grep -F -e \"testdev\" -e \"pc-testdev\" > /dev/null; 19then 20 echo "No Qemu test device support found" 21 exit 2 22fi 23 24if 25 ${qemu} -device '?' 2>&1 | grep -F "pci-testdev" > /dev/null; 26then 27 pci_testdev="-device pci-testdev" 28else 29 pci_testdev="" 30fi 31 32if 33 ${qemu} -device '?' 2>&1 | grep -F "pc-testdev" > /dev/null; 34then 35 pc_testdev="-device pc-testdev -device isa-debug-exit,iobase=0xf4,iosize=0x4" 36else 37 pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" 38fi 39 40command="${qemu} --no-reboot -nodefaults $pc_testdev -vnc none -serial stdio $pci_testdev" 41command+=" -machine accel=$ACCEL" 42if [ "${CONFIG_EFI}" != y ]; then 43 command+=" -kernel" 44fi 45command="$(timeout_cmd) $command" 46 47if [ "${CONFIG_EFI}" = y ]; then 48 # Set ENVIRON_DEFAULT=n to remove '-initrd' flag for QEMU (see 49 # 'scripts/arch-run.bash' for more details). This is because when using 50 # UEFI, the test case binaries are passed to QEMU through the disk 51 # image, not through the '-kernel' flag. And QEMU reports an error if it 52 # gets '-initrd' without a '-kernel' 53 ENVIRON_DEFAULT=n run_qemu ${command} "$@" 54else 55 run_qemu ${command} "$@" 56fi 57