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:46:54 +02:00
|
|
|
echo "usage: self-test [-P] textfile minimodem_tx_args [ -- minimodem_rx_args ]" 1>&2
|
2011-06-19 18:41:19 +02:00
|
|
|
exit 1
|
|
|
|
}
|
2012-08-12 01:25:51 +02:00
|
|
|
textfile="$1"
|
|
|
|
shift
|
2012-08-18 06:46:54 +02:00
|
|
|
|
|
|
|
minimodem_tx_args="$1"
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]
|
|
|
|
do
|
|
|
|
[ "$1" = "--" ] && {
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
}
|
|
|
|
minimodem_tx_args="$minimodem_tx_args $1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
if [ $# -gt 0 ]
|
|
|
|
then
|
|
|
|
minimodem_rx_args="$*"
|
|
|
|
else
|
|
|
|
minimodem_rx_args="$minimodem_tx_args"
|
|
|
|
fi
|
|
|
|
|
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
|
2012-08-18 06:46:54 +02:00
|
|
|
#echo "$MINIMODEM --tx ... $minimodem_tx_args"
|
|
|
|
#echo "$MINIMODEM --rx ... $minimodem_rx_args"
|
2012-08-18 06:22:02 +02:00
|
|
|
|
2012-08-31 00:05:33 +02:00
|
|
|
$MINIMODEM --tx --file $TMPF.wav $minimodem_tx_args < "$textfile"
|
2012-08-18 06:22:02 +02:00
|
|
|
|
|
|
|
# cp $TMPF.wav /tmp/x.wav
|
|
|
|
|
2012-08-18 06:46:54 +02:00
|
|
|
$MINIMODEM --rx --file $TMPF.wav $minimodem_rx_args \
|
2012-08-18 06:22:02 +02:00
|
|
|
> $TMPF.out 2> $TMPF.err || {
|
|
|
|
cat $TMPF.err
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp "$textfile" $TMPF.out
|
|
|
|
|
|
|
|
{
|
|
|
|
read xlitcarrier
|
2012-08-25 18:17:05 +02:00
|
|
|
read xlitblankline
|
2012-08-18 06:22:02 +02:00
|
|
|
read xlithashes xlitnocarrier stats
|
2012-08-18 06:46:54 +02:00
|
|
|
stats="${stats% ###}"
|
2012-08-18 06:22:02 +02:00
|
|
|
} < $TMPF.err
|
|
|
|
|
|
|
|
|
2012-08-25 19:07:26 +02:00
|
|
|
result="OK "
|
2012-08-18 06:22:02 +02:00
|
|
|
exitcode=0
|
|
|
|
|
|
|
|
[ $test_perfect -eq 1 ] && {
|
|
|
|
match="confidence=inf .* (rate perfect)"
|
|
|
|
if grep -q "$match" $TMPF.err
|
|
|
|
then
|
2012-08-25 19:07:26 +02:00
|
|
|
result="PERFECT"
|
2012-08-18 06:22:02 +02:00
|
|
|
else
|
|
|
|
result="IMPERFECT"
|
|
|
|
exitcode=1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-08-25 19:07:26 +02:00
|
|
|
echo -e "$result $stats"
|
2011-06-19 18:41:19 +02:00
|
|
|
|
2012-08-18 06:22:02 +02:00
|
|
|
exit $exitcode
|