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 / tests / autodiff664 / run-tape.sh

43 lines · 2058 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: AGPL-3.0-only
3# Build and run the native tape test and its four compiled mutants.
4# OMC=<pinned seed/out/omc> OUT=<scratch dir> sh tests/autodiff664/run-tape.sh
5# Host build glue only: concatenation and process exits. All logic is in .om.
6set -u
7ROOT=$(cd "$(dirname "$0")/../.." && pwd)
8: "${OMC:?set OMC to the pinned seed/out/omc}"
9: "${OUT:?set OUT to a scratch directory}"
10mkdir -p "$OUT"
11META=$ROOT/native/ecosystem663/metadata.om
12TAPE=$ROOT/native/autodiff664/tape.om
13TEST=$ROOT/tests/autodiff664/tape-test.om
14fail() { echo "TAPE_SUITE_FAIL $1"; exit 1; }
15
16build() { # $1 unit.om $2 out.elf $3 tag
17 "$OMC" < "$1" > "$2" 2> "$OUT/$3.compile.stderr"
18 echo $? > "$OUT/$3.compile.rc"
19 [ "$(cat "$OUT/$3.compile.rc")" = 0 ] || return 1
20 [ "$(od -An -tx1 -N4 "$2" | tr -d ' ')" = 7f454c46 ] || return 1
21 chmod 700 "$2"
22}
23
24sha256sum "$OMC" > "$OUT/omc.sha256"
25cat "$META" "$TAPE" "$TEST" > "$OUT/tape-test.unit.om"
26build "$OUT/tape-test.unit.om" "$OUT/tape-test.elf" tape-test || fail compile
27"$OUT/tape-test.elf" > "$OUT/tape-test.stdout" 2> "$OUT/tape-test.stderr"
28echo $? > "$OUT/tape-test.rc"
29[ "$(cat "$OUT/tape-test.rc")" = 0 ] || fail tape-test
30grep -q '^NATIVE_TAPE_PASS checks=' "$OUT/tape-test.stdout" || fail tape-test-output
31
32build "$ROOT/tests/autodiff664/mutate.om" "$OUT/mutate.elf" mutate || fail mutate-compile
33for mode in 0 1 2 3; do
34 { printf '%s' "$mode"; cat "$TAPE"; } | "$OUT/mutate.elf" > "$OUT/mutant$mode.tape.om"
35 echo $? > "$OUT/mutant$mode.mutate.rc"
36 [ "$(cat "$OUT/mutant$mode.mutate.rc")" = 0 ] || fail "mutant$mode-inject"
37 cat "$META" "$OUT/mutant$mode.tape.om" "$TEST" > "$OUT/mutant$mode.unit.om"
38 build "$OUT/mutant$mode.unit.om" "$OUT/mutant$mode.elf" "mutant$mode" || fail "mutant$mode-compile"
39 "$OUT/mutant$mode.elf" > "$OUT/mutant$mode.stdout" 2> "$OUT/mutant$mode.stderr"
40 echo $? > "$OUT/mutant$mode.rc"
41 [ "$(cat "$OUT/mutant$mode.rc")" = 1 ] || fail "mutant$mode-survived"
42done
43echo "TAPE_SUITE_PASS $(cat "$OUT/tape-test.stdout")"