xref: /linux/tools/testing/selftests/rcutorture/bin/kvm-recheck.sh (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Given the results directories for previous KVM-based torture runs,
5# check the build and console output for errors.  Given a directory
6# containing results directories, this recursively checks them all.
7#
8# Usage: kvm-recheck.sh resdir ...
9#
10# Returns status reflecting the success or not of the last run specified.
11#
12# Copyright (C) IBM Corporation, 2011
13#
14# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
15
16T="`mktemp ${TMPDIR-/tmp}/kvm-recheck.sh.XXXXXX`"
17trap 'rm -f $T' 0 2
18
19configerrors=0
20
21PATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH
22. functions.sh
23for rd in "$@"
24do
25	firsttime=1
26	dirs=`find $rd -name Make.defconfig.out -print | sort | sed -e 's,/[^/]*$,,' | sort -u`
27	for i in $dirs
28	do
29		if test -n "$firsttime"
30		then
31			firsttime=""
32			resdir=`echo $i | sed -e 's,/$,,' -e 's,/[^/]*$,,'`
33			head -1 $resdir/log
34		fi
35		TORTURE_SUITE="`cat $i/../torture_suite`" ; export TORTURE_SUITE
36		configfile=`echo $i | sed -e 's,^.*/,,'`
37		rm -f $i/console.log.*.diags $i/ConfigFragment.diags
38		case "${TORTURE_SUITE}" in
39		X*)
40			;;
41		*)
42			kvm-recheck-${TORTURE_SUITE}.sh $i
43		esac
44		if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -ne 0 && test "`cat $i/qemu-retval`" -ne 137
45		then
46			echo QEMU error, output:
47			cat $i/qemu-output
48		elif test -f "$i/console.log"
49		then
50			if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -eq 137
51			then
52				echo QEMU killed
53			fi
54			configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1
55			if grep -q '^CONFIG_KCSAN=y$' $i/ConfigFragment.input
56			then
57				# KCSAN forces a number of Kconfig options, so remove
58				# complaints about those Kconfig options in KCSAN runs.
59				mv $i/ConfigFragment.diags $i/ConfigFragment.diags.kcsan
60				grep -v -E 'CONFIG_PROVE_RCU|CONFIG_PREEMPT_COUNT' $i/ConfigFragment.diags.kcsan > $i/ConfigFragment.diags
61			fi
62			if test -s $i/ConfigFragment.diags
63			then
64				cat $i/ConfigFragment.diags
65				configerrors=$((configerrors+1))
66			else
67				rm $i/ConfigFragment.diags
68			fi
69			if test -r $i/Make.oldconfig.err
70			then
71				cat $i/Make.oldconfig.err
72			fi
73			parse-build.sh $i/Make.out $configfile
74			parse-console.sh $i/console.log $configfile
75			if test -r $i/Warnings
76			then
77				cat $i/Warnings
78			fi
79		else
80			if test -f "$i/buildonly"
81			then
82				echo Build-only run, no boot/test
83				configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1
84				if test -s $i/ConfigFragment.diags
85				then
86					cat $i/ConfigFragment.diags
87					configerrors=$((configerrors+1))
88				else
89					rm $i/ConfigFragment.diags
90				fi
91				parse-build.sh $i/Make.out $configfile
92			elif test -f "$i/qemu-cmd"
93			then
94				print_bug qemu failed
95				echo "   $i"
96			else
97				print_bug Build failed
98				echo "   $i"
99			fi
100		fi
101	done
102	if test -f "$rd/kcsan.sum"
103	then
104		if ! test -f $i/ConfigFragment.diags
105		then
106			:
107		elif grep -q CONFIG_KCSAN=y $i/ConfigFragment.diags
108		then
109			echo "Compiler or architecture does not support KCSAN!"
110			echo Did you forget to switch your compiler with '--kmake-arg CC=<cc-that-supports-kcsan>'?
111		elif test -s "$rd/kcsan.sum"
112		then
113			echo KCSAN summary in $rd/kcsan.sum
114		else
115			echo Clean KCSAN run in $rd
116		fi
117	fi
118done
119
120if test "$configerrors" -gt 0
121then
122	echo $configerrors runs with .config errors.
123	ret=1
124fi
125EDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1
126builderrors="`tr ' ' '\012' < $T | grep -c '/Make.out.diags'`"
127if test "$builderrors" -gt 0
128then
129	echo $builderrors runs with build errors.
130	ret=2
131fi
132runerrors="`tr ' ' '\012' < $T | grep -c '/console.log.diags'`"
133if test "$runerrors" -gt 0
134then
135	echo $runerrors runs with runtime errors.
136	ret=3
137fi
138exit $ret
139