test: on-hardware SMP self-test (revoke/kill must stop every hart) + make test-qemu
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
IMG="boot.img"
|
||||
IMG="${IMG:-boot.img}"
|
||||
IMG_SIZE_KB=4096
|
||||
TARGET="riscv64gc-unknown-none-elf"
|
||||
BUILD_DIR="target/${TARGET}/release"
|
||||
@@ -30,6 +30,10 @@ copy log-server "log.elf"
|
||||
copy permission-manager "permis.elf"
|
||||
copy storage-qemu "storage.elf"
|
||||
copy session-server "session.elf"
|
||||
# Only the test image: its presence makes init run the SMP self-test.
|
||||
if [ -n "${SMPTEST:-}" ]; then
|
||||
copy smptest "smptest.elf"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Disk contents:"
|
||||
|
||||
27
scripts/test-qemu.sh
Executable file
27
scripts/test-qemu.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user