omnet
aien-dev/omnet
Brought by drakestapleton
omnet / om / codec / test / gen / vectors.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Regenerates test/vectors/malformed.txt: the hand-made corpus of gen/oracle (oracle corpus) with |
| 4 | # the result Go go1.26.0 gives for each case. Test tooling only. |
| 5 | # Usage: sh om/codec/test/gen/vectors.sh Environment: GO (default go). |
| 6 | set -eu |
| 7 | here=$(cd "$(dirname "$0")" && pwd) |
| 8 | root=$(cd "$here/../../../.." && pwd) |
| 9 | out="$root/build/test/codec/gen" |
| 10 | go=${GO:-go} |
| 11 | mkdir -p "$out" |
| 12 | (cd "$here/oracle" && GOTOOLCHAIN=go1.26.0 "$go" build -o "$out/oracle" .) |
| 13 | "$out/oracle" corpus > "$out/corpus.txt" |
| 14 | grep -v '^#' "$out/corpus.txt" | "$out/oracle" > "$out/corpus.res" |
| 15 | v="$here/../vectors/malformed.txt" |
| 16 | { |
| 17 | echo "# om/codec malformed-input corpus: OP ARG RESULT, in the driver's case and result format." |
| 18 | echo "# Cases: test/gen/oracle 'corpus'. Results: Go $(GOTOOLCHAIN=go1.26.0 "$go" env GOVERSION)" \ |
| 19 | "encoding/base64, encoding/base32, encoding/hex and" |
| 20 | echo "# the transcribed tailscale.com v1.102.0 AUMHash/NodePublic UnmarshalText (gen/oracle/main.go)." |
| 21 | echo "# Generated by test/gen/vectors.sh. Lines starting with # name the input class that follows." |
| 22 | awk 'NR == FNR { r[NR] = $0; next } /^#/ { print; next } { print $0, r[++i] }' \ |
| 23 | "$out/corpus.res" "$out/corpus.txt" |
| 24 | } > "$v" |
| 25 | echo "vectors: $(grep -vc '^#' "$v") cases written to $v" |