summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2013-08-02 06:19:56 +1000
committerErik de Castro Lopo <erikd@mega-nerd.com>2013-08-02 06:19:56 +1000
commitb01e568698d8347a145cd5e01859d21ab0bafc91 (patch)
tree24b0aea30dcd8343e6509bd89d3565c8b08dbd69 /test
parentd06d985487cf38f100c5506328285f3f4c6eaaaf (diff)
downloadflac-b01e568698d8347a145cd5e01859d21ab0bafc91.tar.gz
Split regain play tests into separate script.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rwxr-xr-xtest/test_metaflac.sh98
-rwxr-xr-xtest/test_replaygain.sh209
3 files changed, 211 insertions, 98 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index b71eec2c..a6b2ab3f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -26,6 +26,7 @@ check_SCRIPTS = \
test_grabbag.sh \
test_flac.sh \
test_metaflac.sh \
+ test_replaygain.sh \
test_seeking.sh \
test_streams.sh \
test_compression.sh
@@ -54,6 +55,7 @@ endif
$(TESTS_ENVIRONMENT) ./test_grabbag.sh
$(TESTS_ENVIRONMENT) ./test_flac.sh
$(TESTS_ENVIRONMENT) ./test_metaflac.sh
+ $(TESTS_ENVIRONMENT) ./test_replaygain.sh
$(TESTS_ENVIRONMENT) ./test_seeking.sh
$(TESTS_ENVIRONMENT) ./test_streams.sh
$(TESTS_ENVIRONMENT) ./test_compression.sh
diff --git a/test/test_metaflac.sh b/test/test_metaflac.sh
index aeed457d..c4e155a5 100755
--- a/test/test_metaflac.sh
+++ b/test/test_metaflac.sh
@@ -394,101 +394,3 @@ cp -p metaflac.flac.in $flacfile
run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile
cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
echo OK
-
-# Replay gain tests - Test the rates which have specific filter table entries
-# and verify that harmonics can be processed correctly.
-
-tonegenerator ()
-{
- # When using GAWK, use --lint=posix to identify non-POSIX awk usages.
- awk -- '
- BEGIN {
- samplerate = '$1';
-
- tone = 1000;
- duration = 1;
- bitspersample = 24;
-
- samplemidpoint = 1;
- for (sps = 0 ; sps < bitspersample - 1 ; sps++) {
- samplemidpoint *= 2;
- }
-
- samplerange = samplemidpoint - 1;
-
- pi = 4 * atan2(1,1);
-
- for (ix = 0; ix < duration * samplerate; ++ix) {
- sample = sin(2 * pi * tone * ix / samplerate);
- sample *= samplerange;
- sample += samplemidpoint;
- sample = int(sample);
- for (bx = 0; bx < bitspersample/8; ++bx) {
- byte[bx] = sample % 256;
- sample /= 256;
- }
- while (bx--) {
- printf("%c", byte[bx]);
- }
- }
-
- }' /dev/null |
- flac --no-error-on-compression-fail --silent \
- --endian=big --channels=1 --bps=24 --sample-rate=$1 --sign=unsigned -
-}
-
-REPLAYGAIN_FREQ=
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 8000/-12.73"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 12000/-12.98"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 16000/-13.27"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 18900/-13.41"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 22050/-13.77"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 24000/-13.82"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 28000/-14.06"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 32000/-14.08"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 36000/-14.12"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 37800/-14.18"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 44100/-14.17"
-REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 48000/-14.16:1:2:4"
-
-set -e
-
-for ACTION in $REPLAYGAIN_FREQ ; do
- if [ -n "${ACTION##*:*}" ] ; then
- HARMONICS=1
- else
- HARMONICS="${ACTION#*:}"
- fi
- FREQ="${ACTION%%/*}"
- GAIN="${ACTION#*/}"
- GAIN="${GAIN%%:*}"
- while [ -n "$HARMONICS" ] ; do
- MULTIPLE="${HARMONICS%%:*}"
- if [ x"$MULTIPLE" = x"$HARMONICS" ] ; then
- HARMONICS=
- else
- HARMONICS="${HARMONICS#*:}"
- fi
- RATE=$(($MULTIPLE * FREQ))
- [ $MULTIPLE -eq 1 -o -n "${REPLAYGAIN_FREQ##* $RATE/*}" ] || break
- echo -n "Testing FLAC replaygain $RATE ($FREQ x $MULTIPLE) ... "
- tonegenerator $RATE > $flacfile
- run_metaflac --add-replay-gain $flacfile
- run_metaflac --list $flacfile | grep REPLAYGAIN.*GAIN= |
- while read -r REPLAYGAIN ; do
- MEASUREDGAIN="${REPLAYGAIN##*=}"
- MEASUREDGAIN="${MEASUREDGAIN%% *}"
- if [ x"$MEASUREDGAIN" != x"$GAIN" ] ; then
- die "ERROR, Expected $GAIN db instead of $REPLAYGAIN"
- fi
- done
- echo OK
- done
-done
-
-
-rm -f $testdir/out.flac $testdir/out.meta
-
-exit 0
diff --git a/test/test_replaygain.sh b/test/test_replaygain.sh
new file mode 100755
index 00000000..65ad529d
--- /dev/null
+++ b/test/test_replaygain.sh
@@ -0,0 +1,209 @@
+#!/bin/sh -e
+
+# FLAC - Free Lossless Audio Codec
+# Copyright (C) 2002-2009 Josh Coalson
+# Copyright (C) 2011-2013 Xiph.Org Foundation
+#
+# This file is part the FLAC project. FLAC is comprised of several
+# components distributed under different licenses. The codec libraries
+# are distributed under Xiph.Org's BSD-like license (see the file
+# COPYING.Xiph in this distribution). All other programs, libraries, and
+# plugins are distributed under the GPL (see COPYING.GPL). The documentation
+# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
+# FLAC distribution contains at the top the terms under which it may be
+# distributed.
+#
+# Since this particular file is relevant to all components of FLAC,
+# it may be distributed under the Xiph.Org license, which is the least
+# restrictive of those mentioned above. See the file COPYING.Xiph in this
+# distribution.
+
+die ()
+{
+ echo $* 1>&2
+ exit 1
+}
+
+if [ x = x"$1" ] ; then
+ BUILD=debug
+else
+ BUILD="$1"
+fi
+
+# change to 'false' to show all flac/metaflac output (useful for debugging)
+if true ; then
+ SILENT='--silent'
+ TOTALLY_SILENT='--totally-silent'
+else
+ SILENT=''
+ TOTALLY_SILENT=''
+fi
+
+LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/utf8/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../objs/$BUILD/lib:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH
+export MALLOC_CHECK_=3
+export MALLOC_PERTURB_=$(($(date +%s) % 255 + 1))
+PATH=`pwd`/../src/flac:$PATH
+PATH=`pwd`/../src/metaflac:$PATH
+PATH=`pwd`/../objs/$BUILD/bin:$PATH
+
+if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then EGREP='grep -E'
+ else EGREP='egrep'
+fi
+
+testdir="metaflac-test-files"
+flacfile="replaygain.flac"
+
+run_flac ()
+{
+ if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
+ echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_metaflac.valgrind.log
+ valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_metaflac.valgrind.log
+ else
+ flac --no-error-on-compression-fail $*
+ fi
+}
+
+run_metaflac ()
+{
+ if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
+ echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log
+ valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_metaflac.valgrind.log
+ else
+ metaflac $*
+ fi
+}
+
+run_metaflac_silent ()
+{
+ if [ -z "$SILENT" ] ; then
+ run_metaflac $*
+ else
+ if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
+ echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_metaflac.valgrind.log
+ valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 2>/dev/null 4>>test_metaflac.valgrind.log
+ else
+ metaflac $* 2>/dev/null
+ fi
+ fi
+}
+
+check_flac ()
+{
+ run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
+}
+
+echo "Generating stream..."
+bytes=80000
+if dd if=/dev/zero ibs=1 count=$bytes | flac --force --verify -0 --input-size=$bytes --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=8000 - ; then
+ chmod +w $flacfile
+else
+ die "ERROR during generation"
+fi
+
+check_flac
+
+# Replay gain tests - Test the rates which have specific filter table entries
+# and verify that harmonics can be processed correctly.
+
+tonegenerator ()
+{
+ # When using GAWK, use --lint=posix to identify non-POSIX awk usages.
+ awk -- '
+ BEGIN {
+ samplerate = '$1';
+
+ tone = 1000;
+ duration = 1;
+ bitspersample = 24;
+
+ samplemidpoint = 1;
+ for (sps = 0 ; sps < bitspersample - 1 ; sps++) {
+ samplemidpoint *= 2;
+ }
+
+ samplerange = samplemidpoint - 1;
+
+ pi = 4 * atan2(1,1);
+
+ for (ix = 0; ix < duration * samplerate; ++ix) {
+ sample = sin(2 * pi * tone * ix / samplerate);
+ sample *= samplerange;
+ sample += samplemidpoint;
+ sample = int(sample);
+ for (bx = 0; bx < bitspersample/8; ++bx) {
+ byte[bx] = sample % 256;
+ sample /= 256;
+ }
+ while (bx--) {
+ printf("%c", byte[bx]);
+ }
+ }
+
+ }' /dev/null |
+ flac --silent --no-error-on-compression-fail \
+ --endian=big --channels=1 --bps=24 --sample-rate=$1 --sign=unsigned -
+}
+
+REPLAYGAIN_FREQ=
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 8000/-12.73"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 11025/-12.93"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 12000/-12.98"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 16000/-13.27"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 18900/-13.41"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 22050/-13.77"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 24000/-13.82"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 28000/-14.06"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 32000/-14.08"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 36000/-14.12"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 37800/-14.18"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 44100/-14.17"
+REPLAYGAIN_FREQ="$REPLAYGAIN_FREQ 48000/-14.16:1:2:4"
+
+set -e
+
+for ACTION in $REPLAYGAIN_FREQ ; do
+ if [ -n "${ACTION##*:*}" ] ; then
+ HARMONICS=1
+ else
+ HARMONICS="${ACTION#*:}"
+ fi
+ FREQ="${ACTION%%/*}"
+ GAIN="${ACTION#*/}"
+ GAIN="${GAIN%%:*}"
+ while [ -n "$HARMONICS" ] ; do
+ MULTIPLE="${HARMONICS%%:*}"
+ if [ x"$MULTIPLE" = x"$HARMONICS" ] ; then
+ HARMONICS=
+ else
+ HARMONICS="${HARMONICS#*:}"
+ fi
+ RATE=$(($MULTIPLE * FREQ))
+ [ $MULTIPLE -eq 1 -o -n "${REPLAYGAIN_FREQ##* $RATE/*}" ] || break
+ echo -n "Testing FLAC replaygain $RATE ($FREQ x $MULTIPLE) ... "
+ tonegenerator $RATE > $flacfile
+ run_metaflac --add-replay-gain $flacfile
+ run_metaflac --list $flacfile | grep REPLAYGAIN.*GAIN= |
+ while read -r REPLAYGAIN ; do
+ MEASUREDGAIN="${REPLAYGAIN##*=}"
+ MEASUREDGAIN="${MEASUREDGAIN%% *}"
+ if [ x"$MEASUREDGAIN" != x"$GAIN" ] ; then
+ die "ERROR, Expected $GAIN db instead of $REPLAYGAIN"
+ fi
+ done
+ echo OK
+ done
+done
+
+
+rm -f $testdir/out.flac $testdir/out.meta
+
+exit 0