diff mbox

[kvm-unit-tests,10/12] scripts/mkstandalone: simplifiy redirection, again

Message ID 1453209851-27760-11-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
We don't have variables all over the place now, so it's nicer to move
script generator into a separate function and redirect its output.

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

Patch

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index d9cfded36d5e..6ced8e5970ef 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -42,24 +42,10 @@  temp_file ()
 	echo "chmod +x \$$var"
 }
 
-function mkstandalone()
+generate_test ()
 {
-	local testname="$1"
 	local args=( $(escape "${@}") )
 
-	if [ -z "$testname" ]; then
-		return 1
-	fi
-
-	if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then
-		return 1
-	fi
-
-	standalone=tests/$testname
-
-	exec {tmpfd}<&1
-	exec > $standalone
-
 	echo "#!/bin/bash"
 
 	cat config.mak | grep '^ARCH='
@@ -67,8 +53,8 @@  function mkstandalone()
 	if [ ! -f $kernel ]; then
 		echo 'echo "skip '"$testname"' (test kernel not present)"'
 		echo 'exit 1'
-	else
-	# XXX: bad indentation
+		return 1
+	fi
 
 	echo "trap 'rm -f \$cleanup' EXIT"
 
@@ -81,9 +67,24 @@  function mkstandalone()
 
 	echo "run ${args[@]}"
 	echo "exit 0"
+}
+
+function mkstandalone()
+{
+	local testname="$1"
+
+	if [ -z "$testname" ]; then
+		return 1
 	fi
 
-	exec 1<&$tmpfd {tmpfd}<&-
+	if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then
+		return 1
+	fi
+
+	standalone=tests/$testname
+
+	generate_test "$@" > $standalone
+
 	chmod +x $standalone
 
 	return 0