#!/bin/sh # Run libbsd's upstream test suite -- the programmes test/Makefile declares in # check_PROGRAMS once configure has resolved its conditionals for this arm -- # and report one PASS:/FAIL:/SKIP: 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 sets AM_TESTS_ENVIRONMENT (CC, CPPFLAGS, # top_srcdir), but every one of those variables exists for the two check_SCRIPTS # that compile header snippets; not one of the compiled programmes reads the # environment at all. There is no LOG_COMPILER and no per-test wrapper, so there # is nothing else automake would have added. # # THE TWO check_SCRIPTS ARE REPORTED SKIP, BY NAME. Upstream declares # TESTS = $(check_SCRIPTS) $(check_PROGRAMS), and headers-overlay.sh / # headers-system.sh compile a generated .c against each installed header with # $CC. The image ships no C compiler, so they have no subject here -- this is a # build-host check of the header set, not a runtime property of the port. Their # names are staged by do_install_ptest (queried from make, not typed) so this # report names what it did not run rather than being two entries shorter than # upstream's TESTS. # # EACH PROGRAMME IS INVOKED BY ABSOLUTE PATH, which nlist depends on: it calls # nlist(argv[0], ...) to read its own symbol table, so argv[0] has to be # something openable from the working directory the run happens in. # # A WRITABLE WORKING DIRECTORY is provided even though no programme in the suite # writes a file today (checked: the only opens are /dev/null and /dev/zero for # reading, plus pipes). The deployed rootfs is read-only at browser runtime, and # a suite that acquires a scratch-writing case on a version bump should get a red # from that case rather than from the whole run failing to start. set -u pdir=$(cd "$(dirname "$0")" && pwd) work=$(mktemp -d "${TMPDIR:-/tmp}/libbsd-ptest.XXXXXX" 2>/dev/null) \ || { work="${TMPDIR:-/tmp}/libbsd-ptest.$$"; mkdir -p "$work"; } [ -d "$work" ] || { echo "FAIL: libbsd-ptest-setup (no writable scratch dir)"; exit 1; } cd "$work" || { echo "FAIL: libbsd-ptest-setup (cannot enter $work)"; exit 1; } if [ -f "$pdir/skipped-scripts" ]; then while read -r s; do [ -n "$s" ] || continue echo "SKIP: $s" done < "$pdir/skipped-scripts" fi 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