]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - tools/testing/selftests/rcutorture/bin/kvm.sh
rcutorture: Eliminate duplicate .config-check code
[mirror_ubuntu-hirsute-kernel.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:"
43 echo " --builddir absolute-pathname"
44 echo " --configs \"config-file list\""
847bfd25 45 echo " --datestamp string"
c87b9c60 46 echo " --duration minutes"
bb918535 47 echo " --kversion vN.NN"
c87b9c60
PM
48 echo " --rcu-kvm absolute-pathname"
49 echo " --results absolute-pathname"
50 echo " --relbuilddir relative-pathname"
51 exit 1
52}
53
54# checkarg --argname argtype $# arg mustmatch cannotmatch
55checkarg () {
56 if test $3 -le 1
57 then
58 echo $1 needs argument $2 matching \"$5\"
59 usage
60 fi
61 if echo "$4" | grep -q -e "$5"
62 then
63 :
64 else
65 echo $1 $2 \"$4\" must match \"$5\"
66 usage
67 fi
68 if echo "$4" | grep -q -e "$6"
69 then
70 echo $1 $2 \"$4\" must not match \"$6\"
71 usage
72 fi
73}
74
75while test $# -gt 0
76do
c87b9c60
PM
77 case "$1" in
78 --builddir)
79 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' error
80 builddir=$2
81 gotbuilddir=1
82 shift
83 ;;
84 --configs)
85 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
86 configs="$2"
87 shift
88 ;;
847bfd25
PM
89 --datestamp)
90 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
91 ds=$2
92 shift
93 ;;
c87b9c60
PM
94 --duration)
95 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' error
96 dur=$2
97 shift
98 ;;
bb918535
PM
99 --kversion)
100 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' error
101 kversion=$2
102 shift
103 ;;
c87b9c60
PM
104 --rcu-kvm)
105 checkarg --rcu-kvm "(absolute pathname)" "$#" "$2" '^/' error
106 KVM=$2; export KVM
107 if -z "$gotbuilddir"
108 then
109 builddir=${KVM}/b1
110 fi
111 if -n "$gotrelbuilddir"
112 then
113 builddir=${KVM}/${relbuilddir}
114 fi
115 shift
116 ;;
117 --relbuilddir)
118 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
119 relbuilddir=$2
120 gotrelbuilddir=1
121 builddir=${KVM}/${relbuilddir}
122 shift
123 ;;
124 --results)
125 checkarg --results "(absolute pathname)" "$#" "$2" '^/' error
126 resdir=$2
127 shift
128 ;;
129 *)
130 usage
131 ;;
132 esac
133 shift
134done
135
c87b9c60
PM
136PATH=${KVM}/bin:$PATH; export PATH
137CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
4275be83
PM
138KVPATH=${CONFIGFRAG}/$kversion; export KVPATH
139
140if test -z "$configs"
141then
142 configs="`cat $CONFIGFRAG/$kversion/CFLIST`"
143fi
c87b9c60
PM
144
145if test -z "$resdir"
146then
147 resdir=$KVM/res
330a76f1
PM
148 if ! test -e $resdir
149 then
150 mkdir $resdir || :
151 fi
c87b9c60 152else
330a76f1
PM
153 if ! test -e $resdir
154 then
155 mkdir -p "$resdir" || :
156 fi
c87b9c60 157fi
847bfd25 158mkdir $resdir/$ds
330a76f1
PM
159touch $resdir/$ds/log
160echo $scriptname $args >> $resdir/$ds/log
847bfd25 161
c87b9c60
PM
162pwd > $resdir/$ds/testid.txt
163if test -d .git
164then
165 git status >> $resdir/$ds/testid.txt
166 git rev-parse HEAD >> $resdir/$ds/testid.txt
167fi
168builddir=$KVM/b1
330a76f1
PM
169if ! test -e $builddir
170then
171 mkdir $builddir || :
172fi
c87b9c60
PM
173
174for CF in $configs
175do
176 rd=$resdir/$ds/$CF
177 mkdir $rd || :
178 echo Results directory: $rd
4275be83 179 kvm-test-1-rcu.sh $CONFIGFRAG/$kversion/$CF $builddir $rd $dur "-nographic" "rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"
c87b9c60
PM
180done
181# 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