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 / native / omega / allen / gate.sh

164 lines · 12287 bytes Raw Blame History
1#!/bin/sh
2# External build/output comparison only. All behavioral tests execute Omega ELFs.
3set -eu
4root=$(CDPATH= cd -- "$(dirname "$0")/../../.." && pwd)
5cd "$root"
6out=$1
7mkdir -p "$out"
8[ -z "$(ls -A "$out")" ] || { echo 'gate requires fresh output directory' >&2; exit 73; }
9compiler=${OMEGA_COMPILER:-"$root/build/allen-toolchain/seed/out/omc"}
10sh native/omega/allen/test-build.sh "$compiler" "$out/build-checks"
11core="$out/core.om"
12cat native/omega/allen/base.om native/omega/allen/vendor/sha256-core.om \
13 native/omega/allen/runtime.om native/omega/allen/code.om \
14 native/omega/allen/courier.om native/omega/allen/scheduler.om native/omega/allen/memory.om \
15 native/omega/allen/intent.om native/omega/allen/reply.om \
16 native/omega/allen/view.om native/omega/allen/scene.om native/omega/allen/paint.om native/omega/allen/application.om native/omega/allen/scene-input.om native/omega/allen/context.om native/omega/allen/font-data.om native/omega/allen/font.om native/omega/allen/look-paint.om native/omega/allen/surface.om native/omega/allen/presentation.om native/omega/allen/provider-core.om > "$core"
17for name in runtime code courier scheduler application provider-core presentation font surface memory context intent reply view scene scene-input paint edges fixture golden render font-output font-render surface-render; do
18 cat "$core" > "$out/$name.om"
19 case "$name" in golden|render|font-output|font-render|surface-render) ;; *) cat native/omega/allen/tests/check.om >> "$out/$name.om" ;; esac
20 cat "native/omega/allen/tests/$name.om" >> "$out/$name.om"
21 native/omega/allen/build-one.sh "$out/$name.om" "$out/$name"
22 case "$name" in
23 fixture)
24 "$out/$name" < evidence/allen-omega-L694/short.wire > "$out/short.log"
25 "$out/$name" < evidence/allen-omega-L694/long.wire > "$out/long.log"
26 ;;
27 golden) "$out/$name" > "$out/memory-native.bin" ;;
28 render) "$out/$name" > "$out/mind-component.ppm" ;;
29 font-output) "$out/$name" > "$out/font.bin" ;;
30 font-render) "$out/$name" > "$out/font-specimen.ppm" ;;
31 surface-render) "$out/$name" > "$out/provider-surface.ppm" ;;
32 *) "$out/$name" > "$out/$name.log" ;;
33 esac
34 printf '%s compile=0 native-exit=0\n' "$name"
35done
36cmp "$out/font.bin" evidence/allen-omega-L694/L758/legacy-font.bin
37printf 'font native masks match frozen external legacy oracle\n'
38native/omega/allen/golden.sh "$out/reference"
39cmp "$out/memory-native.bin" "$out/reference/memory-golden.bin"
40cat "$core" native/omega/allen/main.om > "$out/allen.om"
41native/omega/allen/build-one.sh "$out/allen.om" "$out/allen"
42"$out/allen" < evidence/allen-omega-L694/stdio-input.txt > "$out/stdio-job.txt" 2> "$out/stdio-display.txt"
43cmp "$out/stdio-job.txt" evidence/allen-omega-L694/stdio-job.txt
44cmp "$out/stdio-display.txt" evidence/allen-omega-L694/stdio-display.txt
45printf 'stdio native-exit=0 golden-cmp=0\n'
46# The fixture generator is Omega too. Refuse the oversized operation and
47# never execute the valid ASK following it (L719/L722 regression).
48native/omega/allen/build-one.sh native/omega/allen/tests/stdio-overflow.om "$out/stdio-overflow-input"
49"$out/stdio-overflow-input" > "$out/stdio-overflow.input"
50set +e
51"$out/allen" < "$out/stdio-overflow.input" > "$out/stdio-overflow.stdout" 2> "$out/stdio-overflow.stderr"
52rc=$?
53set -e
54[ "$rc" = 65 ] || { echo "stdio overflow was not refused: exit=$rc" >&2; exit 1; }
55[ ! -s "$out/stdio-overflow.stdout" ] || { echo 'stdio overflow executed a later job' >&2; exit 1; }
56[ ! -s "$out/stdio-overflow.stderr" ] || { echo 'stdio overflow displayed a later answer' >&2; exit 1; }
57printf 'stdio overflow native-exit=65 no-later-command=PASS\n'
58# Real native provider entry, independent native input/output fixtures.
59cat "$core" native/omega/allen/provider.om > "$out/provider.om"
60native/omega/allen/build-one.sh "$out/provider.om" "$out/provider"
61for name in provider-input provider-output provider-process; do
62 cat "$core" native/omega/allen/tests/check.om "native/omega/allen/tests/$name.om" > "$out/$name.om"
63 native/omega/allen/build-one.sh "$out/$name.om" "$out/$name"
64done
65printf 0 | "$out/provider-input" > "$out/provider.input"
66"$out/provider" < "$out/provider.input" > "$out/provider.output" 2> "$out/provider.stderr"
67{ printf '7\n0\n'; stat -c %s "$out/provider.output" "$out/provider.stderr"; cat "$out/provider.output" "$out/provider.stderr"; } > "$out/provider-process.receipt"
68"$out/provider-process" < "$out/provider-process.receipt" > "$out/provider-process.log"
69"$out/provider-output" < "$out/provider.output" > "$out/provider-stream.log"
70# Byte-at-a-time native producer through a real pipe; collect both exits explicitly.
71printf 7 > "$out/provider.mode"
72mkfifo "$out/provider.pipe"
73"$out/provider-input" < "$out/provider.mode" > "$out/provider.pipe" 2> "$out/provider-producer.stderr" &
74producer=$!
75set +e
76"$out/provider" < "$out/provider.pipe" > "$out/provider-fragment.output" 2> "$out/provider-fragment.stderr"
77consumer_rc=$?
78wait "$producer"
79producer_rc=$?
80set -e
81{ printf '7\n%s\n' "$consumer_rc"; stat -c %s "$out/provider-fragment.output" "$out/provider-fragment.stderr"; cat "$out/provider-fragment.output" "$out/provider-fragment.stderr"; } > "$out/provider-consumer.receipt"
82"$out/provider-process" < "$out/provider-consumer.receipt" > "$out/provider-consumer.log"
83{ printf '7\n%s\n0\n' "$producer_rc"; stat -c %s "$out/provider-producer.stderr"; cat "$out/provider-producer.stderr"; } > "$out/provider-producer.receipt"
84"$out/provider-process" < "$out/provider-producer.receipt" > "$out/provider-producer.log"
85cmp "$out/provider.output" "$out/provider-fragment.output"
86"$out/provider-output" < "$out/provider-fragment.output" > "$out/provider-fragment.log"
87printf 8 | "$out/provider-input" > "$out/provider-boot.expected"
88for mode in 1 2 3 4 5 6; do
89 printf '%s' "$mode" | "$out/provider-input" > "$out/provider-bad-$mode.input"
90 set +e
91 "$out/provider" < "$out/provider-bad-$mode.input" > "$out/provider-bad-$mode.output" 2> "$out/provider-bad-$mode.stderr"
92 rc=$?
93 set -e
94 { printf '%s\n%s\n' "$mode" "$rc"; stat -c %s "$out/provider-bad-$mode.output" "$out/provider-bad-$mode.stderr"; cat "$out/provider-bad-$mode.output" "$out/provider-bad-$mode.stderr"; } > "$out/provider-bad-$mode.receipt"
95 "$out/provider-process" < "$out/provider-bad-$mode.receipt" > "$out/provider-bad-$mode.log"
96 printf 'provider malformed mode=%s exit=65 no-later-command=PASS\n' "$mode"
97done
98printf 'provider native-exit=0 fragmented-pipe=0 output-verifier=0\n'
99# Compiled behavioral mutants must be valid ELFs and fail the original gates.
100sed 's/if or eq get R 1 0 ne seq get R 0/if eq get R 1 0/' "$core" > "$out/stale-mutant.om"
101cat native/omega/allen/tests/check.om native/omega/allen/tests/runtime.om >> "$out/stale-mutant.om"
102sed 's/if ne ulong codecrc get C 3/if false/' "$core" > "$out/crc-mutant.om"
103cat native/omega/allen/tests/check.om native/omega/allen/tests/code.om >> "$out/crc-mutant.om"
104sed 's/ret eq d 0/ret true/' "$core" > "$out/hash-mutant.om"
105cat native/omega/allen/tests/check.om native/omega/allen/tests/memory.om >> "$out/hash-mutant.om"
106sed 's/if ne d 0/if false/' "$core" > "$out/readback-mutant.om"
107cat native/omega/allen/tests/check.om native/omega/allen/tests/memory.om >> "$out/readback-mutant.om"
108sed 's/if ne run get Q 0/if false/' "$core" > "$out/session-mutant.om"
109cat native/omega/allen/tests/check.om native/omega/allen/tests/courier.om >> "$out/session-mutant.om"
110sed 's/delay = ulong 10000/delay = ulong 2000/' "$core" > "$out/keepalive-mutant.om"
111cat native/omega/allen/tests/check.om native/omega/allen/tests/scheduler.om >> "$out/keepalive-mutant.om"
112sed 's/put T 6 1/put T 6 0/' "$core" > "$out/ackstop-mutant.om"
113cat native/omega/allen/tests/check.om native/omega/allen/tests/scheduler.om >> "$out/ackstop-mutant.om"
114sed 's/put Outb i get Appwire i/put Outb i get Outb i/' "$core" > "$out/pendingwire-mutant.om"
115cat native/omega/allen/tests/check.om native/omega/allen/tests/application.om >> "$out/pendingwire-mutant.om"
116sed 's/if or le get R 2 1 ne get C 0 get R 0/if false/' "$core" > "$out/appcode-mutant.om"
117cat native/omega/allen/tests/check.om native/omega/allen/tests/application.om >> "$out/appcode-mutant.om"
118sed 's/if hide/if false/' "$core" > "$out/thinking-mutant.om"
119cat native/omega/allen/tests/check.om native/omega/allen/tests/scene-input.om >> "$out/thinking-mutant.om"
120sed 's/if lt get Nm 8 12/if true/' "$core" > "$out/scenecap-mutant.om"
121cat native/omega/allen/tests/check.om native/omega/allen/tests/scene-input.om >> "$out/scenecap-mutant.om"
122sed 's/if and eq get Ctxgone index 0 lt given limit/if lt given limit/' "$core" > "$out/contextnote-mutant.om"
123cat native/omega/allen/tests/check.om native/omega/allen/tests/context.om >> "$out/contextnote-mutant.om"
124sed 's/if not ctxappend/if false/' "$core" > "$out/contextjob-mutant.om"
125cat native/omega/allen/tests/check.om native/omega/allen/tests/context.om >> "$out/contextjob-mutant.om"
126native/omega/allen/build-one.sh native/omega/allen/tests/provider-mutants.om "$out/provider-mutants"
127{ printf 0; cat "$core"; } | "$out/provider-mutants" > "$out/autosent-mutant.om"
128cat native/omega/allen/tests/check.om native/omega/allen/tests/provider-core.om >> "$out/autosent-mutant.om"
129{ printf 1; cat "$core"; } | "$out/provider-mutants" > "$out/framecheck-mutant.om"
130cat native/omega/allen/tests/check.om native/omega/allen/tests/provider-core.om >> "$out/framecheck-mutant.om"
131native/omega/allen/build-one.sh native/omega/allen/tests/presentation-mutants.om "$out/presentation-mutants"
132{ printf 0; cat "$core"; } | "$out/presentation-mutants" > "$out/staleview-mutant.om"
133cat native/omega/allen/tests/check.om native/omega/allen/tests/presentation.om >> "$out/staleview-mutant.om"
134{ printf 1; cat "$core"; } | "$out/presentation-mutants" > "$out/inputtail-mutant.om"
135cat native/omega/allen/tests/check.om native/omega/allen/tests/presentation.om >> "$out/inputtail-mutant.om"
136native/omega/allen/build-one.sh native/omega/allen/tests/font-mutants.om "$out/font-mutants"
137{ printf 0; cat "$core"; } | "$out/font-mutants" > "$out/fontroot-mutant.om"
138cat native/omega/allen/tests/check.om native/omega/allen/tests/font.om >> "$out/fontroot-mutant.om"
139{ printf 1; cat "$core"; } | "$out/font-mutants" > "$out/fontalpha-mutant.om"
140cat native/omega/allen/tests/check.om native/omega/allen/tests/font.om >> "$out/fontalpha-mutant.om"
141native/omega/allen/build-one.sh native/omega/allen/tests/provider-display-mutants.om "$out/provider-display-mutants"
142{ printf 0; cat "$core"; } | "$out/provider-display-mutants" > "$out/rawask-mutant.om"
143cat native/omega/allen/tests/check.om native/omega/allen/tests/provider-core.om >> "$out/rawask-mutant.om"
144{ printf 1; cat "$core"; } | "$out/provider-display-mutants" > "$out/rawrecv-mutant.om"
145cat native/omega/allen/tests/check.om native/omega/allen/tests/provider-core.om >> "$out/rawrecv-mutant.om"
146{ printf 2; cat "$core"; } | "$out/provider-display-mutants" > "$out/rawreset-mutant.om"
147cat native/omega/allen/tests/check.om native/omega/allen/tests/provider-core.om >> "$out/rawreset-mutant.om"
148native/omega/allen/build-one.sh native/omega/allen/tests/surface-mutants.om "$out/surface-mutants"
149{ printf 0; cat "$core"; } | "$out/surface-mutants" > "$out/clipright-mutant.om"
150cat native/omega/allen/tests/check.om native/omega/allen/tests/surface.om >> "$out/clipright-mutant.om"
151{ printf 1; cat "$core"; } | "$out/surface-mutants" > "$out/blendbg-mutant.om"
152cat native/omega/allen/tests/check.om native/omega/allen/tests/surface.om >> "$out/blendbg-mutant.om"
153for name in stale crc hash readback session keepalive ackstop pendingwire appcode thinking scenecap contextnote contextjob autosent framecheck staleview inputtail fontroot fontalpha rawask rawrecv rawreset clipright blendbg; do
154 native/omega/allen/build-one.sh "$out/$name-mutant.om" "$out/$name-mutant"
155 set +e
156 "$out/$name-mutant" > "$out/$name-mutant.log"
157 rc=$?
158 set -e
159 if [ "$rc" -le 0 ] || [ "$rc" -ge 100 ]; then echo "mutant did not fail behaviorally: $name exit=$rc" >&2; exit 1; fi
160 printf '%s mutant compile=0 rejected-exit=%s\n' "$name" "$rc"
161done
162find native/omega/allen -type f -print0 | sort -z | xargs -0 sha256sum > "$out/source.sha256"
163find "$out" -maxdepth 1 -type f -perm -100 -exec sha256sum {} + > "$out/binaries.sha256"
164printf 'ALLEN_OMEGA_HOST: PASS; target=NOT_RUN; live=NOT_RUN\n'