@@ -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
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(-)