Changeset 1565 for zzuf/trunk/test


Ignore:
Timestamp:
Jan 5, 2007, 12:01:49 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Put back grep and sed into the testsuite, now that we can protect newlines from being fuzzed away.
File:
1 edited

Legend:

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

    r1549 r1565  
    1111    rm -f /tmp/zzuf-text-$$
    1212    strings </dev/urandom | dd bs=1024 count=32 of=/tmp/zzuf-text-$$ 2>/dev/null
     13    echo "" >> /tmp/zzuf-text-$$ # Make sure we have a newline at EOF
    1314}
    1415
    1516check()
    1617{
    17     SEED="$1"
    18     RATIO="$2"
    19     CMD="$3"
    20     ALIAS="$4"
     18    ZZOPTS="$1"
     19    CMD="$2"
     20    ALIAS="$3"
    2121    echo -n " $(echo "$ALIAS:              " | cut -b1-15)"
    22     NEWMD5="$(eval "$ZZUF -s $SEED -r $RATIO $CMD" 2>/dev/null | md5sum | cut -b1-32)"
     22    NEWMD5="$(eval "$ZZUF $ZZOPTS $CMD" 2>/dev/null | md5sum | cut -b1-32)"
    2323    if [ -z "$MD5" ]; then
    2424        MD5="$NEWMD5"
     
    5151ZZUF="$(dirname "$0")/../src/zzuf"
    5252FDCAT="$(dirname "$0")/fdcat"
    53 STRAMCAT="$(dirname "$0")/streamcat"
     53STREAMCAT="$(dirname "$0")/streamcat"
    5454FAILED=0
    5555TESTED=0
     
    6060echo ""
    6161
    62 for file in /tmp/zzuf-zero-$$ /tmp/zzuf-text-$$ /tmp/zzuf-random-$$; do
    63     for r in 0.000000 0.00001 0.0001 0.001 0.01 0.1 1.0 10.0; do
     62for r in 0.000000 0.00001 0.0001 0.001 0.01 0.1 1.0 10.0; do
     63    for file in /tmp/zzuf-zero-$$ /tmp/zzuf-text-$$ /tmp/zzuf-random-$$; do
     64        ZZOPTS="-s $seed -r $r"
     65        case $file in
     66          *text*) ZZOPTS="$ZZOPTS -P '\n'" ;;
     67        esac
    6468        echo "Testing zzuf on $file, ratio $r:"
    6569        OK=1
    6670        MD5=""
    67         check $seed $r "cat $file" "cat"
    68         check $seed $r "-i cat < $file" "cat stdin"
    69         # We don't include grep in the testsuite because it puts a newline
    70         # at the end of its input if it was not there initially.
    71         #check $seed $r "grep -- -a \\'\\' $file" "grep -a"
    72         # We don't include sed in the testsuite because on OS X in also
    73         # puts a newline. Crap.
    74         #check $seed $r "-- sed -e n $file" "sed n"
    75         check $seed $r "dd bs=65536 if=$file" "dd(bs=65536)"
    76         check $seed $r "dd bs=1111 if=$file" "dd(bs=1111)"
    77         check $seed $r "dd bs=1024 if=$file" "dd(bs=1024)"
    78         check $seed $r "dd bs=1 if=$file" "dd(bs=1)"
    79         check $seed $r "$FDCAT $file" "fdcat"
    80         check $seed $r "$STRAMCAT $file" "streamcat"
     71        check "$ZZOPTS" "cat $file" "cat"
     72        check "$ZZOPTS" "-i cat < $file" "cat stdin"
     73        case $file in
     74          *text*)
     75            # We don't include grep or sed when the input is not text, because
     76            # they put a newline at the end of their input if it was not there
     77            # initially. (Linux sed doesn't, but OS X sed does.)
     78            check "$ZZOPTS" "grep -- -a '' $file" "grep -a ''"
     79            check "$ZZOPTS" "-- sed -e n $file" "sed -e n"
     80            #check "$ZZOPTS" "-- cut -b1- $file" "cut -b1-"
     81            ;;
     82        esac
     83        check "$ZZOPTS" "dd bs=65536 if=$file" "dd(bs=65536)"
     84        check "$ZZOPTS" "dd bs=1111 if=$file" "dd(bs=1111)"
     85        check "$ZZOPTS" "dd bs=1024 if=$file" "dd(bs=1024)"
     86        check "$ZZOPTS" "dd bs=1 if=$file" "dd(bs=1)"
     87        check "$ZZOPTS" "$FDCAT $file" "fdcat"
     88        check "$ZZOPTS" "$STREAMCAT $file" "streamcat"
    8189        if [ "$OK" != 1 ]; then
    8290            echo "*** FAILED ***"
Note: See TracChangeset for help on using the changeset viewer.