cannam@86: #!/bin/sh cannam@86: cannam@86: # FLAC - Free Lossless Audio Codec cannam@86: # Copyright (C) 2004,2005,2006,2007 Josh Coalson cannam@86: # cannam@86: # This file is part the FLAC project. FLAC is comprised of several cannam@86: # components distributed under difference licenses. The codec libraries cannam@86: # are distributed under Xiph.Org's BSD-like license (see the file cannam@86: # COPYING.Xiph in this distribution). All other programs, libraries, and cannam@86: # plugins are distributed under the GPL (see COPYING.GPL). The documentation cannam@86: # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the cannam@86: # FLAC distribution contains at the top the terms under which it may be cannam@86: # distributed. cannam@86: # cannam@86: # Since this particular file is relevant to all components of FLAC, cannam@86: # it may be distributed under the Xiph.Org license, which is the least cannam@86: # restrictive of those mentioned above. See the file COPYING.Xiph in this cannam@86: # distribution. cannam@86: cannam@86: die () cannam@86: { cannam@86: echo $* 1>&2 cannam@86: exit 1 cannam@86: } cannam@86: cannam@86: if [ x = x"$1" ] ; then cannam@86: BUILD=debug cannam@86: else cannam@86: BUILD="$1" cannam@86: fi cannam@86: cannam@86: LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH cannam@86: LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH cannam@86: export LD_LIBRARY_PATH cannam@86: PATH=../src/flac:$PATH cannam@86: PATH=../src/metaflac:$PATH cannam@86: PATH=../src/test_seeking:$PATH cannam@86: PATH=../src/test_streams:$PATH cannam@86: PATH=../obj/$BUILD/bin:$PATH cannam@86: cannam@86: if [ x"$FLAC__TEST_LEVEL" = x ] ; then cannam@86: FLAC__TEST_LEVEL=1 cannam@86: fi cannam@86: cannam@86: flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" cannam@86: metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" cannam@86: cannam@86: run_flac () cannam@86: { cannam@86: if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then cannam@86: echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_seeking.valgrind.log cannam@86: valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 flac $* 4>>test_seeking.valgrind.log cannam@86: else cannam@86: flac $* cannam@86: fi cannam@86: } cannam@86: cannam@86: run_metaflac () cannam@86: { cannam@86: if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then cannam@86: echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 metaflac $*" >>test_seeking.valgrind.log cannam@86: valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 metaflac $* 4>>test_seeking.valgrind.log cannam@86: else cannam@86: metaflac $* cannam@86: fi cannam@86: } cannam@86: cannam@86: run_test_seeking () cannam@86: { cannam@86: if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then cannam@86: echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_seeking $*" >>test_seeking.valgrind.log cannam@86: valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log cannam@86: else cannam@86: test_seeking $* cannam@86: fi cannam@86: } cannam@86: cannam@86: echo "Checking for --ogg support in flac..." cannam@86: 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 cannam@86: has_ogg=yes; cannam@86: echo "flac --ogg works" cannam@86: else cannam@86: has_ogg=no; cannam@86: echo "flac --ogg doesn't work" cannam@86: fi cannam@86: cannam@86: cannam@86: echo "Generating streams..." cannam@86: if [ ! -f noise.raw ] ; then cannam@86: test_streams || die "ERROR during test_streams" cannam@86: fi cannam@86: cannam@86: echo "generating FLAC files for seeking:" cannam@86: run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S- --output-name=tiny.flac noise8m32.raw || die "ERROR generating FLAC file" cannam@86: run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S- --output-name=small.flac noise.raw || die "ERROR generating FLAC file" cannam@86: 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" cannam@86: 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" cannam@86: cannam@86: tiny_samples=`metaflac --show-total-samples tiny.flac` cannam@86: small_samples=`metaflac --show-total-samples small.flac` cannam@86: cannam@86: tiny_seek_count=100 cannam@86: if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then cannam@86: small_seek_count=10000 cannam@86: else cannam@86: small_seek_count=100000 cannam@86: fi cannam@86: cannam@86: for suffix in '' '-s' ; do cannam@86: echo "testing tiny$suffix.flac:" cannam@86: if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: cannam@86: echo "testing small$suffix.flac:" cannam@86: if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: cannam@86: echo "removing sample count from tiny$suffix.flac and small$suffix.flac:" cannam@86: if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else cannam@86: die "ERROR: during metaflac" cannam@86: fi cannam@86: cannam@86: echo "testing tiny$suffix.flac with total_samples=0:" cannam@86: if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: cannam@86: echo "testing small$suffix.flac with total_samples=0:" cannam@86: if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: done cannam@86: cannam@86: if [ $has_ogg = "yes" ] ; then cannam@86: cannam@86: echo "generating Ogg FLAC files for seeking:" cannam@86: run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.oga --ogg noise8m32.raw || die "ERROR generating Ogg FLAC file" cannam@86: run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.oga --ogg noise.raw || die "ERROR generating Ogg FLAC file" cannam@86: # seek tables are not used in Ogg FLAC cannam@86: cannam@86: echo "testing tiny.oga:" cannam@86: if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: cannam@86: echo "testing small.oga:" cannam@86: if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else cannam@86: die "ERROR: during test_seeking" cannam@86: fi cannam@86: cannam@86: fi cannam@86: cannam@86: rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac