source: zzuf/trunk/test/testsuite.sh @ 1499

Last change on this file since 1499 was 1499, checked in by Sam Hocevar, 14 years ago
  • Better tests and error reporting in the testsuite.
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1#!/bin/sh
2
3check()
4{
5    RATIO="$1"
6    CMD="$2"
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
19}
20
21ZZUF="$(dirname "$0")/../src/zzuf"
22FAILED=0
23TESTED=0
24
25for file in /etc/passwd $ZZUF; do
26    for r in 0.0 0.001 0.01 0.1 1; do
27        echo "Testing zzuf on $file, ratio $r:"
28        OK=1
29        MD5=""
30        check $r "cat $file" "cat"
31# 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)"
38        if [ "$OK" != 1 ]; then
39            echo "*** FAILED ***"
40            FAILED=$(($FAILED + 1))
41        fi
42        TESTED=$(($TESTED + 1))
43        echo ""
44    done
45done
46
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 TracBrowser for help on using the repository browser.