#!/bin/sh # Run libmpc's upstream test suite -- the 74 programmes tests/Makefile.am # declares in check_PROGRAMS -- and report one PASS:/FAIL: line each, which is # the protocol ptest-runner reads. # # THIS IS NOT `make check`, AND IT CANNOT BE. automake's check-TESTS needs make, # a shell test-driver and the whole build tree; the image ships none of those and # the tree does not survive packaging. What automake would do with these # programmes is exactly what the loop below does -- run each one, exit status is # the verdict -- so the suite's own semantics are preserved while the harness # around it is not. Upstream declares no TESTS_ENVIRONMENT and no per-test # wrapper (LOG_COMPILER is $(VALGRIND), empty unless configured), so there is # nothing else automake would have added. # # TWO ENVIRONMENT FACTS THIS SCRIPT EXISTS TO SATISFY: # # srcdir the programmes find their .dat reference vectors through # getenv("srcdir") (tests/read_data.c:51), falling back to "." -- and # "." is not where the vectors are, because the cwd has to be # writable. Pointed at the read-only vector directory explicitly. # # cwd tio_str writes a scratch file through the RELATIVE path "mpc_test" # (tests/tio_str.c:118 and :168). The deployed rootfs is read-only at # browser runtime, so the run has to happen somewhere writable or # that one programme fails for a reason unrelated to libmpc. # # The scratch directory is created with mktemp -d where available and a # pid-suffixed fallback otherwise; either way it is removed on the way out, so a # second run does not inherit the first one's mpc_test. set -u pdir=$(cd "$(dirname "$0")" && pwd) work=$(mktemp -d "${TMPDIR:-/tmp}/libmpc-ptest.XXXXXX" 2>/dev/null) \ || { work="${TMPDIR:-/tmp}/libmpc-ptest.$$"; mkdir -p "$work"; } [ -d "$work" ] || { echo "FAIL: libmpc-ptest-setup (no writable scratch dir)"; exit 1; } srcdir="$pdir/tests" export srcdir cd "$work" || { echo "FAIL: libmpc-ptest-setup (cannot enter $work)"; exit 1; } for prog in "$pdir"/progs/*; do [ -f "$prog" ] && [ -x "$prog" ] || continue name=$(basename "$prog") if "$prog" >/dev/null 2>&1; then echo "PASS: $name" else echo "FAIL: $name" fi done cd / rm -rf "$work" # The per-test verdicts above are the report; ptest-runner tallies them itself # and a non-zero exit here would be counted a second time as a harness failure. exit 0