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 | # |
| 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 |
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 | |
| 43 | T=/tmp/kvm-test-1-rcu.sh.$$ |
| 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} |
| 50 | title=`echo $config_template | sed -e 's/^.*\///'` |
| 51 | builddir=${2} |
| 52 | if test -z "$builddir" -o ! -d "$builddir" -o ! -w "$builddir" |
| 53 | then |
| 54 | echo "kvm-test-1-rcu.sh :$builddir: Not a writable directory, cannot build into it" |
| 55 | exit 1 |
| 56 | fi |
| 57 | resdir=${3} |
| 58 | if test -z "$resdir" -o ! -d "$resdir" -o ! -w "$resdir" |
| 59 | then |
| 60 | echo "kvm-test-1-rcu.sh :$resdir: Not a writable directory, cannot build into it" |
| 61 | exit 1 |
| 62 | fi |
| 63 | cp $config_template $resdir/ConfigFragment |
| 64 | echo ' ---' `date`: Starting build |
Paul E. McKenney | 330a76f | 2013-09-30 14:49:43 -0700 | [diff] [blame] | 65 | echo ' ---' Kconfig fragment at: $config_template >> $resdir/log |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 66 | cat << '___EOF___' >> $T |
| 67 | CONFIG_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 |
| 93 | if kvm-build.sh $config_template $builddir $T |
| 94 | then |
| 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 |
| 99 | else |
| 100 | cp $builddir/Make*.out $resdir |
| 101 | echo Build failed, not running KVM, see $resdir. |
| 102 | exit 1 |
| 103 | fi |
| 104 | minutes=$4 |
| 105 | seconds=$(($minutes * 60)) |
| 106 | qemu_args=$5 |
| 107 | boot_args=$6 |
| 108 | |
| 109 | cd $KVM |
| 110 | kstarttime=`awk 'BEGIN { print systime() }' < /dev/null` |
| 111 | echo ' ---' `date`: Starting kernel |
Paul E. McKenney | 4f8a031 | 2013-09-30 17:17:57 -0700 | [diff] [blame] | 112 | |
| 113 | # Determine the appropriate flavor of qemu command. |
| 114 | QEMU="`identify_qemu $builddir/vmlinux.o`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 115 | |
| 116 | # Generate -smp qemu argument. |
| 117 | cpu_count=`configNR_CPUS.sh $config_template` |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 118 | vcpus=`identify_qemu_vcpus` |
| 119 | if test $cpu_count -gt $vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 120 | then |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 121 | echo CPU count limited from $cpu_count to $vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 122 | touch $resdir/Warnings |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 123 | echo CPU count limited from $cpu_count to $vcpus >> $resdir/Warnings |
| 124 | cpu_count=$vcpus |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 125 | fi |
Paul E. McKenney | 315c540 | 2013-10-04 13:15:55 -0700 | [diff] [blame] | 126 | qemu_args="`specify_qemu_cpus "$QEMU" "$qemu_args" "$cpu_count"`" |
| 127 | |
| 128 | # Generate architecture-specific and interaction-specific qemu arguments |
| 129 | qemu_args="$qemu_args `identify_qemu_args "$QEMU" "$builddir/console.log"`" |
| 130 | |
| 131 | # Generate qemu -append arguments |
| 132 | qemu_append="`identify_qemu_append "$QEMU"`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 133 | |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 134 | # Pull in Kconfig-fragment boot parameters |
| 135 | boot_args="`configfrag_boot_params "$boot_args" "$config_template"`" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 136 | # Generate CPU-hotplug boot parameters |
Paul E. McKenney | 4275be8 | 2013-09-29 11:13:46 -0700 | [diff] [blame] | 137 | boot_args="`rcutorture_param_onoff "$boot_args" $builddir/.config`" |
| 138 | # Generate rcu_barrier() boot parameter |
| 139 | boot_args="`rcutorture_param_n_barrier_cbs "$boot_args"`" |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 140 | # Pull in standard rcutorture boot arguments |
| 141 | boot_args="$boot_args rcutorture.stat_interval=15 rcutorture.shutdown_secs=$seconds rcutorture.rcutorture_runnable=1" |
Paul E. McKenney | c87b9c6 | 2013-09-28 14:12:21 -0700 | [diff] [blame] | 142 | |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 143 | echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd |
Paul E. McKenney | 1127481 | 2013-10-10 14:52:07 -0700 | [diff] [blame] | 144 | if test -n "$RCU_BUILDONLY" |
| 145 | then |
| 146 | echo Build-only run specified, boot/test omitted. |
| 147 | exit 0 |
| 148 | fi |
Paul E. McKenney | be70a73 | 2013-10-09 11:02:00 -0700 | [diff] [blame] | 149 | $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] | 150 | qemu_pid=$! |
| 151 | commandcompleted=0 |
| 152 | echo Monitoring qemu job at pid $qemu_pid |
| 153 | for ((i=0;i<$seconds;i++)) |
| 154 | do |
| 155 | if kill -0 $qemu_pid > /dev/null 2>&1 |
| 156 | then |
| 157 | sleep 1 |
| 158 | else |
| 159 | commandcompleted=1 |
| 160 | kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }' < /dev/null` |
| 161 | if test $kruntime -lt $seconds |
| 162 | then |
| 163 | echo Completed in $kruntime vs. $seconds >> $resdir/Warnings 2>&1 |
| 164 | else |
| 165 | echo ' ---' `date`: Kernel done |
| 166 | fi |
| 167 | break |
| 168 | fi |
| 169 | done |
| 170 | if test $commandcompleted -eq 0 |
| 171 | then |
| 172 | echo Grace period for qemu job at pid $qemu_pid |
| 173 | for ((i=0;i<=$grace;i++)) |
| 174 | do |
| 175 | if kill -0 $qemu_pid > /dev/null 2>&1 |
| 176 | then |
| 177 | sleep 1 |
| 178 | else |
| 179 | break |
| 180 | fi |
| 181 | if test $i -eq $grace |
| 182 | then |
| 183 | kruntime=`awk 'BEGIN { print systime() - '"$kstarttime"' }'` |
| 184 | echo "!!! Hang at $kruntime vs. $seconds seconds" >> $resdir/Warnings 2>&1 |
| 185 | kill -KILL $qemu_pid |
| 186 | fi |
| 187 | done |
| 188 | fi |
| 189 | |
| 190 | cp $builddir/console.log $resdir |
Paul E. McKenney | 6d40cc0 | 2013-10-28 06:34:22 -0700 | [diff] [blame] | 191 | parse-rcutorture.sh $resdir/console.log $title |
| 192 | parse-console.sh $resdir/console.log $title |