#!/bin/bash # # Check the console output from a torture run for goodness. # The "file" is a pathname on the local system, and "title" is # a text string for error-message purposes. # # The file must contain torture output, but can be interspersed # with other dmesg text, as in console-log output. # # Usage: parse-torture.sh file title # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, you can access it online at # http://www.gnu.org/licenses/gpl-2.0.html. # # Copyright (C) IBM Corporation, 2011 # # Authors: Paul E. McKenney global T := "/tmp/parse-torture.sh.$Pid" global file := $1 global title := $2 trap 'rm -f $T.seq' 0 source functions.sh # check for presence of torture output file. if test -f $file -a -r $file { : } else { echo $title unreadable torture output file: $file exit 1 } # check for abject failure if grep -q FAILURE $file || grep -q -e '-torture.*!!!' $file { global nerrs := $[grep --binary-files=text '!!!' $file | tail -1 | awk '{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}] print_bug $title FAILURE, $nerrs instances echo " " $url exit } grep --binary-files=text 'torture:.*ver:' $file | grep --binary-files=text -v '(null)' | sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' | awk ' BEGIN { ver = 0; badseq = 0; } { if (!badseq && ($5 + 0 != $5 || $5 <= ver)) { badseqno1 = ver; badseqno2 = $5; badseqnr = NR; badseq = 1; } ver = $5 } END { if (badseq) { if (badseqno1 == badseqno2 && badseqno2 == ver) print "GP HANG at " ver " torture stat " badseqnr; else print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " version " badseqnr; } }' > $T.seq if grep -q SUCCESS $file { if test -s $T.seq { print_warning $title $title $[cat $T.seq] echo " " $file exit 2 } } else { if grep -q "_HOTPLUG:" $file { print_warning HOTPLUG FAILURES $title $[cat $T.seq] echo " " $file exit 3 } echo $title no success message, $[grep --binary-files=text 'ver:' $file | wc -l] successful version messages if test -s $T.seq { print_warning $title $[cat $T.seq] } exit 2 } (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:T) op: Equal rhs: {(/tmp/parse-torture.sh.) ($ VSub_Dollar "$$")} spids: [85] ) ] spids: [85] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [89] ) ] spids: [89] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:title) op: Equal rhs: {(DQ ($ VSub_Number "$2"))} spids: [94] ) ] spids: [94] ) (C {(trap)} {(SQ <"rm -f $T.seq">)} {(0)}) (C {(.)} {(functions.sh)}) (If arms: [ (if_arm cond: [ (C {(test)} {(-f)} {(DQ ($ VSub_Name "$file"))} {(-a)} {(-r)} {(DQ ($ VSub_Name "$file"))}) ] action: [(C {(Lit_Other ":")})] spids: [-1 136] ) ] else_action: [ (C {(echo)} {($ VSub_Name "$title")} {(unreadable)} {(torture)} {(output)} {(file) (Lit_Other ":")} {($ VSub_Name "$file")} ) (C {(exit)} {(1)}) ] spids: [141 164] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(grep)} {(-q)} {(FAILURE)} {($ VSub_Name "$file")}) (C {(grep)} {(-q)} {(-e)} {(SQ <"-torture.*!!!">)} {($ VSub_Name "$file")}) ] op_id: Op_DPipe ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nerrs) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(--binary-files) (Lit_Other "=") (text)} {(SQ <"!!!">)} {($ VSub_Name "$file")} ) (C {(tail)} {(-1)}) (C {(awk)} {(SQ <"{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}">)} ) ] negated: False ) ] ) left_token: spids: [199 225] ) } spids: [198] ) ] spids: [198] ) (C {(print_bug)} {($ VSub_Name "$title")} {(FAILURE) (Lit_Comma ",")} {($ VSub_Name "$nerrs")} {(instances)} ) (C {(echo)} {(DQ (" "))} {($ VSub_Name "$url")}) (C {(exit)}) ] spids: [-1 195] ) ] spids: [-1 251] ) (Pipeline children: [ (C {(grep)} {(--binary-files) (Lit_Other "=") (text)} {(SQ <"torture:.*ver:">)} {($ VSub_Name "$file")} ) (C {(grep)} {(--binary-files) (Lit_Other "=") (text)} {(-v)} {(SQ <"(null)">)}) (C {(sed)} {(-e)} {(SQ <"s/^(initramfs)[^]]*] //">)} {(-e)} {(SQ <"s/^\\[[^]]*] //">)}) (SimpleCommand words: [ {(awk)} { (SQ <"\n"> <"BEGIN\t{\n"> <"\tver = 0;\n"> <"\tbadseq = 0;\n"> <"\t}\n"> <"\n"> <"\t{\n"> <"\tif (!badseq && ($5 + 0 != $5 || $5 <= ver)) {\n"> <"\t\tbadseqno1 = ver;\n"> <"\t\tbadseqno2 = $5;\n"> <"\t\tbadseqnr = NR;\n"> <"\t\tbadseq = 1;\n"> <"\t}\n"> <"\tver = $5\n"> <"\t}\n"> <"\n"> <"END\t{\n"> <"\tif (badseq) {\n"> <"\t\tif (badseqno1 == badseqno2 && badseqno2 == ver)\n"> <"\t\t\tprint \"GP HANG at \" ver \" torture stat \" badseqnr;\n"> <"\t\telse\n"> < "\t\t\tprint \"BAD SEQ \" badseqno1 \":\" badseqno2 \" last:\" ver \" version \" badseqnr;\n" > <"\t}\n"> <"\t}"> ) } ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {($ VSub_Name "$T") (.seq)} spids: [327] ) ] ) ] negated: False ) (If arms: [ (if_arm cond: [(C {(grep)} {(-q)} {(SUCCESS)} {($ VSub_Name "$file")})] action: [ (If arms: [ (if_arm cond: [(C {(test)} {(-s)} {($ VSub_Name "$T") (.seq)})] action: [ (C {(print_warning)} {($ VSub_Name "$title")} {($ VSub_Name "$title")} { (CommandSubPart command_list: (CommandList children: [(C {(cat)} {($ VSub_Name "$T") (.seq)})] ) left_token: spids: [365 370] ) } ) (C {(echo)} {(DQ (" "))} {($ VSub_Name "$file")}) (C {(exit)} {(2)}) ] spids: [-1 356] ) ] spids: [-1 387] ) ] spids: [-1 343] ) ] else_action: [ (If arms: [ (if_arm cond: [(C {(grep)} {(-q)} {(DQ ("_HOTPLUG:"))} {($ VSub_Name "$file")})] action: [ (C {(print_warning)} {(HOTPLUG)} {(FAILURES)} {($ VSub_Name "$title")} { (CommandSubPart command_list: (CommandList children:[(C {(cat)} {($ VSub_Name "$T") (.seq)})]) left_token: spids: [416 421] ) } ) (C {(echo)} {(DQ (" "))} {($ VSub_Name "$file")}) (C {(exit)} {(3)}) ] spids: [-1 405] ) ] spids: [-1 438] ) (C {(echo)} {($ VSub_Name "$title")} {(no)} {(success)} {(message) (Lit_Comma ",")} { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(--binary-files) (Lit_Other "=") (text)} {(SQ <"ver:">)} {($ VSub_Name "$file")} ) (C {(wc)} {(-l)}) ] negated: False ) ] ) left_token: spids: [452 470] ) } {(successful)} {(version)} {(messages)} ) (If arms: [ (if_arm cond: [(C {(test)} {(-s)} {($ VSub_Name "$T") (.seq)})] action: [ (C {(print_warning)} {($ VSub_Name "$title")} { (CommandSubPart command_list: (CommandList children:[(C {(cat)} {($ VSub_Name "$T") (.seq)})]) left_token: spids: [496 501] ) } ) ] spids: [-1 489] ) ] spids: [-1 504] ) (C {(exit)} {(2)}) ] spids: [389 511] ) ] )