1*4882a593Smuzhiyun#!/bin/sh 2*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0+ 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# Run a group of kvm.sh tests on the specified commits. This currently 5*4882a593Smuzhiyun# unconditionally does three-minute runs on each scenario in CFLIST, 6*4882a593Smuzhiyun# taking advantage of all available CPUs and trusting the "make" utility. 7*4882a593Smuzhiyun# In the short term, adjustments can be made by editing this script and 8*4882a593Smuzhiyun# CFLIST. If some adjustments appear to have ongoing value, this script 9*4882a593Smuzhiyun# might grow some command-line arguments. 10*4882a593Smuzhiyun# 11*4882a593Smuzhiyun# Usage: kvm-check-branches.sh commit1 commit2..commit3 commit4 ... 12*4882a593Smuzhiyun# 13*4882a593Smuzhiyun# This script considers its arguments one at a time. If more elaborate 14*4882a593Smuzhiyun# specification of commits is needed, please use "git rev-list" to 15*4882a593Smuzhiyun# produce something that this simple script can understand. The reason 16*4882a593Smuzhiyun# for retaining the simplicity is that it allows the user to more easily 17*4882a593Smuzhiyun# see which commit came from which branch. 18*4882a593Smuzhiyun# 19*4882a593Smuzhiyun# This script creates a yyyy.mm.dd-hh.mm.ss-group entry in the "res" 20*4882a593Smuzhiyun# directory. The calls to kvm.sh create the usual entries, but this script 21*4882a593Smuzhiyun# moves them under the yyyy.mm.dd-hh.mm.ss-group entry, each in its own 22*4882a593Smuzhiyun# directory numbered in run order, that is, "0001", "0002", and so on. 23*4882a593Smuzhiyun# For successful runs, the large build artifacts are removed. Doing this 24*4882a593Smuzhiyun# reduces the disk space required by about two orders of magnitude for 25*4882a593Smuzhiyun# successful runs. 26*4882a593Smuzhiyun# 27*4882a593Smuzhiyun# Copyright (C) Facebook, 2020 28*4882a593Smuzhiyun# 29*4882a593Smuzhiyun# Authors: Paul E. McKenney <paulmck@kernel.org> 30*4882a593Smuzhiyun 31*4882a593Smuzhiyunif ! git status > /dev/null 2>&1 32*4882a593Smuzhiyunthen 33*4882a593Smuzhiyun echo '!!!' This script needs to run in a git archive. 1>&2 34*4882a593Smuzhiyun echo '!!!' Giving up. 1>&2 35*4882a593Smuzhiyun exit 1 36*4882a593Smuzhiyunfi 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun# Remember where we started so that we can get back and the end. 39*4882a593Smuzhiyuncurcommit="`git status | head -1 | awk '{ print $NF }'`" 40*4882a593Smuzhiyun 41*4882a593Smuzhiyunnfail=0 42*4882a593Smuzhiyunntry=0 43*4882a593Smuzhiyunresdir="tools/testing/selftests/rcutorture/res" 44*4882a593Smuzhiyunds="`date +%Y.%m.%d-%H.%M.%S`-group" 45*4882a593Smuzhiyunif ! test -e $resdir 46*4882a593Smuzhiyunthen 47*4882a593Smuzhiyun mkdir $resdir || : 48*4882a593Smuzhiyunfi 49*4882a593Smuzhiyunmkdir $resdir/$ds 50*4882a593Smuzhiyunecho Results directory: $resdir/$ds 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunKVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM 53*4882a593SmuzhiyunPATH=${KVM}/bin:$PATH; export PATH 54*4882a593Smuzhiyun. functions.sh 55*4882a593Smuzhiyuncpus="`identify_qemu_vcpus`" 56*4882a593Smuzhiyunecho Using up to $cpus CPUs. 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun# Each pass through this loop does one command-line argument. 59*4882a593Smuzhiyunfor gitbr in $@ 60*4882a593Smuzhiyundo 61*4882a593Smuzhiyun echo ' --- git branch ' $gitbr 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun # Each pass through this loop tests one commit. 64*4882a593Smuzhiyun for i in `git rev-list "$gitbr"` 65*4882a593Smuzhiyun do 66*4882a593Smuzhiyun ntry=`expr $ntry + 1` 67*4882a593Smuzhiyun idir=`awk -v ntry="$ntry" 'END { printf "%04d", ntry; }' < /dev/null` 68*4882a593Smuzhiyun echo ' --- commit ' $i from branch $gitbr 69*4882a593Smuzhiyun date 70*4882a593Smuzhiyun mkdir $resdir/$ds/$idir 71*4882a593Smuzhiyun echo $gitbr > $resdir/$ds/$idir/gitbr 72*4882a593Smuzhiyun echo $i >> $resdir/$ds/$idir/gitbr 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun # Test the specified commit. 75*4882a593Smuzhiyun git checkout $i > $resdir/$ds/$idir/git-checkout.out 2>&1 76*4882a593Smuzhiyun echo git checkout return code: $? "(Commit $ntry: $i)" 77*4882a593Smuzhiyun kvm.sh --cpus $cpus --duration 3 --trust-make > $resdir/$ds/$idir/kvm.sh.out 2>&1 78*4882a593Smuzhiyun ret=$? 79*4882a593Smuzhiyun echo kvm.sh return code $ret for commit $i from branch $gitbr 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun # Move the build products to their resting place. 82*4882a593Smuzhiyun runresdir="`grep -m 1 '^Results directory:' < $resdir/$ds/$idir/kvm.sh.out | sed -e 's/^Results directory://'`" 83*4882a593Smuzhiyun mv $runresdir $resdir/$ds/$idir 84*4882a593Smuzhiyun rrd="`echo $runresdir | sed -e 's,^.*/,,'`" 85*4882a593Smuzhiyun echo Run results: $resdir/$ds/$idir/$rrd 86*4882a593Smuzhiyun if test "$ret" -ne 0 87*4882a593Smuzhiyun then 88*4882a593Smuzhiyun # Failure, so leave all evidence intact. 89*4882a593Smuzhiyun nfail=`expr $nfail + 1` 90*4882a593Smuzhiyun else 91*4882a593Smuzhiyun # Success, so remove large files to save about 1GB. 92*4882a593Smuzhiyun ( cd $resdir/$ds/$idir/$rrd; rm -f */vmlinux */bzImage */System.map */Module.symvers ) 93*4882a593Smuzhiyun fi 94*4882a593Smuzhiyun done 95*4882a593Smuzhiyundone 96*4882a593Smuzhiyundate 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun# Go back to the original commit. 99*4882a593Smuzhiyungit checkout "$curcommit" 100*4882a593Smuzhiyun 101*4882a593Smuzhiyunif test $nfail -ne 0 102*4882a593Smuzhiyunthen 103*4882a593Smuzhiyun echo '!!! ' $nfail failures in $ntry 'runs!!!' 104*4882a593Smuzhiyun exit 1 105*4882a593Smuzhiyunelse 106*4882a593Smuzhiyun echo No failures in $ntry runs. 107*4882a593Smuzhiyun exit 0 108*4882a593Smuzhiyunfi 109