# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+timestamp() {
+ # mark the start time. With Gnu date, you get nanoseconds from %N
+ # (here truncated to microseconds with %6N), but not on BSDs,
+ # Solaris, etc, which will apparently leave either %N or N at the end.
+ date -u +'time: %Y-%m-%d %H:%M:%S.%6NZ' | sed 's/%\?NZ$/000000Z/'
+}
+
subunit_start_test () {
# emit the current protocol start-marker for test $1
+ timestamp
echo "test: $1"
}
subunit_pass_test () {
# emit the current protocol test passed marker for test $1
+ timestamp
echo "success: $1"
}
+# This is just a hack as we have some broken scripts
+# which use "exit $failed", without initializing failed.
+failed=0
subunit_fail_test () {
# emit the current protocol fail-marker for test $1, and emit stdin as
# the error text.
# we use stdin because the failure message can be arbitrarily long, and this
# makes it convenient to write in scripts (using <<END syntax.
+ timestamp
echo "failure: $1 ["
cat -
echo "]"
# the error text.
# we use stdin because the failure message can be arbitrarily long, and this
# makes it convenient to write in scripts (using <<END syntax.
+ timestamp
echo "error: $1 ["
cat -
echo "]"
}
+subunit_skip_test () {
+ # emit the current protocol skip-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ echo "skip: $1 ["
+ cat -
+ echo "]"
+}
+
testit () {
name="$1"
shift
cmdline="$*"
subunit_start_test "$name"
- $cmdline
+ output=`$cmdline 2>&1`
status=$?
if [ x$status = x0 ]; then
+ echo "$output"
subunit_pass_test "$name"
else
- subunit_fail_test "$name"
+ echo "$output" | subunit_fail_test "$name"
fi
return $status
}
+
+testit_expect_failure () {
+ name="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=`$cmdline 2>&1`
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "$output" | subunit_fail_test "$name"
+ else
+ subunit_pass_test "$name"
+ fi
+ return $status
+}
+
+testok () {
+ name=`basename $1`
+ failed=$2
+
+ exit $failed
+}
+
+# work out the top level source directory
+if [ -d source4 ]; then
+ SRCDIR="."
+else
+ SRCDIR=".."
+fi
+export SRCDIR