run_all.sh raw
1 #!/bin/bash
2 # Moxie full test suite. Runs all test suites and reports results.
3 set -euo pipefail
4
5 TESTDIR="$(cd "$(dirname "$0")" && pwd)"
6 export MOXIEROOT="$(cd "$TESTDIR/.." && pwd)"
7 MOXIE="${MOXIE:-$MOXIEROOT/moxie}"
8 export MOXIE PATH="/usr/lib/llvm19/bin:$PATH"
9
10 total_pass=0
11 total_fail=0
12
13 run_suite() {
14 local name="$1"
15 local script="$2"
16 echo "╔══ $name ══╗"
17 if bash "$script"; then
18 total_pass=$((total_pass + 1))
19 else
20 total_fail=$((total_fail + 1))
21 fi
22 echo ""
23 }
24
25 # Cross-compilation smoke test: verify binaries are produced for each target.
26 cross_compile_check() {
27 local tmpdir=$(mktemp -d)
28 trap "rm -rf $tmpdir" RETURN
29
30 # Set up a proper module directory for the cross-compile test.
31 local moddir="$tmpdir/crossmod"
32 mkdir -p "$moddir"
33 cp "$TESTDIR/restrict/pass_valid_patterns.mx" "$moddir/main.mx"
34 printf 'module crossmod\n\nmoxie 0.1.0\n' > "$moddir/moxie.mod"
35
36 echo "╔══ Cross-compilation ══╗"
37 local pass=0
38 local fail=0
39
40 for target in linux/amd64 linux/arm64; do
41 local goos="${target%/*}"
42 local goarch="${target#*/}"
43 local bin="$tmpdir/${goos}_${goarch}"
44 if (cd "$moddir" && GOOS="$goos" GOARCH="$goarch" "$MOXIE" build -no-debug -o "$bin" .) 2>/dev/null; then
45 local fmt=$(file "$bin" | grep -oP '(ELF|Mach-O)[^,]*' | head -1)
46 echo "OK $target ($fmt)"
47 pass=$((pass + 1))
48 else
49 echo "FAIL $target: compilation failed"
50 fail=$((fail + 1))
51 fi
52 done
53
54 echo ""
55 echo "=== Cross-compile: $pass passed, $fail failed ==="
56 [ "$fail" -eq 0 ]
57 }
58
59 run_suite "Restriction tests" "$TESTDIR/restrict/run.sh"
60 run_suite "Spawn tests" "$TESTDIR/spawn/run.sh"
61 run_suite "Secure allocator (M1)" "$TESTDIR/secalloc/run.sh"
62 run_suite "Secure allocator spawn channel (M2)" "$TESTDIR/secalloc-spawn/run.sh"
63 run_suite "Secure allocator spawn builtin (M3.1)" "$TESTDIR/secalloc-spawn-builtin/run.sh"
64 run_suite "Secure allocator rotation (M3.2)" "$TESTDIR/secalloc-rotate/run.sh"
65 run_suite "Secure allocator clear + lockdown (M3.2b)" "$TESTDIR/secalloc-clear/run.sh"
66 run_suite "Secure allocator memfd_secret (M4)" "$TESTDIR/secalloc-memfd/run.sh"
67
68 if cross_compile_check; then
69 total_pass=$((total_pass + 1))
70 else
71 total_fail=$((total_fail + 1))
72 fi
73
74 echo ""
75 echo "════════════════════════════════════════"
76 echo " Suites: $total_pass passed, $total_fail failed"
77 echo "════════════════════════════════════════"
78 [ "$total_fail" -eq 0 ]
79