~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/lkdtm/run.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/lkdtm/run.sh (Architecture m68k) and /tools/testing/selftests/lkdtm/run.sh (Architecture sparc)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 #                                                   3 #
  4 # This reads tests.txt for the list of LKDTM t      4 # This reads tests.txt for the list of LKDTM tests to invoke. Any marked
  5 # with a leading "#" are skipped. The rest of       5 # with a leading "#" are skipped. The rest of the line after the
  6 # test name is either the text to look for in       6 # test name is either the text to look for in dmesg for a "success",
  7 # or the rationale for why a test is marked to      7 # or the rationale for why a test is marked to be skipped.
  8 #                                                   8 #
  9 set -e                                              9 set -e
 10 TRIGGER=/sys/kernel/debug/provoke-crash/DIRECT     10 TRIGGER=/sys/kernel/debug/provoke-crash/DIRECT
 11 CLEAR_ONCE=/sys/kernel/debug/clear_warn_once       11 CLEAR_ONCE=/sys/kernel/debug/clear_warn_once
 12 KSELFTEST_SKIP_TEST=4                              12 KSELFTEST_SKIP_TEST=4
 13                                                    13 
 14 # Verify we have LKDTM available in the kernel     14 # Verify we have LKDTM available in the kernel.
 15 if [ ! -r $TRIGGER ] ; then                        15 if [ ! -r $TRIGGER ] ; then
 16         /sbin/modprobe -q lkdtm || true            16         /sbin/modprobe -q lkdtm || true
 17         if [ ! -r $TRIGGER ] ; then                17         if [ ! -r $TRIGGER ] ; then
 18                 echo "Cannot find $TRIGGER (mi     18                 echo "Cannot find $TRIGGER (missing CONFIG_LKDTM?)"
 19         else                                       19         else
 20                 echo "Cannot write $TRIGGER (n     20                 echo "Cannot write $TRIGGER (need to run as root?)"
 21         fi                                         21         fi
 22         # Skip this test                           22         # Skip this test
 23         exit $KSELFTEST_SKIP_TEST                  23         exit $KSELFTEST_SKIP_TEST
 24 fi                                                 24 fi
 25                                                    25 
 26 # Figure out which test to run from our script     26 # Figure out which test to run from our script name.
 27 test=$(basename $0 .sh)                            27 test=$(basename $0 .sh)
 28 # Look up details about the test from master l     28 # Look up details about the test from master list of LKDTM tests.
 29 line=$(grep -E '^#?'"$test"'\b' tests.txt)         29 line=$(grep -E '^#?'"$test"'\b' tests.txt)
 30 if [ -z "$line" ]; then                            30 if [ -z "$line" ]; then
 31         echo "Skipped: missing test '$test' in     31         echo "Skipped: missing test '$test' in tests.txt"
 32         exit $KSELFTEST_SKIP_TEST                  32         exit $KSELFTEST_SKIP_TEST
 33 fi                                                 33 fi
 34 # Check that the test is known to LKDTM.           34 # Check that the test is known to LKDTM.
 35 if ! grep -E -q '^'"$test"'$' "$TRIGGER" ; the     35 if ! grep -E -q '^'"$test"'$' "$TRIGGER" ; then
 36         echo "Skipped: test '$test' missing in     36         echo "Skipped: test '$test' missing in $TRIGGER!"
 37         exit $KSELFTEST_SKIP_TEST                  37         exit $KSELFTEST_SKIP_TEST
 38 fi                                                 38 fi
 39                                                    39 
 40 # Extract notes/expected output from test list     40 # Extract notes/expected output from test list.
 41 test=$(echo "$line" | cut -d" " -f1)               41 test=$(echo "$line" | cut -d" " -f1)
 42 if echo "$line" | grep -q ' ' ; then               42 if echo "$line" | grep -q ' ' ; then
 43         expect=$(echo "$line" | cut -d" " -f2-     43         expect=$(echo "$line" | cut -d" " -f2-)
 44 else                                               44 else
 45         expect=""                                  45         expect=""
 46 fi                                                 46 fi
 47                                                    47 
 48 # If the test is commented out, report a skip      48 # If the test is commented out, report a skip
 49 if echo "$test" | grep -q '^#' ; then              49 if echo "$test" | grep -q '^#' ; then
 50         test=$(echo "$test" | cut -c2-)            50         test=$(echo "$test" | cut -c2-)
 51         if [ -z "$expect" ]; then                  51         if [ -z "$expect" ]; then
 52                 expect="crashes entire system"     52                 expect="crashes entire system"
 53         fi                                         53         fi
 54         echo "Skipping $test: $expect"             54         echo "Skipping $test: $expect"
 55         exit $KSELFTEST_SKIP_TEST                  55         exit $KSELFTEST_SKIP_TEST
 56 fi                                                 56 fi
 57                                                    57 
 58 # If no expected output given, assume an Oops      58 # If no expected output given, assume an Oops with back trace is success.
 59 repeat=1                                           59 repeat=1
 60 if [ -z "$expect" ]; then                          60 if [ -z "$expect" ]; then
 61         expect="call trace:"                       61         expect="call trace:"
 62 else                                               62 else
 63         if echo "$expect" | grep -q '^repeat:'     63         if echo "$expect" | grep -q '^repeat:' ; then
 64                 repeat=$(echo "$expect" | cut      64                 repeat=$(echo "$expect" | cut -d' ' -f1 | cut -d: -f2)
 65                 expect=$(echo "$expect" | cut      65                 expect=$(echo "$expect" | cut -d' ' -f2-)
 66         fi                                         66         fi
 67 fi                                                 67 fi
 68                                                    68 
 69 # Prepare log for report checking                  69 # Prepare log for report checking
 70 LOG=$(mktemp --tmpdir -t lkdtm-log-XXXXXX)         70 LOG=$(mktemp --tmpdir -t lkdtm-log-XXXXXX)
 71 DMESG=$(mktemp --tmpdir -t lkdtm-dmesg-XXXXXX)     71 DMESG=$(mktemp --tmpdir -t lkdtm-dmesg-XXXXXX)
 72 cleanup() {                                        72 cleanup() {
 73         rm -f "$LOG" "$DMESG"                      73         rm -f "$LOG" "$DMESG"
 74 }                                                  74 }
 75 trap cleanup EXIT                                  75 trap cleanup EXIT
 76                                                    76 
 77 # Reset WARN_ONCE counters so we trip it each      77 # Reset WARN_ONCE counters so we trip it each time this runs.
 78 if [ -w $CLEAR_ONCE ] ; then                       78 if [ -w $CLEAR_ONCE ] ; then
 79         echo 1 > $CLEAR_ONCE                       79         echo 1 > $CLEAR_ONCE
 80 fi                                                 80 fi
 81                                                    81 
 82 # Save existing dmesg so we can detect new con     82 # Save existing dmesg so we can detect new content below
 83 dmesg > "$DMESG"                                   83 dmesg > "$DMESG"
 84                                                    84 
 85 # Since the kernel is likely killing the proce     85 # Since the kernel is likely killing the process writing to the trigger
 86 # file, it must not be the script's shell itse     86 # file, it must not be the script's shell itself. i.e. we cannot do:
 87 #     echo "$test" >"$TRIGGER"                     87 #     echo "$test" >"$TRIGGER"
 88 # Instead, use "cat" to take the signal. Since     88 # Instead, use "cat" to take the signal. Since the shell will yell about
 89 # the signal that killed the subprocess, we mu     89 # the signal that killed the subprocess, we must ignore the failure and
 90 # continue. However we don't silence stderr si     90 # continue. However we don't silence stderr since there might be other
 91 # useful details reported there in the case of     91 # useful details reported there in the case of other unexpected conditions.
 92 for i in $(seq 1 $repeat); do                      92 for i in $(seq 1 $repeat); do
 93         echo "$test" | cat >"$TRIGGER" || true     93         echo "$test" | cat >"$TRIGGER" || true
 94 done                                               94 done
 95                                                    95 
 96 # Record and dump the results                      96 # Record and dump the results
 97 dmesg | comm --nocheck-order -13 "$DMESG" - >      97 dmesg | comm --nocheck-order -13 "$DMESG" - > "$LOG" || true
 98                                                    98 
 99 cat "$LOG"                                         99 cat "$LOG"
100 # Check for expected output                       100 # Check for expected output
101 if grep -E -qi "$expect" "$LOG" ; then            101 if grep -E -qi "$expect" "$LOG" ; then
102         echo "$test: saw '$expect': ok"           102         echo "$test: saw '$expect': ok"
103         exit 0                                    103         exit 0
104 else                                              104 else
105         if grep -E -qi XFAIL: "$LOG" ; then       105         if grep -E -qi XFAIL: "$LOG" ; then
106                 echo "$test: saw 'XFAIL': [SKI    106                 echo "$test: saw 'XFAIL': [SKIP]"
107                 exit $KSELFTEST_SKIP_TEST         107                 exit $KSELFTEST_SKIP_TEST
108         else                                      108         else
109                 echo "$test: missing '$expect'    109                 echo "$test: missing '$expect': [FAIL]"
110                 exit 1                            110                 exit 1
111         fi                                        111         fi
112 fi                                                112 fi
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php