Files
LithosAnanke/scripts/test_nightly_dict_hash.sh
T
Claude c28cc0191b ci: the dict_hash check counts three hashes, not one distinct value (#172)
The stick-high stage passed when one distinct dict_hash appeared: an
architecture whose boot left no accept file, no LOG: line, no serial log or no
PARITY:V4_SYSTEM line gave nothing, and two that agreed passed for three.

It is now a stage of its own, scripts/nightly.sh dict-hash, which stick-high
runs: one hash from each of amd64, aarch64 and riscv64, all found and one value;
otherwise refused, naming the architectures with none or the values that
differ. NIGHTLY_OUT points the stages at another directory, for the tests.

scripts/test_nightly_dict_hash.sh, written first and seen to fail (6 of 6, the
stage not existing), then 7 cases: agree -- pass; differ, no PARITY line, no
LOG: line, not booted, no serial log, none at all -- refused. Two of them
caught lookups that ended the script silently under set -e; guarded.

Captain Bob, 2026-11-12: "172 then finish alpha.5".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-12 15:17:08 +00:00

63 lines
2.3 KiB
Bash

#!/usr/bin/env bash
# SPDX-License-Identifier: LicenseRef-Starship-1.0
# Copyright (c) 2023-2026 Robert A. James
# test_nightly_dict_hash.sh -- the tests of `scripts/nightly.sh dict-hash` (#172): the three
# architectures' boots agree on one dict_hash only when all three report one, and it is the same.
# No QEMU: each case is a scratch NIGHTLY_OUT with accept-<arch>.txt files and serial logs, as the
# accept stages leave them.
#
# Prints PASS:/FAIL: per check and RESULT:; exits 0 only if every check passes.
set -uo pipefail
NIGHTLY="$(cd "$(dirname "$0")" && pwd)/nightly.sh"
T=$(mktemp -d)
trap 'rm -rf "$T"' EXIT
ok=1
boot() { # boot <arch> <hash|none|nolog|nofile>: what accept <arch> leaves
local a=$1 h=$2 log="$T/logs/$1.log"
mkdir -p "$T/out" "$T/logs"
case $h in
nofile) rm -f "$T/out/accept-$a.txt"; return ;;
nolog) printf 'RESULT: PASS\n' > "$T/out/accept-$a.txt"; return ;;
esac
printf 'LOG: %s\nRESULT: PASS\n' "$log" > "$T/out/accept-$a.txt"
if [ "$h" = none ]; then printf 'POST: PASSED\n' > "$log"
else printf 'PARITY:V4_SYSTEM word_count=318 dict_hash=%s\nPOST: PASSED\n' "$h" > "$log"; fi
}
expect() { # expect <pass|refuse> "what"
local want=$1 what=$2 out rc
out=$(NIGHTLY_OUT="$T/out" bash "$NIGHTLY" dict-hash 2>&1); rc=$?
if { [ "$want" = pass ] && [ $rc -eq 0 ]; } ||
{ [ "$want" = refuse ] && [ $rc -eq 1 ] && grep -q "do not agree" <<<"$out"; }; then
echo "PASS: $what"
else
echo "FAIL: $what (exit $rc)"; printf ' %s\n' "$out" | head -4; ok=0
fi
}
H=0x8c92508f748f99cf
boot amd64 $H; boot aarch64 $H; boot riscv64 $H
expect pass "three boots, one dict_hash: pass"
boot riscv64 0x0000000000000001
expect refuse "two hashes differ: refused"
boot riscv64 none
expect refuse "one log has no PARITY:V4_SYSTEM line (two agree): refused"
boot riscv64 nolog
expect refuse "one accept-<arch>.txt names no LOG: (two agree): refused"
boot riscv64 nofile
expect refuse "one architecture was not booted (two agree): refused"
boot riscv64 $H; rm -f "$T/logs/riscv64.log"
expect refuse "one serial log is missing (two agree): refused"
rm -f "$T/out/accept-"*.txt
expect refuse "no architecture booted at all: refused, and says so"
echo "RESULT: $([ $ok = 1 ] && echo PASS || echo FAIL)"
[ $ok = 1 ]