1#!/bin/sh
2#
3# Invoke a text editor on all console.log files for all runs with diagnostics,
4# that is, on all such files having a console.log.diags counterpart.
5# Note that both console.log.diags and console.log are passed to the
6# editor (currently defaulting to "vi"), allowing the user to get an
7# idea of what to search for in the console.log file.
8#
9# Usage: kvm-find-errors.sh directory
10#
11# The "directory" above should end with the date/time directory, for example,
12# "tools/testing/selftests/rcutorture/res/2018.02.25-14:27:27".
13
14rundir="${1}"
15if test -z "$rundir" -o ! -d "$rundir"
16then
17	echo Usage: $0 directory
18fi
19editor=${EDITOR-vi}
20
21# Find builds with errors
22files=
23for i in ${rundir}/*/Make.out
24do
25	if egrep -q "error:|warning:" < $i
26	then
27		egrep "error:|warning:" < $i > $i.diags
28		files="$files $i.diags $i"
29	fi
30done
31if test -n "$files"
32then
33	$editor $files
34else
35	echo No build errors.
36fi
37if grep -q -e "--buildonly" < ${rundir}/log
38then
39	echo Build-only run, no console logs to check.
40fi
41
42# Find console logs with errors
43files=
44for i in ${rundir}/*/console.log
45do
46	if test -r $i.diags
47	then
48		files="$files $i.diags $i"
49	fi
50done
51if test -n "$files"
52then
53	$editor $files
54else
55	echo No errors in console logs.
56fi
57