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
omega-mv / tests / autodiff664 / run-tape.sh
| 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. |
| 6 | set -u |
| 7 | ROOT=$(cd "$(dirname "$0")/../.." && pwd) |
| 8 | : "${OMC:?set OMC to the pinned seed/out/omc}" |
| 9 | : "${OUT:?set OUT to a scratch directory}" |
| 10 | mkdir -p "$OUT" |
| 11 | META=$ROOT/native/ecosystem663/metadata.om |
| 12 | TAPE=$ROOT/native/autodiff664/tape.om |
| 13 | TEST=$ROOT/tests/autodiff664/tape-test.om |
| 14 | fail() { echo "TAPE_SUITE_FAIL $1"; exit 1; } |
| 15 | |
| 16 | build() { # $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 | |
| 24 | sha256sum "$OMC" > "$OUT/omc.sha256" |
| 25 | cat "$META" "$TAPE" "$TEST" > "$OUT/tape-test.unit.om" |
| 26 | build "$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" |
| 28 | echo $? > "$OUT/tape-test.rc" |
| 29 | [ "$(cat "$OUT/tape-test.rc")" = 0 ] || fail tape-test |
| 30 | grep -q '^NATIVE_TAPE_PASS checks=' "$OUT/tape-test.stdout" || fail tape-test-output |
| 31 | |
| 32 | build "$ROOT/tests/autodiff664/mutate.om" "$OUT/mutate.elf" mutate || fail mutate-compile |
| 33 | for 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" |
| 42 | done |
| 43 | echo "TAPE_SUITE_PASS $(cat "$OUT/tape-test.stdout")" |