From 2e76646998df0ca1b7d160329c0f3ac8cdda2fe0 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 20 Aug 2017 09:22:43 +0000 Subject: Move shunit2 into ./contrib and add catch-1.8.7 --- contrib/shunit2-2.0.3/src/test/test-functions.inc | 84 +++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 contrib/shunit2-2.0.3/src/test/test-functions.inc (limited to 'contrib/shunit2-2.0.3/src/test/test-functions.inc') diff --git a/contrib/shunit2-2.0.3/src/test/test-functions.inc b/contrib/shunit2-2.0.3/src/test/test-functions.inc new file mode 100644 index 0000000..fe7b3e9 --- /dev/null +++ b/contrib/shunit2-2.0.3/src/test/test-functions.inc @@ -0,0 +1,84 @@ +# $Id: test-functions.inc 416 2007-01-04 00:50:14Z sfsetse $ +# vim:syntax=sh:sts=2 + +# +# constants +# + +# configure debugging. set the DEBUG environment variable to any +# non-empty value to enable debug output, or TRACE to enable trace +# output. +TRACE=${TRACE:+'tf_trace '} +[ -n "${TRACE}" ] && DEBUG=1 +[ -z "${TRACE}" ] && TRACE=':' + +DEBUG=${DEBUG:+'tf_debug '} +[ -z "${DEBUG}" ] && DEBUG=':' + +# +# variables +# + +tf_RANDOM=0 + +# +# functions +# + +# message functions +tf_trace() { echo "${MY_NAME}:TRACE $@" >&2; } +tf_debug() { echo "${MY_NAME}:DEBUG $@" >&2; } +tf_info() { echo "${MY_NAME}:INFO $@" >&2; } +tf_warn() { echo "${MY_NAME}:WARN $@" >&2; } +tf_error() { echo "${MY_NAME}:ERROR $@" >&2; } +tf_fatal() { echo "${MY_NAME}:FATAL $@" >&2; } + +# generate a random number +tf_generateRandom() +{ + tfgr_random=${tf_RANDOM} + + while [ "${tfgr_random}" = "${tf_RANDOM}" ]; do + if [ -n "${RANDOM:-}" ]; then + # $RANDOM works + tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$ + elif [ -r '/dev/urandom' ]; then + tfgr_random=`od -vAn -N4 -tu4