Blame test/test_seeking.sh

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