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