Changeset 1499 for zzuf/trunk/test


Ignore:
Timestamp:
Dec 18, 2006, 12:07:42 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Better tests and error reporting in the testsuite.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/test/testsuite.sh

    r1496 r1499  
    55    RATIO="$1"
    66    CMD="$2"
    7     $ZZUF -r $RATIO $CMD 2>/dev/null | md5sum
     7    ALIAS="$3"
     8    echo -n " $(echo "$ALIAS:              " | cut -b1-15)"
     9    NEWMD5="$($ZZUF -r $RATIO $CMD 2>/dev/null | md5sum | cut -b1-32)"
     10    if [ -z "$MD5" ]; then
     11        MD5="$NEWMD5"
     12        echo "$NEWMD5"
     13    elif [ "$NEWMD5" != "$MD5" ]; then
     14        OK=0
     15        echo "$NEWMD5"
     16    else
     17        echo ' ...'
     18    fi
    819}
    920
    1021ZZUF="$(dirname "$0")/../src/zzuf"
     22FAILED=0
     23TESTED=0
    1124
    1225for file in /etc/passwd $ZZUF; do
    1326    for r in 0.0 0.001 0.01 0.1 1; do
    1427        echo "Testing zzuf on $file, ratio $r:"
    15         echo "-  cat          $(check $r "cat $file")"
     28        OK=1
     29        MD5=""
     30        check $r "cat $file" "cat"
    1631# don't do grep, it adds a newline at EOF!
    17 #        echo "-  grep -a ''   $(check $r "grep -- -a \\'\\' $file")"
    18         echo "-  sed n        $(check $r "sed n $file")"
    19         echo "-  dd(bs=1)     $(check $r "dd bs=1 if=$file")"
    20         echo "-  dd(bs=1024)  $(check $r "dd bs=1024 if=$file")"
    21         echo "-  dd(bs=1111)  $(check $r "dd bs=1111 if=$file")"
    22         echo "-  dd(bs=65536) $(check $r "dd bs=65536 if=$file")"
     32#        check $r "grep -- -a \\'\\' $file" "grep -a"
     33        check $r "sed n $file" "sed n"
     34        check $r "dd bs=1 if=$file" "dd(bs=1)"
     35        check $r "dd bs=1024 if=$file" "dd(bs=1024)"
     36        check $r "dd bs=1111 if=$file" "dd(bs=1111)"
     37        check $r "dd bs=65536 if=$file" "dd(bs=65536)"
     38        if [ "$OK" != 1 ]; then
     39            echo "*** FAILED ***"
     40            FAILED=$(($FAILED + 1))
     41        fi
     42        TESTED=$(($TESTED + 1))
     43        echo ""
    2344    done
    2445done
    2546
     47if [ "$FAILED" != 0 ]; then
     48    echo "$FAILED tests failed out of $TESTED"
     49    exit 1
     50fi
     51echo "All $TESTED tests OK."
     52exit 0
     53
Note: See TracChangeset for help on using the changeset viewer.