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 for rcuperf and refscale. 37if test "$TORTURE_SUITE" != rcuperf && test "$TORTURE_SUITE" != refscale 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 normalexit = 1; 48 for (i=NF-8;i<=NF;i++) { 49 if (i <= 0 || i !~ /^[0-9]*$/) { 50 bangstring = $0; 51 gsub(/^\[[^]]*] /, "", bangstring); 52 print bangstring; 53 normalexit = 0; 54 exit 0; 55 } 56 sum+=$i; 57 } 58 } 59 END { 60 if (normalexit) 61 print sum " instances" 62 }'` 63 print_bug $title FAILURE, $nerrs 64 exit 65 fi 66 67 grep --binary-files=text 'torture:.*ver:' $file | 68 egrep --binary-files=text -v '\(null\)|rtc: 000000000* ' | 69 sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' | 70 awk ' 71 BEGIN { 72 ver = 0; 73 badseq = 0; 74 } 75 76 { 77 if (!badseq && ($5 + 0 != $5 || $5 <= ver)) { 78 badseqno1 = ver; 79 badseqno2 = $5; 80 badseqnr = NR; 81 badseq = 1; 82 } 83 ver = $5 84 } 85 86 END { 87 if (badseq) { 88 if (badseqno1 == badseqno2 && badseqno2 == ver) 89 print "GP HANG at " ver " torture stat " badseqnr; 90 else 91 print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr; 92 } 93 }' > $T.seq 94 95 if grep -q SUCCESS $file 96 then 97 if test -s $T.seq 98 then 99 print_warning $title `cat $T.seq` 100 echo " " $file 101 exit 2 102 fi 103 else 104 if grep -q "_HOTPLUG:" $file 105 then 106 print_warning HOTPLUG FAILURES $title `cat $T.seq` 107 echo " " $file 108 exit 3 109 fi 110 echo $title no success message, `grep --binary-files=text 'ver:' $file | wc -l` successful version messages 111 if test -s $T.seq 112 then 113 print_warning $title `cat $T.seq` 114 fi 115 exit 2 116 fi 117fi | tee -a $file.diags 118 119console-badness.sh < $file > $T.diags 120if test -s $T.diags 121then 122 print_warning "Assertion failure in $file $title" 123 # cat $T.diags 124 summary="" 125 n_badness=`grep -c Badness $file` 126 if test "$n_badness" -ne 0 127 then 128 summary="$summary Badness: $n_badness" 129 fi 130 n_warn=`grep -v 'Warning: unable to open an initial console' $file | egrep -c 'WARNING:|Warn'` 131 if test "$n_warn" -ne 0 132 then 133 summary="$summary Warnings: $n_warn" 134 fi 135 n_bugs=`egrep -c 'BUG|Oops:' $file` 136 if test "$n_bugs" -ne 0 137 then 138 summary="$summary Bugs: $n_bugs" 139 fi 140 n_calltrace=`grep -c 'Call Trace:' $file` 141 if test "$n_calltrace" -ne 0 142 then 143 summary="$summary Call Traces: $n_calltrace" 144 fi 145 n_lockdep=`grep -c =========== $file` 146 if test "$n_badness" -ne 0 147 then 148 summary="$summary lockdep: $n_badness" 149 fi 150 n_stalls=`egrep -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file` 151 if test "$n_stalls" -ne 0 152 then 153 summary="$summary Stalls: $n_stalls" 154 fi 155 n_starves=`grep -c 'rcu_.*kthread starved for' $file` 156 if test "$n_starves" -ne 0 157 then 158 summary="$summary Starves: $n_starves" 159 fi 160 print_warning Summary: $summary 161 cat $T.diags >> $file.diags 162fi 163for i in $file.*.diags 164do 165 if test -f "$i" 166 then 167 cat $i >> $file.diags 168 fi 169done 170if ! test -s $file.diags 171then 172 rm -f $file.diags 173fi 174