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: kvm-test-1-run.sh config builddir resdir seconds qemu-args boot_args
11 # qemu-args defaults to "-enable-kvm -nographic", along with arguments
12 # specifying the number of CPUs and other options
13 # generated from the underlying CPU architecture.
14 # boot_args defaults to value returned by the per_version_boot_params
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>
41 T
=/tmp
/kvm-test-1-run.sh.$$
45 .
$KVM/bin
/functions.sh
46 .
$CONFIGFRAG/ver_functions.sh
49 config_dir
=`echo $config_template | sed -e 's,/[^/]*$,,'`
50 title
=`echo $config_template | sed -e 's/^.*\///'`
52 if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir"
54 echo "kvm-test-1-run.sh :$builddir: Not a writable directory, cannot build into it"
58 if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir"
60 echo "kvm-test-1-run.sh :$resdir: Not a writable directory, cannot store results into it"
63 cp $config_template $resdir/ConfigFragment
64 echo ' ---' `date`: Starting build
65 echo ' ---' Kconfig fragment
at: $config_template >> $resdir/log
66 if test -r "$config_dir/CFcommon"
68 cat < $config_dir/CFcommon
>> $T
70 # Optimizations below this point
75 # CONFIG_INPUT_JOYSTICK=n
76 # CONFIG_INPUT_TABLET=n
77 # CONFIG_INPUT_TOUCHSCREEN=n
79 # CONFIG_INPUT_MOUSE=n
80 # # CONFIG_NET=n # disables console access, so accept the slower build.
94 base_resdir
=`echo $resdir | sed -e 's/\.[0-9]\+$//'`
95 if test "$base_resdir" != "$resdir" -a -f $base_resdir/bzImage
-a -f $base_resdir/vmlinux
97 # Rerunning previous test, so use that test's kernel.
98 QEMU
="`identify_qemu $base_resdir/vmlinux`"
99 BOOT_IMAGE
="`identify_boot_image $QEMU`"
100 KERNEL
=$base_resdir/${BOOT_IMAGE##*/} # use the last component of ${BOOT_IMAGE}
101 ln -s $base_resdir/Make
*.out
$resdir # for kvm-recheck.sh
102 ln -s $base_resdir/.config
$resdir # for kvm-recheck.sh
103 elif kvm-build.sh
$config_template $builddir $T
105 # Had to build a kernel for this test.
106 QEMU
="`identify_qemu $builddir/vmlinux`"
107 BOOT_IMAGE
="`identify_boot_image $QEMU`"
108 cp $builddir/Make
*.out
$resdir
109 cp $builddir/vmlinux
$resdir
110 cp $builddir/.config
$resdir
111 if test -n "$BOOT_IMAGE"
113 cp $builddir/$BOOT_IMAGE $resdir
114 KERNEL
=$resdir/${BOOT_IMAGE##*/}
116 echo No identifiable boot image
, not running KVM
, see
$resdir.
117 echo Do the torture scripts know about your architecture?
119 parse-build.sh
$resdir/Make.out
$title
122 cp $builddir/Make
*.out
$resdir
123 cp $builddir/.config
$resdir ||
:
124 echo Build failed
, not running KVM
, see
$resdir.
125 if test -f $builddir.
wait
127 mv $builddir.
wait $builddir.ready
131 if test -f $builddir.
wait
133 mv $builddir.
wait $builddir.ready
135 while test -f $builddir.ready
144 kstarttime
=`awk 'BEGIN { print systime() }' < /dev/null`
145 if test -z "$TORTURE_BUILDONLY"
147 echo ' ---' `date`: Starting kernel
150 # Generate -smp qemu argument.
151 qemu_args
="-enable-kvm -nographic $qemu_args"
152 cpu_count
=`configNR_CPUS.sh $config_template`
153 cpu_count
=`configfrag_boot_cpus "$boot_args" "$config_template" "$cpu_count"`
154 vcpus
=`identify_qemu_vcpus`
155 if test $cpu_count -gt $vcpus
157 echo CPU count limited from
$cpu_count to
$vcpus
158 touch $resdir/Warnings
159 echo CPU count limited from
$cpu_count to
$vcpus >> $resdir/Warnings
162 qemu_args
="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
164 # Generate architecture-specific and interaction-specific qemu arguments
165 qemu_args
="$qemu_args `identify_qemu_args "$QEMU" "$resdir/console.log
"`"
167 # Generate qemu -append arguments
168 qemu_append
="`identify_qemu_append "$QEMU"`"
170 # Pull in Kconfig-fragment boot parameters
171 boot_args
="`configfrag_boot_params "$boot_args" "$config_template"`"
172 # Generate kernel-version-specific boot parameters
173 boot_args
="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
175 if test -n "$TORTURE_BUILDONLY"
177 echo Build-only run specified
, boot
/test omitted.
178 touch $resdir/buildonly
181 echo "NOTE: $QEMU either did not run or was interactive" > $resdir/console.log
182 echo $QEMU $qemu_args -m 512 -kernel $KERNEL -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
183 ( $QEMU $qemu_args -m 512 -kernel $KERNEL -append "$qemu_append $boot_args"& echo $
! > $resdir/qemu_pid
; wait `cat $resdir/qemu_pid`; echo $?
> $resdir/qemu-retval
) &
185 sleep 10 # Give qemu's pid a chance to reach the file
186 if test -s "$resdir/qemu_pid"
188 qemu_pid
=`cat "$resdir/qemu_pid"`
189 echo Monitoring qemu job
at pid
$qemu_pid
192 echo Monitoring qemu job
at yet-as-unknown pid
196 if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
198 qemu_pid
=`cat "$resdir/qemu_pid"`
200 kruntime
=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
201 if test -z "$qemu_pid" ||
kill -0 "$qemu_pid" > /dev
/null
2>&1
203 if test $kruntime -ge $seconds
210 if test $kruntime -lt $seconds
212 echo Completed
in $kruntime vs.
$seconds >> $resdir/Warnings
2>&1
213 grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out
>> $resdir/Warnings
2>&1
214 killpid
="`sed -n "s
/^
(qemu
) qemu
: terminating on signal
[0-9]* from pid \
([0-9]*\
).
*$
/\
1/p
" $resdir/Warnings`"
215 if test -n "$killpid"
217 echo "ps -fp $killpid" >> $resdir/Warnings
2>&1
218 ps
-fp $killpid >> $resdir/Warnings
2>&1
221 echo ' ---' `date`: "Kernel done"
226 if test -z "$qemu_pid" -a -s "$resdir/qemu_pid"
228 qemu_pid
=`cat "$resdir/qemu_pid"`
230 if test $commandcompleted -eq 0 -a -n "$qemu_pid"
232 echo Grace period
for qemu job
at pid
$qemu_pid
233 oldline
="`tail $resdir/console.log`"
236 kruntime
=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
237 if kill -0 $qemu_pid > /dev
/null
2>&1
244 newline
="`tail $resdir/console.log`"
245 if test "$newline" != "$oldline" && echo $newline |
grep -q ' [0-9]\+us : '
249 last_ts
="`tail $resdir/console.log | grep '^\[ *[0-9]\+\.[0-9]\+]' | tail -1 | sed -e 's/^\[ *//' -e 's/\..*$//'`"
254 if test "$newline" != "$oldline" -a "$last_ts" -lt $
((seconds
+ $TORTURE_SHUTDOWN_GRACE))
258 if test $must_continue = no
-a $kruntime -ge $
((seconds
+ $TORTURE_SHUTDOWN_GRACE))
260 echo "!!! PID $qemu_pid hung at $kruntime vs. $seconds seconds" >> $resdir/Warnings
2>&1
267 elif test -z "$qemu_pid"
269 echo Unknown PID
, cannot
kill qemu
command
272 parse-torture.sh
$resdir/console.log
$title
273 parse-console.sh
$resdir/console.log
$title