interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / scripts / ck_spark_report_test.sh

41 lines · 2021 bytes Raw Blame History
1#!/bin/sh
2# ck_spark_report_test.sh -- host test of the Spark boot report (L198): frames
3# built by native/net/aienos_report.c (tag AIENUX-SPARK-REPORT) for a 40 KiB
4# report, sent out of order and twice over loopback to the shared receiver
5# tools/ck_imac_report_listen.c, which must rebuild it byte for byte as
6# spark-<run>.unauthenticated.txt and still accept the iMac's parts (scripts/ck_imac_report_test.sh).
7# Hosted only; the RTL8127 itself is covered by native/net tests/rtl8127_test.c.
8# Ends with "AIENUX_SPARK_REPORT: PASS" or "AIENUX_SPARK_REPORT: FAIL <why>".
9set -u
10cd "$(dirname "$0")/.."
11K=native/kernel
12N=native/net
13W=$(mktemp -d "${TMPDIR:-/tmp}/ck_spark_report.XXXXXX")
14trap 'kill $LP 2>/dev/null; rm -rf "$W"' EXIT
15LP=
16fail() { echo "AIENUX_SPARK_REPORT: FAIL $*"; exit 1; }
17CC=${HOSTCC:-cc}
18CF="-std=gnu11 -O2 -Wall -Wextra -Werror"
19$CC $CF -o "$W/listen" $K/tools/ck_imac_report_listen.c || fail "listener does not build"
20$CC $CF -o "$W/send" $N/tests/report_send.c $N/aienos_report.c $N/aienos_net.c || fail "sender does not build"
21i=0
22while [ $i -lt 40960 ]; do printf 'spark boot report line %05d\n' $((i / 29)); i=$((i + 29)); done | head -c 40960 > "$W/sent.txt"
23PORT=$((47900 + $$ % 90))
24mkdir -p "$W/out"
25"$W/listen" $PORT "$W/out" 20 &
26LP=$!
27i=0
28until grep -q "^ready port=$PORT" "$W/out/listen.log" 2>/dev/null; do
29 i=$((i + 1)); [ $i -gt 50 ] && fail "listener not ready: $(cat "$W/out/listen.log" 2>/dev/null)"
30 sleep 0.1
31done
32"$W/send" $PORT "$W/sent.txt" >/dev/null || fail "send"
33i=0
34until grep -q "^complete run=fedcba9876543210 " "$W/out/listen.log"; do
35 i=$((i + 1)); [ $i -gt 50 ] && fail "report not completed: $(cat "$W/out/listen.log")"
36 sleep 0.1
37done
38cmp -s "$W/sent.txt" "$W/out/spark-fedcba9876543210.unauthenticated.txt" || fail "rebuilt report differs"
39[ "$(grep -c '^complete ' "$W/out/listen.log")" = 1 ] || fail "report written more than once"
40grep -q '^ignored' "$W/out/listen.log" && fail "listener ignored a valid part"
41echo "AIENUX_SPARK_REPORT: PASS"