Merge tag 'locks-v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton...
[linux-2.6-microblaze.git] / tools / testing / selftests / rcutorture / bin / kvm-test-1-run-batch.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0+
3 #
4 # Carry out a kvm-based run for the specified batch of scenarios, which
5 # might have been built by --build-only kvm.sh run.
6 #
7 # Usage: kvm-test-1-run-batch.sh SCENARIO [ SCENARIO ... ]
8 #
9 # Each SCENARIO is the name of a directory in the current directory
10 #       containing a ready-to-run qemu-cmd file.
11 #
12 # Copyright (C) 2021 Facebook, Inc.
13 #
14 # Authors: Paul E. McKenney <paulmck@kernel.org>
15
16 T=${TMPDIR-/tmp}/kvm-test-1-run-batch.sh.$$
17 trap 'rm -rf $T' 0
18 mkdir $T
19
20 echo ---- Running batch $*
21 # Check arguments
22 runfiles=
23 for i in "$@"
24 do
25         if ! echo $i | grep -q '^[^/.a-z]\+\(\.[0-9]\+\)\?$'
26         then
27                 echo Bad scenario name: \"$i\" 1>&2
28                 exit 1
29         fi
30         if ! test -d "$i"
31         then
32                 echo Scenario name not a directory: \"$i\" 1>&2
33                 exit 2
34         fi
35         if ! test -f "$i/qemu-cmd"
36         then
37                 echo Scenario lacks a command file: \"$i/qemu-cmd\" 1>&2
38                 exit 3
39         fi
40         rm -f $i/build.*
41         touch $i/build.run
42         runfiles="$runfiles $i/build.run"
43 done
44
45 # Extract settings from the qemu-cmd file.
46 grep '^#' $1/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings
47 . $T/qemu-cmd-settings
48
49 # Start up jitter, start each scenario, wait, end jitter.
50 echo ---- System running test: `uname -a`
51 echo ---- Starting kernels. `date` | tee -a log
52 $TORTURE_JITTER_START
53 for i in "$@"
54 do
55         echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out
56         echo > $i/kvm-test-1-run-qemu.sh.out
57         kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &
58 done
59 for i in $runfiles
60 do
61         while ls $i > /dev/null 2>&1
62         do
63                 :
64         done
65 done
66 echo ---- All kernel runs complete. `date` | tee -a log
67 $TORTURE_JITTER_STOP