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-div0

    r2548 r2573  
    11#!/bin/sh
    22
    3 set -e
     3. "$(dirname "$0")/functions.inc"
    44
    5 DIR="$(dirname "$0")"
    6 ZZUF="$DIR/../src/zzuf"
    75PROGRAM="$DIR/bug-div0"
    86if [ ! -f "$PROGRAM" ]; then
     
    108  exit 1
    119fi
    12 FAILED=0
    13 TESTED=0
    1410
    15 if [ -z "$1" ]; then
    16   seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8)
     11start_test "zzuf division-by-zero test"
     12
     13new_test "bug-div0 < /file-00"
     14if ! $PROGRAM < "$DIR/file-00"; then
     15    fail_test " unexpected exit status $?"
    1716else
    18   seed="$1"
     17    pass_test " OK"
    1918fi
    2019
    21 echo "*** running zzuf division-by-zero test with seed $seed ***"
     20new_test "zzuf -qi -r0 bug-div0 < /file-00"
     21if ! "$ZZUF" -r0 -qi "$PROGRAM" < "$DIR/file-00"; then
     22    fail_test " unexpected exit status $?"
     23else
     24    pass_test " OK"
     25fi
    2226
    23 echo "*** bug-div0 < /file-00"
    24 if ! $PROGRAM < "$DIR/file-00"; then
    25     echo " unexpected exit status $?"
    26     FAILED="$(($FAILED + 1))"
     27new_test "zzuf -qi bug-div0 < file-00"
     28if "$ZZUF" -qi "$PROGRAM" < "$DIR/file-00"; then
     29    fail_test " unexpected exit status $?"
    2730else
    28     echo " OK"
     31    pass_test " OK"
    2932fi
    30 TESTED="$(($TESTED + 1))"
    3133
    32 echo "*** zzuf -qi -r0 bug-div0 < /file-00"
    33 if ! "$ZZUF" -r0 -qi "$PROGRAM" < "$DIR/file-00"; then
    34     echo " unexpected exit status $?"
    35     FAILED="$(($FAILED + 1))"
    36 else
    37     echo " OK"
    38 fi
    39 TESTED="$(($TESTED + 1))"
    40 
    41 echo "*** zzuf -qi bug-div0 < file-00"
    42 if "$ZZUF" -qi "$PROGRAM" < "$DIR/file-00"; then
    43     echo " unexpected exit status $?"
    44     FAILED="$(($FAILED + 1))"
    45 else
    46     echo " OK"
    47 fi
    48 TESTED="$(($TESTED + 1))"
    49 
    50 if [ "$FAILED" != 0 ]; then
    51     echo "*** $FAILED tests failed out of $TESTED ***"
    52     exit 1
    53 fi
    54 echo "*** all $TESTED tests OK ***"
     34stop_test
    5535
    5636exit 0
Note: See TracChangeset for help on using the changeset viewer.