rcutorture: Add KVM-based test framework
[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
54 usage () {
55         echo "Usage: $scriptname optional arguments:"
56         echo "       --builddir absolute-pathname"
57         echo "       --configs \"config-file list\""
58         echo "       --duration minutes"
59         echo "       --rcu-kvm absolute-pathname"
60         echo "       --results absolute-pathname"
61         echo "       --relbuilddir relative-pathname"
62         exit 1
63 }
64
65 # checkarg --argname argtype $# arg mustmatch cannotmatch
66 checkarg () {
67         if test $3 -le 1
68         then
69                 echo $1 needs argument $2 matching \"$5\"
70                 usage
71         fi
72         if echo "$4" | grep -q -e "$5"
73         then
74                 :
75         else
76                 echo $1 $2 \"$4\" must match \"$5\"
77                 usage
78         fi
79         if echo "$4" | grep -q -e "$6"
80         then
81                 echo $1 $2 \"$4\" must not match \"$6\"
82                 usage
83         fi
84 }
85
86 while test $# -gt 0
87 do
88         echo ":$1:"
89         case "$1" in
90         --builddir)
91                 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' error
92                 builddir=$2
93                 gotbuilddir=1
94                 shift
95                 ;;
96         --configs)
97                 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
98                 configs="$2"
99                 shift
100                 ;;
101         --duration)
102                 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' error
103                 dur=$2
104                 shift
105                 ;;
106         --rcu-kvm)
107                 checkarg --rcu-kvm "(absolute pathname)" "$#" "$2" '^/' error
108                 KVM=$2; export KVM
109                 if -z "$gotbuilddir"
110                 then
111                         builddir=${KVM}/b1
112                 fi
113                 if -n "$gotrelbuilddir"
114                 then
115                         builddir=${KVM}/${relbuilddir}
116                 fi
117                 shift
118                 ;;
119         --relbuilddir)
120                 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
121                 relbuilddir=$2
122                 gotrelbuilddir=1
123                 builddir=${KVM}/${relbuilddir}
124                 shift
125                 ;;
126         --results)
127                 checkarg --results "(absolute pathname)" "$#" "$2" '^/' error
128                 resdir=$2
129                 shift
130                 ;;
131         *)
132                 usage
133                 ;;
134         esac
135         shift
136 done
137
138 echo "builddir=$builddir"
139 echo "dur=$dur"
140 echo "KVM=$KVM"
141 echo "resdir=$resdir"
142
143 PATH=${KVM}/bin:$PATH; export PATH
144 CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
145
146 if test -z "$resdir"
147 then
148         resdir=$KVM/res
149         mkdir $resdir || :
150         ds=`date +%Y.%m.%d-%H:%M:%S`
151         mkdir $resdir/$ds
152         echo Datestamp: $ds
153 else
154         mkdir -p "$resdir"
155         ds=""
156 fi
157 pwd > $resdir/$ds/testid.txt
158 if test -d .git
159 then
160         git status >> $resdir/$ds/testid.txt
161         git rev-parse HEAD >> $resdir/$ds/testid.txt
162 fi
163 builddir=$KVM/b1
164 mkdir $builddir || :
165
166 for CF in $configs
167 do
168         rd=$resdir/$ds/$CF
169         mkdir $rd || :
170         echo Results directory: $rd
171         kvm-test-1-rcu.sh $CONFIGFRAG/$CF $builddir $rd $dur "-nographic" "rcutorture.test_no_idle_hz=1 rcutorture.n_barrier_cbs=4 rcutorture.verbose=1"
172 done
173 # 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