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