Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 1 | #!/bin/sh -e |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 2 | |
| 3 | # FLAC - Free Lossless Audio Codec |
Erik de Castro Lopo | b1982fb | 2013-05-25 17:11:19 +1000 | [diff] [blame] | 4 | # Copyright (C) 2004-2009 Josh Coalson |
Erik de Castro Lopo | 6a5fe43 | 2016-12-05 06:35:39 +1100 | [diff] [blame] | 5 | # Copyright (C) 2011-2016 Xiph.Org Foundation |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 6 | # |
| 7 | # This file is part the FLAC project. FLAC is comprised of several |
Ulrich Klauer | cd4ddab | 2013-05-26 22:53:43 +0200 | [diff] [blame] | 8 | # components distributed under different licenses. The codec libraries |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 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 | |
Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 21 | . ./common.sh |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 22 | |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 23 | PATH=../src/flac:$PATH |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 24 | PATH=../src/metaflac:$PATH |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 25 | PATH=../src/test_seeking:$PATH |
| 26 | PATH=../src/test_streams:$PATH |
Erik de Castro Lopo | 85d5c53 | 2013-01-02 22:37:42 +1100 | [diff] [blame] | 27 | PATH=../objs/$BUILD/bin:$PATH |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 28 | |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 29 | if [ x"$FLAC__TEST_LEVEL" = x ] ; then |
| 30 | FLAC__TEST_LEVEL=1 |
| 31 | fi |
| 32 | |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 33 | flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" |
| 34 | metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 35 | |
| 36 | run_flac () |
| 37 | { |
Josh Coalson | de9091e | 2006-05-25 02:48:22 +0000 | [diff] [blame] | 38 | if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then |
Martijn van Beurden | f6585b0 | 2013-04-21 23:12:16 +0200 | [diff] [blame] | 39 | echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 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 |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 41 | else |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 42 | flac${EXE} --no-error-on-compression-fail $* |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 43 | fi |
| 44 | } |
| 45 | |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 46 | run_metaflac () |
| 47 | { |
Josh Coalson | de9091e | 2006-05-25 02:48:22 +0000 | [diff] [blame] | 48 | if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then |
Martijn van Beurden | f6585b0 | 2013-04-21 23:12:16 +0200 | [diff] [blame] | 49 | echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 50 | valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 51 | else |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 52 | metaflac${EXE} $* |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 53 | fi |
| 54 | } |
| 55 | |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 56 | run_test_seeking () |
| 57 | { |
Josh Coalson | de9091e | 2006-05-25 02:48:22 +0000 | [diff] [blame] | 58 | if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then |
Martijn van Beurden | f6585b0 | 2013-04-21 23:12:16 +0200 | [diff] [blame] | 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 |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 61 | else |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 62 | test_seeking${EXE} $* |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 63 | fi |
| 64 | } |
| 65 | |
Erik de Castro Lopo | efaab3c | 2015-10-04 09:43:33 +1100 | [diff] [blame] | 66 | echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 67 | 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 |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 68 | has_ogg=yes; |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 69 | else |
| 70 | has_ogg=no; |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 71 | fi |
Erik de Castro Lopo | d6fa290 | 2013-09-15 19:58:35 +1000 | [diff] [blame] | 72 | echo ${has_ogg} |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 73 | |
| 74 | echo "Generating streams..." |
| 75 | if [ ! -f noise.raw ] ; then |
| 76 | test_streams || die "ERROR during test_streams" |
| 77 | fi |
| 78 | |
| 79 | echo "generating FLAC files for seeking:" |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 80 | 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" |
| 81 | 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" |
| 82 | 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" |
| 83 | 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" |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 84 | |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 85 | tiny_samples=`metaflac${EXE} --show-total-samples tiny.flac` |
| 86 | small_samples=`metaflac${EXE} --show-total-samples small.flac` |
Josh Coalson | f8d544f | 2006-11-16 01:22:33 +0000 | [diff] [blame] | 87 | |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 88 | tiny_seek_count=100 |
| 89 | if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then |
| 90 | small_seek_count=10000 |
| 91 | else |
Erik de Castro Lopo | 774e077 | 2012-02-26 12:19:39 +1100 | [diff] [blame] | 92 | small_seek_count=100 |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 93 | fi |
| 94 | |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 95 | for suffix in '' '-s' ; do |
| 96 | echo "testing tiny$suffix.flac:" |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 97 | if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 98 | die "ERROR: during test_seeking" |
| 99 | fi |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 100 | |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 101 | echo "testing small$suffix.flac:" |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 102 | if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 103 | die "ERROR: during test_seeking" |
| 104 | fi |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 105 | |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 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 |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 110 | |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 111 | echo "testing tiny$suffix.flac with total_samples=0:" |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 112 | if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 113 | die "ERROR: during test_seeking" |
| 114 | fi |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 115 | |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 116 | echo "testing small$suffix.flac with total_samples=0:" |
Josh Coalson | 5c24bb8 | 2007-06-16 00:43:15 +0000 | [diff] [blame] | 117 | if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else |
Josh Coalson | 6b21f66 | 2006-09-13 01:42:27 +0000 | [diff] [blame] | 118 | die "ERROR: during test_seeking" |
| 119 | fi |
| 120 | done |
Josh Coalson | 450572f | 2005-01-26 03:48:06 +0000 | [diff] [blame] | 121 | |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 122 | if [ $has_ogg = "yes" ] ; then |
| 123 | |
Josh Coalson | 461899f | 2005-09-03 02:16:07 +0000 | [diff] [blame] | 124 | echo "generating Ogg FLAC files for seeking:" |
Josh Coalson | 12d3a41 | 2007-08-01 03:02:00 +0000 | [diff] [blame] | 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" |
Josh Coalson | 0b9442c | 2006-10-16 16:18:34 +0000 | [diff] [blame] | 127 | # seek tables are not used in Ogg FLAC |
Josh Coalson | 461899f | 2005-09-03 02:16:07 +0000 | [diff] [blame] | 128 | |
Josh Coalson | 12d3a41 | 2007-08-01 03:02:00 +0000 | [diff] [blame] | 129 | echo "testing tiny.oga:" |
| 130 | if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 131 | die "ERROR: during test_seeking" |
| 132 | fi |
| 133 | |
Josh Coalson | 12d3a41 | 2007-08-01 03:02:00 +0000 | [diff] [blame] | 134 | echo "testing small.oga:" |
| 135 | if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else |
Josh Coalson | 7ffd7e4 | 2005-02-01 01:49:11 +0000 | [diff] [blame] | 136 | die "ERROR: during test_seeking" |
| 137 | fi |
| 138 | |
Josh Coalson | b42b0ee | 2004-11-09 01:27:12 +0000 | [diff] [blame] | 139 | fi |
| 140 | |
Josh Coalson | 12d3a41 | 2007-08-01 03:02:00 +0000 | [diff] [blame] | 141 | rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac |