Factor out common test functionality to test/common.sh.in.
authorErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 16 Sep 2013 09:55:11 +0000 (19:55 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Mon, 16 Sep 2013 20:14:57 +0000 (06:14 +1000)
13 files changed:
.gitignore
configure.ac
test/common.sh.in [new file with mode: 0644]
test/test_bins.sh
test/test_compression.sh
test/test_flac.sh
test/test_grabbag.sh
test/test_libFLAC++.sh
test/test_libFLAC.sh
test/test_metaflac.sh
test/test_replaygain.sh
test/test_seeking.sh
test/test_streams.sh

index 2b255db..cb53d22 100644 (file)
@@ -65,6 +65,7 @@ test/*.raw
 test/*.rf64
 test/*.w64
 test/*.wav
+test/common.sh
 test/cuesheet.diff
 test/cuesheet.log
 test/metaflac-test-files/out.meta
index ed9713b..ed7c9ee 100644 (file)
@@ -491,6 +491,7 @@ AC_CONFIG_FILES([ \
        doc/html/ru/Makefile \
        m4/Makefile \
        man/Makefile \
+       test/common.sh \
        test/Makefile \
        test/cuesheets/Makefile \
        test/flac-to-flac-metadata-test-files/Makefile \
diff --git a/test/common.sh.in b/test/common.sh.in
new file mode 100644 (file)
index 0000000..6955c2a
--- /dev/null
@@ -0,0 +1,69 @@
+#  FLAC - Free Lossless Audio Codec
+#  Copyright (C) 2001-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.
+
+export MALLOC_CHECK_=3
+export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
+
+if [ x = x"$1" ] ; then
+       BUILD=debug
+else
+       BUILD="$1"
+fi
+
+LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../objs/$BUILD/lib:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/libFLAC/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/getopt/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=`pwd`/../src/share/grabbag/.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=../src/libFLAC/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/libFLAC++/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
+
+export LD_LIBRARY_PATH
+
+EXE=@EXEEXT@
+
+# 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
+
+# Functions
+
+function die {
+       echo $* 1>&2
+       exit 1
+}
+
+function make_streams {
+       echo "Generating streams..."
+       if [ ! -f wacky1.wav ] ; then
+               test_streams${EXE} || die "ERROR during test_streams"
+       fi
+}
index 6d48572..5617ae9 100755 (executable)
 #  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
+source common.sh
 
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_==$(($(date +%s) % 255 + 1))
 PATH=../src/flac:$PATH
 PATH=../objs/$BUILD/bin:$PATH
 BINS_PATH=../../test_files/bins
@@ -48,15 +28,15 @@ if [ x"$FLAC__TEST_LEVEL" = x ] ; then
        FLAC__TEST_LEVEL=1
 fi
 
-flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
 
 run_flac ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_bins.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac $* 4>>test_bins.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $* 4>>test_bins.valgrind.log
        else
-               flac $*
+               flac${EXE} $*
        fi
 }
 
index 3c48418..11bd6c3 100755 (executable)
 #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
 #  distribution.
 
-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
+source common.sh
+
 PATH=`pwd`/../src/flac:$PATH
 
 echo "Using FLAC binary :" $(which flac)
@@ -38,7 +32,7 @@ last_size=$(wc -c < noisy-sine.wav)
 echo "Original file size ${last_size} bytes."
 
 for k in 0 1 2 3 4 5 6 7 8 ; do
-       flac -${k} --silent noisy-sine.wav -o ${fname}
+       flac${EXE} -${k} --silent noisy-sine.wav -o ${fname}
        size=$(wc -c < ${fname})
        echo "Compression level ${k}, file size ${size} bytes."
        if test ${last_size} -lt ${size} ; then
index 5e061a9..05ac06c 100755 (executable)
 #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
 #  distribution.
 
+source common.sh
+
 # we use '.' as decimal separator in --skip/--until tests
 export LANG=C LC_ALL=C
 
-die ()
-{
-       echo $* 1>&2
-       exit 1
-}
-
 dddie="die ERROR: creating files with dd"
 
-if [ x = x"$1" ] ; then
-       BUILD=debug
-else
-       BUILD="$1"
-fi
-
-# change to 'false' to show flac 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`/../src/test_streams:$PATH
 PATH=`pwd`/../objs/$BUILD/bin:$PATH
 
-flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
 
 run_flac ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_flac.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_flac.valgrind.log
        else
-               flac --no-error-on-compression-fail $*
+               flac${EXE} --no-error-on-compression-fail $*
        fi
 }
 
@@ -75,16 +46,15 @@ run_metaflac ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_flac.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_flac.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_flac.valgrind.log
        else
-               metaflac $*
+               metaflac${EXE} $*
        fi
 }
 
 md5cmp ()
 {
-       #n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || die "ERROR: comparing FLAC files $1 and $2 by MD5 sum" ) | uniq | wc -l`
-       n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
+       n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac${EXE} --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
        [ "$n" != "" ] && [ $n = 1 ]
 }
 
@@ -95,7 +65,7 @@ else
 fi
 
 echo "Checking for --ogg support in flac..."
-if flac --ogg $SILENT --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
+if flac${EXE} --ogg $SILENT --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
        has_ogg=yes;
        echo "flac --ogg works"
 else
index ac5ebe5..923c812 100755 (executable)
 #  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
+source common.sh
 
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_=$(($(date +%s) % 255 + 1))
 PATH=../src/test_grabbag/cuesheet:$PATH
 PATH=../src/test_grabbag/picture:$PATH
 PATH=../objs/$BUILD/bin:$PATH
@@ -48,9 +31,9 @@ run_test_cuesheet ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log
        else
-               test_cuesheet $*
+               test_cuesheet${EXE} $*
        fi
 }
 
@@ -58,9 +41,9 @@ run_test_picture ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture $* 4>>test_grabbag.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log
        else
-               test_picture $*
+               test_picture${EXE} $*
        fi
 }
 
index 0fe82e2..b982554 100755 (executable)
 #  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
+source common.sh
 
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/libFLAC++/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
 PATH=../src/test_libFLAC++:$PATH
 PATH=../objs/$BUILD/bin:$PATH
 
 run_test_libFLACpp ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC++ $* 4>>test_libFLAC++.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC++${EXE} $* 4>>test_libFLAC++.valgrind.log
        else
-               test_libFLAC++ $*
+               test_libFLAC++${EXE} $*
        fi
 }
 
index 74c04ee..e3bd568 100755 (executable)
 #  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
-
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
+source common.sh
 
 PATH=../src/test_libFLAC:$PATH
 PATH=../objs/$BUILD/bin:$PATH
@@ -44,9 +26,9 @@ PATH=../objs/$BUILD/bin:$PATH
 run_test_libFLAC ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC $* 4>>test_libFLAC.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_libFLAC${EXE} $* 4>>test_libFLAC.valgrind.log
        else
-               test_libFLAC $*
+               test_libFLAC${EXE} $*
        fi
 }
 
index d7cef5d..aff5948 100755 (executable)
 #  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
+source common.sh
 
-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
@@ -61,16 +32,16 @@ fi
 testdir="metaflac-test-files"
 flacfile="metaflac.flac"
 
-flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
-metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
+flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
 
 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
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_metaflac.valgrind.log
        else
-               flac --no-error-on-compression-fail $*
+               flac${EXE} --no-error-on-compression-fail $*
        fi
 }
 
@@ -78,9 +49,9 @@ 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
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_metaflac.valgrind.log
        else
-               metaflac $*
+               metaflac${EXE} $*
        fi
 }
 
@@ -91,9 +62,9 @@ run_metaflac_silent ()
        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
+                       valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 2>/dev/null 4>>test_metaflac.valgrind.log
                else
-                       metaflac $* 2>/dev/null
+                       metaflac${EXE} $* 2>/dev/null
                fi
        fi
 }
@@ -105,7 +76,7 @@ check_flac ()
 
 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
+if dd if=/dev/zero ibs=1 count=$bytes | flac${EXE} --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"
index d77e78e..a847983 100755 (executable)
 #  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
+source common.sh
 
-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
@@ -67,7 +38,7 @@ run_flac ()
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_replaygain.valgrind.log
                valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_replaygain.valgrind.log
        else
-               flac --no-error-on-compression-fail $*
+               flac${EXE} --no-error-on-compression-fail $*
        fi
 }
 
@@ -77,7 +48,7 @@ run_metaflac ()
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_replaygain.valgrind.log
                valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_replaygain.valgrind.log
        else
-               metaflac $*
+               metaflac${EXE} $*
        fi
 }
 
@@ -90,7 +61,7 @@ run_metaflac_silent ()
                        echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_replaygain.valgrind.log
                        valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 2>/dev/null 4>>test_replaygain.valgrind.log
                else
-                       metaflac $* 2>/dev/null
+                       metaflac${EXE} $* 2>/dev/null
                fi
        fi
 }
@@ -102,7 +73,7 @@ check_flac ()
 
 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
+if dd if=/dev/zero ibs=1 count=$bytes | flac${EXE} --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"
@@ -157,7 +128,7 @@ tonegenerator ()
             }
 
     }' /dev/null |
-    flac --silent --no-error-on-compression-fail \
+    flac${EXE} --silent --no-error-on-compression-fail \
         --endian=big --channels=1 --bps=24 --sample-rate=$1 --sign=unsigned -
 }
 
index 3386ff2..7da5523 100755 (executable)
 #  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
+source common.sh
 
-LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
 PATH=../src/flac:$PATH
 PATH=../src/metaflac:$PATH
 PATH=../src/test_seeking:$PATH
@@ -45,16 +30,16 @@ if [ x"$FLAC__TEST_LEVEL" = x ] ; then
        FLAC__TEST_LEVEL=1
 fi
 
-flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
-metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
+flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
 
 run_flac ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_seeking.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_seeking.valgrind.log
        else
-               flac --no-error-on-compression-fail $*
+               flac${EXE} --no-error-on-compression-fail $*
        fi
 }
 
@@ -62,9 +47,9 @@ run_metaflac ()
 {
        if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log
-               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac $* 4>>test_seeking.valgrind.log
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log
        else
-               metaflac $*
+               metaflac${EXE} $*
        fi
 }
 
@@ -74,12 +59,12 @@ run_test_seeking ()
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log
                valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log
        else
-               test_seeking $*
+               test_seeking${EXE} $*
        fi
 }
 
 echo -n "Checking for --ogg support in flac ... "
-if flac --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
+if flac${EXE} --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
        has_ogg=yes;
 else
        has_ogg=no;
@@ -97,8 +82,8 @@ run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed
 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S10x --output-name=tiny-s.flac noise8m32.raw || die "ERROR generating FLAC file"
 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S10x --output-name=small-s.flac noise.raw || die "ERROR generating FLAC file"
 
-tiny_samples=`metaflac --show-total-samples tiny.flac`
-small_samples=`metaflac --show-total-samples small.flac`
+tiny_samples=`metaflac${EXE} --show-total-samples tiny.flac`
+small_samples=`metaflac${EXE} --show-total-samples small.flac`
 
 tiny_seek_count=100
 if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
index 81cf8a8..83cb6b2 100755 (executable)
 #  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
+source common.sh
 
-LD_LIBRARY_PATH=../objs/$BUILD/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-export MALLOC_CHECK_=3
-export MALLOC_PERTURB_=$((RANDOM % 255 + 1))
 PATH=../src/flac:$PATH
 PATH=../src/test_streams:$PATH
 PATH=../objs/$BUILD/bin:$PATH
@@ -42,7 +28,7 @@ if [ x"$FLAC__TEST_LEVEL" = x ] ; then
        FLAC__TEST_LEVEL=1
 fi
 
-flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
 
 run_flac ()
 {
@@ -50,7 +36,7 @@ run_flac ()
                echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_streams.valgrind.log
                valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac --no-error-on-compression-fail $* 4>>test_streams.valgrind.log
        else
-               flac --no-error-on-compression-fail $*
+               flac${EXE} --no-error-on-compression-fail $*
        fi
 }