Changeset 1500 for zzuf/trunk/test


Ignore:
Timestamp:
Dec 18, 2006, 1:48:49 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • More testsuite improvements.
File:
1 edited

Legend:

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

    r1499 r1500  
    11#!/bin/sh
     2
     3create()
     4{
     5    rm -f /tmp/zzuf-zero-$$
     6    dd if=/dev/zero of=/tmp/zzuf-zero-$$ bs=1024 count=32 2>/dev/null
     7    rm -f /tmp/zzuf-random-$$
     8    dd if=/dev/urandom of=/tmp/zzuf-random-$$ bs=1024 count=32 2>/dev/null
     9    rm -f /tmp/zzuf-text-$$
     10    strings /dev/urandom | dd bs=1024 count=32 of=/tmp/zzuf-text-$$ 2>/dev/null
     11}
    212
    313check()
    414{
    5     RATIO="$1"
    6     CMD="$2"
    7     ALIAS="$3"
     15    SEED="$1"
     16    RATIO="$2"
     17    CMD="$3"
     18    ALIAS="$4"
    819    echo -n " $(echo "$ALIAS:              " | cut -b1-15)"
    9     NEWMD5="$($ZZUF -r $RATIO $CMD 2>/dev/null | md5sum | cut -b1-32)"
     20    NEWMD5="$($ZZUF -s $SEED -r $RATIO $CMD 2>/dev/null | md5sum | cut -b1-32)"
    1021    if [ -z "$MD5" ]; then
    1122        MD5="$NEWMD5"
     
    1930}
    2031
     32cleanup() {
     33    rm -f /tmp/zzuf-zero-$$
     34    rm -f /tmp/zzuf-random-$$
     35    rm -f /tmp/zzuf-one-$$
     36    exit 0
     37}
     38
     39trap "echo ''; echo 'Aborted.'; cleanup; exit 0" 1 2 15
     40
     41seed=$(($RANDOM * $$))
    2142ZZUF="$(dirname "$0")/../src/zzuf"
    2243FAILED=0
    2344TESTED=0
    2445
    25 for file in /etc/passwd $ZZUF; do
    26     for r in 0.0 0.001 0.01 0.1 1; do
     46echo "Creating test files"
     47create
     48echo "Using seed $seed"
     49echo ""
     50
     51for file in /tmp/zzuf-text-$$ /tmp/zzuf-zero-$$ /tmp/zzuf-random-$$; do
     52    for r in 0.0 0.00001 0.0001 0.001 0.01 0.1 1.0 10.0; do
    2753        echo "Testing zzuf on $file, ratio $r:"
    2854        OK=1
    2955        MD5=""
    30         check $r "cat $file" "cat"
     56        check $seed $r "cat $file" "cat"
    3157# don't do grep, it adds a newline at EOF!
    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)"
     58#        check $seed $r "grep -- -a \\'\\' $file" "grep -a"
     59        check $seed $r "sed n $file" "sed n"
     60        check $seed $r "dd bs=65536 if=$file" "dd(bs=65536)"
     61        check $seed $r "dd bs=1111 if=$file" "dd(bs=1111)"
     62        check $seed $r "dd bs=1024 if=$file" "dd(bs=1024)"
     63        check $seed $r "dd bs=1 if=$file" "dd(bs=1)"
    3864        if [ "$OK" != 1 ]; then
    3965            echo "*** FAILED ***"
     
    5076fi
    5177echo "All $TESTED tests OK."
     78cleanup
    5279exit 0
    5380
Note: See TracChangeset for help on using the changeset viewer.