1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0+ 2 # SPDX-License-Identifier: GPL-2.0+ 3 # 3 # 4 # Check the console output from an rcutorture 4 # Check the console output from an rcutorture run for oopses. 5 # The "file" is a pathname on the local system 5 # The "file" is a pathname on the local system, and "title" is 6 # a text string for error-message purposes. 6 # a text string for error-message purposes. 7 # 7 # 8 # Usage: parse-console.sh file title 8 # Usage: parse-console.sh file title 9 # 9 # 10 # Copyright (C) IBM Corporation, 2011 10 # Copyright (C) IBM Corporation, 2011 11 # 11 # 12 # Authors: Paul E. McKenney <paulmck@linux.ibm. 12 # Authors: Paul E. McKenney <paulmck@linux.ibm.com> 13 13 14 T="`mktemp -d ${TMPDIR-/tmp}/parse-console.sh. 14 T="`mktemp -d ${TMPDIR-/tmp}/parse-console.sh.XXXXXX`" 15 file="$1" 15 file="$1" 16 title="$2" 16 title="$2" 17 17 18 trap 'rm -f $T.seq $T.diags' 0 18 trap 'rm -f $T.seq $T.diags' 0 19 19 20 . functions.sh 20 . functions.sh 21 21 22 # Check for presence and readability of consol 22 # Check for presence and readability of console output file 23 if test -f "$file" -a -r "$file" 23 if test -f "$file" -a -r "$file" 24 then 24 then 25 : 25 : 26 else 26 else 27 echo $title unreadable console output 27 echo $title unreadable console output file: $file 28 exit 1 28 exit 1 29 fi 29 fi 30 if grep -Pq '\x00' < $file 30 if grep -Pq '\x00' < $file 31 then 31 then 32 print_warning Console output contains 32 print_warning Console output contains nul bytes, old qemu still running? 33 fi 33 fi 34 cat /dev/null > $file.diags 34 cat /dev/null > $file.diags 35 35 36 # Check for proper termination, except for rcu 36 # Check for proper termination, except for rcuscale and refscale. 37 if test "$TORTURE_SUITE" != rcuscale && test " 37 if test "$TORTURE_SUITE" != rcuscale && test "$TORTURE_SUITE" != refscale 38 then 38 then 39 # check for abject failure 39 # check for abject failure 40 40 41 if grep -q FAILURE $file || grep -q -e 41 if grep -q FAILURE $file || grep -q -e '-torture.*!!!' $file 42 then 42 then 43 nerrs=`grep --binary-files=tex 43 nerrs=`grep --binary-files=text '!!!' $file | 44 tail -1 | 44 tail -1 | 45 awk ' 45 awk ' 46 { 46 { 47 normalexit = 1; 47 normalexit = 1; 48 for (i=NF-8;i<=NF;i++) 48 for (i=NF-8;i<=NF;i++) { 49 if (i <= 0 || 49 if (i <= 0 || i !~ /^[0-9]*$/) { 50 bangst 50 bangstring = $0; 51 gsub(/ 51 gsub(/^\[[^]]*] /, "", bangstring); 52 print 52 print bangstring; 53 normal 53 normalexit = 0; 54 exit 0 54 exit 0; 55 } 55 } 56 sum+=$i; 56 sum+=$i; 57 } 57 } 58 } 58 } 59 END { 59 END { 60 if (normalexit) 60 if (normalexit) 61 print sum " in 61 print sum " instances" 62 }'` 62 }'` 63 print_bug $title FAILURE, $ner 63 print_bug $title FAILURE, $nerrs 64 exit 64 exit 65 fi 65 fi 66 66 67 grep --binary-files=text 'torture:.*ve 67 grep --binary-files=text 'torture:.*ver:' $file | 68 grep -E --binary-files=text -v '\(null 68 grep -E --binary-files=text -v '\(null\)|rtc: 000000000* ' | 69 sed -e 's/^(initramfs)[^]]*] //' -e 's 69 sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' | 70 sed -e 's/^.*ver: //' | 70 sed -e 's/^.*ver: //' | 71 awk ' 71 awk ' 72 BEGIN { 72 BEGIN { 73 ver = 0; 73 ver = 0; 74 badseq = 0; 74 badseq = 0; 75 } 75 } 76 76 77 { 77 { 78 if (!badseq && ($1 + 0 != $1 | 78 if (!badseq && ($1 + 0 != $1 || $1 <= ver)) { 79 badseqno1 = ver; 79 badseqno1 = ver; 80 badseqno2 = $1; 80 badseqno2 = $1; 81 badseqnr = NR; 81 badseqnr = NR; 82 badseq = 1; 82 badseq = 1; 83 } 83 } 84 ver = $1 84 ver = $1 85 } 85 } 86 86 87 END { 87 END { 88 if (badseq) { 88 if (badseq) { 89 if (badseqno1 == badse 89 if (badseqno1 == badseqno2 && badseqno2 == ver) 90 print "GP HANG 90 print "GP HANG at " ver " torture stat " badseqnr; 91 else 91 else 92 print "BAD SEQ 92 print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr; 93 } 93 } 94 }' > $T.seq 94 }' > $T.seq 95 95 96 if grep -q SUCCESS $file 96 if grep -q SUCCESS $file 97 then 97 then 98 if test -s $T.seq 98 if test -s $T.seq 99 then 99 then 100 print_warning $title ` 100 print_warning $title `cat $T.seq` 101 echo " " $file 101 echo " " $file 102 exit 2 102 exit 2 103 fi 103 fi 104 else 104 else 105 if grep -q "_HOTPLUG:" $file 105 if grep -q "_HOTPLUG:" $file 106 then 106 then 107 print_warning HOTPLUG 107 print_warning HOTPLUG FAILURES $title `cat $T.seq` 108 echo " " $file 108 echo " " $file 109 exit 3 109 exit 3 110 fi 110 fi 111 echo $title no success message 111 echo $title no success message, `grep --binary-files=text 'ver:' $file | wc -l` successful version messages 112 if test -s $T.seq 112 if test -s $T.seq 113 then 113 then 114 print_warning $title ` 114 print_warning $title `cat $T.seq` 115 fi 115 fi 116 exit 2 116 exit 2 117 fi 117 fi 118 fi | tee -a $file.diags 118 fi | tee -a $file.diags 119 119 120 console-badness.sh < $file > $T.diags 120 console-badness.sh < $file > $T.diags 121 if test -s $T.diags 121 if test -s $T.diags 122 then 122 then 123 print_warning "Assertion failure in $f 123 print_warning "Assertion failure in $file $title" 124 # cat $T.diags 124 # cat $T.diags 125 summary="" 125 summary="" 126 n_badness=`grep -c Badness $file` 126 n_badness=`grep -c Badness $file` 127 if test "$n_badness" -ne 0 127 if test "$n_badness" -ne 0 128 then 128 then 129 summary="$summary Badness: $n 129 summary="$summary Badness: $n_badness" 130 fi 130 fi 131 n_warn=`grep -v 'Warning: unable to op 131 n_warn=`grep -v 'Warning: unable to open an initial console' $file | grep -v 'Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process' | grep -E -c 'WARNING:|Warn'` 132 if test "$n_warn" -ne 0 132 if test "$n_warn" -ne 0 133 then 133 then 134 summary="$summary Warnings: $ 134 summary="$summary Warnings: $n_warn" 135 fi 135 fi 136 n_bugs=`grep -E -c '\bBUG|Oops:' $file 136 n_bugs=`grep -E -c '\bBUG|Oops:' $file` 137 if test "$n_bugs" -ne 0 137 if test "$n_bugs" -ne 0 138 then 138 then 139 summary="$summary Bugs: $n_bu 139 summary="$summary Bugs: $n_bugs" 140 fi 140 fi 141 n_kcsan=`grep -E -c 'BUG: KCSAN: ' $fi 141 n_kcsan=`grep -E -c 'BUG: KCSAN: ' $file` 142 if test "$n_kcsan" -ne 0 142 if test "$n_kcsan" -ne 0 143 then 143 then 144 if test "$n_bugs" = "$n_kcsan" 144 if test "$n_bugs" = "$n_kcsan" 145 then 145 then 146 summary="$summary (all 146 summary="$summary (all bugs kcsan)" 147 else 147 else 148 summary="$summary KCS 148 summary="$summary KCSAN: $n_kcsan" 149 fi 149 fi 150 fi 150 fi 151 n_calltrace=`grep -c 'Call Trace:' $fi 151 n_calltrace=`grep -c 'Call Trace:' $file` 152 if test "$n_calltrace" -ne 0 152 if test "$n_calltrace" -ne 0 153 then 153 then 154 summary="$summary Call Traces 154 summary="$summary Call Traces: $n_calltrace" 155 fi 155 fi 156 n_lockdep=`grep -c =========== $file` 156 n_lockdep=`grep -c =========== $file` 157 if test "$n_badness" -ne 0 157 if test "$n_badness" -ne 0 158 then 158 then 159 summary="$summary lockdep: $n 159 summary="$summary lockdep: $n_badness" 160 fi 160 fi 161 n_stalls=`grep -E -c 'detected stalls 161 n_stalls=`grep -E -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file` 162 if test "$n_stalls" -ne 0 162 if test "$n_stalls" -ne 0 163 then 163 then 164 summary="$summary Stalls: $n_ 164 summary="$summary Stalls: $n_stalls" 165 fi 165 fi 166 n_starves=`grep -c 'rcu_.*kthread star 166 n_starves=`grep -c 'rcu_.*kthread starved for' $file` 167 if test "$n_starves" -ne 0 167 if test "$n_starves" -ne 0 168 then 168 then 169 summary="$summary Starves: $n 169 summary="$summary Starves: $n_starves" 170 fi 170 fi 171 print_warning Summary: $summary 171 print_warning Summary: $summary 172 cat $T.diags >> $file.diags 172 cat $T.diags >> $file.diags 173 fi 173 fi 174 for i in $file.*.diags 174 for i in $file.*.diags 175 do 175 do 176 if test -f "$i" 176 if test -f "$i" 177 then 177 then 178 cat $i >> $file.diags 178 cat $i >> $file.diags 179 fi 179 fi 180 done 180 done 181 if ! test -s $file.diags 181 if ! test -s $file.diags 182 then 182 then 183 rm -f $file.diags 183 rm -f $file.diags 184 fi 184 fi 185 185 186 # Call extract_ftrace_from_console function, i 186 # Call extract_ftrace_from_console function, if the output is empty, 187 # don't create $file.ftrace. Otherwise output 187 # don't create $file.ftrace. Otherwise output the results to $file.ftrace 188 extract_ftrace_from_console $file > $file.ftra 188 extract_ftrace_from_console $file > $file.ftrace 189 if [ ! -s $file.ftrace ]; then 189 if [ ! -s $file.ftrace ]; then 190 rm -f $file.ftrace 190 rm -f $file.ftrace 191 fi 191 fi
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.