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 / om / tls / test / x509 / limbo.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # C2SP x509-limbo against om/tls/x509.om. Usage: sh om/tls/test/x509/limbo.sh OMC [LIMBO_DIR] |
| 4 | # LIMBO_DIR is a clone of https://github.com/C2SP/x509-limbo (cloned into build/ when absent) and is |
| 5 | # checked against the pinned commit below. gen_limbo.py turns limbo.json into driver R records, |
| 6 | # driver.om runs them, limbo.py compares with the expected results; every disagreement must be |
| 7 | # listed in limbo_allow.txt with its reason. Final line "LIMBO PASS|FAIL cases=.. agree=.. ...". |
| 8 | set -eu |
| 9 | omc=${1:?usage: limbo.sh OMC [LIMBO_DIR]} |
| 10 | here=$(cd "$(dirname "$0")" && pwd) |
| 11 | tls=$(cd "$here/../.." && pwd) |
| 12 | root=$(cd "$tls/../.." && pwd) |
| 13 | pin=$(sed -n 's/^OMC_PIN=//p' "$root/om/units.sh") |
| 14 | limbo_pin=1080e565f26e544bbe9cf99953be8a57c08e7e20 |
| 15 | out="$root/build/tls/x509/limbo" |
| 16 | src=${2:-$root/build/tls/x509/limbo-src} |
| 17 | run() { nice -n 19 ionice -c3 "$@"; } |
| 18 | |
| 19 | [ "$(sha256sum < "$omc" | cut -c1-64)" = "$pin" ] || { echo "LIMBO FAIL omc is not the pinned compiler"; exit 1; } |
| 20 | [ -d "$src/.git" ] || git clone -q https://github.com/C2SP/x509-limbo "$src" |
| 21 | head=$(git -C "$src" rev-parse HEAD) |
| 22 | case $limbo_pin in "$head"*) ;; *) |
| 23 | git -C "$src" fetch -q origin "$limbo_pin" 2>/dev/null || true |
| 24 | git -C "$src" -c advice.detachedHead=false checkout -q "$limbo_pin" || { echo "LIMBO FAIL limbo not at $limbo_pin"; exit 1; } |
| 25 | head=$(git -C "$src" rev-parse HEAD) ;; |
| 26 | esac |
| 27 | rm -rf "$out" |
| 28 | mkdir -p "$out" |
| 29 | python3 "$here/gen_limbo.py" "$src/limbo.json" "$out" > /dev/null |
| 30 | { echo om2; cat "$tls/sha2.om" "$tls/hkdf.om" "$tls/ec.om" "$tls/rsa.om" "$tls/x509.om" "$here/driver.om"; } > "$out/driver.om" |
| 31 | if ! run "$omc" < "$out/driver.om" > "$out/driver" 2> "$out/driver.err" || [ -s "$out/driver.err" ]; then |
| 32 | echo "LIMBO FAIL omc refused driver.om: $(cat "$out/driver.err")" |
| 33 | exit 1 |
| 34 | fi |
| 35 | chmod +x "$out/driver" |
| 36 | rc=0 |
| 37 | (cd "$out" && run ./driver < cases.txt > results.txt) || rc=$? |
| 38 | echo "limbo $head driver $(sha256sum < "$out/driver" | cut -c1-64) exit $rc" |
| 39 | [ "$rc" -eq 0 ] || { echo "LIMBO FAIL driver exit $rc (a trap is a failure)"; exit 1; } |
| 40 | python3 "$here/limbo.py" "$out/meta.tsv" "$out/results.txt" "$here/limbo_allow.txt" | tee "$out/judge.txt" | grep -v '^ *[0-9]* explained' |
| 41 | tail -1 "$out/judge.txt" | grep -q '^LIMBO PASS' |