28 lines
945 B
Bash
Executable File
28 lines
945 B
Bash
Executable File
#!/bin/bash
|
|
# Boots IMAGE headless and waits for init's SMP self-test to report; the
|
|
# machine halts itself when done. Exit 0 only on "SMPTEST PASS".
|
|
set -uo pipefail
|
|
|
|
IMAGE="${1:?usage: test-qemu.sh IMAGE}"
|
|
SMP="${SMP:-4}"
|
|
KERNEL="target/riscv64gc-unknown-none-elf/release/adapter-riscv"
|
|
LOG="$(mktemp -t kos-test-qemu.XXXXXX)"
|
|
|
|
timeout ${QT:-120} qemu-system-riscv64 -machine virt -smp "${SMP}" -bios default \
|
|
-kernel "${KERNEL}" \
|
|
-drive "file=${IMAGE},if=none,format=raw,id=hd0" -device virtio-blk-device,drive=hd0 \
|
|
-device virtio-gpu-device -device virtio-keyboard-device \
|
|
-display none -serial "file:${LOG}" -monitor none
|
|
status=$?
|
|
|
|
grep -a "smptest:\|SMPTEST" "${LOG}"
|
|
if grep -aq "SMPTEST PASS" "${LOG}"; then
|
|
echo "test-qemu: pass (${SMP} harts)"
|
|
rm -f "${LOG}"
|
|
exit 0
|
|
fi
|
|
[ "${status}" -eq 124 ] && echo "test-qemu: timed out"
|
|
echo "test-qemu: FAIL, last serial output (${LOG}):"
|
|
tail -20 "${LOG}"
|
|
exit 1
|