xref: /linux/tools/testing/selftests/rcutorture/bin/kvm-check-branches.sh (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
16582e7f1SPaul E. McKenney#!/bin/sh
26582e7f1SPaul E. McKenney# SPDX-License-Identifier: GPL-2.0+
36582e7f1SPaul E. McKenney#
46582e7f1SPaul E. McKenney# Run a group of kvm.sh tests on the specified commits.  This currently
56582e7f1SPaul E. McKenney# unconditionally does three-minute runs on each scenario in CFLIST,
66582e7f1SPaul E. McKenney# taking advantage of all available CPUs and trusting the "make" utility.
76582e7f1SPaul E. McKenney# In the short term, adjustments can be made by editing this script and
86582e7f1SPaul E. McKenney# CFLIST.  If some adjustments appear to have ongoing value, this script
96582e7f1SPaul E. McKenney# might grow some command-line arguments.
106582e7f1SPaul E. McKenney#
116582e7f1SPaul E. McKenney# Usage: kvm-check-branches.sh commit1 commit2..commit3 commit4 ...
126582e7f1SPaul E. McKenney#
136582e7f1SPaul E. McKenney# This script considers its arguments one at a time.  If more elaborate
146582e7f1SPaul E. McKenney# specification of commits is needed, please use "git rev-list" to
156582e7f1SPaul E. McKenney# produce something that this simple script can understand.  The reason
166582e7f1SPaul E. McKenney# for retaining the simplicity is that it allows the user to more easily
176582e7f1SPaul E. McKenney# see which commit came from which branch.
186582e7f1SPaul E. McKenney#
196582e7f1SPaul E. McKenney# This script creates a yyyy.mm.dd-hh.mm.ss-group entry in the "res"
206582e7f1SPaul E. McKenney# directory.  The calls to kvm.sh create the usual entries, but this script
216582e7f1SPaul E. McKenney# moves them under the yyyy.mm.dd-hh.mm.ss-group entry, each in its own
226582e7f1SPaul E. McKenney# directory numbered in run order, that is, "0001", "0002", and so on.
236582e7f1SPaul E. McKenney# For successful runs, the large build artifacts are removed.  Doing this
246582e7f1SPaul E. McKenney# reduces the disk space required by about two orders of magnitude for
256582e7f1SPaul E. McKenney# successful runs.
266582e7f1SPaul E. McKenney#
276582e7f1SPaul E. McKenney# Copyright (C) Facebook, 2020
286582e7f1SPaul E. McKenney#
296582e7f1SPaul E. McKenney# Authors: Paul E. McKenney <paulmck@kernel.org>
306582e7f1SPaul E. McKenney
316582e7f1SPaul E. McKenneyif ! git status > /dev/null 2>&1
326582e7f1SPaul E. McKenneythen
336582e7f1SPaul E. McKenney	echo '!!!' This script needs to run in a git archive. 1>&2
346582e7f1SPaul E. McKenney	echo '!!!' Giving up. 1>&2
356582e7f1SPaul E. McKenney	exit 1
366582e7f1SPaul E. McKenneyfi
376582e7f1SPaul E. McKenney
38*148df92fSPaul E. McKenney# Remember where we started so that we can get back at the end.
396582e7f1SPaul E. McKenneycurcommit="`git status | head -1 | awk '{ print $NF }'`"
406582e7f1SPaul E. McKenney
416582e7f1SPaul E. McKenneynfail=0
426582e7f1SPaul E. McKenneyntry=0
436582e7f1SPaul E. McKenneyresdir="tools/testing/selftests/rcutorture/res"
446582e7f1SPaul E. McKenneyds="`date +%Y.%m.%d-%H.%M.%S`-group"
456582e7f1SPaul E. McKenneyif ! test -e $resdir
466582e7f1SPaul E. McKenneythen
476582e7f1SPaul E. McKenney	mkdir $resdir || :
486582e7f1SPaul E. McKenneyfi
496582e7f1SPaul E. McKenneymkdir $resdir/$ds
506582e7f1SPaul E. McKenneyecho Results directory: $resdir/$ds
516582e7f1SPaul E. McKenney
52a7d89cfbSPaul E. McKenneyRCUTORTURE="`pwd`/tools/testing/selftests/rcutorture"; export RCUTORTURE
53a7d89cfbSPaul E. McKenneyPATH=${RCUTORTURE}/bin:$PATH; export PATH
546582e7f1SPaul E. McKenney. functions.sh
555be7d80dSPaul E. McKenneyecho Using all `identify_qemu_vcpus` CPUs.
566582e7f1SPaul E. McKenney
576582e7f1SPaul E. McKenney# Each pass through this loop does one command-line argument.
586582e7f1SPaul E. McKenneyfor gitbr in $@
596582e7f1SPaul E. McKenneydo
606582e7f1SPaul E. McKenney	echo ' --- git branch ' $gitbr
616582e7f1SPaul E. McKenney
626582e7f1SPaul E. McKenney	# Each pass through this loop tests one commit.
636582e7f1SPaul E. McKenney	for i in `git rev-list "$gitbr"`
646582e7f1SPaul E. McKenney	do
656582e7f1SPaul E. McKenney		ntry=`expr $ntry + 1`
666582e7f1SPaul E. McKenney		idir=`awk -v ntry="$ntry" 'END { printf "%04d", ntry; }' < /dev/null`
676582e7f1SPaul E. McKenney		echo ' --- commit ' $i from branch $gitbr
686582e7f1SPaul E. McKenney		date
696582e7f1SPaul E. McKenney		mkdir $resdir/$ds/$idir
706582e7f1SPaul E. McKenney		echo $gitbr > $resdir/$ds/$idir/gitbr
716582e7f1SPaul E. McKenney		echo $i >> $resdir/$ds/$idir/gitbr
726582e7f1SPaul E. McKenney
736582e7f1SPaul E. McKenney		# Test the specified commit.
746582e7f1SPaul E. McKenney		git checkout $i > $resdir/$ds/$idir/git-checkout.out 2>&1
756582e7f1SPaul E. McKenney		echo git checkout return code: $? "(Commit $ntry: $i)"
76*148df92fSPaul E. McKenney		kvm.sh --allcpus --duration 3 --trust-make --datestamp "$ds/$idir" > $resdir/$ds/$idir/kvm.sh.out 2>&1
776582e7f1SPaul E. McKenney		ret=$?
786582e7f1SPaul E. McKenney		echo kvm.sh return code $ret for commit $i from branch $gitbr
79*148df92fSPaul E. McKenney		echo Run results: $resdir/$ds/$idir
806582e7f1SPaul E. McKenney		if test "$ret" -ne 0
816582e7f1SPaul E. McKenney		then
826582e7f1SPaul E. McKenney			# Failure, so leave all evidence intact.
836582e7f1SPaul E. McKenney			nfail=`expr $nfail + 1`
846582e7f1SPaul E. McKenney		else
856582e7f1SPaul E. McKenney			# Success, so remove large files to save about 1GB.
866582e7f1SPaul E. McKenney			( cd $resdir/$ds/$idir/$rrd; rm -f */vmlinux */bzImage */System.map */Module.symvers )
876582e7f1SPaul E. McKenney		fi
886582e7f1SPaul E. McKenney	done
896582e7f1SPaul E. McKenneydone
906582e7f1SPaul E. McKenneydate
916582e7f1SPaul E. McKenney
926582e7f1SPaul E. McKenney# Go back to the original commit.
936582e7f1SPaul E. McKenneygit checkout "$curcommit"
946582e7f1SPaul E. McKenney
956582e7f1SPaul E. McKenneyif test $nfail -ne 0
966582e7f1SPaul E. McKenneythen
976582e7f1SPaul E. McKenney	echo '!!! ' $nfail failures in $ntry 'runs!!!'
986582e7f1SPaul E. McKenney	exit 1
996582e7f1SPaul E. McKenneyelse
1006582e7f1SPaul E. McKenney	echo No failures in $ntry runs.
1016582e7f1SPaul E. McKenney	exit 0
1026582e7f1SPaul E. McKenneyfi
103