Files
lab-rv32i-c-gpio-edges-debo…/tests/test_card.sh
T

39 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
tmp_dir="$(mktemp -d /tmp/c13-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-13-gpio-edges-debounce-*.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 32
awk 'BEGIN { RS="\f" } { compact=$0; gsub(/[[:space:]]/, "", compact); if (length(compact) < 100) exit 1 }' \
"$tmp_dir/card.txt" || { echo "FAIL: empty PDF page" >&2; exit 1; }
awk 'BEGIN { RS="\f" } \
/A[1-8] (CONTEXT|STRUCTURE|DISPATCH|APPLICATION|FLOW|STATE|RUNTIME|PATTERNS)/ && !/TASK0[1-4]/ { exit 1 }' \
"$tmp_dir/card.txt" || { echo "FAIL: anonymous A1-A8 page" >&2; exit 1; }
jq -e '
.tasks_order == ["task01", "task02", "task03", "task04"] 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: 4 tasks, 32 A blocks, valid PDF, no empty/anonymous page\n'