3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001,2002 Josh Coalson
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.
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.
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.
26 LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
27 export LD_LIBRARY_PATH
28 PATH=../src/flac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH
30 flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
34 if [ "$FLAC__VALGRIND" = yes ] ; then
35 valgrind --leak-check=yes --show-reachable=yes --num-callers=10 --logfile-fd=4 flac $* 4>>valgrind.log
41 echo "Checking for --ogg support in flac..."
42 if 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
44 echo "flac --ogg works"
47 echo "flac --ogg doesn't work"
50 ############################################################################
51 # test --skip and --until
52 ############################################################################
55 # first make some chopped-up files
57 echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
58 dddie="die ERROR: creating files for --skip/--until tests"
59 dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
60 dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
61 dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
62 dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
63 dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
64 dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
65 dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
67 eopt="--silent --verify --lax --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
68 dopt="--silent --decode --force-raw-format --endian=big --sign=signed"
71 # test --skip when encoding
74 echo -n "testing --skip=# (encode)... "
75 run_flac $eopt --skip=10 -o z50c.skip10.flac 50c.raw || die "ERROR generating FLAC file"
76 run_flac $dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
77 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --skip=10 (encode)"
78 rm -f z50c.skip10.flac z50c.skip10.raw
81 echo -n "testing --skip=mm:ss (encode)... "
82 run_flac $eopt --skip=0:01 -o z50c.skip0:01.flac 50c.raw || die "ERROR generating FLAC file"
83 run_flac $dopt -o z50c.skip0:01.raw z50c.skip0:01.flac || die "ERROR decoding FLAC file"
84 cmp 50c.skip10.raw z50c.skip0:01.raw || die "ERROR: file mismatch for --skip=0:01 (encode)"
85 rm -f z50c.skip0:01.flac z50c.skip0:01.raw
88 echo -n "testing --skip=mm:ss.sss (encode)... "
89 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.flac 50c.raw || die "ERROR generating FLAC file"
90 run_flac $dopt -o z50c.skip0:01.1001.raw z50c.skip0:01.1001.flac || die "ERROR decoding FLAC file"
91 cmp 50c.skip11.raw z50c.skip0:01.1001.raw || die "ERROR: file mismatch for --skip=0:01.1001 (encode)"
92 rm -f z50c.skip0:01.1001.flac z50c.skip0:01.1001.raw
96 # test --skip when decoding
99 echo -n "testing --skip=# (decode)... "
100 run_flac $eopt -o z50c.flac 50c.raw || die "ERROR generating FLAC file"
101 run_flac $dopt --skip=10 -o z50c.skip10.raw z50c.flac || die "ERROR decoding FLAC file"
102 cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --skip=10 (decode)"
103 rm -f z50c.skip10.raw
106 echo -n "testing --skip=mm:ss (decode)... "
107 run_flac $dopt --skip=0:01 -o z50c.skip0:01.raw z50c.flac || die "ERROR decoding FLAC file"
108 cmp 50c.skip10.raw z50c.skip0:01.raw || die "ERROR: file mismatch for --skip=0:01 (decode)"
109 rm -f z50c.skip0:01.raw
112 echo -n "testing --skip=mm:ss.sss (decode)... "
113 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.raw z50c.flac || die "ERROR decoding FLAC file"
114 cmp 50c.skip11.raw z50c.skip0:01.1001.raw || die "ERROR: file mismatch for --skip=0:01.1001 (decode)"
115 rm -f z50c.skip0:01.1001.raw
121 # test --until when encoding
124 echo -n "testing --until=# (encode)... "
125 run_flac $eopt --until=40 -o z50c.until40.flac 50c.raw || die "ERROR generating FLAC file"
126 run_flac $dopt -o z50c.until40.raw z50c.until40.flac || die "ERROR decoding FLAC file"
127 cmp 50c.until40.raw z50c.until40.raw || die "ERROR: file mismatch for --until=40 (encode)"
128 rm -f z50c.until40.flac z50c.until40.raw
131 echo -n "testing --until=mm:ss (encode)... "
132 run_flac $eopt --until=0:04 -o z50c.until0:04.flac 50c.raw || die "ERROR generating FLAC file"
133 run_flac $dopt -o z50c.until0:04.raw z50c.until0:04.flac || die "ERROR decoding FLAC file"
134 cmp 50c.until40.raw z50c.until0:04.raw || die "ERROR: file mismatch for --until=0:04 (encode)"
135 rm -f z50c.until0:04.flac z50c.until0:04.raw
138 echo -n "testing --until=mm:ss.sss (encode)... "
139 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.flac 50c.raw || die "ERROR generating FLAC file"
140 run_flac $dopt -o z50c.until0:03.9001.raw z50c.until0:03.9001.flac || die "ERROR decoding FLAC file"
141 cmp 50c.until39.raw z50c.until0:03.9001.raw || die "ERROR: file mismatch for --until=0:03.9001 (encode)"
142 rm -f z50c.until0:03.9001.flac z50c.until0:03.9001.raw
145 echo -n "testing --until=-# (encode)... "
146 run_flac $eopt --until=-10 -o z50c.until-10.flac 50c.raw || die "ERROR generating FLAC file"
147 run_flac $dopt -o z50c.until-10.raw z50c.until-10.flac || die "ERROR decoding FLAC file"
148 cmp 50c.until40.raw z50c.until-10.raw || die "ERROR: file mismatch for --until=-10 (encode)"
149 rm -f z50c.until-10.flac z50c.until-10.raw
152 echo -n "testing --until=-mm:ss (encode)... "
153 run_flac $eopt --until=-0:01 -o z50c.until-0:01.flac 50c.raw || die "ERROR generating FLAC file"
154 run_flac $dopt -o z50c.until-0:01.raw z50c.until-0:01.flac || die "ERROR decoding FLAC file"
155 cmp 50c.until40.raw z50c.until-0:01.raw || die "ERROR: file mismatch for --until=-0:01 (encode)"
156 rm -f z50c.until-0:01.flac z50c.until-0:01.raw
159 echo -n "testing --until=-mm:ss.sss (encode)... "
160 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.flac 50c.raw || die "ERROR generating FLAC file"
161 run_flac $dopt -o z50c.until-0:01.1001.raw z50c.until-0:01.1001.flac || die "ERROR decoding FLAC file"
162 cmp 50c.until39.raw z50c.until-0:01.1001.raw || die "ERROR: file mismatch for --until=-0:01.1001 (encode)"
163 rm -f z50c.until-0:01.1001.flac z50c.until-0:01.1001.raw
167 # test --until when decoding
170 run_flac $eopt -o z50c.flac 50c.raw || die "ERROR generating FLAC file"
172 echo -n "testing --until=# (decode)... "
173 run_flac $dopt --until=40 -o z50c.until40.raw z50c.flac || die "ERROR decoding FLAC file"
174 cmp 50c.until40.raw z50c.until40.raw || die "ERROR: file mismatch for --until=40 (decode)"
175 rm -f z50c.until40.raw
178 echo -n "testing --until=mm:ss (decode)... "
179 run_flac $dopt --until=0:04 -o z50c.until0:04.raw z50c.flac || die "ERROR decoding FLAC file"
180 cmp 50c.until40.raw z50c.until0:04.raw || die "ERROR: file mismatch for --until=0:04 (decode)"
181 rm -f z50c.until0:04.raw
184 echo -n "testing --until=mm:ss.sss (decode)... "
185 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.raw z50c.flac || die "ERROR decoding FLAC file"
186 cmp 50c.until39.raw z50c.until0:03.9001.raw || die "ERROR: file mismatch for --until=0:03.9001 (decode)"
187 rm -f z50c.until0:03.9001.raw
190 echo -n "testing --until=-# (decode)... "
191 run_flac $dopt --until=-10 -o z50c.until-10.raw z50c.flac || die "ERROR decoding FLAC file"
192 cmp 50c.until40.raw z50c.until-10.raw || die "ERROR: file mismatch for --until=-10 (decode)"
193 rm -f z50c.until-10.raw
196 echo -n "testing --until=-mm:ss (decode)... "
197 run_flac $dopt --until=-0:01 -o z50c.until-0:01.raw z50c.flac || die "ERROR decoding FLAC file"
198 cmp 50c.until40.raw z50c.until-0:01.raw || die "ERROR: file mismatch for --until=-0:01 (decode)"
199 rm -f z50c.until-0:01.raw
202 echo -n "testing --until=-mm:ss.sss (decode)... "
203 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.raw z50c.flac || die "ERROR decoding FLAC file"
204 cmp 50c.until39.raw z50c.until-0:01.1001.raw || die "ERROR: file mismatch for --until=-0:01.1001 (decode)"
205 rm -f z50c.until-0:01.1001.raw
211 # test --skip and --until when encoding
214 echo -n "testing --skip=10 --until=# (encode)... "
215 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.flac 50c.raw || die "ERROR generating FLAC file"
216 run_flac $dopt -o z50c.skip10.until40.raw z50c.skip10.until40.flac || die "ERROR decoding FLAC file"
217 cmp 50c.skip10.until40.raw z50c.skip10.until40.raw || die "ERROR: file mismatch for --skip=10 --until=40 (encode)"
218 rm -f z50c.skip10.until40.flac z50c.skip10.until40.raw
221 echo -n "testing --skip=10 --until=mm:ss (encode)... "
222 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.flac 50c.raw || die "ERROR generating FLAC file"
223 run_flac $dopt -o z50c.skip10.until0:04.raw z50c.skip10.until0:04.flac || die "ERROR decoding FLAC file"
224 cmp 50c.skip10.until40.raw z50c.skip10.until0:04.raw || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode)"
225 rm -f z50c.skip10.until0:04.flac z50c.skip10.until0:04.raw
228 echo -n "testing --skip=10 --until=mm:ss.sss (encode)... "
229 run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.flac 50c.raw || die "ERROR generating FLAC file"
230 run_flac $dopt -o z50c.skip10.until0:03.9001.raw z50c.skip10.until0:03.9001.flac || die "ERROR decoding FLAC file"
231 cmp 50c.skip10.until39.raw z50c.skip10.until0:03.9001.raw || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode)"
232 rm -f z50c.skip10.until0:03.9001.flac z50c.skip10.until0:03.9001.raw
235 echo -n "testing --skip=10 --until=+# (encode)... "
236 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.flac 50c.raw || die "ERROR generating FLAC file"
237 run_flac $dopt -o z50c.skip10.until+30.raw z50c.skip10.until+30.flac || die "ERROR decoding FLAC file"
238 cmp 50c.skip10.until40.raw z50c.skip10.until+30.raw || die "ERROR: file mismatch for --skip=10 --until=+30 (encode)"
239 rm -f z50c.skip10.until+30.flac z50c.skip10.until+30.raw
242 echo -n "testing --skip=10 --until=+mm:ss (encode)... "
243 run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0:03.flac 50c.raw || die "ERROR generating FLAC file"
244 run_flac $dopt -o z50c.skip10.until+0:03.raw z50c.skip10.until+0:03.flac || die "ERROR decoding FLAC file"
245 cmp 50c.skip10.until40.raw z50c.skip10.until+0:03.raw || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode)"
246 rm -f z50c.skip10.until+0:03.flac z50c.skip10.until+0:03.raw
249 echo -n "testing --skip=10 --until=+mm:ss.sss (encode)... "
250 run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0:02.9001.flac 50c.raw || die "ERROR generating FLAC file"
251 run_flac $dopt -o z50c.skip10.until+0:02.9001.raw z50c.skip10.until+0:02.9001.flac || die "ERROR decoding FLAC file"
252 cmp 50c.skip10.until39.raw z50c.skip10.until+0:02.9001.raw || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode)"
253 rm -f z50c.skip10.until+0:02.9001.flac z50c.skip10.until+0:02.9001.raw
256 echo -n "testing --skip=10 --until=-# (encode)... "
257 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.flac 50c.raw || die "ERROR generating FLAC file"
258 run_flac $dopt -o z50c.skip10.until-10.raw z50c.skip10.until-10.flac || die "ERROR decoding FLAC file"
259 cmp 50c.skip10.until40.raw z50c.skip10.until-10.raw || die "ERROR: file mismatch for --skip=10 --until=-10 (encode)"
260 rm -f z50c.skip10.until-10.flac z50c.skip10.until-10.raw
263 echo -n "testing --skip=10 --until=-mm:ss (encode)... "
264 run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.flac 50c.raw || die "ERROR generating FLAC file"
265 run_flac $dopt -o z50c.skip10.until-0:01.raw z50c.skip10.until-0:01.flac || die "ERROR decoding FLAC file"
266 cmp 50c.skip10.until40.raw z50c.skip10.until-0:01.raw || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode)"
267 rm -f z50c.skip10.until-0:01.flac z50c.skip10.until-0:01.raw
270 echo -n "testing --skip=10 --until=-mm:ss.sss (encode)... "
271 run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.flac 50c.raw || die "ERROR generating FLAC file"
272 run_flac $dopt -o z50c.skip10.until-0:01.1001.raw z50c.skip10.until-0:01.1001.flac || die "ERROR decoding FLAC file"
273 cmp 50c.skip10.until39.raw z50c.skip10.until-0:01.1001.raw || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode)"
274 rm -f z50c.skip10.until-0:01.1001.flac z50c.skip10.until-0:01.1001.raw
278 # test --skip and --until when decoding
281 run_flac $eopt -o z50c.flac 50c.raw || die "ERROR generating FLAC file"
283 echo -n "testing --skip=10 --until=# (decode)... "
284 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.raw z50c.flac || die "ERROR decoding FLAC file"
285 cmp 50c.skip10.until40.raw z50c.skip10.until40.raw || die "ERROR: file mismatch for --skip=10 --until=40 (decode)"
286 rm -f z50c.skip10.until40.raw
289 echo -n "testing --skip=10 --until=mm:ss (decode)... "
290 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.raw z50c.flac || die "ERROR decoding FLAC file"
291 cmp 50c.skip10.until40.raw z50c.skip10.until0:04.raw || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode)"
292 rm -f z50c.skip10.until0:04.raw
295 echo -n "testing --skip=10 --until=mm:ss.sss (decode)... "
296 run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.raw z50c.flac || die "ERROR decoding FLAC file"
297 cmp 50c.skip10.until39.raw z50c.skip10.until0:03.9001.raw || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode)"
298 rm -f z50c.skip10.until0:03.9001.raw
301 echo -n "testing --skip=10 --until=-# (decode)... "
302 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.raw z50c.flac || die "ERROR decoding FLAC file"
303 cmp 50c.skip10.until40.raw z50c.skip10.until-10.raw || die "ERROR: file mismatch for --skip=10 --until=-10 (decode)"
304 rm -f z50c.skip10.until-10.raw
307 echo -n "testing --skip=10 --until=-mm:ss (decode)... "
308 run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.raw z50c.flac || die "ERROR decoding FLAC file"
309 cmp 50c.skip10.until40.raw z50c.skip10.until-0:01.raw || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode)"
310 rm -f z50c.skip10.until-0:01.raw
313 echo -n "testing --skip=10 --until=-mm:ss.sss (decode)... "
314 run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.raw z50c.flac || die "ERROR decoding FLAC file"
315 cmp 50c.skip10.until39.raw z50c.skip10.until-0:01.1001.raw || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode)"
316 rm -f z50c.skip10.until-0:01.1001.raw
328 echo "Generating streams..."
329 if [ ! -f wacky1.wav ] ; then
330 test_streams || die "ERROR during test_streams"
333 echo "Generating multiple input files from noise..."
334 run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw || die "ERROR generating FLAC file"
335 run_flac --decode --silent noise.flac || die "ERROR generating WAVE file"
337 mv noise.wav file0.wav
338 cp file0.wav file1.wav
339 cp file1.wav file2.wav
347 if [ $streamtype = ogg ] ; then
349 encode_options="$encode_options --ogg"
354 if [ $sector_align = sector_align ] ; then
355 encode_options="$encode_options --sector-align"
358 run_flac $encode_options file0.wav file1.wav file2.wav || die "ERROR"
360 mv file$n.$suffix file${n}x.$suffix
362 run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
363 if [ $sector_align != sector_align ] ; then
365 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
369 rm -f file${n}x.$suffix file${n}x.wav
373 echo "Testing multiple files without verify..."
374 test_multifile flac no_sector_align ""
376 echo "Testing multiple files with verify..."
377 test_multifile flac no_sector_align "--verify"
379 echo "Testing multiple files with --sector-align, without verify..."
380 test_multifile flac sector_align ""
382 echo "Testing multiple files with --sector-align, with verify..."
383 test_multifile flac sector_align "--verify"
385 if [ $has_ogg = "yes" ] ; then
386 echo "Testing multiple files with --ogg, without verify..."
387 test_multifile ogg no_sector_align ""
389 echo "Testing multiple files with --ogg, with verify..."
390 test_multifile ogg no_sector_align "--verify"
392 echo "Testing multiple files with --ogg and --sector-align, without verify..."
393 test_multifile ogg sector_align ""
395 echo "Testing multiple files with --ogg and --sector-align, with verify..."
396 test_multifile sector_align ogg "--verify"
398 echo "Testing multiple files with --ogg and --serial-number, with verify..."
399 test_multifile ogg no_sector_align "--serial-number=321 --verify"