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