Add gapk testsuit

This testsuite takes a PCM auidio file and encodes from it every
supported format, and compares that output with a known sample (from an
earlier, trusted version of gakp, shipped as part of this project).

I then re-decodes this file to PCM and also compares that with a shipped
reference re-decode.
This commit is contained in:
Harald Welte 2017-05-28 21:28:57 +02:00
parent 84f4f86fdf
commit 2ba67e8c9e
27 changed files with 111 additions and 0 deletions

13
test/common.sh Normal file
View File

@ -0,0 +1,13 @@
# directory containing the reference files for comparing against
REFDIR=./ref-files
if [ -f ../src/gapk ]; then
GAPK=../src/gapk
elif [ -f `which gapk` ]; then
GAPK=`whiich gapk`
else
exit 1
fi
echo Using gapk found at $GAPK
FORMATS="amr-efr gsm racal-hr racal-fr racal-efr ti-hr ti-fr ti-efr rtp-efr rtp-hr-etsi rtp-hr-ietf"

14
test/play_all_formats.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
OUTDIR=/tmp
INFILE=$1
. ./common.sh
for f in $FORMATS; do
BASE=`basename $INFILE`
PLAYFILE=$OUTDIR/$BASE.$f
echo
echo Format $f: Playing back $PLAYFILE
echo $GAPK -f $f -i $PLAYFILE -g rawpcm-s16le -A default
$GAPK -f $f -i $PLAYFILE -g rawpcm-s16le -A default
done

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

62
test/test_all_formats.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/sh
# This script generates test data for all formats by doing the
# following:
# * encode the user-specified PCM file into each format
# * re-decode that format back to PCM
#
# Use this to generate test files that are to be shipped together with
# gapk. Always use the
# directory in which the temporary output is stored
OUTDIR=/tmp
# name of the input s16le file to use for encoding and re-decoding
INFILE=$1
# source some common parameters
. ./common.sh
RETVAL=0
for f in $FORMATS; do
BASE=`basename $INFILE`
OUTFILE=$OUTDIR/$BASE.$f
echo Format $f: Encoding $INFILE to $OUTFILE
$GAPK -f rawpcm-s16le -i $INFILE -g $f -o $OUTFILE
# compare with reference
diff $OUTFILE $REFDIR/`basename $OUTFILE`
if [ $? -ne 0 ]; then
echo "===> FAIL"
RETVAL=1
else
echo "===> PASS"
fi
echo
DECFILE=$OUTFILE.s16
echo Format $f: Decoding $OUTFILE to $DECFILE
$GAPK -f $f -i $OUTFILE -g rawpcm-s16le -o $DECFILE
# compare with reference
diff $DECFILE $REFDIR/`basename $DECFILE`
if [ $? -ne 0 ]; then
echo "===> FAIL"
RETVAL=1
else
echo "===> PASS"
fi
echo
done
echo -n "Overall Verdict: "
if [ $RETVAL -ne 0 ]; then
echo "FAIL"
else
echo "PASS"
fi
exit $RETVAL

22
test/update_ref_files.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# This script re-generates the reference data shipped together with
# gapk. To be used by gapk maintainers only.
. ./common.sh
INFILE=$1
OUTDIR=$REFDIR
for f in $FORMATS; do
BASE=`basename $INFILE`
OUTFILE=$OUTDIR/$BASE.$f
echo
echo Format $f: Encoding $INFILE to $OUTFILE
$GAPK -f rawpcm-s16le -i $INFILE -g $f -o $OUTFILE
DECFILE=$OUTFILE.s16
echo Format $f: Decoding $OUTFILE to $DECFILE
$GAPK -f $f -i $OUTFILE -g rawpcm-s16le -o $DECFILE
done