Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/lkdtm: Add way to repeat a test

Some LKDTM tests need to be run more than once (usually to setup and
then later trigger). Until now, the only case was the SOFT_LOCKUP test,
which wasn't useful to run in the bulk selftests. The coming stack canary
checking needs to run twice, so support this with a new test output prefix
"repeat".

Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20211022223826.330653-2-keescook@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Kees Cook and committed by
Greg Kroah-Hartman
149538cd 0e53a9e0

+9 -1
+9 -1
tools/testing/selftests/lkdtm/run.sh
··· 56 56 fi 57 57 58 58 # If no expected output given, assume an Oops with back trace is success. 59 + repeat=1 59 60 if [ -z "$expect" ]; then 60 61 expect="call trace:" 62 + else 63 + if echo "$expect" | grep -q '^repeat:' ; then 64 + repeat=$(echo "$expect" | cut -d' ' -f1 | cut -d: -f2) 65 + expect=$(echo "$expect" | cut -d' ' -f2-) 66 + fi 61 67 fi 62 68 63 69 # Prepare log for report checking ··· 89 83 # the signal that killed the subprocess, we must ignore the failure and 90 84 # continue. However we don't silence stderr since there might be other 91 85 # useful details reported there in the case of other unexpected conditions. 92 - echo "$test" | cat >"$TRIGGER" || true 86 + for i in $(seq 1 $repeat); do 87 + echo "$test" | cat >"$TRIGGER" || true 88 + done 93 89 94 90 # Record and dump the results 95 91 dmesg | comm --nocheck-order -13 "$DMESG" - > "$LOG" || true