1#!/bin/bash 2# 3# A quick standard test of Haiku booting under qemu in various configurations 4# 5 6if [ $# -lt 3 ]; then 7 echo "Usage: $0 <arch> <bios|efi> <image>" 8 exit 1; 9fi 10 11ARCH=$1 12PLATFORM=$2 13IMAGE=$3 14EMULATOR=qemu-system-$ARCH 15EXTRAS="" 16 17function check_logs { 18 FILE=$1 19 echo -n " Potential KDL Detected: " 20 if grep -q "kdebug>" $FILE; then 21 echo "YES" 22 else 23 echo "NO" 24 fi 25 echo " Potential issues in logs:" 26 egrep -i "FATAL|ERROR|FAIL|GDB" $FILE | grep -vi " No error" 27} 28 29case "$PLATFORM" in 30"bios") 31 EXTRAS="$EXTRAS" 32 ;; 33"efi") 34 EXTRAS="$EXTRAS -bios /usr/share/edk2/ovmf/OVMF_CODE.fd" 35 ;; 36*) 37 EXTRAS="$EXTRAS" 38 ;; 39esac 40 41echo "We're going to step through the potential boot options for $ARCH under qemu" 42echo "" 43echo -n "Press enter to begin..." 44read 45 46case "$ARCH" in 47"x86" | "x86_64") 48 MEMORY=2048 49 TEST_FILE="/tmp/test-$ARCH.iso" 50 TEST_SERIALLOG="/tmp/test-$ARCH-serial.mon" 51 EXTRAS="$EXTRAS -serial file:$TEST_SERIALLOG" 52 EMULATOR="$EMULATOR --enable-kvm -m $MEMORY $EXTRAS" 53 rm -f $TEST_FILE $TEST_SERIALLOG 54 55 echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 56 echo "+++ Testing $PLATFORM CDROM boot..." 57 cp $IMAGE $TEST_FILE 58 $EMULATOR -cdrom $TEST_FILE 59 check_logs $TEST_SERIALLOG 60 rm -f $TEST_FILE $TEST_SERIALLOG 61 62 echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 63 echo "+++ Testing $PLATFORM IDE boot..." 64 cp $IMAGE $TEST_FILE 65 $EMULATOR -drive file=$TEST_FILE,format=raw,if=ide 66 check_logs $TEST_SERIALLOG 67 rm -f $TEST_FILE $TEST_SERIALLOG 68 69 echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 70 echo "+++ Testing $PLATFORM USB boot..." 71 cp $IMAGE $TEST_FILE 72 $EMULATOR -drive if=none,id=stick,file=$TEST_FILE,format=raw -device qemu-xhci,id=xhci -device usb-storage,bus=xhci.0,drive=stick 73 check_logs $TEST_SERIALLOG 74 rm -f $TEST_FILE $TEST_SERIALLOG 75 ;; 76*) 77 echo "Error: Unknown architecture!" 78 ;; 79esac 80