886f97d287843db26444dad94336370f8d669dbc
3 # Run a series of 14 tests under KVM. These are not particularly
4 # well-selected or well-tuned, but are the current set. Run from the
5 # top level of the source tree.
7 # Edit the definitions below to set the locations of the various directories,
8 # as well as the test duration.
10 # Usage: sh kvm.sh [ options ]
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, you can access it online at
24 # http://www.gnu.org/licenses/gpl-2.0.html.
26 # Copyright (C) IBM Corporation, 2011
28 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
39 KVM
="`pwd`/tools/testing/selftests/rcutorture"; export KVM
40 PATH
=${KVM}/bin
:$PATH; export PATH
41 TORTURE_DEFCONFIG
=defconfig
42 TORTURE_INITRD
="$KVM/initrd"; export TORTURE_INITRD
48 ds
=`date +%Y.%m.%d-%H:%M:%S`
54 echo "Usage: $scriptname optional arguments:"
55 echo " --bootargs kernel-boot-arguments"
57 echo " --configs \"config-file list\""
59 echo " --datestamp string"
60 echo " --defconfig string"
61 echo " --dryrun sched|script"
62 echo " --duration minutes"
64 echo " --kmake-arg kernel-make-arguments"
65 echo " --kversion vN.NN"
66 echo " --mac nn:nn:nn:nn:nn:nn"
68 echo " --qemu-args qemu-system-..."
69 echo " --qemu-cmd qemu-system-..."
70 echo " --results absolute-pathname"
79 checkarg
--bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
87 checkarg
--configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
92 checkarg
--cpus "(number)" "$#" "$2" '^[0-9]*$' '^--'
97 checkarg
--datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
102 checkarg
--defconfig "defconfigtype" "$#" "$2" '^[^/][^/]*$' '^--'
107 checkarg
--dryrun "sched|script" $# "$2" 'sched\|script' '^--'
112 checkarg
--duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
117 TORTURE_QEMU_INTERACTIVE
=1; export TORTURE_QEMU_INTERACTIVE
120 checkarg
--kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
121 TORTURE_KMAKE_ARG
="$2"
125 checkarg
--kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
130 checkarg
--mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
135 TORTURE_INITRD
=""; export TORTURE_INITRD
138 checkarg
--qemu-args "-qemu args" $# "$2" '^-' '^error'
143 checkarg
--qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
144 RCU_QEMU_CMD
="$2"; export RCU_QEMU_CMD
148 checkarg
--results "(absolute pathname)" "$#" "$2" '^/' '^error'
153 checkarg
--torture "(suite name)" "$#" "$2" '^\(lock\|rcu\)$' '^--'
158 echo Unknown argument
$1
165 CONFIGFRAG
=${KVM}/configs
/${TORTURE_SUITE}; export CONFIGFRAG
166 KVPATH
=${CONFIGFRAG}/$kversion; export KVPATH
168 if test -z "$configs"
170 configs
="`cat $CONFIGFRAG/$kversion/CFLIST`"
178 if test "$dryrun" = ""
182 mkdir
-p "$resdir" ||
:
186 # Be noisy only if running the script.
187 echo Results directory
: $resdir/$ds
188 echo $scriptname $args
190 touch $resdir/$ds/log
191 echo $scriptname $args >> $resdir/$ds/log
192 echo ${TORTURE_SUITE} > $resdir/$ds/TORTURE_SUITE
194 pwd > $resdir/$ds/testid.txt
197 git status
>> $resdir/$ds/testid.txt
198 git rev-parse HEAD
>> $resdir/$ds/testid.txt
202 # Create a file of test-name/#cpus pairs, sorted by decreasing #cpus.
206 if test -f "$CONFIGFRAG/$kversion/$CF"
208 echo $CF `configNR_CPUS.sh $CONFIGFRAG/$kversion/$CF` >> $T/cfgcpu
210 echo "The --configs file $CF does not exist, terminating."
214 sort -k2nr $T/cfgcpu
> $T/cfgcpu.
sort
216 # Use a greedy bin-packing algorithm, sorting the list accordingly.
217 awk < $T/cfgcpu.
sort > $T/cfgcpu.pack
-v ncpus
=$cpus '
223 # Read file of tests and corresponding required numbers of CPUs.
234 # Each pass through the following loop creates on test batch
235 # that can be executed concurrently given ncpus. Note that a
236 # given test that requires more than the available CPUs will run in
237 # their own batch. Such tests just have to make do with what
239 while (nc != ncpus) {
243 # Each pass through the following loop considers one
244 # test for inclusion in the current batch.
245 for (i = 0; i < njobs; i++) {
247 continue; # Already part of a batch.
248 if (nc >= cpus[i] || nc == ncpus) {
250 # This test fits into the current batch.
254 break; # Too-big test in its own batch.
259 # Dump out the tests in batch order.
260 for (b = 1; b <= batch; b++)
261 for (i = 0; i < njobs; i++)
263 print cf[i], cpus[i];
266 # Generate a script to execute the tests in appropriate batches.
267 cat << ___EOF___ > $T/script
268 TORTURE_SUITE="$TORTURE_SUITE"; export TORTURE_SUITE
269 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
271 awk < $T/cfgcpu.pack \
272 -v CONFIGDIR
="$CONFIGFRAG/$kversion/" \
277 -v RCU_QEMU_ARG
=$RCU_QEMU_ARG \
278 -v TORTURE_BOOTARGS
=$TORTURE_BOOTARGS \
289 # Dump out the scripting required to run one test batch.
290 function dump(first, pastlast)
292 print "echo ----Start batch: `date`";
293 print "echo ----Start batch: `date` >> " rd "/log";
295 for (j = first; j < pastlast; j++) {
298 if (cfrep[cf[j]] == "") {
303 cfr[jn] = cf[j] "." cfrep[cf[j]];
305 if (cpusr[jn] > ncpus && ncpus != 0)
309 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date`";
310 print "echo ", cfr[jn], cpusr[jn] ovf ": Starting build. `date` >> " rd "/log";
311 print "rm -f " builddir ".*";
312 print "touch " builddir ".wait";
313 print "mkdir " builddir " > /dev/null 2>&1 || :";
314 print "mkdir " rd cfr[jn] " || :";
315 print "kvm-test-1-run.sh " CONFIGDIR cf[j], builddir, rd cfr[jn], dur " \"" RCU_QEMU_ARG "\" \"" TORTURE_BOOTARGS "\" > " rd cfr[jn] "/kvm-test-1-run.sh.out 2>&1 &"
316 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date`";
317 print "echo ", cfr[jn], cpusr[jn] ovf ": Waiting for build to complete. `date` >> " rd "/log";
318 print "while test -f " builddir ".wait"
322 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date`";
323 print "echo ", cfr[jn], cpusr[jn] ovf ": Build complete. `date` >> " rd "/log";
326 for (j = 1; j < jn; j++) {
328 print "rm -f " builddir ".ready"
329 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date`";
330 print "echo ----", cfr[j], cpusr[j] ovf ": Starting kernel. `date` >> " rd "/log";
333 print "echo ---- All kernel runs complete. `date`";
334 print "echo ---- All kernel runs complete. `date` >> " rd "/log";
335 for (j = 1; j < jn; j++) {
337 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results:";
338 print "echo ----", cfr[j], cpusr[j] ovf ": Build/run results: >> " rd "/log";
339 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out";
340 print "cat " rd cfr[j] "/kvm-test-1-run.sh.out >> " rd "/log";
349 # Each pass through the following loop considers one test.
350 for (i = 0; i < njobs; i++) {
352 # Sequential test specified, each test its own batch.
355 } else if (nc < cpus[i] && i != 0) {
356 # Out of CPUs, dump out a batch.
361 # Account for the CPUs needed by the current test.
364 # Dump the last batch.
369 if test "$dryrun" = script
371 # Dump out the script, but define the environment variables that
372 # it needs to run standalone.
373 echo CONFIGFRAG
="$CONFIGFRAG; export CONFIGFRAG"
374 echo KVM
="$KVM; export KVM"
375 echo KVPATH
="$KVPATH; export KVPATH"
376 echo PATH
="$PATH; export PATH"
377 echo TORTURE_BUILDONLY
="$TORTURE_BUILDONLY; export TORTURE_BUILDONLY"
378 echo TORTURE_INITRD
="$TORTURE_INITRD; export TORTURE_INITRD"
379 echo TORTURE_KMAKE_ARG
="$TORTURE_KMAKE_ARG; export TORTURE_KMAKE_ARG"
380 echo RCU_QEMU_CMD
="$RCU_QEMU_CMD; export RCU_QEMU_CMD"
381 echo TORTURE_QEMU_INTERACTIVE
="$TORTURE_QEMU_INTERACTIVE; export TORTURE_QEMU_INTERACTIVE"
382 echo TORTURE_QEMU_MAC
="$TORTURE_QEMU_MAC; export TORTURE_QEMU_MAC"
383 echo "mkdir -p "$resdir" || :"
384 echo "mkdir $resdir/$ds"
387 elif test "$dryrun" = sched
389 # Extract the test run schedule from the script.
390 egrep 'Start batch|Starting build\.' $T/script |
392 sed -e 's/:.*$//' -e 's/^echo //'
395 # Not a dryru, so run the script.
399 # Tracing: trace_event=rcu:rcu_grace_period,rcu:rcu_future_grace_period,rcu:rcu_grace_period_init,rcu:rcu_nocb_wake,rcu:rcu_preempt_task,rcu:rcu_unlock_preempted_task,rcu:rcu_quiescent_state_report,rcu:rcu_fqs,rcu:rcu_callback,rcu:rcu_kfree_callback,rcu:rcu_batch_start,rcu:rcu_invoke_callback,rcu:rcu_invoke_kfree_callback,rcu:rcu_batch_end,rcu:rcu_torture_read,rcu:rcu_barrier
403 echo " --- `date` Test summary:"
404 echo Results directory
: $resdir/$ds
405 if test -n "$TORTURE_BUILDONLY"
407 kvm-recheck.sh
$resdir/$ds
This page took 0.040554 seconds and 4 git commands to generate.