diff options
author | Amitay Isaacs <amitay@gmail.com> | 2015-07-06 14:45:23 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2015-07-09 06:23:21 +0200 |
commit | 93dc2f08398e7c905195faef3882d3a253c7997a (patch) | |
tree | 4593fad25499d853b8c21e293ba0f5b0c53e516a /ctdb/tests | |
parent | 6cff239a1e00dadc37d6b72706b3ee529b999c0d (diff) | |
download | samba-93dc2f08398e7c905195faef3882d3a253c7997a.tar.gz |
ctdb-tests: Add simple test harnesses for running unit tests
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tests')
-rw-r--r-- | ctdb/tests/scripts/unit.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ctdb/tests/scripts/unit.sh b/ctdb/tests/scripts/unit.sh index 44675ae1c7a..46ae876e4a1 100644 --- a/ctdb/tests/scripts/unit.sh +++ b/ctdb/tests/scripts/unit.sh @@ -156,6 +156,54 @@ test_fail () return 1 } +test_header_default () +{ + echo "==================================================" + echo "Running \"$*\"" +} + +reset_test_header () +{ + # Re-define this function to get different header + test_header () + { + test_header_default "$@" + } +} + +reset_test_header + +# Simple test harness for running binary unit tests +unit_test () +{ + test_header "$@" + + _wrapper="$VALGRIND" + if $TEST_COMMAND_TRACE ; then + _wrapper="strace" + fi + _out=$($_wrapper "$@" 2>&1) + + result_check || exit $? +} + +# Simple test harness for running shell script unit tests +script_test () +{ + test_header "$@" + + _shell="" + if ${TEST_COMMAND_TRACE} ; then + _shell="sh -x" + else + _shell="sh" + fi + + _out=$($_shell "$@" 2>&1) + + result_check || exit $? +} + local="${TEST_SUBDIR}/scripts/local.sh" if [ -r "$local" ] ; then . "$local" |