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-run.sh config builddir resdir minutes qemu-args boot_args
11 # qemu-args defaults to "-nographic", along with arguments specifying the
12 # number of CPUs and other options generated from
13 # 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>
43 T=/tmp/kvm-test-1-run.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-run.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-run.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 QEMU="`identify_qemu $builddir/vmlinux`"
98 BOOT_IMAGE="`identify_boot_image $QEMU`"
99 cp $builddir/Make*.out $resdir
100 cp $builddir/.config $resdir
101 if test -n "$BOOT_IMAGE"
103 cp $builddir/$BOOT_IMAGE $resdir
105 echo No identifiable boot image, not running KVM, see $resdir.
106 echo Do the torture scripts know about your architecture?
108 parse-build.sh $resdir/Make.out $title
109 if test -f $builddir.wait
111 mv $builddir.wait $builddir.ready
114 cp $builddir/Make*.out $resdir
115 cp $builddir/.config $resdir || :
116 echo Build failed, not running KVM, see $resdir.
117 if test -f $builddir.wait
119 mv $builddir.wait $builddir.ready
123 while test -f $builddir.ready
128 seconds=$(($minutes * 60))
133 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
134 echo ' ---' `date`: Starting kernel
136 # Generate -smp qemu argument.
137 qemu_args="-nographic $qemu_args"
138 cpu_count=`configNR_CPUS.sh $config_template`
139 vcpus=`identify_qemu_vcpus`
140 if test $cpu_count -gt $vcpus
142 echo CPU count limited from $cpu_count to $vcpus
143 touch $resdir/Warnings
144 echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings
147 qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`"
149 # Generate architecture-specific and interaction-specific qemu arguments
150 qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`"
152 # Generate qemu -append arguments
153 qemu_append="`identify_qemu_append "$QEMU"`"
155 # Pull in Kconfig-fragment boot parameters
156 boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
157 # Generate kernel-version-specific boot parameters
158 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
160 echo $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
161 if test -n "$TORTURE_BUILDONLY"
163 echo Build-only run specified, boot/test omitted.
166 ( $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
169 echo Monitoring qemu job at pid $qemu_pid
172 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
173 if kill -0 $qemu_pid > /dev/null 2>&1
175 if test $kruntime -ge $seconds
182 if test $kruntime -lt $seconds
184 echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1
185 grep "^(qemu) qemu:" $resdir/kvm-test-1-run.sh.out >> $resdir/Warnings 2>&1
186 killpid="`sed -n "s/^(qemu) qemu: terminating on signal [0-9]* from pid \([0-9]*\).*$/\1/p" $resdir/Warnings`"
187 if test -n "$killpid"
189 echo "ps -fp $killpid" >> $resdir/Warnings 2>&1
190 ps -fp $killpid >> $resdir/Warnings 2>&1
193 echo ' ---' `date`: Kernel done
198 if test $commandcompleted -eq 0
200 echo Grace period for qemu job at pid $qemu_pid
203 kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null`
204 if kill -0 $qemu_pid > /dev/null 2>&1
210 if test $kruntime -ge $((seconds + grace))
212 echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1
220 cp $builddir/console.log $resdir
221 parse-torture.sh $resdir/console.log $title
222 parse-console.sh $resdir/console.log $title