blob: 5526550a5d568511c83e1444f5ba87d6a4fc92b1 [file] [log] [blame]
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -07001#!/bin/bash
2#
3# Run a kvm-based test of the specified tree on the specified configs.
4# Fully automated run and error checking, no graphics console.
5#
6# Execute this in the source tree. Do not run it as a background task
7# because qemu does not seem to like that much.
8#
9# Usage: sh kvm-test-1-rcu.sh config builddir resdir minutes qemu-args bootargs
10#
11# qemu-args defaults to "" -- you will want "-nographic" if running headless.
12# bootargs defaults to "root=/dev/sda noapic selinux=0 console=ttyS0"
13# "initcall_debug debug rcutorture.stat_interval=15"
14# "rcutorture.shutdown_secs=$((minutes * 60))"
15# "rcutorture.rcutorture_runnable=1"
16#
17# Anything you specify for either qemu-args or bootargs is appended to
18# the default values. The "-smp" value is deduced from the contents of
19# the config fragment.
20#
21# More sophisticated argument parsing is clearly needed.
22#
23# This program is free software; you can redistribute it and/or modify
24# it under the terms of the GNU General Public License as published by
25# the Free Software Foundation; either version 2 of the License, or
26# (at your option) any later version.
27#
28# This program is distributed in the hope that it will be useful,
29# but WITHOUT ANY WARRANTY; without even the implied warranty of
30# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31# GNU General Public License for more details.
32#
33# You should have received a copy of the GNU General Public License
34# along with this program; if not, write to the Free Software
35# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36#
37# Copyright (C) IBM Corporation, 2011
38#
39# Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
40
41grace=120
42
43T=/tmp/kvm-test-1-rcu.sh.$$
44trap 'rm -rf $T' 0
45
46. $KVM/bin/functions.sh
Paul E. McKenney4275be82013-09-29 11:13:46 -070047. $KVPATH/ver_functions.sh
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070048
49config_template=${1}
50title=`echo $config_template | sed -e 's/^.*\///'`
51builddir=${2}
52if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir"
53then
54 echo "kvm-test-1-rcu.sh :$builddir: Not a writable directory, cannot build into it"
55 exit 1
56fi
57resdir=${3}
58if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir"
59then
60 echo "kvm-test-1-rcu.sh :$resdir: Not a writable directory, cannot build into it"
61 exit 1
62fi
63cp $config_template $resdir/ConfigFragment
64echo ' ---' `date`: Starting build
Paul E. McKenney330a76f2013-09-30 14:49:43 -070065echo ' ---' Kconfig fragment at: $config_template >> $resdir/log
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -070066cat << '___EOF___' >> $T
67CONFIG_RCU_TORTURE_TEST=y
68___EOF___
69# Optimizations below this point
70# CONFIG_USB=n
71# CONFIG_SECURITY=n
72# CONFIG_NFS_FS=n
73# CONFIG_SOUND=n
74# CONFIG_INPUT_JOYSTICK=n
75# CONFIG_INPUT_TABLET=n
76# CONFIG_INPUT_TOUCHSCREEN=n
77# CONFIG_INPUT_MISC=n
78# CONFIG_INPUT_MOUSE=n
79# # CONFIG_NET=n # disables console access, so accept the slower build.
80# CONFIG_SCSI=n
81# CONFIG_ATA=n
82# CONFIG_FAT_FS=n
83# CONFIG_MSDOS_FS=n
84# CONFIG_VFAT_FS=n
85# CONFIG_ISO9660_FS=n
86# CONFIG_QUOTA=n
87# CONFIG_HID=n
88# CONFIG_CRYPTO=n
89# CONFIG_PCCARD=n
90# CONFIG_PCMCIA=n
91# CONFIG_CARDBUS=n
92# CONFIG_YENTA=n
93if kvm-build.sh $config_template $builddir $T
94then
95 cp $builddir/Make*.out $resdir
96 cp $builddir/.config $resdir
97 cp $builddir/arch/x86/boot/bzImage $resdir
98 parse-build.sh $resdir/Make.out $title
99else
100 cp $builddir/Make*.out $resdir
101 echo Build failed, not running KVM, see $resdir.
102 exit 1
103fi
104minutes=$4
105seconds=$(($minutes * 60))
106qemu_args=$5
107boot_args=$6
108
109cd $KVM
110kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
111echo ' ---' `date`: Starting kernel
112if file linux-2.6/*.o | grep -q 64-bit
113then
114 QEMU=qemu-system-x86_64
115else
116 QEMU=qemu-system-i386
117fi
118
119# Generate -smp qemu argument.
120cpu_count=`configNR_CPUS.sh $config_template`
121ncpus=`grep '^processor' /proc/cpuinfo | wc -l`
122if test $cpu_count -gt $ncpus
123then
124 echo CPU count limited from $cpu_count to $ncpus
125 touch $resdir/Warnings
126 echo CPU count limited from $cpu_count to $ncpus >> $resdir/Warnings
127 cpu_count=$ncpus
128fi
129if echo $qemu_args | grep -q -e -smp
130then
131 echo CPU count specified by caller
132else
133 qemu_args="$qemu_args -smp $cpu_count"
134fi
135
136# Generate CPU-hotplug boot parameters
Paul E. McKenney4275be82013-09-29 11:13:46 -0700137boot_args="`rcutorture_param_onoff "$boot_args" $builddir/.config`"
138# Generate rcu_barrier() boot parameter
139boot_args="`rcutorture_param_n_barrier_cbs "$boot_args"`"
Paul E. McKenney0cc24412013-09-29 20:22:32 -0700140# Pull in Kconfig-fragment boot parameters
141boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
Paul E. McKenneyc87b9c62013-09-28 14:12:21 -0700142
143echo $QEMU -name rcu-test -serial file:$builddir/console.log $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"noapic selinux=0 console=ttyS0 initcall_debug debug rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args\" > $resdir/qemu-cmd
144$QEMU -name rcu-test -serial file:$builddir/console.log $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "noapic selinux=0 console=ttyS0 initcall_debug debug rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1 $boot_args" &
145qemu_pid=$!
146commandcompleted=0
147echo Monitoring qemu job at pid $qemu_pid
148for ((i=0;i<$seconds;i++))
149do
150 if kill -0 $qemu_pid > /dev/null 2>&1
151 then
152 sleep 1
153 else
154 commandcompleted=1
155 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
156 if test $kruntime -lt $seconds
157 then
158 echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
159 else
160 echo ' ---' `date`: Kernel done
161 fi
162 break
163 fi
164done
165if test $commandcompleted -eq 0
166then
167 echo Grace period for qemu job at pid $qemu_pid
168 for ((i=0;i<=$grace;i++))
169 do
170 if kill -0 $qemu_pid > /dev/null 2>&1
171 then
172 sleep 1
173 else
174 break
175 fi
176 if test $i -eq $grace
177 then
178 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'`
179 echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
180 kill -KILL $qemu_pid
181 fi
182 done
183fi
184
185cp $builddir/console.log $resdir
186parse-rcutorture.sh $resdir/console.log $title >> $resdir/Warnings 2>&1
187parse-console.sh $resdir/console.log $title >> $resdir/Warnings 2>&1
188cat $resdir/Warnings