# gsl-run.sh — shared driver runner for the 76-gsl* suites. # # Sourced by tests/76-gsl.test and tests/76-gsl-heavy.test. It exists because # those two files are ONE suite split by cost (see the header of 76-gsl.test), # and a copy of this classifier in each would be two things to keep in step. GSLT=${BST_GSL_ROOT:-}/usr/libexec/gsl-tests # gsl_scratch_init — THE DRIVERS MUST NOT RUN FROM ${libexecdir}. Seven of them # (block, histogram, matrix, ntuple, rng, spmatrix, vector) create scratch files # in the CURRENT directory and read them back; upstream's CLEANFILES names # test.txt, test.dat and test_static.dat. Run from a read-only root they fail on # their own fopen, which reads exactly like a numerics failure and is not one. gsl_scratch_init() { gsl_scratch=${TMPDIR:-/tmp}/bst-gsl.$$ mkdir -p "$gsl_scratch" 2>/dev/null || gsl_scratch=/tmp } gsl_scratch_done() { rm -rf "$gsl_scratch"; } # gsl_run — run one driver and classify its verdict. # # THE THREE OUTCOMES ARE KEPT APART DELIBERATELY, because they are attributed to # different things and a bare exit status cannot tell them apart: # # ok exit 0 and `Completed [N/N]`. # no summary the driver never reached gsl_test_summary() — it trapped, # was killed, or died in a syscall. That is a PLATFORM # finding, and reporting it as "some assertions failed" would # misattribute it to gsl's numerics. # Completed [P/T] P < T: the driver ran to completion and disagreed with its # own compiled-in expected values. That IS a numerics # finding, and the first FAIL line is carried so the reader # sees which one without re-running anything. gsl_run() { _d=$1 if [ ! -f "$GSLT/$_d" ]; then bst_notok "gsl/$_d" "driver not installed at $GSLT/$_d" return fi _out=$(cd "$gsl_scratch" && "$GSLT/$_d" 2>&1); _rc=$? # The scratch dir is emptied between drivers rather than having named files # removed: a driver that starts writing a fourth file would otherwise leave a # stale one for the next to read back. rm -f "$gsl_scratch"/* 2>/dev/null if bst_execfail "$_out"; then bst_unrun "gsl/$_d" "$_out"; return; fi _sum=$(printf '%s\n' "$_out" | sed -n 's/^Completed \[\([0-9][0-9]*\)\/\([0-9][0-9]*\)\].*/\1 \2/p' | tail -1) if [ -z "$_sum" ]; then bst_notok "gsl/$_d" "no 'Completed [n/m]' summary -- driver did not finish: rc=$_rc $(_bst_1line "$_out")" return fi _p=${_sum% *}; _t=${_sum#* } if [ "$_rc" -eq 0 ] && [ "$_p" = "$_t" ]; then bst_ok "gsl/$_d" else _first=$(printf '%s\n' "$_out" | grep '^FAIL' | head -1) bst_notok "gsl/$_d" "rc=$_rc passed $_p of $_t -- $(_bst_1line "$_first")" fi } gsl_run_all() { gsl_scratch_init for _drv in $1; do gsl_run "$_drv"; done gsl_scratch_done }