tests: self-test handles perfect tests

This commit is contained in:
Kamal Mostafa 2012-08-17 21:22:02 -07:00
parent 18b1eb7457
commit 24eaf984b5
10 changed files with 52 additions and 41 deletions

View File

@ -20,7 +20,6 @@
EXTRA_DIST = \
run-self-tests \
self-test \
self-test-perfect \
test-* \
testdata-*

View File

@ -156,7 +156,6 @@ top_srcdir = @top_srcdir@
EXTRA_DIST = \
run-self-tests \
self-test \
self-test-perfect \
test-* \
testdata-*

View File

@ -9,21 +9,59 @@ MINIMODEM="${MINIMODEM-./minimodem}"
}
}
test_perfect=0
[ "$1" = "-P" ] && {
test_perfect=1
shift
}
[ $# -ge 2 ] || {
echo "usage: self-test textfile minimodem_args" 1>&2
echo "usage: self-test [-P] textfile minimodem_args" 1>&2
exit 1
}
textfile="$1"
shift
minimodem_args="$*"
TMPF="/tmp/minimodem-test-$$.wav"
trap "rm -f $TMPF" 0
TMPF="/tmp/minimodem-test-$$"
trap "rm -f $TMPF.*" 0
set -e
echo
echo "$MINIMODEM ... $minimodem_args < $textfile"
$MINIMODEM --tx -T 1 --file $TMPF $minimodem_args < "$textfile"
# ls -l $TMPF
$MINIMODEM --rx --file $TMPF $minimodem_args | diff "$textfile" -
#echo
#echo "$MINIMODEM ... $minimodem_args < $textfile"
$MINIMODEM --tx -T 1 --file $TMPF.wav $minimodem_args < "$textfile"
# cp $TMPF.wav /tmp/x.wav
$MINIMODEM --rx --file $TMPF.wav $minimodem_args \
> $TMPF.out 2> $TMPF.err || {
cat $TMPF.err
exit 1
}
cmp "$textfile" $TMPF.out
{
read xlitcarrier
read xlithashes xlitnocarrier stats
} < $TMPF.err
result="OK "
exitcode=0
[ $test_perfect -eq 1 ] && {
match="confidence=inf .* (rate perfect)"
if grep -q "$match" $TMPF.err
then
result="PERFECT "
else
result="IMPERFECT"
exitcode=1
fi
}
echo -e "$result $stats"
exit $exitcode

View File

@ -1,25 +0,0 @@
#!/bin/bash
[ $# -ge 2 ] || {
echo "usage: self-test-perfect textfile minimodem_args" 1>&2
exit 1
}
textfile="$1"
shift
minimodem_args="$*"
TMPF=/tmp/minimodem-test.$$
trap "rm -f $TMPF" 0
# test for "confidence=1.00" and "rate perfect"
./self-test "$textfile" $minimodem_args 2>&1 | tee $TMPF
ndata=$(wc -c <$textfile)
match="ndata=$ndata confidence=inf .* (rate perfect)"
grep -q "$match" $TMPF || {
echo "Not perfect; expected: $match"
exit 1
}
echo "Perfect!"
exit 0

View File

@ -1,4 +1,4 @@
# test for confidence=1.00 when using exact integer multiple frequencies
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400

View File

@ -1,2 +1,2 @@
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400 --lut=0

View File

@ -1,2 +1,2 @@
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400 --lut=16

View File

@ -1,2 +1,2 @@
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400 --lut=0 --float-samples

View File

@ -1,2 +1,2 @@
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400 --lut=16 --float-samples

View File

@ -1,2 +1,2 @@
exec ./self-test-perfect testdata-ascii.txt \
exec ./self-test -P testdata-ascii.txt \
1200 --samplerate 24000 -M 1200 -S 2400 --float-samples