192 lines · bash
1#!/bin/bash2# 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" is6# a text string for error-message purposes.7#8# Usage: parse-console.sh file title9#10# Copyright (C) IBM Corporation, 201111#12# Authors: Paul E. McKenney <paulmck@linux.ibm.com>13 14T="`mktemp -d ${TMPDIR-/tmp}/parse-console.sh.XXXXXX`"15file="$1"16title="$2"17 18trap 'rm -f $T.seq $T.diags' 019 20. functions.sh21 22# Check for presence and readability of console output file23if test -f "$file" -a -r "$file"24then25 :26else27 echo $title unreadable console output file: $file28 exit 129fi30if grep -Pq '\x00' < $file31then32 print_warning Console output contains nul bytes, old qemu still running?33fi34cat /dev/null > $file.diags35 36# Check for proper termination, except for rcuscale and refscale.37if test "$TORTURE_SUITE" != rcuscale && test "$TORTURE_SUITE" != refscale38then39 # check for abject failure40 41 if grep -q FAILURE $file || grep -q -e '-torture.*!!!' $file42 then43 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, $nerrs64 exit65 fi66 67 grep --binary-files=text 'torture:.*ver:' $file |68 grep -E --binary-files=text -v '\(null\)|rtc: 000000000* ' |69 sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' |70 sed -e 's/^.*ver: //' |71 awk '72 BEGIN {73 ver = 0;74 badseq = 0;75 }76 77 {78 if (!badseq && ($1 + 0 != $1 || $1 <= ver)) {79 badseqno1 = ver;80 badseqno2 = $1;81 badseqnr = NR;82 badseq = 1;83 }84 ver = $185 }86 87 END {88 if (badseq) {89 if (badseqno1 == badseqno2 && badseqno2 == ver)90 print "GP HANG at " ver " torture stat " badseqnr;91 else92 print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr;93 }94 }' > $T.seq95 96 if grep -q SUCCESS $file97 then98 if test -s $T.seq99 then100 print_warning $title `cat $T.seq`101 echo " " $file102 exit 2103 fi104 else105 if grep -q "_HOTPLUG:" $file106 then107 print_warning HOTPLUG FAILURES $title `cat $T.seq`108 echo " " $file109 exit 3110 fi111 echo $title no success message, `grep --binary-files=text 'ver:' $file | wc -l` successful version messages112 if test -s $T.seq113 then114 print_warning $title `cat $T.seq`115 fi116 exit 2117 fi118fi | tee -a $file.diags119 120console-badness.sh < $file > $T.diags121if test -s $T.diags122then123 print_warning "Assertion failure in $file $title"124 # cat $T.diags125 summary=""126 n_badness=`grep -c Badness $file`127 if test "$n_badness" -ne 0128 then129 summary="$summary Badness: $n_badness"130 fi131 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 0133 then134 summary="$summary Warnings: $n_warn"135 fi136 n_bugs=`grep -E -c '\bBUG|Oops:' $file`137 if test "$n_bugs" -ne 0138 then139 summary="$summary Bugs: $n_bugs"140 fi141 n_kcsan=`grep -E -c 'BUG: KCSAN: ' $file`142 if test "$n_kcsan" -ne 0143 then144 if test "$n_bugs" = "$n_kcsan"145 then146 summary="$summary (all bugs kcsan)"147 else148 summary="$summary KCSAN: $n_kcsan"149 fi150 fi151 n_calltrace=`grep -c 'Call Trace:' $file`152 if test "$n_calltrace" -ne 0153 then154 summary="$summary Call Traces: $n_calltrace"155 fi156 n_lockdep=`grep -c =========== $file`157 if test "$n_badness" -ne 0158 then159 summary="$summary lockdep: $n_badness"160 fi161 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 0163 then164 summary="$summary Stalls: $n_stalls"165 fi166 n_starves=`grep -c 'rcu_.*kthread starved for' $file`167 if test "$n_starves" -ne 0168 then169 summary="$summary Starves: $n_starves"170 fi171 print_warning Summary: $summary172 cat $T.diags >> $file.diags173fi174for i in $file.*.diags175do176 if test -f "$i"177 then178 cat $i >> $file.diags179 fi180done181if ! test -s $file.diags182then183 rm -f $file.diags184fi185 186# Call extract_ftrace_from_console function, if the output is empty,187# don't create $file.ftrace. Otherwise output the results to $file.ftrace188extract_ftrace_from_console $file > $file.ftrace189if [ ! -s $file.ftrace ]; then190 rm -f $file.ftrace191fi192