feat: add lab-rv32i-c-interrupts card
This commit is contained in:
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
tmp_dir="$(mktemp -d /tmp/c10-card.XXXXXX)"
|
||||
cleanup() {
|
||||
rm -rf -- "$tmp_dir"
|
||||
}
|
||||
trap cleanup EXIT HUP INT TERM
|
||||
|
||||
"$root/scripts/render_card_layouts.sh" >/dev/null
|
||||
"$root/scripts/render_new_pdf.sh" >/dev/null
|
||||
|
||||
pdf="$(find "$root/doc/pdf" -maxdepth 1 -type f \
|
||||
-name 'mpabi-inf-c-10-traps-interrupt-control-*.pdf' -print -quit)"
|
||||
test -n "$pdf"
|
||||
qpdf --check "$pdf" >/dev/null
|
||||
pdftotext -layout "$pdf" "$tmp_dir/card.txt"
|
||||
|
||||
blocks="$(rg -o 'A[1-8] (CONTEXT|STRUCTURE|DISPATCH|APPLICATION|FLOW|STATE|RUNTIME|PATTERNS)' \
|
||||
"$tmp_dir/card.txt" | wc -l)"
|
||||
test "$blocks" -eq 24
|
||||
|
||||
if awk 'BEGIN { RS="\f" } { compact=$0; gsub(/[[:space:]]/, "", compact); if (length(compact) < 100) exit 1 }' \
|
||||
"$tmp_dir/card.txt"; then
|
||||
:
|
||||
else
|
||||
echo "FAIL: empty or nearly empty PDF page" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if awk 'BEGIN { RS="\f" } \
|
||||
/A[1-8] (CONTEXT|STRUCTURE|DISPATCH|APPLICATION|FLOW|STATE|RUNTIME|PATTERNS)/ && !/TASK0[1-3]/ { exit 1 }' \
|
||||
"$tmp_dir/card.txt"; then
|
||||
:
|
||||
else
|
||||
echo "FAIL: A1-A8 block on a page without its TASK heading" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
jq -e '
|
||||
.tasks_order == ["task01", "task02", "task03"] and
|
||||
all(.tasks[];
|
||||
[.viewpoints[].id] == ["A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8"] and
|
||||
all(.viewpoints[]; .status == "enabled" or .status == "unavailable"))
|
||||
' "$root/json/card_source.json" >/dev/null
|
||||
node --check "$root/web/app.js"
|
||||
|
||||
printf 'PASS card: 3 tasks, 24 A blocks, valid PDF, no empty/anonymous page\n'
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/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}"
|
||||
objdump="${RISCV_PREFIX:-riscv64-unknown-elf-}objdump"
|
||||
|
||||
make -C "$root" -s tasks "RV_ENV_ROOT=$env_root"
|
||||
|
||||
run_task() {
|
||||
local task="$1"
|
||||
shift
|
||||
local log="$root/build/$task/oracle.log"
|
||||
"$tb" --bin "$root/build/$task/prog.bin" --cycles 500000 --cpuret --logfile "$log"
|
||||
grep -Fqx 'CPU requested halt. Exit code 0' "$log"
|
||||
local expected
|
||||
for expected in "$@"; do
|
||||
grep -Fqx "$expected" "$log" || {
|
||||
printf 'FAIL %s missing <%s>\n' "$task" "$expected" >&2
|
||||
sed -n '1,160p' "$log" >&2
|
||||
return 1
|
||||
}
|
||||
done
|
||||
printf 'PASS Hazard3 oracle: %s\n' "$task"
|
||||
}
|
||||
|
||||
run_task task01_ecall_resume \
|
||||
'T01 count=00000001' \
|
||||
'T01 mcause=0000000b' \
|
||||
'T01 delta=00000004' \
|
||||
'T01 resumed=00000001' \
|
||||
'T01 pass=00000001'
|
||||
|
||||
run_task task02_machine_software_irq \
|
||||
'T02 count=00000001' \
|
||||
'T02 mcause=80000003' \
|
||||
'T02 pending_before=00000001' \
|
||||
'T02 pending_in_handler=00000001' \
|
||||
'T02 pending_after=00000000' \
|
||||
'T02 resumed=00000001' \
|
||||
'T02 pass=00000001'
|
||||
|
||||
run_task task03_pending_enable_matrix \
|
||||
'T03 pending=00000001' \
|
||||
'T03 blocked_no_msie=00000001' \
|
||||
'T03 blocked_no_mie=00000001' \
|
||||
'T03 delivered_both=00000001' \
|
||||
'T03 count=00000001' \
|
||||
'T03 mcause=80000003' \
|
||||
'T03 pending_after=00000000' \
|
||||
'T03 pass=00000001'
|
||||
|
||||
for pair in 'task01_ecall_resume handle_exception' \
|
||||
'task02_machine_software_irq isr_machine_softirq' \
|
||||
'task03_pending_enable_matrix isr_machine_softirq'; do
|
||||
read -r task symbol <<<"$pair"
|
||||
"$objdump" -d "$root/build/$task/prog.elf" |
|
||||
sed -n "/<$symbol>:/,/^$/p" |
|
||||
grep -Eq '[[:space:]]mret$'
|
||||
done
|
||||
|
||||
t01_mepc=$(sed -n 's/^T01 mepc=//p' "$root/build/task01_ecall_resume/oracle.log")
|
||||
t01_resume=$(sed -n 's/^T01 resume_pc=//p' "$root/build/task01_ecall_resume/oracle.log")
|
||||
(( 16#$t01_resume - 16#$t01_mepc == 4 ))
|
||||
printf 'PASS independent oracle: mepc+4, pending/enable matrix, ISR mret\n'
|
||||
Reference in New Issue
Block a user