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