Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 1 | #!/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 | # |
Paul E. McKenney | d3b1548 | 2014-02-06 20:35:41 -0800 | [diff] [blame] | 9 | # Usage: sh kvm-test-1-run.sh config builddir resdir minutes qemu-args boot_args |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 10 | # |
Paul E. McKenney | d3b1548 | 2014-02-06 20:35:41 -0800 | [diff] [blame] | 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 |
| 15 | # shell function. |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 16 | # |
Paul E. McKenney | 4a261db | 2014-01-13 22:57:48 -0800 | [diff] [blame] | 17 | # Anything you specify for either qemu-args or boot_args is appended to |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 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 |
Paul E. McKenney | 0e342a8 | 2013-12-03 09:54:18 -0800 | [diff] [blame] | 34 | # along with this program; if not, you can access it online at |
| 35 | # http://www.gnu.org/licenses/gpl-2.0.html. |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 36 | # |
| 37 | # Copyright (C) IBM Corporation, 2011 |
| 38 | # |
| 39 | # Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
| 40 | |
| 41 | grace=120 |
| 42 | |
Paul E. McKenney | d3b1548 | 2014-02-06 20:35:41 -0800 | [diff] [blame] | 43 | T=/tmp/kvm-test-1-run.sh.$$ |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 44 | trap 'rm -rf $T' 0 |
| 45 | |
| 46 | . $KVM/bin/functions.sh |
Paul E. McKenney | 4275be8 | 2013-09-29 11:13:46 -0700 | [diff] [blame] | 47 | . $KVPATH/ver_functions.sh |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 48 | |
| 49 | config_template=${1} |
Paul E. McKenney | d2ebf7e | 2014-02-06 11:54:32 -0800 | [diff] [blame] | 50 | config_dir=`echo $config_template | sed -e 's,/[^/]*$,,'` |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 51 | title=`echo $config_template | sed -e 's/^.*\///'` |
| 52 | builddir=${2} |
| 53 | if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir" |
| 54 | then |
Paul E. McKenney | d3b1548 | 2014-02-06 20:35:41 -0800 | [diff] [blame] | 55 | echo "kvm-test-1-run.sh :$builddir: Not a writable directory, cannot build into it" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 56 | exit 1 |
| 57 | fi |
| 58 | resdir=${3} |
| 59 | if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir" |
| 60 | then |
Paul E. McKenney | d3b1548 | 2014-02-06 20:35:41 -0800 | [diff] [blame] | 61 | echo "kvm-test-1-run.sh :$resdir: Not a writable directory, cannot store results into it" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 62 | exit 1 |
| 63 | fi |
| 64 | cp $config_template $resdir/ConfigFragment |
| 65 | echo ' ---' `date`: Starting build |
Paul E. McKenney | 330a76f | 2013-09-30 14:49:43 -0700 | [diff] [blame] | 66 | echo ' ---' Kconfig fragment at: $config_template >> $resdir/log |
Paul E. McKenney | d2ebf7e | 2014-02-06 11:54:32 -0800 | [diff] [blame] | 67 | if test -r "$config_dir/CFcommon" |
| 68 | then |
| 69 | cat < $config_dir/CFcommon >> $T |
| 70 | fi |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 71 | # Optimizations below this point |
| 72 | # CONFIG_USB=n |
| 73 | # CONFIG_SECURITY=n |
| 74 | # CONFIG_NFS_FS=n |
| 75 | # CONFIG_SOUND=n |
| 76 | # CONFIG_INPUT_JOYSTICK=n |
| 77 | # CONFIG_INPUT_TABLET=n |
| 78 | # CONFIG_INPUT_TOUCHSCREEN=n |
| 79 | # CONFIG_INPUT_MISC=n |
| 80 | # CONFIG_INPUT_MOUSE=n |
| 81 | # # CONFIG_NET=n # disables console access, so accept the slower build. |
| 82 | # CONFIG_SCSI=n |
| 83 | # CONFIG_ATA=n |
| 84 | # CONFIG_FAT_FS=n |
| 85 | # CONFIG_MSDOS_FS=n |
| 86 | # CONFIG_VFAT_FS=n |
| 87 | # CONFIG_ISO9660_FS=n |
| 88 | # CONFIG_QUOTA=n |
| 89 | # CONFIG_HID=n |
| 90 | # CONFIG_CRYPTO=n |
| 91 | # CONFIG_PCCARD=n |
| 92 | # CONFIG_PCMCIA=n |
| 93 | # CONFIG_CARDBUS=n |
| 94 | # CONFIG_YENTA=n |
| 95 | if kvm-build.sh $config_template $builddir $T |
| 96 | then |
| 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 |
Paul E. McKenney | bad8044 | 2014-01-13 23:16:55 -0800 | [diff] [blame] | 101 | if test -f $builddir.wait |
| 102 | then |
| 103 | mv $builddir.wait $builddir.ready |
| 104 | fi |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 105 | else |
| 106 | cp $builddir/Make*.out $resdir |
| 107 | echo Build failed, not running KVM, see $resdir. |
Paul E. McKenney | bad8044 | 2014-01-13 23:16:55 -0800 | [diff] [blame] | 108 | if test -f $builddir.wait |
| 109 | then |
| 110 | mv $builddir.wait $builddir.ready |
| 111 | fi |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 112 | exit 1 |
| 113 | fi |
Paul E. McKenney | bad8044 | 2014-01-13 23:16:55 -0800 | [diff] [blame] | 114 | while test -f $builddir.ready |
| 115 | do |
| 116 | sleep 1 |
| 117 | done |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 118 | minutes=$4 |
| 119 | seconds=$(($minutes * 60)) |
| 120 | qemu_args=$5 |
| 121 | boot_args=$6 |
| 122 | |
| 123 | cd $KVM |
| 124 | kstarttime=`awk 'BEGIN { print systime() }' < /dev/null` |
| 125 | echo ' ---' `date`: Starting kernel |
Paul E. McKenney | 4f8a031 | 2013-09-30 17:17:57 -0700 | [diff] [blame] | 126 | |
| 127 | # Determine the appropriate flavor of qemu command. |
Paul E. McKenney | 43e38ab | 2014-01-15 15:48:41 -0800 | [diff] [blame] | 128 | QEMU="`identify_qemu $builddir/vmlinux`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 129 | |
| 130 | # Generate -smp qemu argument. |
Paul E. McKenney | 16d301c | 2014-01-14 21:28:57 -0800 | [diff] [blame] | 131 | qemu_args="-nographic $qemu_args" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 132 | cpu_count=`configNR_CPUS.sh $config_template` |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 133 | vcpus=`identify_qemu_vcpus` |
| 134 | if test $cpu_count -gt $vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 135 | then |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 136 | echo CPU count limited from $cpu_count to $vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 137 | touch $resdir/Warnings |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 138 | echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings |
| 139 | cpu_count=$vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 140 | fi |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 141 | qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`" |
| 142 | |
| 143 | # Generate architecture-specific and interaction-specific qemu arguments |
| 144 | qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`" |
| 145 | |
| 146 | # Generate qemu -append arguments |
| 147 | qemu_append="`identify_qemu_append "$QEMU"`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 148 | |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 149 | # Pull in Kconfig-fragment boot parameters |
| 150 | boot_args="`configfrag_boot_params "$boot_args" "$config_template"`" |
Paul E. McKenney | a5afdeb | 2014-02-06 17:50:32 -0800 | [diff] [blame] | 151 | # Generate kernel-version-specific boot parameters |
| 152 | boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 153 | |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 154 | echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd |
Paul E. McKenney | 805ffee | 2014-02-26 15:39:41 -0800 | [diff] [blame^] | 155 | if test -n "$TORTURE_BUILDONLY" |
Paul E. McKenney | 1127481 | 2013-10-10 14:52:07 -0700 | [diff] [blame] | 156 | then |
| 157 | echo Build-only run specified, boot/test omitted. |
| 158 | exit 0 |
| 159 | fi |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 160 | $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args" & |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 161 | qemu_pid=$! |
| 162 | commandcompleted=0 |
| 163 | echo Monitoring qemu job at pid $qemu_pid |
| 164 | for ((i=0;i<$seconds;i++)) |
| 165 | do |
| 166 | if kill -0 $qemu_pid > /dev/null 2>&1 |
| 167 | then |
| 168 | sleep 1 |
| 169 | else |
| 170 | commandcompleted=1 |
| 171 | kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` |
| 172 | if test $kruntime -lt $seconds |
| 173 | then |
| 174 | echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1 |
| 175 | else |
| 176 | echo ' ---' `date`: Kernel done |
| 177 | fi |
| 178 | break |
| 179 | fi |
| 180 | done |
| 181 | if test $commandcompleted -eq 0 |
| 182 | then |
| 183 | echo Grace period for qemu job at pid $qemu_pid |
| 184 | for ((i=0;i<=$grace;i++)) |
| 185 | do |
| 186 | if kill -0 $qemu_pid > /dev/null 2>&1 |
| 187 | then |
| 188 | sleep 1 |
| 189 | else |
| 190 | break |
| 191 | fi |
| 192 | if test $i -eq $grace |
| 193 | then |
| 194 | kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'` |
| 195 | echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1 |
| 196 | kill -KILL $qemu_pid |
| 197 | fi |
| 198 | done |
| 199 | fi |
| 200 | |
| 201 | cp $builddir/console.log $resdir |
Paul E. McKenney | 4074b51 | 2014-02-26 10:57:04 -0800 | [diff] [blame] | 202 | parse-torture.sh $resdir/console.log $title |
Paul E. McKenney | 6d40cc0 | 2013-10-28 06:34:22 -0700 | [diff] [blame] | 203 | parse-console.sh $resdir/console.log $title |