blob: b3cf62476499ecc987db74062650a9e370e4a008 [file] [log] [blame]
Josh Coalsonb42b0ee2004-11-09 01:27:12 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
Josh Coalsone74bd952007-02-02 06:58:19 +00004# Copyright (C) 2004,2005,2006,2007 Josh Coalson
Josh Coalsonb42b0ee2004-11-09 01:27:12 +00005#
6# This file is part the FLAC project. FLAC is comprised of several
7# components distributed under difference licenses. The codec libraries
8# are distributed under Xiph.Org's BSD-like license (see the file
9# COPYING.Xiph in this distribution). All other programs, libraries, and
10# plugins are distributed under the GPL (see COPYING.GPL). The documentation
11# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
12# FLAC distribution contains at the top the terms under which it may be
13# distributed.
14#
15# Since this particular file is relevant to all components of FLAC,
16# it may be distributed under the Xiph.Org license, which is the least
17# restrictive of those mentioned above. See the file COPYING.Xiph in this
18# distribution.
19
20die ()
21{
22 echo $* 1>&2
23 exit 1
24}
25
26if [ x = x"$1" ] ; then
27 BUILD=debug
28else
29 BUILD="$1"
30fi
31
32LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000033LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
34export LD_LIBRARY_PATH
35PATH=../src/flac:$PATH
Josh Coalson450572f2005-01-26 03:48:06 +000036PATH=../src/metaflac:$PATH
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000037PATH=../src/test_seeking:$PATH
38PATH=../src/test_streams:$PATH
39PATH=../obj/$BUILD/bin:$PATH
40
41flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalson450572f2005-01-26 03:48:06 +000042metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000043
44run_flac ()
45{
Josh Coalsonde9091e2006-05-25 02:48:22 +000046 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000047 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 flac $*" >>test_seeking.valgrind.log
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000048 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_seeking.valgrind.log
49 else
50 flac $*
51 fi
52}
53
Josh Coalson450572f2005-01-26 03:48:06 +000054run_metaflac ()
55{
Josh Coalsonde9091e2006-05-25 02:48:22 +000056 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000057 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 metaflac $*" >>test_seeking.valgrind.log
Josh Coalson450572f2005-01-26 03:48:06 +000058 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_seeking.valgrind.log
59 else
60 metaflac $*
61 fi
62}
63
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000064run_test_seeking ()
65{
Josh Coalsonde9091e2006-05-25 02:48:22 +000066 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000067 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_seeking $*" >>test_seeking.valgrind.log
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000068 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_seeking $* 4>>test_seeking.valgrind.log
69 else
70 test_seeking $*
71 fi
72}
73
Josh Coalson7ffd7e42005-02-01 01:49:11 +000074echo "Checking for --ogg support in flac..."
75if 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
76 has_ogg=yes;
77 echo "flac --ogg works"
78else
79 has_ogg=no;
80 echo "flac --ogg doesn't work"
81fi
82
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000083
84echo "Generating streams..."
85if [ ! -f noise.raw ] ; then
86 test_streams || die "ERROR during test_streams"
87fi
88
89echo "generating FLAC files for seeking:"
Josh Coalson6b21f662006-09-13 01:42:27 +000090run_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"
91run_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"
92run_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"
93run_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 Coalsonb42b0ee2004-11-09 01:27:12 +000094
Josh Coalsonf8d544f2006-11-16 01:22:33 +000095tiny_samples=`metaflac --show-total-samples tiny.flac`
96small_samples=`metaflac --show-total-samples small.flac`
97
Josh Coalson6b21f662006-09-13 01:42:27 +000098for suffix in '' '-s' ; do
99 echo "testing tiny$suffix.flac:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000100 if run_test_seeking tiny$suffix.flac 100 $tiny_samples ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000101 die "ERROR: during test_seeking"
102 fi
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000103
Josh Coalson6b21f662006-09-13 01:42:27 +0000104 echo "testing small$suffix.flac:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000105 if run_test_seeking small$suffix.flac 1000 $small_samples ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000106 die "ERROR: during test_seeking"
107 fi
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000108
Josh Coalson6b21f662006-09-13 01:42:27 +0000109 echo "removing sample count from tiny$suffix.flac and small$suffix.flac:"
110 if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else
111 die "ERROR: during metaflac"
112 fi
Josh Coalson450572f2005-01-26 03:48:06 +0000113
Josh Coalson6b21f662006-09-13 01:42:27 +0000114 echo "testing tiny$suffix.flac with total_samples=0:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000115 if run_test_seeking tiny$suffix.flac 100 $tiny_samples ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000116 die "ERROR: during test_seeking"
117 fi
Josh Coalson450572f2005-01-26 03:48:06 +0000118
Josh Coalson6b21f662006-09-13 01:42:27 +0000119 echo "testing small$suffix.flac with total_samples=0:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000120 if run_test_seeking small$suffix.flac 1000 $small_samples ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000121 die "ERROR: during test_seeking"
122 fi
123done
Josh Coalson450572f2005-01-26 03:48:06 +0000124
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000125if [ $has_ogg = "yes" ] ; then
126
Josh Coalson461899f2005-09-03 02:16:07 +0000127 echo "generating Ogg FLAC files for seeking:"
128 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.ogg --ogg noise8m32.raw || die "ERROR generating Ogg FLAC file"
129 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.ogg --ogg noise.raw || die "ERROR generating Ogg FLAC file"
Josh Coalson0b9442c2006-10-16 16:18:34 +0000130 # seek tables are not used in Ogg FLAC
Josh Coalson461899f2005-09-03 02:16:07 +0000131
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000132 echo "testing tiny.ogg:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000133 if run_test_seeking tiny.ogg 100 $tiny_samples ; then : ; else
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000134 die "ERROR: during test_seeking"
135 fi
136
137 echo "testing small.ogg:"
Josh Coalsonf8d544f2006-11-16 01:22:33 +0000138 if run_test_seeking small.ogg 1000 $small_samples ; then : ; else
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000139 die "ERROR: during test_seeking"
140 fi
141
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000142fi
143
Josh Coalson6b21f662006-09-13 01:42:27 +0000144rm -f tiny.flac tiny.ogg small.flac small.ogg tiny-s.flac small-s.flac