Repository navigation
Expand file tree
/
Copy pathlinear_gate.sh
More file actions
executable file
·75 lines (66 loc) · 2.9 KB
/
Copy pathlinear_gate.sh
File metadata and controls
executable file
·75 lines (66 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# THE LINEARITY GATE: our checker's diagnostics against `codexcheck`, on the 26
# corpus units that exercise the linear / mutable discipline.
#
# ./linear_gate.sh
#
# TWO-SIDED ON PURPOSE. Eighteen of these MUST be refused and eight MUST pass
# clean, and the eight are the half that is easy to lose: a checker that reports
# an error on every program passes the first half of this gate perfectly.
#
# The oracle prints one of two shapes and both carry the count:
#
# check-errors 0 ... clean
# CODEGEN-HALTED: 3 error(s); ... first CDX2061 ... ... refused
#
# so the comparison is the COUNT, plus the first code where there is one. A
# count that matches with the wrong code is not agreement, and this reports it
# as CODE so it cannot hide inside a green number.
set -u
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UNITS="${UNITS:-$HOME/units-current}"
BIN="${CHECKDUMP:-${CARGO_TARGET_DIR:-$HOME/build/rust-target}/release/checkdump}"
ORACLE="${CODEXCHECK:-$HOME/codexir/codexcheck}"
[ -x "$BIN" ] || { echo "no checkdump at $BIN; cargo build --release"; exit 2; }
[ -x "$ORACLE" ] || { echo "no codexcheck at $ORACLE"; exit 2; }
[ -d "$UNITS" ] || { echo "no units at $UNITS"; exit 2; }
. "$ROOT/gate_provenance.sh"
gate_provenance "$UNITS"
# `mutable-launder-sum-return` refuses for CDX2002 Unknown name: Some -- a
# different subsystem, and counting it here would make this gate lie about
# linearity. Excluded by name, with the reason.
declare -A NOT_OURS=( [mutable-launder-sum-return]="CDX2002 Unknown name: Some -- not the linear discipline" )
agree=0; differ=0; skipped=0
for u in "$UNITS"/linear-*.codex "$UNITS"/mutable-*.codex "$UNITS"/serial-*.codex; do
[ -e "$u" ] || continue
n="$(basename "$u" .codex)"
if [ -n "${NOT_OURS[$n]:-}" ]; then
printf '%-30s skipped -- %s\n' "$n" "${NOT_OURS[$n]}"
skipped=$((skipped + 1)); continue
fi
# count and first code from either shape, from either side
read_pair() {
local out="$1"
local c k
c="$(printf '%s' "$out" | sed -n 's/^check-errors \([0-9]*\).*/\1/p' | head -1)"
if [ -z "$c" ]; then
c="$(printf '%s' "$out" | sed -n 's/^CODEGEN-HALTED: \([0-9]*\) error.*/\1/p' | head -1)"
fi
k="$(printf '%s' "$out" | grep -o 'CDX[0-9]*' | head -1)"
printf '%s %s' "${c:-?}" "${k:--}"
}
ours="$(read_pair "$("$BIN" check "$u" 2>/dev/null)")"
theirs="$(read_pair "$("$ORACLE" < "$u" 2>&1)")"
if [ "$ours" = "$theirs" ]; then
printf '%-30s ok %s\n' "$n" "$theirs"
agree=$((agree + 1))
else
printf '%-30s DIFFERS ours[%s] oracle[%s]\n' "$n" "$ours" "$theirs"
differ=$((differ + 1))
fi
done
echo
echo "$agree agree, $differ differ, $skipped skipped"
[ $differ -eq 0 ] || { echo RED; exit 1; }
[ $agree -gt 0 ] || { echo "nothing was compared"; echo RED; exit 1; }
echo GREEN