interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / omc / gate12.sh

71 lines · 3844 bytes Raw Blame History
1#!/bin/sh
2# gate12.sh -- documented capacities (OMEGESE 9.6, decision 23 as amended 2026-11-11). omc's tables live in
3# one arena, which itself grows at run time (a run-time pool, landing 2 of docs/RUNTIME-POOLS.md); what is
4# left are the host's refusal of that growth, the depth omc's own stack can hold, and the program's own pool limits (OMEGESE 9.4, error 23). Each case is generated, compiled by seed/out/omc, and
5# checked for the documented accept/refuse boundary. The units one past each old table size (8192 names,
6# 4096 functions, 512 blocks, 8 MiB input) are accepted; seed/omc/gate-nocaps.sh takes them far past.
7# RC=0 only when all pass.
8set -eu
9R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
10cd "$R"
11S=seed/out/omc
12[ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; }
13mkdir -p build/seed/r12
14T=$(mktemp -d build/seed/r12/cap.XXXXXX)
15trap 'rm -rf "$T"' EXIT HUP INT TERM
16bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
17say() { printf '%s\n' "$*"; }
18
19accept() { # name file
20 set +e
21 "$S" < "$2" > "$T/$1.out" 2> "$T/$1.err"
22 rc=$?
23 set -e
24 [ "$rc" = 0 ] || bad "$1: exit $rc ($(head -1 "$T/$1.err"))"
25 [ -s "$T/$1.out" ] || bad "$1: empty output"
26 say "PASS $1 accepted"
27}
28refuse() { # name file code
29 set +e
30 "$S" < "$2" > "$T/$1.out" 2> "$T/$1.err"
31 rc=$?
32 set -e
33 [ "$rc" = "$3" ] || bad "$1: exit $rc, wanted $3 ($(head -1 "$T/$1.err"))"
34 grep -q "error $3" "$T/$1.err" || bad "$1: diagnostic does not name error $3"
35 say "PASS $1 error $3"
36}
37
38awk 'BEGIN{for(i=0;i<8193;i++)printf "global g%d uchar 1\n",i; print "fn main to int"; print "ret 0"; print "end"}' > "$T/g8193.om"
39awk 'BEGIN{for(i=0;i<4096;i++)printf "fn q%d to int\nret 0\nend\n",i; print "fn main to int"; print "ret 0"; print "end"}' > "$T/f4096.om"
40awk 'BEGIN{print "fn main to int"; print "x = ulong 1"; for(i=0;i<513;i++)print "if eq x 1"; print "ret 0"; for(i=0;i<513;i++)print "end"; print "ret 0"; print "end"}' > "$T/b513.om"
41printf 'fn main to int\na = new uchar 4194305 0\nret 0\nend\n' > "$T/local.om"
42printf 'fn main to int\na = new uchar 16777217 0\nret 0\nend\n' > "$T/arr.om"
43awk 'BEGIN{for(i=0;i<64;i++)printf "global h%d uchar 16777216\n",i; print "global k uchar 1"; print "fn main to int"; print "ret 0"; print "end"}' > "$T/pools.om"
44# a value nested 32768 deep: past what omc's own 8 MiB stack holds (32767 is accepted)
45for d in 32767 32768; do
46 { printf 'fn main to int\ny = ulong 7\nx = '; awk -v d=$d 'BEGIN { for (i = 0; i < d; i++) printf "ulong " }'; printf 'y\nret int rem x 256\nend\n'; } > "$T/v$d.om"
47done
48# an input one byte over the old 8 MiB buffer: a program after note lines
49{ yes 'note padding' | head -c 8388609 | sed '$d'; printf 'fn main to int\nret 0\nend\n'; } > "$T/big.om"
50# an input past the old static arena (16777216 words, 134217728 bytes), a program after note lines
51{ yes 'note padding' | head -c 134217729 | sed '$d'; printf 'fn main to int\nret 0\nend\n'; } > "$T/arena.om"
52
53accept g8193 "$T/g8193.om"
54accept f4096 "$T/f4096.om"
55accept b513 "$T/b513.om"
56refuse local "$T/local.om" 23
57refuse arr "$T/arr.om" 23
58refuse pools "$T/pools.om" 23
59accept v32767 "$T/v32767.om"
60refuse v32768 "$T/v32768.om" 14
61accept big "$T/big.om"
62accept arena "$T/arena.om"
63# the same input when the host refuses the arena's growth (prlimit --as=67108864): error 14, full=1
64set +e; prlimit --as=67108864 "$S" < "$T/arena.om" > "$T/arenah.out" 2> "$T/arenah.err"; rc=$?; set -e
65[ "$rc" = 14 ] || bad "arena under prlimit --as=67108864: exit $rc, wanted 14 ($(head -1 "$T/arenah.err"))"
66grep -q '^omc-use 1 arena=[0-9]* .* full=1 ' "$T/arenah.err" || bad "arena under prlimit: no omc-use record with full=1"
67say "PASS arena under prlimit --as=67108864 error 14 full=1"
68rm -f "$T/arena.om" "$T/big.om"
69
70say "PASS gate12 11 cases"
71exit 0