summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh
blob: 5be670dd400901d77f7838ecc01163a79503a25b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0+
#
# Given the results directories for previous KVM-based torture runs,
# check the build and console output for errors.  Given a directory
# containing results directories, this recursively checks them all.
#
# Usage: kvm-recheck.sh resdir ...
#
# Returns status reflecting the success or not of the last run specified.
#
# Copyright (C) IBM Corporation, 2011
#
# Authors: Paul E. McKenney <paulmck@linux.ibm.com>

T=/tmp/kvm-recheck.sh.$$
trap 'rm -f $T' 0 2

configerrors=0

PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
. functions.sh
for rd in "$@"
do
	firsttime=1
	dirs=`find $rd -name Make.defconfig.out -print | sort | sed -e 's,/[^/]*$,,' | sort -u`
	for i in $dirs
	do
		if test -n "$firsttime"
		then
			firsttime=""
			resdir=`echo $i | sed -e 's,/$,,' -e 's,/[^/]*$,,'`
			head -1 $resdir/log
		fi
		TORTURE_SUITE="`cat $i/../torture_suite`" ; export TORTURE_SUITE
		configfile=`echo $i | sed -e 's,^.*/,,'`
		rm -f $i/console.log.*.diags $i/ConfigFragment.diags
		case "${TORTURE_SUITE}" in
		X*)
			;;
		*)
			kvm-recheck-${TORTURE_SUITE}.sh $i
		esac
		if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -ne 0 && test "`cat $i/qemu-retval`" -ne 137
		then
			echo QEMU error, output:
			cat $i/qemu-output
		elif test -f "$i/console.log"
		then
			if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -eq 137
			then
				echo QEMU killed
			fi
			configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1
			if grep -q '^CONFIG_KCSAN=y$' $i/ConfigFragment.input
			then
				# KCSAN forces a number of Kconfig options, so remove
				# complaints about those Kconfig options in KCSAN runs.
				mv $i/ConfigFragment.diags $i/ConfigFragment.diags.kcsan
				grep -v -E 'CONFIG_PROVE_RCU|CONFIG_PREEMPT_COUNT' $i/ConfigFragment.diags.kcsan > $i/ConfigFragment.diags
			fi
			if test -s $i/ConfigFragment.diags
			then
				cat $i/ConfigFragment.diags
				configerrors=$((configerrors+1))
			else
				rm $i/ConfigFragment.diags
			fi
			if test -r $i/Make.oldconfig.err
			then
				cat $i/Make.oldconfig.err
			fi
			parse-build.sh $i/Make.out $configfile
			parse-console.sh $i/console.log $configfile
			if test -r $i/Warnings
			then
				cat $i/Warnings
			fi
		else
			if test -f "$i/buildonly"
			then
				echo Build-only run, no boot/test
				configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1
				if test -s $i/ConfigFragment.diags
				then
					cat $i/ConfigFragment.diags
					configerrors=$((configerrors+1))
				else
					rm $i/ConfigFragment.diags
				fi
				parse-build.sh $i/Make.out $configfile
			elif test -f "$i/qemu-cmd"
			then
				print_bug qemu failed
				echo "   $i"
			else
				print_bug Build failed
				echo "   $i"
			fi
		fi
	done
	if test -f "$rd/kcsan.sum"
	then
		if ! test -f $i/ConfigFragment.diags
		then
			:
		elif grep -q CONFIG_KCSAN=y $i/ConfigFragment.diags
		then
			echo "Compiler or architecture does not support KCSAN!"
			echo Did you forget to switch your compiler with '--kmake-arg CC=<cc-that-supports-kcsan>'?
		elif test -s "$rd/kcsan.sum"
		then
			echo KCSAN summary in $rd/kcsan.sum
		else
			echo Clean KCSAN run in $rd
		fi
	fi
done

if test "$configerrors" -gt 0
then
	echo $configerrors runs with .config errors.
	ret=1
fi
EDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1
builderrors="`tr ' ' '\012' < $T | grep -c '/Make.out.diags'`"
if test "$builderrors" -gt 0
then
	echo $builderrors runs with build errors.
	ret=2
fi
runerrors="`tr ' ' '\012' < $T | grep -c '/console.log.diags'`"
if test "$runerrors" -gt 0
then
	echo $runerrors runs with runtime errors.
	ret=3
fi
exit $ret