Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/galaxy/tests/live.sh # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / galaxy / tests / live.sh` 113 lines ยท 6110 bytes Raw Blame History 1 #!/bin/sh 2 # galaxy/tests/live.sh: gate for live.om (the page that keeps itself current). 3 # OMC=/abs/seed/out/omc sh galaxy/tests/live.sh 4 # Replays recorded stream bytes through the daemon (it reads stdin when given an argument) and 5 # requires the page it writes to equal, byte for byte, the page the filter prints for the feed a 6 # reader would write by hand from the same events. Dates are checked against `date -u`. Pacing is 7 # checked on stream time: 10 s after a publish is held, 30 s is published. 8 # Negative controls: a mutant that reads "open" where the floor shows "moving" must not match, and 9 # a mutant without the 30 s rule must publish the held event. 10 set -u 11 HERE=$(cd "$(dirname "$0")" && pwd) 12 G=$HERE/.. 13 OMC=${OMC:-$HOME/work/flux/omega-mv/seed/out/omc} 14 PIN=`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` 15 T=$(mktemp -d) || exit 2 16 trap 'rm -rf "$T"' EXIT 17 pass=0 18 fail=0 19 ok() { pass=$((pass + 1)); echo "PASS $1"; } 20 no() { fail=$((fail + 1)); echo "FAIL $1"; } 21 eq() { if [ "$2" = "$3" ]; then ok "$1"; else no "$1: got '$2' want '$3'"; fi; } 22 23 got=$(sha256sum "$OMC" 2>/dev/null | cut -d' ' -f1) 24 if [ "$got" != "$PIN" ]; then 25 echo "compiler pin mismatch: $got" >&2 26 exit 2 27 fi 28 cat "$G/page.om" "$G/live.om" | "$OMC" >"$T/live" 2>"$T/live.err" 29 eq "live compile exit" "$?" 0 30 cat "$G/page.om" "$G/cli.om" | "$OMC" >"$T/cli" 2>"$T/cli.err" 31 eq "cli compile exit" "$?" 0 32 chmod +x "$T/live" "$T/cli" 33 34 # 1. replay: two events (a full one, then a patch that replaces generated and machine) 35 mkdir "$T/a" && cp "$HERE/stars.tsv" "$T/a/" 36 (cd "$T/a" && "$T/live" replay <"$HERE/stream.sse") 37 eq "replay exit" "$?" 0 38 asof=$(date -u -d @`1794260414` '+%Y-%m-%d %H:%M') 39 sed "s/@ASOF@/$asof/" "$HERE/live-expect.tsv" >"$T/expect.tsv" 40 "$T/cli" <"$T/expect.tsv" >"$T/expect.html" 41 if cmp -s "$T/a/index.html" "$T/expect.html"; then ok "replayed page equals the hand-written feed's page"; else no "replayed page equals the hand-written feed's page"; fi 42 printf 'css\n' | "$T/cli" >"$T/expect.css" 43 if cmp -s "$T/a/galaxy.css" "$T/expect.css"; then ok "stylesheet written"; else no "stylesheet written"; fi 44 eq "no temporary file left" "$(ls "$T/a" | grep -c 'tmp$')" 0 45 eq "ten cells" "$(grep -o "class='cell'" "$T/a/index.html" | wc -l | tr -d ' ')" 10 46 47 # 2. bad input after good input changes nothing: a cut-off event, junk, and a 2,000,000-byte line, 48 # then an event that carries only a generated second 60 s on. Pacing holds the bad events, so that 49 # last event is what publishes the figures as the bad input left them: only the minute may change. 50 mkdir "$T/b" && cp "$HERE/stars.tsv" "$T/b/" 51 { cat "$HERE/stream.sse" 52 printf 'data: {"stations":[{"id":"intake"\n\n' 53 printf 'data: not json at all\n\n\000\001\002\n' 54 awk 'BEGIN { printf "data: {\"x\":\""; for (i = 0; i < `2000000`; i++) printf "a"; printf "\"}\n\n" }' 55 printf 'data: {"generated":`1794260474`}\n\n'; } >"$T/bad.sse" 56 (cd "$T/b" && "$T/live" replay <"$T/bad.sse") 57 eq "bad input exit" "$?" 0 58 sed "s/@ASOF@/$(date -u -d @`1794260474` '+%Y-%m-%d %H:%M')/" "$HERE/live-expect.tsv" | "$T/cli" >"$T/expect-b.html" 59 if cmp -s "$T/b/index.html" "$T/expect-b.html"; then ok "bad input changes no figure (published after it)"; else no "bad input changes no figure (published after it)"; fi 60 61 # 3. no stations yet: nothing is published 62 mkdir "$T/c" 63 printf 'data: {"generated":5,"machine":{"gpu_w":1}}\n\n' | (cd "$T/c" && "$T/live" replay) 64 eq "patch before any stations exit" "$?" 0 65 eq "nothing published before the stations are known" "$(ls "$T/c" | grep -c '^index.html$')" 0 66 67 # 4. dates against date -u (epoch, leap days, year ends, a far year) 68 for n in 0 86399 `951782400` `951868799` `1709164800` `1735689599` `1735689600` `1794260414` `4102444800` `4107542399`; do 69 mkdir "$T/d$n" 70 printf 'data: {"generated":%s,"stations":[{"id":"intake","name":"x","moving":1,"done24":1}]}\n\n' "$n" | (cd "$T/d$n" && "$T/live" replay) 71 want="Read from the Spark $(date -u -d "@$n" '+%Y-%m-%d %H:%M') UTC" 72 eq "date of $n" "$(grep -o 'Read from the Spark [0-9: -]* UTC' "$T/d$n/index.html")" "$want" 73 done 74 75 # 5. pacing by the stream's own generated second 76 ev() { printf 'data: {"generated":%s,"machine":{"gpu_w":%s}}\n\n' "$1" "$2"; } 77 first='data: {"generated":`1000000`,"machine":{"gpu_w":10},"stations":[{"id":"intake","name":"x","moving":1,"done24":1}]}' 78 gpu() { grep -o '
GPU, watts
[0-9]*' "$1" | grep -o '[0-9]*$'; } 79 mkdir "$T/p1" 80 { printf '%s\n\n' "$first"; ev `1000010` 99; } >"$T/p1.sse" 81 (cd "$T/p1" && "$T/live" replay <"$T/p1.sse") 82 eq "an event 10 s after a publish is held" "$(gpu "$T/p1/index.html")" 10 83 mkdir "$T/p2" 84 { printf '%s\n\n' "$first"; ev `1000010` 99; ev `1000029` 98; ev `1000030` 55; ev `1000031` 77; } | (cd "$T/p2" && "$T/live" replay) 85 eq "an event 30 s after a publish is published and the next one held" "$(gpu "$T/p2/index.html")" 55 86 mkdir "$T/p3" 87 { printf '%s\n\n' "$first"; ev 999000 7; } | (cd "$T/p3" && "$T/live" replay) 88 eq "an event whose generated second went backwards is published" "$(gpu "$T/p3/index.html")" 7 89 90 # negative control: read "open" instead of "moving"; the replayed page must no longer match 91 sed 's/^text vkmov "moving"$/text vkmov "open"/' "$G/live.om" >"$T/mutant.om" 92 if cmp -s "$G/live.om" "$T/mutant.om"; then 93 no "mutant differs from source" 94 else 95 cat "$G/page.om" "$T/mutant.om" | "$OMC" >"$T/mutant" 2>/dev/null && chmod +x "$T/mutant" 96 mkdir "$T/m" && cp "$HERE/stars.tsv" "$T/m/" 97 (cd "$T/m" && "$T/mutant" replay <"$HERE/stream.sse") 98 if cmp -s "$T/m/index.html" "$T/expect.html"; then no "mutant reading open is caught"; else ok "mutant reading open is caught"; fi 99 fi 100 101 # negative control: drop the 30 s rule; the event held in case 5 must then be on the page 102 sed 's/^if ge sub g l 30$/if true/' "$G/live.om" >"$T/mutant2.om" 103 if cmp -s "$G/live.om" "$T/mutant2.om"; then 104 no "mutant2 differs from source" 105 else 106 cat "$G/page.om" "$T/mutant2.om" | "$OMC" >"$T/mutant2" 2>/dev/null && chmod +x "$T/mutant2" 107 mkdir "$T/m2" 108 (cd "$T/m2" && "$T/mutant2" replay <"$T/p1.sse") 109 eq "mutant without the 30 s rule publishes the held event" "$(gpu "$T/m2/index.html")" 99 110 fi 111 112 echo "RESULT pass=$pass fail=$fail" 113 [ "$fail" -eq 0 ]