162306a36Sopenharmony_ci#!/bin/bash 262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+ 362306a36Sopenharmony_ci# 462306a36Sopenharmony_ci# Given the results directories for previous KVM-based torture runs, 562306a36Sopenharmony_ci# check the build and console output for errors. Given a directory 662306a36Sopenharmony_ci# containing results directories, this recursively checks them all. 762306a36Sopenharmony_ci# 862306a36Sopenharmony_ci# Usage: kvm-recheck.sh resdir ... 962306a36Sopenharmony_ci# 1062306a36Sopenharmony_ci# Returns status reflecting the success or not of the last run specified. 1162306a36Sopenharmony_ci# 1262306a36Sopenharmony_ci# Copyright (C) IBM Corporation, 2011 1362306a36Sopenharmony_ci# 1462306a36Sopenharmony_ci# Authors: Paul E. McKenney <paulmck@linux.ibm.com> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciT=/tmp/kvm-recheck.sh.$$ 1762306a36Sopenharmony_citrap 'rm -f $T' 0 2 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciconfigerrors=0 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciPATH=`pwd`/tools/testing/selftests/rcutorture/bin:$PATH; export PATH 2262306a36Sopenharmony_ci. functions.sh 2362306a36Sopenharmony_cifor rd in "$@" 2462306a36Sopenharmony_cido 2562306a36Sopenharmony_ci firsttime=1 2662306a36Sopenharmony_ci dirs=`find $rd -name Make.defconfig.out -print | sort | sed -e 's,/[^/]*$,,' | sort -u` 2762306a36Sopenharmony_ci for i in $dirs 2862306a36Sopenharmony_ci do 2962306a36Sopenharmony_ci if test -n "$firsttime" 3062306a36Sopenharmony_ci then 3162306a36Sopenharmony_ci firsttime="" 3262306a36Sopenharmony_ci resdir=`echo $i | sed -e 's,/$,,' -e 's,/[^/]*$,,'` 3362306a36Sopenharmony_ci head -1 $resdir/log 3462306a36Sopenharmony_ci fi 3562306a36Sopenharmony_ci TORTURE_SUITE="`cat $i/../torture_suite`" ; export TORTURE_SUITE 3662306a36Sopenharmony_ci configfile=`echo $i | sed -e 's,^.*/,,'` 3762306a36Sopenharmony_ci rm -f $i/console.log.*.diags $i/ConfigFragment.diags 3862306a36Sopenharmony_ci case "${TORTURE_SUITE}" in 3962306a36Sopenharmony_ci X*) 4062306a36Sopenharmony_ci ;; 4162306a36Sopenharmony_ci *) 4262306a36Sopenharmony_ci kvm-recheck-${TORTURE_SUITE}.sh $i 4362306a36Sopenharmony_ci esac 4462306a36Sopenharmony_ci if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -ne 0 && test "`cat $i/qemu-retval`" -ne 137 4562306a36Sopenharmony_ci then 4662306a36Sopenharmony_ci echo QEMU error, output: 4762306a36Sopenharmony_ci cat $i/qemu-output 4862306a36Sopenharmony_ci elif test -f "$i/console.log" 4962306a36Sopenharmony_ci then 5062306a36Sopenharmony_ci if test -f "$i/qemu-retval" && test "`cat $i/qemu-retval`" -eq 137 5162306a36Sopenharmony_ci then 5262306a36Sopenharmony_ci echo QEMU killed 5362306a36Sopenharmony_ci fi 5462306a36Sopenharmony_ci configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1 5562306a36Sopenharmony_ci if grep -q '^CONFIG_KCSAN=y$' $i/ConfigFragment.input 5662306a36Sopenharmony_ci then 5762306a36Sopenharmony_ci # KCSAN forces a number of Kconfig options, so remove 5862306a36Sopenharmony_ci # complaints about those Kconfig options in KCSAN runs. 5962306a36Sopenharmony_ci mv $i/ConfigFragment.diags $i/ConfigFragment.diags.kcsan 6062306a36Sopenharmony_ci grep -v -E 'CONFIG_PROVE_RCU|CONFIG_PREEMPT_COUNT' $i/ConfigFragment.diags.kcsan > $i/ConfigFragment.diags 6162306a36Sopenharmony_ci fi 6262306a36Sopenharmony_ci if test -s $i/ConfigFragment.diags 6362306a36Sopenharmony_ci then 6462306a36Sopenharmony_ci cat $i/ConfigFragment.diags 6562306a36Sopenharmony_ci configerrors=$((configerrors+1)) 6662306a36Sopenharmony_ci else 6762306a36Sopenharmony_ci rm $i/ConfigFragment.diags 6862306a36Sopenharmony_ci fi 6962306a36Sopenharmony_ci if test -r $i/Make.oldconfig.err 7062306a36Sopenharmony_ci then 7162306a36Sopenharmony_ci cat $i/Make.oldconfig.err 7262306a36Sopenharmony_ci fi 7362306a36Sopenharmony_ci parse-build.sh $i/Make.out $configfile 7462306a36Sopenharmony_ci parse-console.sh $i/console.log $configfile 7562306a36Sopenharmony_ci if test -r $i/Warnings 7662306a36Sopenharmony_ci then 7762306a36Sopenharmony_ci cat $i/Warnings 7862306a36Sopenharmony_ci fi 7962306a36Sopenharmony_ci else 8062306a36Sopenharmony_ci if test -f "$i/buildonly" 8162306a36Sopenharmony_ci then 8262306a36Sopenharmony_ci echo Build-only run, no boot/test 8362306a36Sopenharmony_ci configcheck.sh $i/.config $i/ConfigFragment > $i/ConfigFragment.diags 2>&1 8462306a36Sopenharmony_ci if test -s $i/ConfigFragment.diags 8562306a36Sopenharmony_ci then 8662306a36Sopenharmony_ci cat $i/ConfigFragment.diags 8762306a36Sopenharmony_ci configerrors=$((configerrors+1)) 8862306a36Sopenharmony_ci else 8962306a36Sopenharmony_ci rm $i/ConfigFragment.diags 9062306a36Sopenharmony_ci fi 9162306a36Sopenharmony_ci parse-build.sh $i/Make.out $configfile 9262306a36Sopenharmony_ci elif test -f "$i/qemu-cmd" 9362306a36Sopenharmony_ci then 9462306a36Sopenharmony_ci print_bug qemu failed 9562306a36Sopenharmony_ci echo " $i" 9662306a36Sopenharmony_ci else 9762306a36Sopenharmony_ci print_bug Build failed 9862306a36Sopenharmony_ci echo " $i" 9962306a36Sopenharmony_ci fi 10062306a36Sopenharmony_ci fi 10162306a36Sopenharmony_ci done 10262306a36Sopenharmony_ci if test -f "$rd/kcsan.sum" 10362306a36Sopenharmony_ci then 10462306a36Sopenharmony_ci if ! test -f $i/ConfigFragment.diags 10562306a36Sopenharmony_ci then 10662306a36Sopenharmony_ci : 10762306a36Sopenharmony_ci elif grep -q CONFIG_KCSAN=y $i/ConfigFragment.diags 10862306a36Sopenharmony_ci then 10962306a36Sopenharmony_ci echo "Compiler or architecture does not support KCSAN!" 11062306a36Sopenharmony_ci echo Did you forget to switch your compiler with '--kmake-arg CC=<cc-that-supports-kcsan>'? 11162306a36Sopenharmony_ci elif test -s "$rd/kcsan.sum" 11262306a36Sopenharmony_ci then 11362306a36Sopenharmony_ci echo KCSAN summary in $rd/kcsan.sum 11462306a36Sopenharmony_ci else 11562306a36Sopenharmony_ci echo Clean KCSAN run in $rd 11662306a36Sopenharmony_ci fi 11762306a36Sopenharmony_ci fi 11862306a36Sopenharmony_cidone 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ciif test "$configerrors" -gt 0 12162306a36Sopenharmony_cithen 12262306a36Sopenharmony_ci echo $configerrors runs with .config errors. 12362306a36Sopenharmony_ci ret=1 12462306a36Sopenharmony_cifi 12562306a36Sopenharmony_ciEDITOR=echo kvm-find-errors.sh "${@: -1}" > $T 2>&1 12662306a36Sopenharmony_cibuilderrors="`tr ' ' '\012' < $T | grep -c '/Make.out.diags'`" 12762306a36Sopenharmony_ciif test "$builderrors" -gt 0 12862306a36Sopenharmony_cithen 12962306a36Sopenharmony_ci echo $builderrors runs with build errors. 13062306a36Sopenharmony_ci ret=2 13162306a36Sopenharmony_cifi 13262306a36Sopenharmony_cirunerrors="`tr ' ' '\012' < $T | grep -c '/console.log.diags'`" 13362306a36Sopenharmony_ciif test "$runerrors" -gt 0 13462306a36Sopenharmony_cithen 13562306a36Sopenharmony_ci echo $runerrors runs with runtime errors. 13662306a36Sopenharmony_ci ret=3 13762306a36Sopenharmony_cifi 13862306a36Sopenharmony_ciexit $ret 139