rcutorture: Add KVM-based test framework
[platform/adaptation/renesas_rcar/renesas_kernel.git] / tools / testing / selftests / rcutorture / bin / parse-rcutorture.sh
1 #!/bin/sh
2 #
3 # Check the console output from an rcutorture run for goodness.
4 # The "file" is a pathname on the local system, and "title" is
5 # a text string for error-message purposes.
6 #
7 # The file must contain rcutorture output, but can be interspersed
8 # with other dmesg text.
9 #
10 # Usage:
11 #       sh parse-rcutorture.sh file title
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #
27 # Copyright (C) IBM Corporation, 2011
28 #
29 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
30
31 T=/tmp/parse-rcutorture.sh.$$
32 file="$1"
33 title="$2"
34
35 trap 'rm -f $T.seq' 0
36
37 # check for presence of rcutorture.txt file
38
39 if test -f "$file" -a -r "$file"
40 then
41         :
42 else
43         echo $title unreadable rcutorture.txt file: $file
44         exit 1
45 fi
46
47 # check for abject failure
48
49 if grep -q FAILURE $file || grep -q -e '-torture.*!!!' $file
50 then
51         nerrs=`grep --binary-files=text '!!!' $file | tail -1 | awk '{for (i=NF-8;i<=NF;i++) sum+=$i; } END {print sum}'`
52         echo $title FAILURE, $nerrs instances
53         echo "   " $url
54         exit
55 fi
56
57 grep --binary-files=text 'torture:.*ver:' $file | grep --binary-files=text -v '(null)' | sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' |
58 awk '
59 BEGIN   {
60         ver = 0;
61         badseq = 0;
62         }
63
64         {
65         if (!badseq && ($5 + 0 != $5 || $5 <= ver)) {
66                 badseqno1 = ver;
67                 badseqno2 = $5;
68                 badseqnr = NR;
69                 badseq = 1;
70         }
71         ver = $5
72         }
73
74 END     {
75         if (badseq) {
76                 if (badseqno1 == badseqno2 && badseqno2 == ver)
77                         print "RCU GP HANG at " ver " rcutorture stat " badseqnr;
78                 else
79                         print "BAD SEQ " badseqno1 ":" badseqno2 " last:" ver " RCU version " badseqnr;
80         }
81         }' > $T.seq
82
83 if grep -q SUCCESS $file
84 then
85         if test -s $T.seq
86         then
87                 echo WARNING $title `cat $T.seq`
88                 echo "   " $file
89                 exit 2
90         fi
91 else
92         if grep -q RCU_HOTPLUG $file
93         then
94                 echo WARNING: HOTPLUG FAILURES $title `cat $T.seq`
95                 echo "   " $file
96                 exit 3
97         fi
98         echo $title no success message, `grep --binary-files=text 'ver:' $file | wc -l` successful RCU version messages
99         if test -s $T.seq
100         then
101                 echo WARNING $title `cat $T.seq`
102         fi
103         exit 2
104 fi