kernel-selftest: Report per-test results in ptest

run-ptest printed "PASS: kernel-selftest" or "[FAIL]: kernel-selftest".
The latter does not match the FAIL: pattern of the ptest log parser, so
whenever any selftest failed testimage reported no results at all:

  ptests which had no test results:
  ['kernel-selftest']

Convert the per-test TAP lines from run_kselftest.sh into PASS:, FAIL:
and SKIP: lines, so results are recorded and failing selftests are
listed by name.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-11-11 22:46:08 -08:00
1 parent 1a0b3b004c
commit 8679eabed8
1 file changed
+19 -6
@@ -7,9 +7,22 @@
# move to their own process group, escape the per-test timeout and keep the
# runner blocked (and silent) until they finish, so ptest-runner kills the
# whole suite. Skip it.
/usr/kernel-selftest/run_kselftest.sh -s -S ftrace:ftracetest-ktap -S filesystems:file_stressor
if [ $? == 0 ]; then
echo "PASS: kernel-selftest"
else
echo "[FAIL]: kernel-selftest"
fi
#
# Turn the runner's per-test TAP lines ("ok 3 selftests: cgroup: test_core",
# "not ok 4 ... # exit=1", "ok 5 ... # SKIP") into PASS:/FAIL:/SKIP: lines
# that ptest log parsers understand, keeping the original output too.
/usr/kernel-selftest/run_kselftest.sh -s -S ftrace:ftracetest-ktap -S filesystems:file_stressor 2>&1 | awk '
{ print; fflush() }
/^(not )?ok [0-9]+ selftests: / {
res = "PASS"
if ($0 ~ /^not ok/)
res = "FAIL"
else if ($0 ~ /# SKIP/)
res = "SKIP"
name = $0
sub(/^(not )?ok [0-9]+ selftests: /, "", name)
sub(/ *#.*$/, "", name)
sub(/: /, ":", name)
print res ": " name
fflush()
}'