1#!/bin/sh -e 2 3# FLAC - Free Lossless Audio Codec 4# Copyright (C) 2004-2009 Josh Coalson 5# Copyright (C) 2011-2016 Xiph.Org Foundation 6# 7# This file is part the FLAC project. FLAC is comprised of several 8# components distributed under different licenses. The codec libraries 9# are distributed under Xiph.Org's BSD-like license (see the file 10# COPYING.Xiph in this distribution). All other programs, libraries, and 11# plugins are distributed under the GPL (see COPYING.GPL). The documentation 12# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the 13# FLAC distribution contains at the top the terms under which it may be 14# distributed. 15# 16# Since this particular file is relevant to all components of FLAC, 17# it may be distributed under the Xiph.Org license, which is the least 18# restrictive of those mentioned above. See the file COPYING.Xiph in this 19# distribution. 20 21. ./common.sh 22 23PATH=../src/flac:$PATH 24PATH=../src/metaflac:$PATH 25PATH=../src/test_seeking:$PATH 26PATH=../src/test_streams:$PATH 27PATH=../objs/$BUILD/bin:$PATH 28 29if [ x"$FLAC__TEST_LEVEL" = x ] ; then 30 FLAC__TEST_LEVEL=1 31fi 32 33flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" 34metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" 35 36run_flac () 37{ 38 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then 39 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log 40 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 41 else 42 flac${EXE} --no-error-on-compression-fail $* 43 fi 44} 45 46run_metaflac () 47{ 48 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then 49 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log 50 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log 51 else 52 metaflac${EXE} $* 53 fi 54} 55 56run_test_seeking () 57{ 58 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then 59 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log 60 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log 61 else 62 test_seeking${EXE} $* 63 fi 64} 65 66echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C 67if 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 68 has_ogg=yes; 69else 70 has_ogg=no; 71fi 72echo ${has_ogg} 73 74echo "Generating streams..." 75if [ ! -f noise.raw ] ; then 76 test_streams || die "ERROR during test_streams" 77fi 78 79echo "generating FLAC files for seeking:" 80run_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" 81run_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" 82run_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" 83run_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" 84 85tiny_samples=`metaflac${EXE} --show-total-samples tiny.flac` 86small_samples=`metaflac${EXE} --show-total-samples small.flac` 87 88tiny_seek_count=100 89if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then 90 small_seek_count=10000 91else 92 small_seek_count=100 93fi 94 95for suffix in '' '-s' ; do 96 echo "testing tiny$suffix.flac:" 97 if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 98 die "ERROR: during test_seeking" 99 fi 100 101 echo "testing small$suffix.flac:" 102 if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else 103 die "ERROR: during test_seeking" 104 fi 105 106 echo "removing sample count from tiny$suffix.flac and small$suffix.flac:" 107 if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else 108 die "ERROR: during metaflac" 109 fi 110 111 echo "testing tiny$suffix.flac with total_samples=0:" 112 if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 113 die "ERROR: during test_seeking" 114 fi 115 116 echo "testing small$suffix.flac with total_samples=0:" 117 if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else 118 die "ERROR: during test_seeking" 119 fi 120done 121 122if [ $has_ogg = "yes" ] ; then 123 124 echo "generating Ogg FLAC files for seeking:" 125 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" 126 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" 127 # seek tables are not used in Ogg FLAC 128 129 echo "testing tiny.oga:" 130 if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 131 die "ERROR: during test_seeking" 132 fi 133 134 echo "testing small.oga:" 135 if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else 136 die "ERROR: during test_seeking" 137 fi 138 139fi 140 141rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac 142