treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / testing / selftests / rcutorture / bin / parse-console.sh
blob4bf62d7b1cbce6a400d70cf76e1b6bd53dba2d66
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
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.
8 # Usage: parse-console.sh file title
10 # Copyright (C) IBM Corporation, 2011
12 # Authors: Paul E. McKenney <paulmck@linux.ibm.com>
14 T=${TMPDIR-/tmp}/parse-console.sh.$$
15 file="$1"
16 title="$2"
18 trap 'rm -f $T.seq $T.diags' 0
20 . functions.sh
22 # Check for presence and readability of console output file
23 if test -f "$file" -a -r "$file"
24 then
26 else
27 echo $title unreadable console output file: $file
28 exit 1
30 if grep -Pq '\x00' < $file
31 then
32 print_warning Console output contains nul bytes, old qemu still running?
34 cat /dev/null > $file.diags
36 # Check for proper termination, except that rcuperf runs don't indicate this.
37 if test "$TORTURE_SUITE" != rcuperf
38 then
39 # check for abject failure
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 '
47 for (i=NF-8;i<=NF;i++)
48 sum+=$i;
50 END { print sum }'`
51 print_bug $title FAILURE, $nerrs instances
52 exit
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;
65 if (!badseq && ($5 + 0 != $5 || $5 <= ver)) {
66 badseqno1 = ver;
67 badseqno2 = $5;
68 badseqnr = NR;
69 badseq = 1;
71 ver = $5
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;
81 }' > $T.seq
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
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
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`
103 exit 2
105 fi | tee -a $file.diags
107 egrep '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 |
108 grep -v 'ODEBUG: ' |
109 grep -v 'This means that this is a DEBUG kernel and it is' |
110 grep -v 'Warning: unable to open an initial console' > $T.diags
111 if test -s $T.diags
112 then
113 print_warning "Assertion failure in $file $title"
114 # cat $T.diags
115 summary=""
116 n_badness=`grep -c Badness $file`
117 if test "$n_badness" -ne 0
118 then
119 summary="$summary Badness: $n_badness"
121 n_warn=`grep -v 'Warning: unable to open an initial console' $file | egrep -c 'WARNING:|Warn'`
122 if test "$n_warn" -ne 0
123 then
124 summary="$summary Warnings: $n_warn"
126 n_bugs=`egrep -c 'BUG|Oops:' $file`
127 if test "$n_bugs" -ne 0
128 then
129 summary="$summary Bugs: $n_bugs"
131 n_calltrace=`grep -c 'Call Trace:' $file`
132 if test "$n_calltrace" -ne 0
133 then
134 summary="$summary Call Traces: $n_calltrace"
136 n_lockdep=`grep -c =========== $file`
137 if test "$n_badness" -ne 0
138 then
139 summary="$summary lockdep: $n_badness"
141 n_stalls=`egrep -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file`
142 if test "$n_stalls" -ne 0
143 then
144 summary="$summary Stalls: $n_stalls"
146 n_starves=`grep -c 'rcu_.*kthread starved for' $file`
147 if test "$n_starves" -ne 0
148 then
149 summary="$summary Starves: $n_starves"
151 print_warning Summary: $summary
152 cat $T.diags >> $file.diags
154 for i in $file.*.diags
156 if test -f "$i"
157 then
158 cat $i >> $file.diags
160 done
161 if ! test -s $file.diags
162 then
163 rm -f $file.diags