interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / om / codec / test / gen / check-tailscale.sh

39 lines · 1650 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0
3# One-time cross-check of gen/oracle's transcription of tailscale.com v1.102.0 tka.AUMHash and
4# key.NodePublic text methods against the real package. Not run by run.sh: it needs network access
5# for the tailscale.com module and a Go toolchain >= 1.26.5 (that module's minimum), while
6# gen/oracle is built with go1.26.0.
7# Usage: sh om/codec/test/gen/check-tailscale.sh [SEED...] (default seeds 1 2 3)
8# Environment: GO (default go). Exit 0 only when both referees agree on every case.
9set -eu
10here=$(cd "$(dirname "$0")" && pwd)
11root=$(cd "$here/../../../.." && pwd)
12out="$root/build/test/codec/tscheck"
13go=${GO:-go}
14mkdir -p "$out"
15(cd "$here/oracle" && GOTOOLCHAIN=go1.26.0 "$go" build -o "$out/oracle" .)
16(cd "$here/tsoracle" && GOTOOLCHAIN=local "$go" build -o "$out/tsoracle" .)
17echo "codec: oracle $(GOTOOLCHAIN=go1.26.0 "$go" version)"
18echo "codec: tsoracle $(GOTOOLCHAIN=local "$go" version)"
19fail=0
20check() { # check NAME CASEFILE
21 grep -E '^(aume|aumd|nkye|nkyd) ' "$2" > "$out/$1.in" || true
22 "$out/oracle" < "$out/$1.in" > "$out/$1.oracle"
23 "$out/tsoracle" < "$out/$1.in" > "$out/$1.ts"
24 n=$(wc -l < "$out/$1.in" | tr -d ' ')
25 if cmp -s "$out/$1.oracle" "$out/$1.ts"; then
26 echo "codec: tailscale cross-check $1 $n/$n PASS"
27 else
28 echo "codec: tailscale cross-check $1 FAIL ($(cmp "$out/$1.oracle" "$out/$1.ts" 2>&1 || true))"
29 fail=1
30 fi
31}
32"$out/oracle" corpus | grep -v '^#' > "$out/corpus.cases"
33check corpus "$out/corpus.cases"
34[ $# -gt 0 ] || set -- 1 2 3
35for s in "$@"; do
36 "$out/oracle" rand "$s" > "$out/rand-$s.cases"
37 check "rand-$s" "$out/rand-$s.cases"
38done
39exit "$fail"