From e67671d834f33e1a70f913f0c61f9d0c36292aa8 Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 21:33:50 +0330 Subject: bench: a trap (zy exit 2) is labelled runtime trap with the stdout tail, since zy reports traps on stdout, in suite.py and bench.sh --- tests/bench/bench.sh | 9 +++++---- tests/bench/suite.py | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/bench/bench.sh b/tests/bench/bench.sh index 4032aa0..68232c6 100644 --- a/tests/bench/bench.sh +++ b/tests/bench/bench.sh @@ -24,13 +24,14 @@ if command -v aarch64-linux-gnu-gcc >/dev/null && command -v qemu-aarch64 >/dev/ fi # seconds per run of kernel $2 on vm $1: the slope between $3 runs and 1 run, # best of three each, so starting up and compiling cancel out -# a nonzero zy exit (1 compile error, 2 trap) fails the whole bench, with the stderr tail +# a nonzero zy exit (1 compile error, 2 runtime trap) fails the whole bench, with the tail of +# stderr and stdout (zy reports a trap on stdout) t(){ local s e c err=$(mktemp); s=$(date +%s.%N) - (cat tests/programs/bench.zc; printf '`%s%s' $2 $3) | $1 >/dev/null 2>$err; c=$? + (cat tests/programs/bench.zc; printf '`%s%s' $2 $3) | $1 >$err.out 2>$err; c=$? e=$(date +%s.%N) - if [ $c != 0 ]; then echo "bench.sh: tests/programs/bench.zc kernel $2 ($3 reps) on $1: zy exited $c; stderr tail:" >&2; tail -n 8 $err >&2; rm -f $err; return 1; fi - rm -f $err; echo "$e - $s" | bc + if [ $c != 0 ]; then echo "bench.sh: tests/programs/bench.zc kernel $2 ($3 reps) on $1: zy exited $c ($([ $c = 2 ] && echo runtime trap || { [ $c = 1 ] && echo compile error || echo failed; })); stderr and stdout tail:" >&2; tail -n 8 $err $err.out >&2; rm -f $err $err.out; return 1; fi + rm -f $err $err.out; echo "$e - $s" | bc } best(){ local b=999 x i; for i in 1 2 3; do x=$(t "$1" $2 $3) || return 1; b=$(echo "if ($x < $b) $x else $b" | bc); done; echo $b; } # grows the run count until the difference is at least a second, so the noise diff --git a/tests/bench/suite.py b/tests/bench/suite.py index 83677f5..4870038 100644 --- a/tests/bench/suite.py +++ b/tests/bench/suite.py @@ -97,11 +97,13 @@ def bench_sh(): def zy_failure(what, code, out, err, expect=None): """None when a zy run is good, else the message: a nonzero exit (1 is a compile error, - a trap will be 2) or output other than the expected checksum""" + 2 is a runtime trap) or output other than the expected checksum""" tail = lambda b: "\n".join(b.decode(errors="replace").rstrip().splitlines()[-8:]) or "(empty)" if code != 0: kind = {1: "compile error", 2: "runtime trap"}.get(code, "failed") - return "bench: %s: zy exited %d (%s); stderr tail:\n%s" % (what, code, kind, tail(err)) + # zy reports a trap on stdout, so the tail is of stdout when stderr is empty + which, text = ("stderr", err) if err.strip() else ("stdout", out) + return "bench: %s: zy exited %d (%s); %s tail:\n%s" % (what, code, kind, which, tail(text)) if expect is not None and out.decode(errors="replace").strip() != expect: return "bench: %s: printed %r, expected %r; stderr tail:\n%s" % (what, out.decode(errors="replace").strip()[-200:], expect, tail(err)) return None -- cgit v1.2.3