aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bench/bench.sh6
-rw-r--r--tests/drivers/jit_x64_test.sh34
-rwxr-xr-xtests/test.sh7
3 files changed, 43 insertions, 4 deletions
diff --git a/tests/bench/bench.sh b/tests/bench/bench.sh
index 65f455e..4ef2ca5 100644
--- a/tests/bench/bench.sh
+++ b/tests/bench/bench.sh
@@ -4,8 +4,12 @@
cd "$(dirname "$0")/../.."; T=$(mktemp -d); trap 'rm -rf $T' EXIT
CC=${CC:-$(sh src/tools/findcc.sh)} || exit 1
make -s build/core/genome.bin || exit 1
-$CC -O2 -w -DJTYPE=int src/core/core.c src/core/io_linux.c -Isrc/core -Ibuild/core/map --embed-dir=build/core -o $T/zy
+$CC -O2 -w -DJTYPE=int -DZYINTERP src/core/core.c src/core/io_linux.c -Isrc/core -Ibuild/core/map --embed-dir=build/core -o $T/zy
vms=("$T/zy"); names=("interp")
+# the host's own jit, where there is one (x86-64 linux: blocks are translated, o3 regions run on the region interpreter)
+if [ "$(uname -s)" = Linux ] && [ "$(uname -m)" = x86_64 ]; then
+ $CC -O2 -w -DJTYPE=int src/core/core.c src/core/io_linux.c -Isrc/core -Ibuild/core/map --embed-dir=build/core -o $T/zyn && { vms+=("$T/zyn"); names+=("x86-64 jit"); }
+fi
if command -v llvm-config >/dev/null; then
$CC -O2 -w -DJTYPE=int -DZYLLVM $(llvm-config --cflags) src/core/core.c src/core/io_linux.c -Isrc/core -Ibuild/core/map --embed-dir=build/core -o $T/zyl $(llvm-config --ldflags --libs) && { vms+=("$T/zyl"); names+=("llvm"); }
fi
diff --git a/tests/drivers/jit_x64_test.sh b/tests/drivers/jit_x64_test.sh
new file mode 100644
index 0000000..ce0438f
--- /dev/null
+++ b/tests/drivers/jit_x64_test.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# runs every program in tests/programs, examples and examples/learn on two cores
+# and compares stdout and the exit status. usage:
+# bash tests/drivers/jit_x64_test.sh <reference core> <jit core> [name-filter]
+# the reference is normally the interpreter (built with -DZYINTERP) and the second
+# core the x86-64 jit. each program is the core's stdin, with nothing after it, and
+# runs with a timeout (JIT_TEST_TIMEOUT seconds, 120 by default). a program that
+# differs is listed with the first lines of the difference; the exit status of
+# this script is the number of programs that differ.
+ref=${1:?usage: jit_x64_test.sh <reference core> <jit core> [filter]}
+jit=${2:?usage: jit_x64_test.sh <reference core> <jit core> [filter]}
+filter=${3:-}
+limit=${JIT_TEST_TIMEOUT:-120}
+root=$(cd "$(dirname "$0")/../.." && pwd)
+cd "$root" || exit 2
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+pass=0 fail=0 total=0
+for f in tests/programs/*.zc examples/*.zc examples/learn/*.zc; do
+ [ -n "$filter" ] && [[ "$f" != *$filter* ]] && continue
+ total=$((total + 1))
+ timeout "$limit" "$ref" < "$f" > "$tmp/ref.out" 2> "$tmp/ref.err"; rr=$?
+ timeout "$limit" "$jit" < "$f" > "$tmp/jit.out" 2> "$tmp/jit.err"; rj=$?
+ if [ "$rr" = "$rj" ] && cmp -s "$tmp/ref.out" "$tmp/jit.out"; then
+ pass=$((pass + 1))
+ else
+ fail=$((fail + 1))
+ echo "DIFF $f (status $rr vs $rj)"
+ diff "$tmp/ref.out" "$tmp/jit.out" | head -6
+ head -3 "$tmp/jit.err"
+ fi
+done
+echo "$pass of $total programs agree, $fail differ"
+exit "$fail"
diff --git a/tests/test.sh b/tests/test.sh
index 298c356..ec93827 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -52,9 +52,10 @@ ROOT=$T
CC=${CC:-$(sh src/tools/findcc.sh)} || exit 1
export CC
-# the language server runs on the interpreter unless the host has the arm64 jit, and a
-# check of a large document then takes many seconds: stretch the drivers' deadlines
-if [ -z "${ZC_TEST_TIMEOUT_SCALE:-}" ]; then case "$(uname -m)" in arm64|aarch64) ZC_TEST_TIMEOUT_SCALE=1;; *) ZC_TEST_TIMEOUT_SCALE=8;; esac; fi
+# the language server runs on the interpreter unless the host has a jit (arm64, or x86-64
+# linux), and a check of a large document then takes many seconds: stretch the drivers'
+# deadlines. the x86-64 jit gets a little room, since it does not compile o3 regions
+if [ -z "${ZC_TEST_TIMEOUT_SCALE:-}" ]; then case "$(uname -s)-$(uname -m)" in *-arm64|*-aarch64) ZC_TEST_TIMEOUT_SCALE=1;; Linux-x86_64) ZC_TEST_TIMEOUT_SCALE=2;; *) ZC_TEST_TIMEOUT_SCALE=8;; esac; fi
export ZC_TEST_TIMEOUT_SCALE
# the default map, generated as make does it, and the tools built against it
$CC -O2 -w -fwrapv src/tools/genmap.c -o $T/genmap || exit 1