Linux-libre 5.3.12-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / rcutorture / bin / kvm-find-errors.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Invoke a text editor on all console.log files for all runs with diagnostics,
5 # that is, on all such files having a console.log.diags counterpart.
6 # Note that both console.log.diags and console.log are passed to the
7 # editor (currently defaulting to "vi"), allowing the user to get an
8 # idea of what to search for in the console.log file.
9 #
10 # Usage: kvm-find-errors.sh directory
11 #
12 # The "directory" above should end with the date/time directory, for example,
13 # "tools/testing/selftests/rcutorture/res/2018.02.25-14:27:27".
14 # Returns error status reflecting the success (or not) of the specified run.
15 #
16 # Copyright (C) IBM Corporation, 2018
17 #
18 # Author: Paul E. McKenney <paulmck@linux.ibm.com>
19
20 rundir="${1}"
21 if test -z "$rundir" -o ! -d "$rundir"
22 then
23         echo Usage: $0 directory
24 fi
25 editor=${EDITOR-vi}
26
27 # Find builds with errors
28 files=
29 for i in ${rundir}/*/Make.out
30 do
31         if egrep -q "error:|warning:" < $i
32         then
33                 egrep "error:|warning:" < $i > $i.diags
34                 files="$files $i.diags $i"
35         fi
36 done
37 if test -n "$files"
38 then
39         $editor $files
40 else
41         echo No build errors.
42 fi
43 if grep -q -e "--buildonly" < ${rundir}/log
44 then
45         echo Build-only run, no console logs to check.
46 fi
47
48 # Find console logs with errors
49 files=
50 for i in ${rundir}/*/console.log
51 do
52         if test -r $i.diags
53         then
54                 files="$files $i.diags $i"
55         fi
56 done
57 if test -n "$files"
58 then
59         $editor $files
60         exit 1
61 else
62         echo No errors in console logs.
63         exit 0
64 fi