minimodem-mirror/tests/self-test

68 lines
1.1 KiB
Plaintext
Raw Normal View History

2011-06-19 18:41:19 +02:00
#!/bin/bash
2011-07-08 17:53:06 +02:00
MINIMODEM="${MINIMODEM-./minimodem}"
2012-08-15 20:44:26 +02:00
[ -f "$MINIMODEM" ] || {
MINIMODEM="../src/minimodem"
[ -f "$MINIMODEM" ] || {
echo "E: cannot find minimodem in ./ or ../src/" 1>&2
exit 1
}
}
2011-07-08 17:53:06 +02:00
2012-08-18 06:22:02 +02:00
test_perfect=0
[ "$1" = "-P" ] && {
test_perfect=1
shift
}
2012-08-12 01:25:51 +02:00
[ $# -ge 2 ] || {
2012-08-18 06:22:02 +02:00
echo "usage: self-test [-P] textfile minimodem_args" 1>&2
2011-06-19 18:41:19 +02:00
exit 1
}
2012-08-12 01:25:51 +02:00
textfile="$1"
shift
minimodem_args="$*"
2011-06-19 18:41:19 +02:00
2012-08-18 06:22:02 +02:00
TMPF="/tmp/minimodem-test-$$"
trap "rm -f $TMPF.*" 0
2011-06-19 18:41:19 +02:00
set -e
2012-08-18 06:22:02 +02:00
#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"
2011-06-19 18:41:19 +02:00
2012-08-18 06:22:02 +02:00
exit $exitcode