Last change
on this file since 2541 was
2541,
checked in by Sam Hocevar, 13 years ago
|
- Split the test suite into the RNG test and the Unix utils test.
|
-
Property svn:executable set to
*
|
File size:
1.8 KB
|
Line | |
---|
1 | #!/bin/sh |
---|
2 | |
---|
3 | set -e |
---|
4 | |
---|
5 | checkflip() |
---|
6 | { |
---|
7 | r=$1 |
---|
8 | expect=$2 |
---|
9 | s2=$seed |
---|
10 | mib=20 |
---|
11 | echo "*** $mib MiB of zeroes, ratio $r ***" |
---|
12 | echo " expected ....... $expect" |
---|
13 | rmax=-1 |
---|
14 | rmin=-1 |
---|
15 | rtot=0 |
---|
16 | for x in 0 1 2 3 4 5 6 7 8 9; do |
---|
17 | ret=`dd if=/dev/zero bs=1048576 count=$mib 2>/dev/null | "$ZZUF" -s $s2 -r $r | "$ZZERO"` |
---|
18 | if [ "$rmax" = -1 -o "$ret" -gt "$rmax" ]; then rmax=$ret; fi |
---|
19 | if [ "$rmin" = -1 -o "$ret" -lt "$rmin" ]; then rmin=$ret; fi |
---|
20 | rtot=`expr $rtot + $ret || true` |
---|
21 | echo " try $x .......... $ret" |
---|
22 | s2=`expr $s2 + 1` |
---|
23 | done |
---|
24 | rmean=`expr '(' $rtot + 5 ')' / 10 || true` |
---|
25 | delta=`expr $rmean - $expect || true` |
---|
26 | if [ "$delta" -gt -5 -a "$delta" -lt 5 ]; then |
---|
27 | result="ok" |
---|
28 | elif [ $(($rmean * 8)) -lt $(($expect * 7)) \ |
---|
29 | -o $(($rmean * 7)) -gt $(($expect * 8)) ]; then |
---|
30 | result="FAILED" |
---|
31 | FAILED=$(($FAILED + 1)) |
---|
32 | else |
---|
33 | result="ok" |
---|
34 | fi |
---|
35 | TESTED=$(($TESTED + 1)) |
---|
36 | echo " min/avg/max $rmin/$rmean/$rmax .......... $result" |
---|
37 | } |
---|
38 | |
---|
39 | DIR="$(dirname "$0")" |
---|
40 | ZZUF="$DIR/../src/zzuf" |
---|
41 | ZZERO="$DIR/zzero" |
---|
42 | if [ ! -f "$ZZERO" ]; then |
---|
43 | echo "error: test/zzero is missing" |
---|
44 | exit 1 |
---|
45 | fi |
---|
46 | FAILED=0 |
---|
47 | TESTED=0 |
---|
48 | |
---|
49 | if [ -z "$1" ]; then |
---|
50 | seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8) |
---|
51 | else |
---|
52 | seed="$1" |
---|
53 | fi |
---|
54 | |
---|
55 | echo "*** running zzuf RNG test suite with seed $seed ***" |
---|
56 | |
---|
57 | # if X flips are performed on N bits set to 0, the average number of bits |
---|
58 | # set to 1 is: N / 2 * (1 - pow(1 - 2 / N, X) |
---|
59 | checkflip 0.000000001 0 |
---|
60 | checkflip 0.00000001 1 |
---|
61 | checkflip 0.0000001 16 |
---|
62 | checkflip 0.000001 167 |
---|
63 | checkflip 0.00001 1677 |
---|
64 | checkflip 0.0001 16775 |
---|
65 | checkflip 0.001 167604 |
---|
66 | checkflip 0.01 1661055 |
---|
67 | checkflip 0.1 15205967 |
---|
68 | |
---|
69 | echo "" |
---|
70 | if [ "$FAILED" != 0 ]; then |
---|
71 | echo "*** $FAILED tests failed out of $TESTED ***" |
---|
72 | exit 1 |
---|
73 | fi |
---|
74 | echo "*** all $TESTED tests OK ***" |
---|
75 | |
---|
76 | exit 0 |
---|
77 | |
---|
Note: See
TracBrowser
for help on using the repository browser.