blob: 69b6523bb8543f8ffc2f2eb5622de0d2c3c89ee1 [file] [log] [blame]
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -07001#!/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
Paul E. McKenney330a76f2013-09-30 14:49:43 -070031args="$*"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070032
33dur=30
Paul E. McKenney73931b52013-10-15 10:42:25 -070034KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
35builddir="${KVM}/b1"
36RCU_INITRD="$KVM/initrd"; export RCU_INITRD
Paul E. McKenney74878fb2013-10-15 11:51:23 -070037RCU_KMAKE_ARG=""; export RCU_KMAKE_ARG
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070038resdir=""
Paul E. McKenney4275be82013-09-29 11:13:46 -070039configs=""
Paul E. McKenney847bfd22013-09-28 18:44:11 -070040ds=`date +%Y.%m.%d-%H:%M:%S`
Paul E. McKenneybb918532013-09-28 20:37:45 -070041kversion=""
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070042
43usage () {
44 echo "Usage: $scriptname optional arguments:"
Paul E. McKenney7dca9272013-10-14 08:19:39 -070045 echo " --bootargs kernel-boot-arguments"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070046 echo " --builddir absolute-pathname"
Paul E. McKenney11274812013-10-10 14:52:07 -070047 echo " --buildonly"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070048 echo " --configs \"config-file list\""
Paul E. McKenney847bfd22013-09-28 18:44:11 -070049 echo " --datestamp string"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070050 echo " --duration minutes"
Paul E. McKenney315c5402013-10-04 13:15:55 -070051 echo " --interactive"
Paul E. McKenney74878fb2013-10-15 11:51:23 -070052 echo " --kmake-arg kernel-make-arguments"
Paul E. McKenneybb918532013-09-28 20:37:45 -070053 echo " --kversion vN.NN"
Paul E. McKenney315c5402013-10-04 13:15:55 -070054 echo " --mac nn:nn:nn:nn:nn:nn"
Paul E. McKenney73931b52013-10-15 10:42:25 -070055 echo " --no-initrd"
Paul E. McKenneye9ce6402013-10-15 09:22:48 -070056 echo " --qemu-args qemu-system-..."
Paul E. McKenney4f8a0312013-09-30 17:17:57 -070057 echo " --qemu-cmd qemu-system-..."
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070058 echo " --results absolute-pathname"
59 echo " --relbuilddir relative-pathname"
60 exit 1
61}
62
63# checkarg --argname argtype $# arg mustmatch cannotmatch
64checkarg () {
65 if test $3 -le 1
66 then
67 echo $1 needs argument $2 matching \"$5\"
68 usage
69 fi
70 if echo "$4" | grep -q -e "$5"
71 then
72 :
73 else
74 echo $1 $2 \"$4\" must match \"$5\"
75 usage
76 fi
77 if echo "$4" | grep -q -e "$6"
78 then
79 echo $1 $2 \"$4\" must not match \"$6\"
80 usage
81 fi
82}
83
84while test $# -gt 0
85do
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070086 case "$1" in
Paul E. McKenney7dca9272013-10-14 08:19:39 -070087 --bootargs)
88 checkarg --bootargs "(list of kernel boot arguments)" "$#" "$2" '.*' '^--'
89 RCU_BOOTARGS="$2"
90 shift
91 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070092 --builddir)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -070093 checkarg --builddir "(absolute pathname)" "$#" "$2" '^/' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070094 builddir=$2
95 gotbuilddir=1
96 shift
97 ;;
Paul E. McKenney11274812013-10-10 14:52:07 -070098 --buildonly)
99 RCU_BUILDONLY=1; export RCU_BUILDONLY
100 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700101 --configs)
102 checkarg --configs "(list of config files)" "$#" "$2" '^[^/]*$' '^--'
103 configs="$2"
104 shift
105 ;;
Paul E. McKenney847bfd22013-09-28 18:44:11 -0700106 --datestamp)
107 checkarg --datestamp "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
108 ds=$2
109 shift
110 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700111 --duration)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700112 checkarg --duration "(minutes)" $# "$2" '^[0-9]*$' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700113 dur=$2
114 shift
115 ;;
Paul E. McKenney315c5402013-10-04 13:15:55 -0700116 --interactive)
117 RCU_QEMU_INTERACTIVE=1; export RCU_QEMU_INTERACTIVE
118 ;;
Paul E. McKenney74878fb2013-10-15 11:51:23 -0700119 --kmake-arg)
120 checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
121 RCU_KMAKE_ARG="$2"; export RCU_KMAKE_ARG
122 shift
123 ;;
Paul E. McKenneybb918532013-09-28 20:37:45 -0700124 --kversion)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700125 checkarg --kversion "(kernel version)" $# "$2" '^v[0-9.]*$' '^error'
Paul E. McKenneybb918532013-09-28 20:37:45 -0700126 kversion=$2
127 shift
128 ;;
Paul E. McKenney315c5402013-10-04 13:15:55 -0700129 --mac)
130 checkarg --mac "(MAC address)" $# "$2" '^\([0-9a-fA-F]\{2\}:\)\{5\}[0-9a-fA-F]\{2\}$' error
131 RCU_QEMU_MAC=$2; export RCU_QEMU_MAC
132 shift
133 ;;
Paul E. McKenney73931b52013-10-15 10:42:25 -0700134 --no-initrd)
135 RCU_INITRD=""; export RCU_INITRD
136 ;;
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700137 --qemu-args)
138 checkarg --qemu-args "-qemu args" $# "$2" '^-' '^error'
139 RCU_QEMU_ARG="$2"
140 shift
141 ;;
Paul E. McKenney4f8a0312013-09-30 17:17:57 -0700142 --qemu-cmd)
143 checkarg --qemu-cmd "(qemu-system-...)" $# "$2" 'qemu-system-' '^--'
144 RCU_QEMU_CMD="$2"; export RCU_QEMU_CMD
145 shift
146 ;;
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700147 --relbuilddir)
148 checkarg --relbuilddir "(relative pathname)" "$#" "$2" '^[^/]*$' '^--'
149 relbuilddir=$2
150 gotrelbuilddir=1
151 builddir=${KVM}/${relbuilddir}
152 shift
153 ;;
154 --results)
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700155 checkarg --results "(absolute pathname)" "$#" "$2" '^/' '^error'
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700156 resdir=$2
157 shift
158 ;;
159 *)
Paul E. McKenney2bcdf4e2013-10-01 10:14:09 -0700160 echo Unknown argument $1
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700161 usage
162 ;;
163 esac
164 shift
165done
166
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700167PATH=${KVM}/bin:$PATH; export PATH
168CONFIGFRAG=${KVM}/configs; export CONFIGFRAG
Paul E. McKenney4275be82013-09-29 11:13:46 -0700169KVPATH=${CONFIGFRAG}/$kversion; export KVPATH
170
171if test -z "$configs"
172then
173 configs="`cat $CONFIGFRAG/$kversion/CFLIST`"
174fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700175
176if test -z "$resdir"
177then
178 resdir=$KVM/res
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700179 if ! test -e $resdir
180 then
181 mkdir $resdir || :
182 fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700183else
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700184 if ! test -e $resdir
185 then
186 mkdir -p "$resdir" || :
187 fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700188fi
Paul E. McKenney847bfd22013-09-28 18:44:11 -0700189mkdir $resdir/$ds
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700190touch $resdir/$ds/log
191echo $scriptname $args >> $resdir/$ds/log
Paul E. McKenney847bfd22013-09-28 18:44:11 -0700192
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700193pwd > $resdir/$ds/testid.txt
194if test -d .git
195then
196 git status >> $resdir/$ds/testid.txt
197 git rev-parse HEAD >> $resdir/$ds/testid.txt
198fi
199builddir=$KVM/b1
Paul E. McKenney330a76f2013-09-30 14:49:43 -0700200if ! test -e $builddir
201then
202 mkdir $builddir || :
203fi
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700204
205for CF in $configs
206do
207 rd=$resdir/$ds/$CF
208 mkdir $rd || :
209 echo Results directory: $rd
Paul E. McKenneye9ce6402013-10-15 09:22:48 -0700210 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"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700211done
212# 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