3 # Run a kvm-based test of the specified tree on the specified configs.
4 # Fully automated run and error checking, no graphics console.
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.
9 # Usage: sh kvm-test-1-rcu.sh config builddir resdir minutes qemu-args boot_args
11 # qemu-args defaults to "" -- you will want "-nographic" if running headless.
12 # boot_args 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"
17 # Anything you specify for either qemu-args or boot_args is appended to
18 # the default values. The "-smp" value is deduced from the contents of
19 # the config fragment.
21 # More sophisticated argument parsing is clearly needed.
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.
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.
33 # You should have received a copy of the GNU General Public License
34 # along with this program; if not, you can access it online at
35 # http://www.gnu.org/licenses/gpl-2.0.html.
37 # Copyright (C) IBM Corporation, 2011
39 # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
43 T=/tmp/kvm-test-1-rcu.sh.$$
46 . $KVM/bin/functions.sh
47 . $KVPATH/ver_functions.sh
50 config_dir=`echo $config_template | sed -e 's,/[^/]*$,,'`
51 title=`echo $config_template | sed -e 's/^.*\///'`
53 if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir"
55 echo "kvm-test-1-rcu.sh :$builddir: Not a writable directory, cannot build into it"
59 if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir"
61 echo "kvm-test-1-rcu.sh :$resdir: Not a writable directory, cannot store results into it"
64 cp $config_template $resdir/ConfigFragment
65 echo ' ---' `date`: Starting build
66 echo ' ---' Kconfig fragment at: $config_template >> $resdir/log
67 if test -r "$config_dir/CFcommon"
69 cat < $config_dir/CFcommon >> $T
71 # Optimizations below this point
76 # CONFIG_INPUT_JOYSTICK=n
77 # CONFIG_INPUT_TABLET=n
78 # CONFIG_INPUT_TOUCHSCREEN=n
80 # CONFIG_INPUT_MOUSE=n
81 # # CONFIG_NET=n # disables console access, so accept the slower build.
95 if kvm-build.sh $config_template $builddir $T
97 cp $builddir/Make*.out $resdir
98 cp $builddir/.config $resdir
99 cp $builddir/arch/x86/boot/bzImage $resdir
100 parse-build.sh $resdir/Make.out $title
101 if test -f $builddir.wait
103 mv $builddir.wait $builddir.ready
106 cp $builddir/Make*.out $resdir
107 echo Build failed, not running KVM, see $resdir.
108 if test -f $builddir.wait
110 mv $builddir.wait $builddir.ready
114 while test -f $builddir.ready
119 seconds=$(($minutes * 60))
124 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
125 echo ' ---' `date`: Starting kernel
127 # Determine the appropriate flavor of qemu command.
128 QEMU="`identify_qemu $builddir/vmlinux`"
130 # Generate -smp qemu argument.
131 qemu_args="-nographic $qemu_args"
132 cpu_count=`configNR_CPUS.sh $config_template`
133 vcpus=`identify_qemu_vcpus`
134 if test $cpu_count -gt $vcpus
136 echo CPU count limited from $cpu_count to $vcpus
137 touch $resdir/Warnings
138 echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings
141 qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
143 # Generate architecture-specific and interaction-specific qemu arguments
144 qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`"
146 # Generate qemu -append arguments
147 qemu_append="`identify_qemu_append "$QEMU"`"
149 # Pull in Kconfig-fragment boot parameters
150 boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
151 # Generate kernel-version-specific boot parameters
152 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
154 echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
155 if test -n "$RCU_BUILDONLY"
157 echo Build-only run specified, boot/test omitted.
160 $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args" &
163 echo Monitoring qemu job at pid $qemu_pid
164 for ((i=0;i<$seconds;i++))
166 if kill -0 $qemu_pid > /dev/null 2>&1
171 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
172 if test $kruntime -lt $seconds
174 echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
176 echo ' ---' `date`: Kernel done
181 if test $commandcompleted -eq 0
183 echo Grace period for qemu job at pid $qemu_pid
184 for ((i=0;i<=$grace;i++))
186 if kill -0 $qemu_pid > /dev/null 2>&1
192 if test $i -eq $grace
194 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'`
195 echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
201 cp $builddir/console.log $resdir
202 parse-rcutorture.sh $resdir/console.log $title
203 parse-console.sh $resdir/console.log $title