* Split the test suite into the RNG test and the Unix utils test.
This commit is contained in:
+2
-2
@@ -1,9 +1,9 @@
|
||||
|
||||
EXTRA_DIST = testsuite.sh file-00 file-ff file-random file-text
|
||||
EXTRA_DIST = rng utils file-00 file-ff file-random file-text
|
||||
|
||||
noinst_PROGRAMS = zzcat zzero
|
||||
|
||||
TESTS = testsuite.sh
|
||||
TESTS = rng utils
|
||||
|
||||
zzcat_SOURCES = zzcat.c
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
checkflip()
|
||||
{
|
||||
r=$1
|
||||
expect=$2
|
||||
s2=$seed
|
||||
mib=20
|
||||
echo "*** $mib MiB of zeroes, ratio $r ***"
|
||||
echo " expected ....... $expect"
|
||||
rmax=-1
|
||||
rmin=-1
|
||||
rtot=0
|
||||
for x in 0 1 2 3 4 5 6 7 8 9; do
|
||||
ret=`dd if=/dev/zero bs=1048576 count=$mib 2>/dev/null | "$ZZUF" -s $s2 -r $r | "$ZZERO"`
|
||||
if [ "$rmax" = -1 -o "$ret" -gt "$rmax" ]; then rmax=$ret; fi
|
||||
if [ "$rmin" = -1 -o "$ret" -lt "$rmin" ]; then rmin=$ret; fi
|
||||
rtot=`expr $rtot + $ret || true`
|
||||
echo " try $x .......... $ret"
|
||||
s2=`expr $s2 + 1`
|
||||
done
|
||||
rmean=`expr '(' $rtot + 5 ')' / 10 || true`
|
||||
delta=`expr $rmean - $expect || true`
|
||||
if [ "$delta" -gt -5 -a "$delta" -lt 5 ]; then
|
||||
result="ok"
|
||||
elif [ $(($rmean * 8)) -lt $(($expect * 7)) \
|
||||
-o $(($rmean * 7)) -gt $(($expect * 8)) ]; then
|
||||
result="FAILED"
|
||||
FAILED=$(($FAILED + 1))
|
||||
else
|
||||
result="ok"
|
||||
fi
|
||||
TESTED=$(($TESTED + 1))
|
||||
echo " min/avg/max $rmin/$rmean/$rmax .......... $result"
|
||||
}
|
||||
|
||||
DIR="$(dirname "$0")"
|
||||
ZZUF="$DIR/../src/zzuf"
|
||||
ZZERO="$DIR/zzero"
|
||||
if [ ! -f "$ZZERO" ]; then
|
||||
echo "error: test/zzero is missing"
|
||||
exit 1
|
||||
fi
|
||||
FAILED=0
|
||||
TESTED=0
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8)
|
||||
else
|
||||
seed="$1"
|
||||
fi
|
||||
|
||||
echo "*** running zzuf RNG test suite with seed $seed ***"
|
||||
|
||||
# if X flips are performed on N bits set to 0, the average number of bits
|
||||
# set to 1 is: N / 2 * (1 - pow(1 - 2 / N, X)
|
||||
checkflip 0.000000001 0
|
||||
checkflip 0.00000001 1
|
||||
checkflip 0.0000001 16
|
||||
checkflip 0.000001 167
|
||||
checkflip 0.00001 1677
|
||||
checkflip 0.0001 16775
|
||||
checkflip 0.001 167604
|
||||
checkflip 0.01 1661055
|
||||
checkflip 0.1 15205967
|
||||
|
||||
echo ""
|
||||
if [ "$FAILED" != 0 ]; then
|
||||
echo "*** $FAILED tests failed out of $TESTED ***"
|
||||
exit 1
|
||||
fi
|
||||
echo "*** all $TESTED tests OK ***"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -2,40 +2,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
checkflip()
|
||||
{
|
||||
r=$1
|
||||
expect=$2
|
||||
s2=$seed
|
||||
mib=20
|
||||
echo "*** $mib MiB of zeroes, ratio $r ***"
|
||||
echo " expected ....... $expect"
|
||||
rmax=-1
|
||||
rmin=-1
|
||||
rtot=0
|
||||
for x in 0 1 2 3 4 5 6 7 8 9; do
|
||||
ret=`dd if=/dev/zero bs=1048576 count=$mib 2>/dev/null | "$ZZUF" -s $s2 -r $r | "$ZZERO"`
|
||||
if [ "$rmax" = -1 -o "$ret" -gt "$rmax" ]; then rmax=$ret; fi
|
||||
if [ "$rmin" = -1 -o "$ret" -lt "$rmin" ]; then rmin=$ret; fi
|
||||
rtot=`expr $rtot + $ret || true`
|
||||
echo " try $x .......... $ret"
|
||||
s2=`expr $s2 + 1`
|
||||
done
|
||||
rmean=`expr '(' $rtot + 5 ')' / 10 || true`
|
||||
delta=`expr $rmean - $expect || true`
|
||||
if [ "$delta" -gt -5 -a "$delta" -lt 5 ]; then
|
||||
result="ok"
|
||||
elif [ $(($rmean * 8)) -lt $(($expect * 7)) \
|
||||
-o $(($rmean * 7)) -gt $(($expect * 8)) ]; then
|
||||
result="FAILED"
|
||||
FAILED=$(($FAILED + 1))
|
||||
else
|
||||
result="ok"
|
||||
fi
|
||||
TESTED=$(($TESTED + 1))
|
||||
echo " min/avg/max $rmin/$rmean/$rmax .......... $result"
|
||||
}
|
||||
|
||||
checkutils()
|
||||
{
|
||||
r=$1
|
||||
@@ -125,11 +91,6 @@ if [ ! -f "$ZZCAT" ]; then
|
||||
echo "error: test/zzcat is missing"
|
||||
exit 1
|
||||
fi
|
||||
ZZERO="$DIR/zzero"
|
||||
if [ ! -f "$ZZERO" ]; then
|
||||
echo "error: test/zzero is missing"
|
||||
exit 1
|
||||
fi
|
||||
if file /bin/cat | grep -q 'statically linked'; then
|
||||
STATIC_CAT=1
|
||||
fi
|
||||
@@ -145,24 +106,8 @@ else
|
||||
seed="$1"
|
||||
fi
|
||||
|
||||
echo "*** running zzuf test suite with seed $seed ***"
|
||||
echo "*** running zzuf utils test suite with seed $seed ***"
|
||||
|
||||
echo ""
|
||||
echo "*** check #1: random number generator ***"
|
||||
# if X flips are performed on N bits set to 0, the average number of bits
|
||||
# set to 1 is: N / 2 * (1 - pow(1 - 2 / N, X)
|
||||
checkflip 0.000000001 0
|
||||
checkflip 0.00000001 1
|
||||
checkflip 0.0000001 16
|
||||
checkflip 0.000001 167
|
||||
checkflip 0.00001 1677
|
||||
checkflip 0.0001 16775
|
||||
checkflip 0.001 167604
|
||||
checkflip 0.01 1661055
|
||||
checkflip 0.1 15205967
|
||||
|
||||
echo ""
|
||||
echo "*** check #2: libc functions coverage ***"
|
||||
checkutils 0.0
|
||||
checkutils 0.000000001
|
||||
checkutils 0.0000001
|
||||
Reference in New Issue
Block a user