interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / test_build_failures.sh

44 lines · 1914 bytes Raw Blame History
1#!/bin/sh
2# Offline qualification controls; the real native runner builds and runs every caller.
3set -eu
4ROOT=$(cd "$(dirname "$0")/../.." && pwd)
5: "${OMEGA_NATIVE_OMC:?set OMEGA_NATIVE_OMC to the pinned seeded compiler}"
6ZIG=${ZIG:-$HOME/.local/opt/zig-linux-aarch64-0.13.0/zig}
7GO=${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; }
9D=$(mktemp -d)
10trap 'rm -rf "$D"' EXIT HUP INT TERM
11mkdir "$D/zig-fail" "$D/go-fail"
12cat > "$D/zig-fail/zig" <<'SH'
13#!/bin/sh
14printf 'CONTROL: Zig build refused\n' >&2
15exit 42
16SH
17cat > "$D/go-fail/go" <<'SH'
18#!/bin/sh
19printf 'CONTROL: Go build refused\n' >&2
20exit 43
21SH
22chmod +x "$D/zig-fail/zig" "$D/go-fail/go"
23P=$(dirname "$ZIG"):$(dirname "$GO"):$PATH
24check() {
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}
34check zig-build "$D/zig-fail:$P" 'NATIVE-CALL FAIL' 'CONTROL: Zig build refused'
35check 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.
37check 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}
41grep -Fq 'PASS zig caller' "$D/positive.log"
42grep -Fq 'PASS go caller' "$D/positive.log"
43grep -Fq 'NATIVE-CALL PASS (not run: none)' "$D/positive.log"
44echo 'PASS native callers: Zig and Go built and executed; no missing languages'