omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / test_build_failures.sh
| 1 | #!/bin/sh |
| 2 | # Offline qualification controls; the real native runner builds and runs every caller. |
| 3 | set -eu |
| 4 | ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
| 5 | : "${OMEGA_NATIVE_OMC:?set OMEGA_NATIVE_OMC to the pinned seeded compiler}" |
| 6 | ZIG=${ZIG:-$HOME/.local/opt/zig-linux-aarch64-0.13.0/zig} |
| 7 | GO=${GO:-$HOME/.local/opt/go1.27.3/bin/go} |
| 8 | [ -x "$ZIG" ] && [ -x "$GO" ] || { echo 'NOT_RUN: real Zig and Go toolchains required'; exit 1; } |
| 9 | D=$(mktemp -d) |
| 10 | trap 'rm -rf "$D"' EXIT HUP INT TERM |
| 11 | mkdir "$D/zig-fail" "$D/go-fail" |
| 12 | cat > "$D/zig-fail/zig" <<'SH' |
| 13 | #!/bin/sh |
| 14 | printf 'CONTROL: Zig build refused\n' >&2 |
| 15 | exit 42 |
| 16 | SH |
| 17 | cat > "$D/go-fail/go" <<'SH' |
| 18 | #!/bin/sh |
| 19 | printf 'CONTROL: Go build refused\n' >&2 |
| 20 | exit 43 |
| 21 | SH |
| 22 | chmod +x "$D/zig-fail/zig" "$D/go-fail/go" |
| 23 | P=$(dirname "$ZIG"):$(dirname "$GO"):$PATH |
| 24 | check() { |
| 25 | name=$1; path=$2; verdict=$3; signal=$4 |
| 26 | rc=0 |
| 27 | (cd "$ROOT" && PATH="$path" sh tests/native/run.sh) > "$D/$name.log" 2>&1 || rc=$? |
| 28 | if [ "$rc" -eq 0 ] || ! grep -Fq "$verdict" "$D/$name.log" || |
| 29 | ! grep -Fq "$signal" "$D/$name.log" || grep -Fq 'NATIVE-CALL PASS' "$D/$name.log"; then |
| 30 | cat "$D/$name.log"; echo "FAIL control $name (exit $rc)"; exit 1 |
| 31 | fi |
| 32 | echo "PASS control $name (exit $rc; $verdict)" |
| 33 | } |
| 34 | check zig-build "$D/zig-fail:$P" 'NATIVE-CALL FAIL' 'CONTROL: Zig build refused' |
| 35 | check go-build "$D/go-fail:$P" 'NATIVE-CALL FAIL' 'CONTROL: Go build refused' |
| 36 | # Missing toolchains are NOT_RUN, not a green qualification. Other system tools stay available. |
| 37 | check missing '/usr/bin:/bin' 'NATIVE-CALL NOT_RUN' 'NOT_RUN zig caller' |
| 38 | (cd "$ROOT" && PATH="$P" sh tests/native/run.sh) > "$D/positive.log" 2>&1 || { |
| 39 | cat "$D/positive.log"; echo 'FAIL positive native callers'; exit 1; |
| 40 | } |
| 41 | grep -Fq 'PASS zig caller' "$D/positive.log" |
| 42 | grep -Fq 'PASS go caller' "$D/positive.log" |
| 43 | grep -Fq 'NATIVE-CALL PASS (not run: none)' "$D/positive.log" |
| 44 | echo 'PASS native callers: Zig and Go built and executed; no missing languages' |