#!/bin/sh # ptest-runner entry point for kmod's upstream testsuite. # # Only the preload-independent unit programs are shipped. kmod's harness fakes # the filesystem, uname(2), init_module(2) and delete_module(2) by LD_PRELOADing # four -shared override libraries, and no DSO can exist on this arm, so the # eleven programs whose cases set a .config vector cannot be built at all -- see # the recipe bbappend. What remains is upstream's own coverage of the containers # libkmod is built from: hash, array, scratchbuf, strbuf and list. # # Each program prints "TESTSUITE: PASSED: " (and FAILED/SKIPPED); this # translates them to the PASS:/FAIL:/SKIP: verbs ptest-runner parses. cd "$(dirname "$0")" || exit 1 tmp="${TMPDIR:-/tmp}/kmod-ptest.$$" rc=0 # :. The count is asserted, not decorative: # TESTSUITE_MAIN finds its cases through the __start_kmod_tests/__stop_kmod_tests # linker section symbols, declared weak, so if those do not resolve the iteration # is simply empty and the program exits 0 having asserted nothing -- a silent # green indistinguishable from a clean run in any summary that only counts cases. for spec in test-hash:9 test-array:6 test-scratchbuf:2 test-strbuf:2 test-list:7; do prog=${spec%:*} want=${spec#*:} exe="testsuite/$prog" if [ ! -x "$exe" ]; then echo "FAIL: $prog/present" rc=1 continue fi "$exe" > "$tmp" 2>&1 prc=$? # Upstream LOGs to stdout, which is a pipe under ptest-runner and therefore # fully buffered; each fork()ed child inherits the parent's pending buffer # and flushes it again on exit, so every result line reappears once per # subsequent case. Dedupe by case name -- the counts depend on it, not just # the tidiness of the output. sed -n 's/.*PASSED: \([A-Za-z0-9_]*\).*/PASS: \1/p' "$tmp" | sort -u sed -n 's/.*SKIPPED: \([A-Za-z0-9_]*\).*/SKIP: \1/p' "$tmp" | sort -u got=$(sed -n 's/.*\(PASSED\|SKIPPED\): \([A-Za-z0-9_]*\).*/\2/p' "$tmp" | sort -u | wc -l) [ -n "$got" ] || got=0 # TESTSUITE_MAIN exits at the FIRST failing case, so a program that fails # also comes up short on the count; both are reported, because "6 of 9 ran" # and "the run aborted" are different things to a reader. if [ "$got" -eq 0 ]; then echo "FAIL: $prog/no-cases" rc=1 elif [ "$got" -ne "$want" ]; then echo "FAIL: $prog/cases-$got-of-$want" rc=1 fi if [ "$prc" -ne 0 ]; then echo "FAIL: $prog/exit-$prc" rc=1 fi done rm -f "$tmp" exit $rc