blob: 4c8025042fd24fcf709d98cd96f11829bcd538ff [file] [log] [blame]
Josh Coalson463d0f82002-12-10 06:41:27 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
4# Copyright (C) 2001,2002 Josh Coalson
5#
6# This program is part of FLAC; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
21export LD_LIBRARY_PATH
22PATH=../src/flac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH
23
24flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
25if [ $? != 0 ] ; then exit 1 ; fi
26
27run_flac ()
28{
29 if [ "$FLAC__VALGRIND" = yes ] ; then
30 valgrind --leak-check=yes --show-reachable=yes --num-callers=10 --logfile-fd=4 flac $* 4>>valgrind.log
31 else
32 flac $*
33 fi
34}
35
36echo "Checking for --ogg support in flac..."
37if 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
38 has_ogg=yes;
39 echo "flac --ogg works"
40else
41 has_ogg=no;
42 echo "flac --ogg doesn't work"
43fi
44
45#
46# test --skip
47#
48echo "123456789012345678901234567890123456789" > 39c.raw
49echo "012345678901234567890123456789012345678" > 39cu.raw
50echo "0123456789012345678901234567890123456789" > 40c.raw
51echo "01234567890123456789012345678901234567890123456789" > 50c.raw
52
53# test encode --skip=#
54echo "testing --skip=# (encode)"
55if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=10 -o 50c.skip10.flac 50c.raw ; then : ; else
56 echo "ERROR generating FLAC file" 1>&2
57 exit 1
58fi
59if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip10.raw 50c.skip10.flac ; then : ; else
60 echo "ERROR decoding FLAC file" 1>&2
61 exit 1
62fi
63if cmp 40c.raw 50c.skip10.raw ; then : ; else
64 echo "ERROR: file mismatch for --skip=10 (encode)" 1>&2
65 exit 1
66fi
67rm -f 50c.skip10.flac 50c.skip10.raw
68echo OK
69
70# test encode --skip=mm:ss
71echo "testing --skip=mm:ss (encode)"
72if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=0:01 -o 50c.skip0:01.flac 50c.raw ; then : ; else
73 echo "ERROR generating FLAC file" 1>&2
74 exit 1
75fi
76if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip0:01.raw 50c.skip0:01.flac ; then : ; else
77 echo "ERROR decoding FLAC file" 1>&2
78 exit 1
79fi
80if cmp 40c.raw 50c.skip0:01.raw ; then : ; else
81 echo "ERROR: file mismatch for --skip=0:01 (encode)" 1>&2
82 exit 1
83fi
84rm -f 50c.skip0:01.flac 50c.skip0:01.raw
85echo OK
86
87# test encode --skip=mm:ss.sss
88echo "testing --skip=mm:ss.sss (encode)"
89if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 --skip=0:01.1 -o 50c.skip0:01.1.flac 50c.raw ; then : ; else
90 echo "ERROR generating FLAC file" 1>&2
91 exit 1
92fi
93if run_flac --silent --decode --force-raw-format --endian=big --sign=signed -o 50c.skip0:01.1.raw 50c.skip0:01.1.flac ; then : ; else
94 echo "ERROR decoding FLAC file" 1>&2
95 exit 1
96fi
97if cmp 39c.raw 50c.skip0:01.1.raw ; then : ; else
98 echo "ERROR: file mismatch for --skip=0:01.1 (encode)" 1>&2
99 exit 1
100fi
101rm -f 50c.skip0:01.1.flac 50c.skip0:01.1.raw
102echo OK
103
104# test decode --skip=#
105echo "testing --skip=# (decode)"
106if run_flac --silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1 -o 50c.flac 50c.raw ; then : ; else
107 echo "ERROR generating FLAC file" 1>&2
108 exit 1
109fi
110if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=10 -o 50c.skip10.raw 50c.flac ; then : ; else
111 echo "ERROR decoding FLAC file" 1>&2
112 exit 1
113fi
114if cmp 40c.raw 50c.skip10.raw ; then : ; else
115 echo "ERROR: file mismatch for --skip=10 (decode)" 1>&2
116 exit 1
117fi
118rm -f 50c.skip10.raw
119echo OK
120
121# test decode --skip=mm:ss
122echo "testing --skip=mm:ss (decode)"
123if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=0:01 -o 50c.skip0:01.raw 50c.flac ; then : ; else
124 echo "ERROR decoding FLAC file" 1>&2
125 exit 1
126fi
127if cmp 40c.raw 50c.skip0:01.raw ; then : ; else
128 echo "ERROR: file mismatch for --skip=0:01 (decode)" 1>&2
129 exit 1
130fi
131rm -f 50c.skip0:01.raw
132echo OK
133
134# test decode --skip=mm:ss.sss
135echo "testing --skip=mm:ss.sss (decode)"
136if run_flac --silent --decode --force-raw-format --endian=big --sign=signed --skip=0:01.1 -o 50c.skip0:01.1.raw 50c.flac ; then : ; else
137 echo "ERROR decoding FLAC file" 1>&2
138 exit 1
139fi
140if cmp 39c.raw 50c.skip0:01.1.raw ; then : ; else
141 echo "ERROR: file mismatch for --skip=0:01.1 (decode)" 1>&2
142 exit 1
143fi
144rm -f 50c.skip0:01.1.raw
145echo OK
146
147rm -f 50c.flac
148
149
150#
151# multi-file tests
152#
153
154echo "Generating streams..."
155if [ ! -f wacky1.wav ] ; then
156 if test_streams ; then : ; else
157 echo "ERROR during test_streams" 1>&2
158 exit 1
159 fi
160fi
161
162echo "Generating multiple input files from noise..."
163if run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw ; then : ; else
164 echo "ERROR generating FLAC file" 1>&2
165 exit 1
166fi
167if run_flac --decode --silent noise.flac ; then : ; else
168 echo "ERROR generating WAVE file" 1>&2
169 exit 1
170fi
171rm -f noise.flac
172mv noise.wav file0.wav
173cp file0.wav file1.wav
174cp file1.wav file2.wav
175
176test_multifile ()
177{
178 streamtype=$1
179 sector_align=$2
180 encode_options="$3"
181
182 if [ $streamtype = ogg ] ; then
183 suffix=ogg
184 encode_options="$encode_options --ogg"
185 else
186 suffix=flac
187 fi
188
189 if [ $sector_align = sector_align ] ; then
190 encode_options="$encode_options --sector-align"
191 fi
192
193 if run_flac $encode_options file0.wav file1.wav file2.wav ; then : ; else
194 echo "ERROR" 1>&2
195 exit 1
196 fi
197 for n in 0 1 2 ; do
198 mv file$n.$suffix file${n}x.$suffix
199 done
200 if run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix ; then : ; else
201 echo "ERROR" 1>&2
202 exit 1
203 fi
204 if [ $sector_align != sector_align ] ; then
205 for n in 0 1 2 ; do
206 if cmp file$n.wav file${n}x.wav ; then : ; else
207 echo "ERROR: file mismatch on file #$n" 1>&2
208 exit 1
209 fi
210 done
211 fi
212 for n in 0 1 2 ; do
213 rm -f file${n}x.$suffix file${n}x.wav
214 done
215}
216
217echo "Testing multiple files without verify..."
218test_multifile flac no_sector_align ""
219
220echo "Testing multiple files with verify..."
221test_multifile flac no_sector_align "--verify"
222
223echo "Testing multiple files with --sector-align, without verify..."
224test_multifile flac sector_align ""
225
226echo "Testing multiple files with --sector-align, with verify..."
227test_multifile flac sector_align "--verify"
228
229if [ $has_ogg = "yes" ] ; then
230 echo "Testing multiple files with --ogg, without verify..."
231 test_multifile ogg no_sector_align ""
232
233 echo "Testing multiple files with --ogg, with verify..."
234 test_multifile ogg no_sector_align "--verify"
235
236 echo "Testing multiple files with --ogg and --sector-align, without verify..."
237 test_multifile ogg sector_align ""
238
239 echo "Testing multiple files with --ogg and --sector-align, with verify..."
240 test_multifile sector_align ogg "--verify"
241
242 echo "Testing multiple files with --ogg and --serial-number, with verify..."
243 test_multifile ogg no_sector_align "--serial-number=321 --verify"
244fi