a833160dcdc3d65ce7cf4748643391afc28a0620
[platform/adaptation/renesas_rcar/renesas_kernel.git] / tools / testing / selftests / rcutorture / bin / kvm.sh
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
30 scriptname=$0
31 args="$*"
32
33 dur=30
34 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
35 builddir="${KVM}/b1"
36 RCU_INITRD="$KVM/initrd"; export RCU_INITRD
37 resdir=""
38 configs=""
39 ds=`date +%Y.%m.%d-%H:%M:%S`
40 kversion=""
41
42 usage () {
43         echo "Usage: $scriptname optional arguments:"
44         echo "       --bootargs kernel-boot-arguments"
45         echo "       --builddir absolute-pathname"
46         echo "       --buildonly"
47         echo "       --configs \"config-file list\""
48         echo "       --datestamp string"
49         echo "       --duration minutes"
50         echo "       --interactive"
51         echo "       --kversion vN.NN"
52         echo "       --mac nn:nn:nn:nn:nn:nn"
53         echo "       --no-initrd"
54         echo "       --qemu-args qemu-system-..."
55         echo "       --qemu-cmd qemu-system-..."
56         echo "       --results absolute-pathname"
57         echo "       --relbuilddir relative-pathname"
58         exit 1
59 }
60
61 # checkarg --argname argtype $# arg mustmatch cannotmatch
62 checkarg () {
63         if test $3 -le 1
64         then
65                 echo $1 needs argument $2 matching \"$5\"
66                 usage
67         fi
68         if echo "$4" | grep -q -e "$5"
69         then
70                 :
71         else
72                 echo $1 $2 \"$4\" must match \"$5\"
73                 usage
74         fi
75         if echo "$4" | grep -q -e "$6"
76         then
77                 echo $1 $2 \"$4\" must not match \"$6\"
78                 usage
79         fi
80 }
81
82 while test $# -gt 0
83 do
84         case "$1" in
85         --bootargs)
86                 checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
87                 RCU_BOOTARGS="$2"
88                 shift
89                 ;;
90         --builddir)
91                 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
92                 builddir=$2
93                 gotbuilddir=1
94                 shift
95                 ;;
96         --buildonly)
97                 RCU_BUILDONLY=1; export RCU_BUILDONLY
98                 ;;
99         --configs)
100                 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
101                 configs="$2"
102                 shift
103                 ;;
104         --datestamp)
105                 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
106                 ds=$2
107                 shift
108                 ;;
109         --duration)
110                 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
111                 dur=$2
112                 shift
113                 ;;
114         --interactive)
115                 RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
116                 ;;
117         --kversion)
118                 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
119                 kversion=$2
120                 shift
121                 ;;
122         --mac)
123                 checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
124                 RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
125                 shift
126                 ;;
127         --no-initrd)
128                 RCU_INITRD=""; export RCU_INITRD
129                 ;;
130         --qemu-args)
131                 checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
132                 RCU_QEMU_ARG="$2"
133                 shift
134                 ;;
135         --qemu-cmd)
136                 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
137                 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
138                 shift
139                 ;;
140         --relbuilddir)
141                 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
142                 relbuilddir=$2
143                 gotrelbuilddir=1
144                 builddir=${KVM}/${relbuilddir}
145                 shift
146                 ;;
147         --results)
148                 checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error'
149                 resdir=$2
150                 shift
151                 ;;
152         *)
153                 echo Unknown argument $1
154                 usage
155                 ;;
156         esac
157         shift
158 done
159
160 PATH=${KVM}/bin:$PATH; export PATH
161 CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
162 KVPATH=${CONFIGFRAG}/$kversion; export KVPATH
163
164 if test -z "$configs"
165 then
166         configs="`cat $CONFIGFRAG/$kversion/CFLIST`"
167 fi
168
169 if test -z "$resdir"
170 then
171         resdir=$KVM/res
172         if ! test -e $resdir
173         then
174                 mkdir $resdir || :
175         fi
176 else
177         if ! test -e $resdir
178         then
179                 mkdir -p "$resdir" || :
180         fi
181 fi
182 mkdir $resdir/$ds
183 touch $resdir/$ds/log
184 echo $scriptname $args >> $resdir/$ds/log
185
186 pwd > $resdir/$ds/testid.txt
187 if test -d .git
188 then
189         git status >> $resdir/$ds/testid.txt
190         git rev-parse HEAD >> $resdir/$ds/testid.txt
191 fi
192 builddir=$KVM/b1
193 if ! test -e $builddir
194 then
195         mkdir $builddir || :
196 fi
197
198 for CF in $configs
199 do
200         rd=$resdir/$ds/$CF
201         mkdir $rd || :
202         echo Results directory: $rd
203         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"
204 done
205 # 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