Commit 00505165 authored by Paul E. McKenney's avatar Paul E. McKenney
Browse files

torture: Add --duration argument to kvm-again.sh



This commit adds a --duration argument to kvm-again.sh to allow the user
to override the --duration specified for the original kvm.sh run.

Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 7cf86c0b
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ PATH=${KVM}/bin:$PATH; export PATH
. functions.sh

dryrun=
dur=
default_link="cp -R"
rundir="`pwd`/tools/testing/selftests/rcutorture/res/`date +%Y.%m.%d-%H.%M.%S-again`"

@@ -61,6 +62,7 @@ starttime="`get_starttime`"
usage () {
	echo "Usage: $scriptname $oldrun [ arguments ]:"
	echo "       --dryrun"
	echo "       --duration minutes | <seconds>s | <hours>h | <days>d"
	echo "       --link hard|soft|copy"
	echo "       --remote"
	echo "       --rundir /new/res/path"
@@ -73,6 +75,23 @@ do
	--dryrun)
		dryrun=1
		;;
	--duration)
		checkarg --duration "(minutes)" $# "$2" '^[0-9][0-9]*\(s\|m\|h\|d\|\)$' '^error'
		mult=60
		if echo "$2" | grep -q 's$'
		then
			mult=1
		elif echo "$2" | grep -q 'h$'
		then
			mult=3600
		elif echo "$2" | grep -q 'd$'
		then
			mult=86400
		fi
		ts=`echo $2 | sed -e 's/[smhd]$//'`
		dur=$(($ts*mult))
		shift
		;;
	--link)
		checkarg --link "hard|soft|copy" "$#" "$2" 'hard\|soft\|copy' '^--'
		case "$2" in
@@ -134,7 +153,11 @@ do
	cp "$i" $T
	qemu_cmd_dir="`dirname "$i"`"
	kernel_dir="`echo $qemu_cmd_dir | sed -e 's/\.[0-9]\+$//'`"
	kvm-transform.sh $kernel_dir/bzImage $qemu_cmd_dir/console.log < $T/qemu-cmd > $i
	kvm-transform.sh $kernel_dir/bzImage $qemu_cmd_dir/console.log $dur < $T/qemu-cmd > $i
	if test -n "$dur"
	then
		echo "# seconds=$dur" >> $i
	fi
	echo "# TORTURE_KCONFIG_GDB_ARG=''" >> $i
done
grep -v '^#' $T/batches.oldrun | awk '
+23 −6
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
#
# Transform a qemu-cmd file to allow reuse.
#
# Usage: kvm-transform.sh bzImage console.log < qemu-cmd-in > qemu-cmd-out
# Usage: kvm-transform.sh bzImage console.log [ seconds ] < qemu-cmd-in > qemu-cmd-out
#
#	bzImage: Kernel and initrd from the same prior kvm.sh run.
#	console.log: File into which to place console output.
@@ -29,20 +29,37 @@ then
	echo "Need console log file name."
	exit 1
fi
seconds=$3
if test -n "$seconds" && echo $seconds | grep -q '[^0-9]'
then
	echo "Invalid duration, should be numeric in seconds: '$seconds'"
	exit 1
fi

awk -v image="$image" -v consolelog="$consolelog" -v seconds="$seconds" '
/^#/ {
	print $0;
	next;
}

awk -v image="$image" -v consolelog="$consolelog" '
{
	line = "";
	for (i = 1; i <= NF; i++) {
		if ("" seconds != "" && $i ~ /\.shutdown_secs=[0-9]*$/) {
			sub(/[0-9]*$/, seconds, $i);
			if (line == "")
				line = $i;
			else
				line = line " " $i;
		} else if (line == "") {
			line = $i;
		} else {
			line = line " " $i;
		}
		if ($i == "-serial") {
			i++;
			line = line " file:" consolelog;
		}
		if ($i == "-kernel") {
		} else if ($i == "-kernel") {
			i++;
			line = line " " image;
		}