diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2015-11-16 14:23:22 +0100 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2015-11-16 14:23:22 +0100 |
commit | 66a46dbc688d6d48b03dbbc92c4eeece1d5b5547 (patch) | |
tree | dc4bafb1d60a4f385ded0c11208e1afd5fdfa2ac /share/dtf | |
parent | d80e394f60d6ed1df14391f20a79305ab00f6662 (diff) | |
download | dtf-66a46dbc688d6d48b03dbbc92c4eeece1d5b5547.tar.gz dtf-66a46dbc688d6d48b03dbbc92c4eeece1d5b5547.tar.xz dtf-66a46dbc688d6d48b03dbbc92c4eeece1d5b5547.zip |
lib: don't require bash
* bin/dtf-gen: Use /bin/sh shebang.
* share/dtf/lib/default: Likewise.
(__dtf_internal_fail): New internal method.
(__dtf_run_testcase): Play with mkfifo.
* share/dtf/tpl/run.tpl: Use /bin/sh shebang. Remove $outputdir
before script start.
Diffstat (limited to 'share/dtf')
-rw-r--r-- | share/dtf/lib/default | 39 | ||||
-rw-r--r-- | share/dtf/tpl/run.tpl | 8 |
2 files changed, 39 insertions, 8 deletions
diff --git a/share/dtf/lib/default b/share/dtf/lib/default index 6c53c40..3d9bb9e 100644 --- a/share/dtf/lib/default +++ b/share/dtf/lib/default @@ -1,9 +1,9 @@ -#! /bin/bash +#! /bin/sh # Global library file. Methods prefixed by '__dtf_' are internal, for example # __dtf_is_testdir. Other methods prefixed by 'dtf_' are API. -: ${SHELL=/bin/bash} +: ${SHELL=/bin/sh} __dtf_is_testdir () @@ -18,6 +18,13 @@ __dtf_is_testdir () } +__dtf_internal_fail () +{ + __dtf_control_msg "internal fail: $*" + __dtf_rc=1 +} + + __dtf_run_testcase () { resultdir="$outputdir/$testname" @@ -34,18 +41,36 @@ __dtf_run_testcase () "$@" shift + __save_rc=1 if $__DTF_TOP_TEST; then eval "$@" 4>&2 3>&1 \ 2>> "$stderr" \ 1>> "$stdout" + __save_rc=$? else - # TODO: avoid bashishm - eval "$@" \ - 2> >(tee -a "$stderr" >&2) \ - 1> >(tee -a "$stdout") + for _d_i in stdout stderr + do + _d_fifo=$resultdir/fifo-$_d_i + eval "_d_fifo_$_d_i=\$_d_fifo" + test -e "$_d_fifo" && continue + mkfifo "$_d_fifo" && continue + __dtf_internal_fail "can't create $_d_fifo fifo" + return 1 + done + + tee -a "$stdout" < "$_d_fifo_stdout" >&1 & + tee -a "$stderr" < "$_d_fifo_stderr" >&2 & + + eval "$@" 2> $_d_fifo_stderr >$_d_fifo_stdout + __save_rc=$? + + rm "$_d_fifo_stdout" "$_d_fifo_stderr" || { + __dtf_internal_fail "can't remove fifos" + return 1 + } fi - case $? in + case $__save_rc in 0|77) return 0 ;; diff --git a/share/dtf/tpl/run.tpl b/share/dtf/tpl/run.tpl index 663e302..0495675 100644 --- a/share/dtf/tpl/run.tpl +++ b/share/dtf/tpl/run.tpl @@ -1,8 +1,14 @@ -#! /bin/bash -x +#! /bin/sh # vi: ft=sh test -z "$outputdir" && outputdir="$PWD/DTF_RESULT" +$__DTF_TOP_TEST && { + exec 3>&1 4>&2 + rm -rf "$outputdir" +} + + . "$top_srcdir/library" __dtf_rc=0 |