blob: b85cff951cc0a95a3547596371b5a708cbd14065 [file] [log] [blame]
Josh Coalsonb42b0ee2004-11-09 01:27:12 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
Josh Coalsona78fac62005-01-25 04:17:55 +00004# Copyright (C) 2004,2005 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
33LD_LIBRARY_PATH=../src/libOggFLAC/.libs:$LD_LIBRARY_PATH
34LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
35export LD_LIBRARY_PATH
36PATH=../src/flac:$PATH
Josh Coalson450572f2005-01-26 03:48:06 +000037PATH=../src/metaflac:$PATH
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000038PATH=../src/test_seeking:$PATH
39PATH=../src/test_streams:$PATH
40PATH=../obj/$BUILD/bin:$PATH
41
42flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalson450572f2005-01-26 03:48:06 +000043metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000044
45run_flac ()
46{
47 if [ x"$FLAC__VALGRIND" = xyes ] ; then
48 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{
56 if [ x"$FLAC__VALGRIND" = xyes ] ; then
57 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_seeking.valgrind.log
58 else
59 metaflac $*
60 fi
61}
62
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000063run_test_seeking ()
64{
65 if [ x"$FLAC__VALGRIND" = xyes ] ; then
66 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_seeking $* 4>>test_seeking.valgrind.log
67 else
68 test_seeking $*
69 fi
70}
71
Josh Coalson7ffd7e42005-02-01 01:49:11 +000072echo "Checking for --ogg support in flac..."
73if 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
74 has_ogg=yes;
75 echo "flac --ogg works"
76else
77 has_ogg=no;
78 echo "flac --ogg doesn't work"
79fi
80
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000081
82echo "Generating streams..."
83if [ ! -f noise.raw ] ; then
84 test_streams || die "ERROR during test_streams"
85fi
86
87echo "generating FLAC files for seeking:"
88run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.flac noise8m32.raw || die "ERROR generating FLAC file"
89run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.flac noise.raw || die "ERROR generating FLAC file"
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000090
91echo "testing tiny.flac:"
92if run_test_seeking tiny.flac 100 ; then : ; else
93 die "ERROR: during test_seeking"
94fi
95
96echo "testing small.flac:"
97if run_test_seeking small.flac 1000 ; then : ; else
98 die "ERROR: during test_seeking"
99fi
100
Josh Coalson450572f2005-01-26 03:48:06 +0000101echo "removing sample count from tiny.flac and small.flac:"
102if run_metaflac --no-filename --set-total-samples=0 tiny.flac small.flac ; then : ; else
103 die "ERROR: during metaflac"
104fi
105
106echo "testing tiny.flac with total_samples=0:"
107if run_test_seeking tiny.flac 100 ; then : ; else
108 die "ERROR: during test_seeking"
109fi
110
111echo "testing small.flac with total_samples=0:"
112if run_test_seeking small.flac 1000 ; then : ; else
113 die "ERROR: during test_seeking"
114fi
115
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000116if [ $has_ogg = "yes" ] ; then
117
Josh Coalson461899f2005-09-03 02:16:07 +0000118 echo "generating Ogg FLAC files for seeking:"
119 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"
120 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"
121
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000122 echo "testing tiny.ogg:"
123 if run_test_seeking tiny.ogg 100 ; then : ; else
124 die "ERROR: during test_seeking"
125 fi
126
127 echo "testing small.ogg:"
128 if run_test_seeking small.ogg 1000 ; then : ; else
129 die "ERROR: during test_seeking"
130 fi
131
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000132fi
133
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000134rm -f tiny.flac tiny.ogg small.flac small.ogg