Ignore:
Timestamp:
Jul 20, 2008, 11:57:58 AM (12 years ago)
Author:
Sam Hocevar
Message:
  • Factored the test suite to avoid excessive code duplication.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/test/check-utils

    r2567 r2573  
    11#!/bin/sh
    22
    3 set -e
     3. "$(dirname "$0")/functions.inc"
    44
    55checkutils()
     
    7474        REFMD5="$MD5"
    7575        echo "$MD5"
     76    elif [ "$MD5" != "$REFMD5" ]; then
     77        fail_test "$MD5 FAILED"
    7678    else
    77         TESTED=$(($TESTED + 1))
    78         if [ "$MD5" != "$REFMD5" ]; then
    79             FAILED=$(($FAILED + 1))
    80             echo "$MD5 FAILED"
    81         else
    82             echo 'ok'
    83         fi
     79        pass_test 'ok'
    8480    fi
    8581}
    8682
    87 DIR="$(dirname "$0")"
    88 ZZUF="$DIR/../src/zzuf"
    89 ZZCAT="$DIR/zzcat"
    90 if [ ! -f "$ZZCAT" ]; then
    91   echo "error: test/zzcat is missing"
    92   exit 1
    93 fi
    94 if file /bin/cat | grep 'statically linked' >/dev/null 2>&1; then
    95   STATIC_CAT=1
    96 fi
    97 if file /bin/dd | grep 'statically linked' >/dev/null 2>&1; then
    98   STATIC_DD=1
    99 fi
    100 if tail -n 1 /dev/null >/dev/null 2>&1; then
    101   TAILN="tail -n "
    102   TAILP="tail -n +"
    103 else
    104   TAILN="tail -"
    105   TAILP="tail +"
    106 fi
    107 FAILED=0
    108 TESTED=0
    109 
    110 if [ -z "$1" ]; then
    111   seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8)
    112 else
    113   seed="$1"
    114 fi
    115 
    116 echo "*** running zzuf utils test suite with seed $seed ***"
     83start_test "zzuf utils test suite"
    11784
    11885checkutils 0.0
     
    12087checkutils 1.0
    12188
    122 if [ "$FAILED" != 0 ]; then
    123     echo "*** $FAILED tests failed out of $TESTED ***"
    124     exit 1
    125 fi
    126 echo "*** all $TESTED tests OK ***"
     89stop_test
    12790
    128 exit 0
    129 
Note: See TracChangeset for help on using the changeset viewer.