1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
## -*- sh -*-
##
## common_utils.test - Testing CommonUtils namespace functions
##
## $Id: common_utils.test,v 1.3 2005/01/07 02:28:57 vlg Exp $
# Common definitions
if test -z "$srcdir" ; then
srcdir=`echo "$0" | sed 's,[^/]*$,,'`
test "$srcdir" = "$0" && srdir=.
test -z "$srcdir" && srcdir=.
test "${VERBOSE+set}" != set && VERBOSE=1
fi
. $srcdir/defs
# this is the output we should expect to see
cat <<\EOF >ok
Testing split () ...
(42 bytes) Test string:
7065 6163 6865 7320 726f 7365 7309 6265 peaches roses\tbe
6572 0a62 7265 6164 0c62 7574 7465 720d er\nbread\fbutter\r
6672 6965 6e64 7368 6970 friendship
peaches
roses
beer
bread
butter
friendship
split() test passed
Testing split_pair() ...
split_pair() test passed
Testing [lr]trim() ...
[lr]trim() test passed
Testing trim_sides() ...
trim_sides() test passed
Testing strenv() ...
setenv() test passed
EOF
# Unexpected output
cat <<\EOF >errok
EOF
# You can specify command-line arguments here
RUNTEST="${top_builddir}/tests/common_utils_test"
# Run test
$RUNTEST 2> err | tee -i out >&2
# Test against expected output
if ${CMP} -s out ok; then
:
else
echo "ok:" >&2
cat ok >&2
exit 1
fi
# Mungle error output to remove leading directories, 'lt-' or
# trailing '.exe'
sed -e "s,^[^:]*[lt-]*common_utils_test[.ex]*:,common_utils_test;," err >sederr && mv sederr err
# Show stderr if doesn't match expected output if VERBOSE=1
if "$CMP" -s err errok; then
:
else
echo "err:" >&2
cat err >&2
echo "errok:" >&2
cat errok >&2
exit 1
fi
|