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