Browse Source

torture: Choose bzImage location based on architecture

Currently, the scripts hard-code arch/x86/boot/bzImage, which does not
work well for other architectures.  This commit therefore provides a
identify_boot_image function that selects the correct bzImage location
relative to the top of the Linux source tree.  This commit also adds a
--bootimage argument that allows selecting some other file, for example,
"vmlinux".

This change requires that the definition of the QEMU variable be
computed earlier in order to identify where to look for the boot image
when it comes time to copy it to the results directory.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Paul E. McKenney 11 years ago
parent
commit
f189cc8c94

+ 24 - 0
tools/testing/selftests/rcutorture/bin/functions.sh

@@ -76,6 +76,30 @@ configfrag_hotplug_cpu () {
 	grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1"
 	grep -q '^CONFIG_HOTPLUG_CPU=y$' "$1"
 }
 }
 
 
+# identify_boot_image qemu-cmd
+#
+# Returns the relative path to the kernel build image.  This will be
+# arch/<arch>/boot/bzImage unless overridden with the TORTURE_BOOT_IMAGE
+# environment variable.
+identify_boot_image () {
+	if test -n "$TORTURE_BOOT_IMAGE"
+	then
+		echo $TORTURE_BOOT_IMAGE
+	else
+		case "$1" in
+		qemu-system-x86_64|qemu-system-i386)
+			echo arch/x86/boot/bzImage
+			;;
+		qemu-system-ppc64)
+			echo arch/powerpc/boot/bzImage
+			;;
+		*)
+			echo ""
+			;;
+		esac
+	fi
+}
+
 # identify_qemu builddir
 # identify_qemu builddir
 #
 #
 # Returns our best guess as to which qemu command is appropriate for
 # Returns our best guess as to which qemu command is appropriate for

+ 11 - 6
tools/testing/selftests/rcutorture/bin/kvm-test-1-run.sh

@@ -94,9 +94,17 @@ fi
 # CONFIG_YENTA=n
 # CONFIG_YENTA=n
 if kvm-build.sh $config_template $builddir $T
 if kvm-build.sh $config_template $builddir $T
 then
 then
+	QEMU="`identify_qemu $builddir/vmlinux`"
+	BOOT_IMAGE="`identify_boot_image $QEMU`"
 	cp $builddir/Make*.out $resdir
 	cp $builddir/Make*.out $resdir
 	cp $builddir/.config $resdir
 	cp $builddir/.config $resdir
-	cp $builddir/arch/x86/boot/bzImage $resdir
+	if test -n "$BOOT_IMAGE"
+	then
+		cp $builddir/$BOOT_IMAGE $resdir
+	else
+		echo No identifiable boot image, not running KVM, see $resdir.
+		echo Do the torture scripts know about your architecture?
+	fi
 	parse-build.sh $resdir/Make.out $title
 	parse-build.sh $resdir/Make.out $title
 	if test -f $builddir.wait
 	if test -f $builddir.wait
 	then
 	then
@@ -124,9 +132,6 @@ cd $KVM
 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 kstarttime=`awk 'BEGIN { print systime() }' < /dev/null`
 echo ' ---' `date`: Starting kernel
 echo ' ---' `date`: Starting kernel
 
 
-# Determine the appropriate flavor of qemu command.
-QEMU="`identify_qemu $builddir/vmlinux`"
-
 # Generate -smp qemu argument.
 # Generate -smp qemu argument.
 qemu_args="-nographic $qemu_args"
 qemu_args="-nographic $qemu_args"
 cpu_count=`configNR_CPUS.sh $config_template`
 cpu_count=`configNR_CPUS.sh $config_template`
@@ -151,13 +156,13 @@ boot_args="`configfrag_boot_params "$boot_args" "$config_template"`"
 # Generate kernel-version-specific boot parameters
 # Generate kernel-version-specific boot parameters
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 boot_args="`per_version_boot_params "$boot_args" $builddir/.config $seconds`"
 
 
-echo $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
+echo $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append \"$qemu_append $boot_args\" > $resdir/qemu-cmd
 if test -n "$TORTURE_BUILDONLY"
 if test -n "$TORTURE_BUILDONLY"
 then
 then
 	echo Build-only run specified, boot/test omitted.
 	echo Build-only run specified, boot/test omitted.
 	exit 0
 	exit 0
 fi
 fi
-( $QEMU $qemu_args -m 512 -kernel $builddir/arch/x86/boot/bzImage -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
+( $QEMU $qemu_args -m 512 -kernel $builddir/$BOOT_IMAGE -append "$qemu_append $boot_args"; echo $? > $resdir/qemu-retval ) &
 qemu_pid=$!
 qemu_pid=$!
 commandcompleted=0
 commandcompleted=0
 echo Monitoring qemu job at pid $qemu_pid
 echo Monitoring qemu job at pid $qemu_pid

+ 8 - 0
tools/testing/selftests/rcutorture/bin/kvm.sh

@@ -39,6 +39,7 @@ dryrun=""
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 KVM="`pwd`/tools/testing/selftests/rcutorture"; export KVM
 PATH=${KVM}/bin:$PATH; export PATH
 PATH=${KVM}/bin:$PATH; export PATH
 TORTURE_DEFCONFIG=defconfig
 TORTURE_DEFCONFIG=defconfig
+TORTURE_BOOT_IMAGE=""
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_INITRD="$KVM/initrd"; export TORTURE_INITRD
 TORTURE_KMAKE_ARG=""
 TORTURE_KMAKE_ARG=""
 TORTURE_SUITE=rcu
 TORTURE_SUITE=rcu
@@ -53,6 +54,7 @@ kversion=""
 usage () {
 usage () {
 	echo "Usage: $scriptname optional arguments:"
 	echo "Usage: $scriptname optional arguments:"
 	echo "       --bootargs kernel-boot-arguments"
 	echo "       --bootargs kernel-boot-arguments"
+	echo "       --bootimage relative-path-to-kernel-boot-image"
 	echo "       --buildonly"
 	echo "       --buildonly"
 	echo "       --configs \"config-file list\""
 	echo "       --configs \"config-file list\""
 	echo "       --cpus N"
 	echo "       --cpus N"
@@ -80,6 +82,11 @@ do
 		TORTURE_BOOTARGS="$2"
 		TORTURE_BOOTARGS="$2"
 		shift
 		shift
 		;;
 		;;
+	--bootimage)
+		checkarg --bootimage "(relative path to kernel boot image)" "$#" "$2" '[a-zA-Z0-9][a-zA-Z0-9_]*' '^--'
+		TORTURE_BOOT_IMAGE="$2"
+		shift
+		;;
 	--buildonly)
 	--buildonly)
 		TORTURE_BUILDONLY=1
 		TORTURE_BUILDONLY=1
 		;;
 		;;
@@ -245,6 +252,7 @@ CONFIGFRAG="$CONFIGFRAG"; export CONFIGFRAG
 KVM="$KVM"; export KVM
 KVM="$KVM"; export KVM
 KVPATH="$KVPATH"; export KVPATH
 KVPATH="$KVPATH"; export KVPATH
 PATH="$PATH"; export PATH
 PATH="$PATH"; export PATH
+TORTURE_BOOT_IMAGE="$TORTURE_BOOT_IMAGE"; export TORTURE_BOOT_IMAGE
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_BUILDONLY="$TORTURE_BUILDONLY"; export TORTURE_BUILDONLY
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_DEFCONFIG="$TORTURE_DEFCONFIG"; export TORTURE_DEFCONFIG
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD
 TORTURE_INITRD="$TORTURE_INITRD"; export TORTURE_INITRD