rcutorture: Add kernel-version argument
[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
32 dur=30
33 KVM=`pwd`/tools/testing/selftests/rcutorture; export KVM
34 builddir=${KVM}/b1
35 resdir=""
36 configs=" sysidleY.2013.06.19a \
37           sysidleN.2013.06.19a \
38           P1-S-T-NH-SD-SMP-HP \
39           P2-2-t-nh-sd-SMP-hp \
40           P3-3-T-nh-SD-SMP-hp \
41           P4-A-t-NH-sd-SMP-HP \
42           P5-U-T-NH-sd-SMP-hp \
43           P6---t-nh-SD-smp-hp \
44           N1-S-T-NH-SD-SMP-HP \
45           N2-2-t-nh-sd-SMP-hp \
46           N3-3-T-nh-SD-SMP-hp \
47           N4-A-t-NH-sd-SMP-HP \
48           N5-U-T-NH-sd-SMP-hp \
49           PT1-nh \
50           PT2-NH \
51           NT1-nh \
52           NT3-NH"
53 ds=`date +%Y.%m.%d-%H:%M:%S`
54 kversion=""
55
56 usage () {
57         echo "Usage: $scriptname optional arguments:"
58         echo "       --builddir absolute-pathname"
59         echo "       --configs \"config-file list\""
60         echo "       --datestamp string"
61         echo "       --duration minutes"
62         echo "       --kversion vN.NN"
63         echo "       --rcu-kvm absolute-pathname"
64         echo "       --results absolute-pathname"
65         echo "       --relbuilddir relative-pathname"
66         exit 1
67 }
68
69 # checkarg --argname argtype $# arg mustmatch cannotmatch
70 checkarg () {
71         if test $3 -le 1
72         then
73                 echo $1 needs argument $2 matching \"$5\"
74                 usage
75         fi
76         if echo "$4" | grep -q -e "$5"
77         then
78                 :
79         else
80                 echo $1 $2 \"$4\" must match \"$5\"
81                 usage
82         fi
83         if echo "$4" | grep -q -e "$6"
84         then
85                 echo $1 $2 \"$4\" must not match \"$6\"
86                 usage
87         fi
88 }
89
90 while test $# -gt 0
91 do
92         echo ":$1:"
93         case "$1" in
94         --builddir)
95                 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' error
96                 builddir=$2
97                 gotbuilddir=1
98                 shift
99                 ;;
100         --configs)
101                 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
102                 configs="$2"
103                 shift
104                 ;;
105         --datestamp)
106                 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
107                 ds=$2
108                 shift
109                 ;;
110         --duration)
111                 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' error
112                 dur=$2
113                 shift
114                 ;;
115         --kversion)
116                 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' error
117                 kversion=$2
118                 shift
119                 ;;
120         --rcu-kvm)
121                 checkarg --rcu-kvm "(absolute pathname)" "$#" "$2" '^/' error
122                 KVM=$2; export KVM
123                 if -z "$gotbuilddir"
124                 then
125                         builddir=${KVM}/b1
126                 fi
127                 if -n "$gotrelbuilddir"
128                 then
129                         builddir=${KVM}/${relbuilddir}
130                 fi
131                 shift
132                 ;;
133         --relbuilddir)
134                 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
135                 relbuilddir=$2
136                 gotrelbuilddir=1
137                 builddir=${KVM}/${relbuilddir}
138                 shift
139                 ;;
140         --results)
141                 checkarg --results "(absolute pathname)" "$#" "$2" '^/' error
142                 resdir=$2
143                 shift
144                 ;;
145         *)
146                 usage
147                 ;;
148         esac
149         shift
150 done
151
152 echo "builddir=$builddir"
153 echo "dur=$dur"
154 echo "KVM=$KVM"
155 echo "resdir=$resdir"
156
157 PATH=${KVM}/bin:$PATH; export PATH
158 CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
159
160 if test -z "$resdir"
161 then
162         resdir=$KVM/res
163         mkdir $resdir || :
164 else
165         mkdir -p "$resdir" || :
166 fi
167 mkdir $resdir/$ds
168 echo Datestamp: $ds
169
170 pwd > $resdir/$ds/testid.txt
171 if test -d .git
172 then
173         git status >> $resdir/$ds/testid.txt
174         git rev-parse HEAD >> $resdir/$ds/testid.txt
175 fi
176 builddir=$KVM/b1
177 mkdir $builddir || :
178
179 for CF in $configs
180 do
181         rd=$resdir/$ds/$CF
182         mkdir $rd || :
183         echo Results directory: $rd
184         kvm-test-1-rcu.sh $CONFIGFRAG/$kversion/$CF $builddir $rd $dur "-nographic" "rcutorture.test_no_idle_hz=1 rcutorture.n_barrier_cbs=4 rcutorture.verbose=1"
185 done
186 # 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