run_qemu.sh 977 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. # This script starts a bootable image in QEMU using legacy BIOS boot.
  3. # http://redsymbol.net/articles/unofficial-bash-strict-mode/
  4. set -euo pipefail
  5. IFS=$'\n\t'
  6. DIR=$(dirname "$(realpath "$0")")
  7. cd "$DIR" || exit
  8. BOOT_IMAGE="grub_boot.img"
  9. # add "-d int \" to debug CPU exceptions
  10. # "-display none" is necessary for the CI but locally the display and the
  11. # combat monitor are really helpful
  12. set +e
  13. qemu-system-x86_64 \
  14. -boot d \
  15. -cdrom "$BOOT_IMAGE" \
  16. -m 24m \
  17. -debugcon stdio \
  18. -no-reboot \
  19. -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
  20. -display none `# relevant for the CI`
  21. EXIT_CODE=$?
  22. # Custom exit code used by the integration test to report success.
  23. QEMU_EXIT_SUCCESS=73
  24. echo "#######################################"
  25. if [[ $EXIT_CODE -eq $QEMU_EXIT_SUCCESS ]]; then
  26. echo "SUCCESS - Integration Test 'multiboot2'"
  27. exit 0
  28. else
  29. echo "FAILED - Integration Test 'multiboot2'"
  30. exit "$EXIT_CODE"
  31. fi