rcutorture: Add --qemu-args argument to kvm.sh
[linux-2.6-block.git] / tools / testing / selftests / rcutorture / bin / kvm.sh
CommitLineData
c87b9c60
PM
1#!/bin/bash
2#
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.
6#
7# Edit the definitions below to set the locations of the various directories,
8# as well as the test duration.
9#
10# Usage: sh kvm.sh [ options ]
11#
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.
16#
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.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25#
26# Copyright (C) IBM Corporation, 2011
27#
28# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
29
30scriptname=$0
330a76f1 31args="$*"
c87b9c60
PM
32
33dur=30
34KVM=`pwd`/tools/testing/selftests/rcutorture; export KVM
35builddir=${KVM}/b1
36resdir=""
4275be83 37configs=""
847bfd25 38ds=`date +%Y.%m.%d-%H:%M:%S`
bb918535 39kversion=""
c87b9c60
PM
40
41usage () {
42 echo "Usage: $scriptname optional arguments:"
7dca9273 43 echo " --bootargs kernel-boot-arguments"
c87b9c60 44 echo " --builddir absolute-pathname"
11274813 45 echo " --buildonly"
c87b9c60 46 echo " --configs \"config-file list\""
847bfd25 47 echo " --datestamp string"
c87b9c60 48 echo " --duration minutes"
315c540d 49 echo " --interactive"
bb918535 50 echo " --kversion vN.NN"
315c540d 51 echo " --mac nn:nn:nn:nn:nn:nn"
e9ce6400 52 echo " --qemu-args qemu-system-..."
4f8a0312 53 echo " --qemu-cmd qemu-system-..."
c87b9c60
PM
54 echo " --results absolute-pathname"
55 echo " --relbuilddir relative-pathname"
56 exit 1
57}
58
59# checkarg --argname argtype $# arg mustmatch cannotmatch
60checkarg () {
61 if test $3 -le 1
62 then
63 echo $1 needs argument $2 matching \"$5\"
64 usage
65 fi
66 if echo "$4" | grep -q -e "$5"
67 then
68 :
69 else
70 echo $1 $2 \"$4\" must match \"$5\"
71 usage
72 fi
73 if echo "$4" | grep -q -e "$6"
74 then
75 echo $1 $2 \"$4\" must not match \"$6\"
76 usage
77 fi
78}
79
80while test $# -gt 0
81do
c87b9c60 82 case "$1" in
7dca9273
PM
83 --bootargs)
84 checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
85 RCU_BOOTARGS="$2"
86 shift
87 ;;
c87b9c60 88 --builddir)
e9ce6400 89 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
c87b9c60
PM
90 builddir=$2
91 gotbuilddir=1
92 shift
93 ;;
11274813
PM
94 --buildonly)
95 RCU_BUILDONLY=1; export RCU_BUILDONLY
96 ;;
c87b9c60
PM
97 --configs)
98 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
99 configs="$2"
100 shift
101 ;;
847bfd25
PM
102 --datestamp)
103 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
104 ds=$2
105 shift
106 ;;
c87b9c60 107 --duration)
e9ce6400 108 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
c87b9c60
PM
109 dur=$2
110 shift
111 ;;
315c540d
PM
112 --interactive)
113 RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
114 ;;
bb918535 115 --kversion)
e9ce6400 116 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
bb918535
PM
117 kversion=$2
118 shift
119 ;;
315c540d
PM
120 --mac)
121 checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
122 RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
123 shift
124 ;;
e9ce6400
PM
125 --qemu-args)
126 checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
127 RCU_QEMU_ARG="$2"
128 shift
129 ;;
4f8a0312
PM
130 --qemu-cmd)
131 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
132 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
133 shift
134 ;;
c87b9c60
PM
135 --relbuilddir)
136 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
137 relbuilddir=$2
138 gotrelbuilddir=1
139 builddir=${KVM}/${relbuilddir}
140 shift
141 ;;
142 --results)
e9ce6400 143 checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error'
c87b9c60
PM
144 resdir=$2
145 shift
146 ;;
147 *)
2bcdf4e3 148 echo Unknown argument $1
c87b9c60
PM
149 usage
150 ;;
151 esac
152 shift
153done
154
c87b9c60
PM
155PATH=${KVM}/bin:$PATH; export PATH
156CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
4275be83
PM
157KVPATH=${CONFIGFRAG}/$kversion; export KVPATH
158
159if test -z "$configs"
160then
161 configs="`cat $CONFIGFRAG/$kversion/CFLIST`"
162fi
c87b9c60
PM
163
164if test -z "$resdir"
165then
166 resdir=$KVM/res
330a76f1
PM
167 if ! test -e $resdir
168 then
169 mkdir $resdir || :
170 fi
c87b9c60 171else
330a76f1
PM
172 if ! test -e $resdir
173 then
174 mkdir -p "$resdir" || :
175 fi
c87b9c60 176fi
847bfd25 177mkdir $resdir/$ds
330a76f1
PM
178touch $resdir/$ds/log
179echo $scriptname $args >> $resdir/$ds/log
847bfd25 180
c87b9c60
PM
181pwd > $resdir/$ds/testid.txt
182if test -d .git
183then
184 git status >> $resdir/$ds/testid.txt
185 git rev-parse HEAD >> $resdir/$ds/testid.txt
186fi
187builddir=$KVM/b1
330a76f1
PM
188if ! test -e $builddir
189then
190 mkdir $builddir || :
191fi
c87b9c60
PM
192
193for CF in $configs
194do
195 rd=$resdir/$ds/$CF
196 mkdir $rd || :
197 echo Results directory: $rd
e9ce6400 198 kvm-test-1-rcu.sh $CONFIGFRAG/$kversion/$CF $builddir $rd $dur "-nographic $RCU_QEMU_ARG" "rcutorture.test_no_idle_hz=1 rcutorture.verbose=1 $RCU_BOOTARGS"
c87b9c60
PM
199done
200# Tracing: trace_event=rcu:rcu_nocb_grace_period,rcu:rcu_grace_period,rcu:rcu_grace_period_init,rcu:rcu_quiescent_state_report,rcu:rcu_fqs,rcu:rcu_callback,rcu:rcu_torture_read,rcu:rcu_invoke_callback,rcu:rcu_fqs,rcu:rcu_dyntick,rcu:rcu_unlock_preempted_task