diff mbox

[kvm-unit-tests,09/12] scripts/mkstandalone: use scripts/runtime

Message ID 1453209851-27760-10-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Jan. 19, 2016, 1:24 p.m. UTC
Patch is based around a call to run with required parameters.

This brings a lot of changes to the behavior.  The only change that
could be considered as negative is that we don't print summary messages
to stderr.  The main benefit is that the final scripts/mkstandalone.sh
is fairly orthogonal, so we don't need to do every future change twice.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 scripts/mkstandalone.sh | 57 ++++++++++++-------------------------------------
 1 file changed, 14 insertions(+), 43 deletions(-)
diff mbox

Patch

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 70efe64af243..d9cfded36d5e 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -20,6 +20,13 @@  fi
 unittests=$TEST_DIR/unittests.cfg
 mkdir -p tests
 
+escape ()
+{
+	for arg in "${@}"; do
+		printf "%q " "$arg"; # XXX: trailing whitespace
+	done
+}
+
 temp_file ()
 {
 	local var="$1"
@@ -38,13 +45,7 @@  temp_file ()
 function mkstandalone()
 {
 	local testname="$1"
-	local groups="$2"
-	local smp="$3"
-	local kernel="$4"
-	local opts="$5"
-	local arch="$6"
-	local check="$7"
-	local accel="$8"
+	local args=( $(escape "${@}") )
 
 	if [ -z "$testname" ]; then
 		return 1
@@ -63,21 +64,8 @@  function mkstandalone()
 
 	cat config.mak | grep '^ARCH='
 
-if [ "$check" ]; then
-	cat <<EOF
-for param in $check; do
-	path=\`echo \$param | cut -d= -f1\`
-	value=\`echo \$param | cut -d= -f2\`
-	if [ -f "\$path" ] && [ "\`cat \$path\`" != "\$value" ]; then
-		echo "skip $testname (\$path not equal to \$value)" 1>&2
-		exit 1
-	fi
-done
-
-EOF
-fi
 	if [ ! -f $kernel ]; then
-		echo 'echo "skip '"$testname"' (test kernel not present)" 1>&2'
+		echo 'echo "skip '"$testname"' (test kernel not present)"'
 		echo 'exit 1'
 	else
 	# XXX: bad indentation
@@ -85,31 +73,14 @@  fi
 	echo "trap 'rm -f \$cleanup' EXIT"
 
 	temp_file bin "$kernel"
+	args[3]='$bin'
+
 	temp_file RUNTIME_arch_run "$TEST_DIR/run"
 
-	cat <<EOF
+	cat scripts/runtime.bash
 
-MAX_SMP="MAX_SMP"
-echo \$RUNTIME_arch_run \$bin -smp $smp $opts
-
-if \$RUNTIME_arch_run _NO_FILE_4Uhere_ 2>&1 | grep 'No accelerator found'; then
-	ret=2
-else
-	MAX_SMP=\`getconf _NPROCESSORS_CONF\`
-	while \$RUNTIME_arch_run \$bin -smp \$MAX_SMP 2>&1 | grep 'exceeds max cpus' > /dev/null; do
-		MAX_SMP=\`expr \$MAX_SMP - 1\`
-	done
-
-	\$RUNTIME_arch_run \$bin -smp $smp $opts
-	ret=\$?
-fi
-if [ \$ret -le 1 ]; then
-	echo PASS $testname 1>&2
-else
-	echo FAIL $testname 1>&2
-fi
-exit 0
-EOF
+	echo "run ${args[@]}"
+	echo "exit 0"
 	fi
 
 	exec 1<&$tmpfd {tmpfd}<&-