39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
env_root="${RV_ENV_ROOT:-/home/user/dev/edu/rv32i-hazard3-student-env}"
|
|
tb="${HAZARD3_TB:-$env_root/vendor/Hazard3/test/sim/tb_verilator/tb}"
|
|
|
|
test -x "$tb"
|
|
make -C "$root" -s tasks "RV_ENV_ROOT=$env_root"
|
|
|
|
assert_words() {
|
|
local output="$1"
|
|
shift
|
|
local actual expected
|
|
mapfile -t actual < <(printf '%s\n' "$output" | grep -E '^[0-9a-f]{8}$')
|
|
expected=("$@")
|
|
[[ "${actual[*]}" == "${expected[*]}" ]] || {
|
|
printf 'FAIL words\nexpected: %s\nactual: %s\n' \
|
|
"${expected[*]}" "${actual[*]}" >&2
|
|
return 1
|
|
}
|
|
}
|
|
|
|
task1="$($tb --bin "$root/build/task01_uart_polling/prog.bin" --cycles 500000 --cpuret)"
|
|
printf '%s\n' "$task1" | grep -F 'Exit code 0' >/dev/null
|
|
printf '%s\n' "$task1" | grep -Fqx 'T'
|
|
assert_words "$task1" c1201001 00000003 00000050 00000002 00000054 00000001
|
|
printf 'PASS Task01 polling oracle\n'
|
|
|
|
task2="$($tb --bin "$root/build/task02_uart_rx_interrupt/prog.bin" --cycles 500000 --cpuret)"
|
|
printf '%s\n' "$task2" | grep -F 'Exit code 0' >/dev/null
|
|
assert_words "$task2" c1202002 00000001 00000001 00000010 00000013 00000052 00000000 00000001
|
|
printf 'PASS Task02 IRQ oracle\n'
|
|
|
|
task3="$($tb --bin "$root/build/task03_uart_mailbox/prog.bin" --cycles 500000 --cpuret)"
|
|
printf '%s\n' "$task3" | grep -F 'Exit code 0' >/dev/null
|
|
assert_words "$task3" c1203003 00000003 00000002 00000001 00000041 00000043 00000000 00000001
|
|
printf 'PASS Task03 mailbox oracle\n'
|