source: zzuf/trunk/test/functions.inc @ 4245

Last change on this file since 4245 was 4245, checked in by sam, 5 years ago

Move zzcat to the main src/ directory. It's becoming mature enough to be
distributed.

File size: 1.2 KB
Line 
1# Source this file in shell scripts:
2# . "$(dirname "$0")/functions.inc"
3
4DIR="$(dirname "$0")"
5ZZUF="$DIR/../src/zzuf -E '[.]ilist$'"
6
7ZZCAT="$DIR/../src/zzcat"
8if [ ! -f "$ZZCAT" ]; then
9  echo "error: test/zzcat is missing"
10  exit 1
11fi
12
13ZZERO="$DIR/zzero"
14if [ ! -f "$ZZERO" ]; then
15  echo "error: test/zzero is missing"
16  exit 1
17fi
18
19if file /bin/cat | grep 'statically linked' >/dev/null 2>&1; then
20  STATIC_CAT=1
21fi
22if file /bin/dd | grep 'statically linked' >/dev/null 2>&1; then
23  STATIC_DD=1
24fi
25if tail -n 1 /dev/null >/dev/null 2>&1; then
26  TAILN="tail -n "
27  TAILP="tail -n +"
28else
29  TAILN="tail -"
30  TAILP="tail +"
31fi
32
33FAILED=0
34TESTED=0
35
36if [ -z "$1" ]; then
37  seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8)
38else
39  seed="$1"
40fi
41
42start_test() {
43    echo ""
44    echo "*** running $1 with seed $seed ***"
45}
46
47new_test() {
48    echo "*** $1 *** "
49}
50
51pass_test() {
52    TESTED="$(($TESTED + 1))"
53    echo "$1"
54}
55
56fail_test() {
57    TESTED="$(($TESTED + 1))"
58    FAILED="$(($FAILED + 1))"
59    echo "$1"
60}
61
62stop_test() {
63    if [ "$FAILED" != 0 ]; then
64        echo "*** $FAILED tests failed out of $TESTED ***"
65        exit 1
66    fi
67    echo "*** all $TESTED tests OK ***"
68    echo ""
69}
70
Note: See TracBrowser for help on using the repository browser.