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