blob: 27300fc5a50e9ca0d60c4ad863d5202aa0355e36 [file] [log] [blame]
Josh Coalson463d0f82002-12-10 06:41:27 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
Josh Coalson95643902004-01-17 04:14:43 +00004# Copyright (C) 2001,2002,2003,2004 Josh Coalson
Josh Coalson463d0f82002-12-10 06:41:27 +00005#
Josh Coalsone8a76012003-02-07 00:14:32 +00006# 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.
Josh Coalson463d0f82002-12-10 06:41:27 +000014#
Josh Coalsone8a76012003-02-07 00:14:32 +000015# 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.
Josh Coalson463d0f82002-12-10 06:41:27 +000019
Josh Coalson8fac5d62002-12-12 03:57:47 +000020die ()
21{
22 echo $* 1>&2
23 exit 1
24}
25
Josh Coalson463d0f82002-12-10 06:41:27 +000026LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
27export LD_LIBRARY_PATH
28PATH=../src/flac:../src/test_streams:../obj/release/bin:../obj/debug/bin:$PATH
29
Josh Coalson8fac5d62002-12-12 03:57:47 +000030flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
Josh Coalson463d0f82002-12-10 06:41:27 +000031
32run_flac ()
33{
Josh Coalsonecf57b72003-01-14 09:00:25 +000034 if [ x"$FLAC__VALGRIND" = xyes ] ; then
Josh Coalson80936c52002-12-30 23:31:47 +000035 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
Josh Coalson463d0f82002-12-10 06:41:27 +000036 else
37 flac $*
38 fi
39}
40
41echo "Checking for --ogg support in flac..."
42if 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
43 has_ogg=yes;
44 echo "flac --ogg works"
45else
46 has_ogg=no;
47 echo "flac --ogg doesn't work"
48fi
49
Josh Coalson5126bb02002-12-17 08:15:48 +000050
51echo "Generating streams..."
52if [ ! -f wacky1.wav ] ; then
53 test_streams || die "ERROR during test_streams"
54fi
55
56############################################################################
57# basic 'round-trip' tests of various kinds of streams
58############################################################################
59
60rt_test_raw ()
61{
62 f="$1"
63 channels=`echo $f | awk -F- '{print $2}'`
64 bytes_per_sample=`echo $f | awk -F- '{print $3}'`
65 bps=`expr $bytes_per_sample '*' 8`
66 echo -n "round-trip test ($f) encode... "
67 run_flac --silent --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=$bps --channels=$channels $f -o rt.flac || die "ERROR"
68 echo -n "decode... "
69 run_flac --silent --decode --force-raw-format --endian=little --sign=signed -o rt.raw rt.flac || die "ERROR"
70 echo -n "compare... "
71 cmp $f rt.raw || die "ERROR: file mismatch"
72 echo "OK"
73 rm -f rt.flac rt.raw
74}
75
76rt_test_wav ()
77{
78 f="$1"
79 echo -n "round-trip test ($f) encode... "
80 run_flac --silent --verify $f -o rt.flac || die "ERROR"
81 echo -n "decode... "
82 run_flac --silent --decode -o rt.wav rt.flac || die "ERROR"
83 echo -n "compare... "
84 cmp $f rt.wav || die "ERROR: file mismatch"
85 echo "OK"
86 rm -f rt.flac rt.wav
87}
88
89rt_test_aiff ()
90{
91 f="$1"
92 echo -n "round-trip test ($f) encode... "
93 run_flac --silent --verify $f -o rt.flac || die "ERROR"
94 echo -n "decode... "
95 run_flac --silent --decode -o rt.aiff rt.flac || die "ERROR"
96 echo -n "compare... "
97 cmp $f rt.aiff || die "ERROR: file mismatch"
98 echo "OK"
99 rm -f rt.flac rt.aiff
100}
101
102for f in rt-*.raw ; do
103 rt_test_raw $f
104done
105for f in rt-*.wav ; do
106 rt_test_wav $f
107done
108for f in rt-*.aiff ; do
109 rt_test_aiff $f
110done
111
Josh Coalson8fac5d62002-12-12 03:57:47 +0000112############################################################################
113# test --skip and --until
114############################################################################
115
Josh Coalson463d0f82002-12-10 06:41:27 +0000116#
Josh Coalson8232e292002-12-14 06:22:22 +0000117# first make some chopped-up raw files
Josh Coalson463d0f82002-12-10 06:41:27 +0000118#
Josh Coalson8fac5d62002-12-12 03:57:47 +0000119echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
120dddie="die ERROR: creating files for --skip/--until tests"
121dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
122dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
123dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
124dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
125dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
126dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
127dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
Josh Coalson463d0f82002-12-10 06:41:27 +0000128
Josh Coalson8232e292002-12-14 06:22:22 +0000129wav_eopt="--silent --verify --lax"
130wav_dopt="--silent --decode"
131
132raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
133raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000134
135#
Josh Coalson5126bb02002-12-17 08:15:48 +0000136# convert them to WAVE and AIFF files
Josh Coalson8fac5d62002-12-12 03:57:47 +0000137#
Josh Coalson8232e292002-12-14 06:22:22 +0000138convert_to_wav ()
139{
140 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to WAVE"
141 run_flac $wav_dopt $1.flac || die "ERROR converting $1.raw to WAVE"
142}
143convert_to_wav 50c
144convert_to_wav 50c.skip10
145convert_to_wav 50c.skip11
146convert_to_wav 50c.until40
147convert_to_wav 50c.until39
148convert_to_wav 50c.skip10.until40
149convert_to_wav 50c.skip10.until39
Josh Coalson8fac5d62002-12-12 03:57:47 +0000150
Josh Coalson5126bb02002-12-17 08:15:48 +0000151convert_to_aiff ()
152{
153 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to AIFF"
154 run_flac $wav_dopt $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
155}
156convert_to_aiff 50c
157convert_to_aiff 50c.skip10
158convert_to_aiff 50c.skip11
159convert_to_aiff 50c.until40
160convert_to_aiff 50c.until39
161convert_to_aiff 50c.skip10.until40
162convert_to_aiff 50c.skip10.until39
163
Josh Coalson8232e292002-12-14 06:22:22 +0000164test_skip_until ()
165{
166 fmt=$1
Josh Coalson463d0f82002-12-10 06:41:27 +0000167
Josh Coalson5126bb02002-12-17 08:15:48 +0000168 [ $fmt = wav ] || [ $fmt = aiff ] || [ $fmt = raw ] || die "ERROR: internal error, bad format '$fmt'"
Josh Coalson463d0f82002-12-10 06:41:27 +0000169
Josh Coalson8232e292002-12-14 06:22:22 +0000170 if [ $fmt = raw ] ; then
171 eopt="$raw_eopt"
172 dopt="$raw_dopt"
173 else
174 eopt="$wav_eopt"
175 dopt="$wav_dopt"
176 fi
Josh Coalson463d0f82002-12-10 06:41:27 +0000177
Josh Coalson8232e292002-12-14 06:22:22 +0000178 #
179 # test --skip when encoding
180 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000181
Josh Coalson8232e292002-12-14 06:22:22 +0000182 echo -n "testing --skip=# (encode) ($fmt)... "
183 run_flac $eopt --skip=10 -o z50c.skip10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
184 run_flac $dopt -o z50c.skip10.$fmt z50c.skip10.flac || die "ERROR decoding FLAC file ($fmt)"
185 cmp 50c.skip10.$fmt z50c.skip10.$fmt || die "ERROR: file mismatch for --skip=10 (encode) ($fmt)"
186 rm -f z50c.skip10.flac z50c.skip10.$fmt
187 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000188
Josh Coalson8232e292002-12-14 06:22:22 +0000189 echo -n "testing --skip=mm:ss (encode) ($fmt)... "
190 run_flac $eopt --skip=0:01 -o z50c.skip0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
191 run_flac $dopt -o z50c.skip0:01.$fmt z50c.skip0:01.flac || die "ERROR decoding FLAC file ($fmt)"
192 cmp 50c.skip10.$fmt z50c.skip0:01.$fmt || die "ERROR: file mismatch for --skip=0:01 (encode) ($fmt)"
193 rm -f z50c.skip0:01.flac z50c.skip0:01.$fmt
194 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000195
Josh Coalson8232e292002-12-14 06:22:22 +0000196 echo -n "testing --skip=mm:ss.sss (encode) ($fmt)... "
197 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
198 run_flac $dopt -o z50c.skip0:01.1001.$fmt z50c.skip0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
199 cmp 50c.skip11.$fmt z50c.skip0:01.1001.$fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) ($fmt)"
200 rm -f z50c.skip0:01.1001.flac z50c.skip0:01.1001.$fmt
201 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000202
Josh Coalson8232e292002-12-14 06:22:22 +0000203 #
204 # test --skip when decoding
205 #
Josh Coalson463d0f82002-12-10 06:41:27 +0000206
Josh Coalson8232e292002-12-14 06:22:22 +0000207 echo -n "testing --skip=# (decode) ($fmt)... "
208 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
209 run_flac $dopt --skip=10 -o z50c.skip10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
210 cmp 50c.skip10.$fmt z50c.skip10.$fmt || die "ERROR: file mismatch for --skip=10 (decode) ($fmt)"
211 rm -f z50c.skip10.$fmt
212 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000213
Josh Coalson8232e292002-12-14 06:22:22 +0000214 echo -n "testing --skip=mm:ss (decode) ($fmt)... "
215 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
216 cmp 50c.skip10.$fmt z50c.skip0:01.$fmt || die "ERROR: file mismatch for --skip=0:01 (decode) ($fmt)"
217 rm -f z50c.skip0:01.$fmt
218 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000219
Josh Coalson8232e292002-12-14 06:22:22 +0000220 echo -n "testing --skip=mm:ss.sss (decode) ($fmt)... "
221 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
222 cmp 50c.skip11.$fmt z50c.skip0:01.1001.$fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) ($fmt)"
223 rm -f z50c.skip0:01.1001.$fmt
224 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000225
Josh Coalson8232e292002-12-14 06:22:22 +0000226 rm -f z50c.flac
Josh Coalson8fac5d62002-12-12 03:57:47 +0000227
Josh Coalson8232e292002-12-14 06:22:22 +0000228 #
229 # test --until when encoding
230 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000231
Josh Coalson8232e292002-12-14 06:22:22 +0000232 echo -n "testing --until=# (encode) ($fmt)... "
233 run_flac $eopt --until=40 -o z50c.until40.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
234 run_flac $dopt -o z50c.until40.$fmt z50c.until40.flac || die "ERROR decoding FLAC file ($fmt)"
235 cmp 50c.until40.$fmt z50c.until40.$fmt || die "ERROR: file mismatch for --until=40 (encode) ($fmt)"
236 rm -f z50c.until40.flac z50c.until40.$fmt
237 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000238
Josh Coalson8232e292002-12-14 06:22:22 +0000239 echo -n "testing --until=mm:ss (encode) ($fmt)... "
240 run_flac $eopt --until=0:04 -o z50c.until0:04.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
241 run_flac $dopt -o z50c.until0:04.$fmt z50c.until0:04.flac || die "ERROR decoding FLAC file ($fmt)"
242 cmp 50c.until40.$fmt z50c.until0:04.$fmt || die "ERROR: file mismatch for --until=0:04 (encode) ($fmt)"
243 rm -f z50c.until0:04.flac z50c.until0:04.$fmt
244 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000245
Josh Coalson8232e292002-12-14 06:22:22 +0000246 echo -n "testing --until=mm:ss.sss (encode) ($fmt)... "
247 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
248 run_flac $dopt -o z50c.until0:03.9001.$fmt z50c.until0:03.9001.flac || die "ERROR decoding FLAC file ($fmt)"
249 cmp 50c.until39.$fmt z50c.until0:03.9001.$fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) ($fmt)"
250 rm -f z50c.until0:03.9001.flac z50c.until0:03.9001.$fmt
251 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000252
Josh Coalson8232e292002-12-14 06:22:22 +0000253 echo -n "testing --until=-# (encode) ($fmt)... "
254 run_flac $eopt --until=-10 -o z50c.until-10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
255 run_flac $dopt -o z50c.until-10.$fmt z50c.until-10.flac || die "ERROR decoding FLAC file ($fmt)"
256 cmp 50c.until40.$fmt z50c.until-10.$fmt || die "ERROR: file mismatch for --until=-10 (encode) ($fmt)"
257 rm -f z50c.until-10.flac z50c.until-10.$fmt
258 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000259
Josh Coalson8232e292002-12-14 06:22:22 +0000260 echo -n "testing --until=-mm:ss (encode) ($fmt)... "
261 run_flac $eopt --until=-0:01 -o z50c.until-0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
262 run_flac $dopt -o z50c.until-0:01.$fmt z50c.until-0:01.flac || die "ERROR decoding FLAC file ($fmt)"
263 cmp 50c.until40.$fmt z50c.until-0:01.$fmt || die "ERROR: file mismatch for --until=-0:01 (encode) ($fmt)"
264 rm -f z50c.until-0:01.flac z50c.until-0:01.$fmt
265 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000266
Josh Coalson8232e292002-12-14 06:22:22 +0000267 echo -n "testing --until=-mm:ss.sss (encode) ($fmt)... "
268 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
269 run_flac $dopt -o z50c.until-0:01.1001.$fmt z50c.until-0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
270 cmp 50c.until39.$fmt z50c.until-0:01.1001.$fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) ($fmt)"
271 rm -f z50c.until-0:01.1001.flac z50c.until-0:01.1001.$fmt
272 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000273
Josh Coalson8232e292002-12-14 06:22:22 +0000274 #
275 # test --until when decoding
276 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000277
Josh Coalson8232e292002-12-14 06:22:22 +0000278 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000279
Josh Coalson8232e292002-12-14 06:22:22 +0000280 echo -n "testing --until=# (decode) ($fmt)... "
281 run_flac $dopt --until=40 -o z50c.until40.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
282 cmp 50c.until40.$fmt z50c.until40.$fmt || die "ERROR: file mismatch for --until=40 (decode) ($fmt)"
283 rm -f z50c.until40.$fmt
284 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000285
Josh Coalson8232e292002-12-14 06:22:22 +0000286 echo -n "testing --until=mm:ss (decode) ($fmt)... "
287 run_flac $dopt --until=0:04 -o z50c.until0:04.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
288 cmp 50c.until40.$fmt z50c.until0:04.$fmt || die "ERROR: file mismatch for --until=0:04 (decode) ($fmt)"
289 rm -f z50c.until0:04.$fmt
290 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000291
Josh Coalson8232e292002-12-14 06:22:22 +0000292 echo -n "testing --until=mm:ss.sss (decode) ($fmt)... "
293 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
294 cmp 50c.until39.$fmt z50c.until0:03.9001.$fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) ($fmt)"
295 rm -f z50c.until0:03.9001.$fmt
296 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000297
Josh Coalson8232e292002-12-14 06:22:22 +0000298 echo -n "testing --until=-# (decode) ($fmt)... "
299 run_flac $dopt --until=-10 -o z50c.until-10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
300 cmp 50c.until40.$fmt z50c.until-10.$fmt || die "ERROR: file mismatch for --until=-10 (decode) ($fmt)"
301 rm -f z50c.until-10.$fmt
302 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000303
Josh Coalson8232e292002-12-14 06:22:22 +0000304 echo -n "testing --until=-mm:ss (decode) ($fmt)... "
305 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
306 cmp 50c.until40.$fmt z50c.until-0:01.$fmt || die "ERROR: file mismatch for --until=-0:01 (decode) ($fmt)"
307 rm -f z50c.until-0:01.$fmt
308 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000309
Josh Coalson8232e292002-12-14 06:22:22 +0000310 echo -n "testing --until=-mm:ss.sss (decode) ($fmt)... "
311 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
312 cmp 50c.until39.$fmt z50c.until-0:01.1001.$fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) ($fmt)"
313 rm -f z50c.until-0:01.1001.$fmt
314 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000315
Josh Coalson8232e292002-12-14 06:22:22 +0000316 rm -f z50c.flac
Josh Coalson8fac5d62002-12-12 03:57:47 +0000317
Josh Coalson8232e292002-12-14 06:22:22 +0000318 #
319 # test --skip and --until when encoding
320 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000321
Josh Coalson8232e292002-12-14 06:22:22 +0000322 echo -n "testing --skip=10 --until=# (encode) ($fmt)... "
323 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
324 run_flac $dopt -o z50c.skip10.until40.$fmt z50c.skip10.until40.flac || die "ERROR decoding FLAC file ($fmt)"
325 cmp 50c.skip10.until40.$fmt z50c.skip10.until40.$fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) ($fmt)"
326 rm -f z50c.skip10.until40.flac z50c.skip10.until40.$fmt
327 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000328
Josh Coalson8232e292002-12-14 06:22:22 +0000329 echo -n "testing --skip=10 --until=mm:ss (encode) ($fmt)... "
330 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
331 run_flac $dopt -o z50c.skip10.until0:04.$fmt z50c.skip10.until0:04.flac || die "ERROR decoding FLAC file ($fmt)"
332 cmp 50c.skip10.until40.$fmt z50c.skip10.until0:04.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) ($fmt)"
333 rm -f z50c.skip10.until0:04.flac z50c.skip10.until0:04.$fmt
334 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000335
Josh Coalson8232e292002-12-14 06:22:22 +0000336 echo -n "testing --skip=10 --until=mm:ss.sss (encode) ($fmt)... "
337 run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
338 run_flac $dopt -o z50c.skip10.until0:03.9001.$fmt z50c.skip10.until0:03.9001.flac || die "ERROR decoding FLAC file ($fmt)"
339 cmp 50c.skip10.until39.$fmt z50c.skip10.until0:03.9001.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) ($fmt)"
340 rm -f z50c.skip10.until0:03.9001.flac z50c.skip10.until0:03.9001.$fmt
341 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000342
Josh Coalson8232e292002-12-14 06:22:22 +0000343 echo -n "testing --skip=10 --until=+# (encode) ($fmt)... "
344 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
345 run_flac $dopt -o z50c.skip10.until+30.$fmt z50c.skip10.until+30.flac || die "ERROR decoding FLAC file ($fmt)"
346 cmp 50c.skip10.until40.$fmt z50c.skip10.until+30.$fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) ($fmt)"
347 rm -f z50c.skip10.until+30.flac z50c.skip10.until+30.$fmt
348 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000349
Josh Coalson8232e292002-12-14 06:22:22 +0000350 echo -n "testing --skip=10 --until=+mm:ss (encode) ($fmt)... "
351 run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0:03.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
352 run_flac $dopt -o z50c.skip10.until+0:03.$fmt z50c.skip10.until+0:03.flac || die "ERROR decoding FLAC file ($fmt)"
353 cmp 50c.skip10.until40.$fmt z50c.skip10.until+0:03.$fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) ($fmt)"
354 rm -f z50c.skip10.until+0:03.flac z50c.skip10.until+0:03.$fmt
355 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000356
Josh Coalson8232e292002-12-14 06:22:22 +0000357 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) ($fmt)... "
358 run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0:02.9001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
359 run_flac $dopt -o z50c.skip10.until+0:02.9001.$fmt z50c.skip10.until+0:02.9001.flac || die "ERROR decoding FLAC file ($fmt)"
360 cmp 50c.skip10.until39.$fmt z50c.skip10.until+0:02.9001.$fmt || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode) ($fmt)"
361 rm -f z50c.skip10.until+0:02.9001.flac z50c.skip10.until+0:02.9001.$fmt
362 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000363
Josh Coalson8232e292002-12-14 06:22:22 +0000364 echo -n "testing --skip=10 --until=-# (encode) ($fmt)... "
365 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
366 run_flac $dopt -o z50c.skip10.until-10.$fmt z50c.skip10.until-10.flac || die "ERROR decoding FLAC file ($fmt)"
367 cmp 50c.skip10.until40.$fmt z50c.skip10.until-10.$fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) ($fmt)"
368 rm -f z50c.skip10.until-10.flac z50c.skip10.until-10.$fmt
369 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000370
Josh Coalson8232e292002-12-14 06:22:22 +0000371 echo -n "testing --skip=10 --until=-mm:ss (encode) ($fmt)... "
372 run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
373 run_flac $dopt -o z50c.skip10.until-0:01.$fmt z50c.skip10.until-0:01.flac || die "ERROR decoding FLAC file ($fmt)"
374 cmp 50c.skip10.until40.$fmt z50c.skip10.until-0:01.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) ($fmt)"
375 rm -f z50c.skip10.until-0:01.flac z50c.skip10.until-0:01.$fmt
376 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000377
Josh Coalson8232e292002-12-14 06:22:22 +0000378 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) ($fmt)... "
379 run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
380 run_flac $dopt -o z50c.skip10.until-0:01.1001.$fmt z50c.skip10.until-0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
381 cmp 50c.skip10.until39.$fmt z50c.skip10.until-0:01.1001.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode) ($fmt)"
382 rm -f z50c.skip10.until-0:01.1001.flac z50c.skip10.until-0:01.1001.$fmt
383 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000384
Josh Coalson8232e292002-12-14 06:22:22 +0000385 #
386 # test --skip and --until when decoding
387 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000388
Josh Coalson8232e292002-12-14 06:22:22 +0000389 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000390
Josh Coalson8232e292002-12-14 06:22:22 +0000391 echo -n "testing --skip=10 --until=# (decode) ($fmt)... "
392 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
393 cmp 50c.skip10.until40.$fmt z50c.skip10.until40.$fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) ($fmt)"
394 rm -f z50c.skip10.until40.$fmt
395 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000396
Josh Coalson8232e292002-12-14 06:22:22 +0000397 echo -n "testing --skip=10 --until=mm:ss (decode) ($fmt)... "
398 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
399 cmp 50c.skip10.until40.$fmt z50c.skip10.until0:04.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) ($fmt)"
400 rm -f z50c.skip10.until0:04.$fmt
401 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000402
Josh Coalson8232e292002-12-14 06:22:22 +0000403 echo -n "testing --skip=10 --until=mm:ss.sss (decode) ($fmt)... "
404 run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
405 cmp 50c.skip10.until39.$fmt z50c.skip10.until0:03.9001.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) ($fmt)"
406 rm -f z50c.skip10.until0:03.9001.$fmt
407 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000408
Josh Coalson8232e292002-12-14 06:22:22 +0000409 echo -n "testing --skip=10 --until=-# (decode) ($fmt)... "
410 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
411 cmp 50c.skip10.until40.$fmt z50c.skip10.until-10.$fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) ($fmt)"
412 rm -f z50c.skip10.until-10.$fmt
413 echo OK
414
415 echo -n "testing --skip=10 --until=-mm:ss (decode) ($fmt)... "
416 run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
417 cmp 50c.skip10.until40.$fmt z50c.skip10.until-0:01.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) ($fmt)"
418 rm -f z50c.skip10.until-0:01.$fmt
419 echo OK
420
421 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) ($fmt)... "
422 run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0:01.1001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
423 cmp 50c.skip10.until39.$fmt z50c.skip10.until-0:01.1001.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode) ($fmt)"
424 rm -f z50c.skip10.until-0:01.1001.$fmt
425 echo OK
426
427 rm -f z50c.flac
428}
429
430test_skip_until raw
431test_skip_until wav
Josh Coalson5126bb02002-12-17 08:15:48 +0000432test_skip_until aiff
Josh Coalson463d0f82002-12-10 06:41:27 +0000433
Josh Coalson9238a142002-12-21 03:29:26 +0000434
435############################################################################
436# test 'fixup' code that happens when a FLAC file with total_samples == 0
437# in the STREAMINFO block is converted to WAVE or AIFF, requiring the
438# decoder go back and fix up the chunk headers
439############################################################################
440
441echo -n "WAVE fixup test... "
442echo -n "prepare... "
443convert_to_wav noise || die "ERROR creating reference WAVE"
444echo -n "encode... "
445cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
446echo -n "decode... "
447run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
448echo -n "compare... "
449cmp noise.wav fixup.wav || die "ERROR: file mismatch"
450echo OK
451rm -f noise.wav fixup.wav fixup.flac
452
453echo -n "AIFF fixup test... "
454echo -n "prepare... "
455convert_to_aiff noise || die "ERROR creating reference AIFF"
456echo -n "encode... "
457cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
458echo -n "decode... "
459run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
460echo -n "compare... "
461cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
462echo OK
463rm -f noise.aiff fixup.aiff fixup.flac
464
465
466############################################################################
Josh Coalson463d0f82002-12-10 06:41:27 +0000467# multi-file tests
Josh Coalson9238a142002-12-21 03:29:26 +0000468############################################################################
Josh Coalson463d0f82002-12-10 06:41:27 +0000469
Josh Coalson463d0f82002-12-10 06:41:27 +0000470echo "Generating multiple input files from noise..."
Josh Coalson8fac5d62002-12-12 03:57:47 +0000471run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw || die "ERROR generating FLAC file"
472run_flac --decode --silent noise.flac || die "ERROR generating WAVE file"
Josh Coalson463d0f82002-12-10 06:41:27 +0000473rm -f noise.flac
474mv noise.wav file0.wav
475cp file0.wav file1.wav
476cp file1.wav file2.wav
477
478test_multifile ()
479{
480 streamtype=$1
481 sector_align=$2
482 encode_options="$3"
483
484 if [ $streamtype = ogg ] ; then
485 suffix=ogg
486 encode_options="$encode_options --ogg"
487 else
488 suffix=flac
489 fi
490
491 if [ $sector_align = sector_align ] ; then
492 encode_options="$encode_options --sector-align"
493 fi
494
Josh Coalson8fac5d62002-12-12 03:57:47 +0000495 run_flac $encode_options file0.wav file1.wav file2.wav || die "ERROR"
Josh Coalson463d0f82002-12-10 06:41:27 +0000496 for n in 0 1 2 ; do
497 mv file$n.$suffix file${n}x.$suffix
498 done
Josh Coalson8fac5d62002-12-12 03:57:47 +0000499 run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
Josh Coalson463d0f82002-12-10 06:41:27 +0000500 if [ $sector_align != sector_align ] ; then
501 for n in 0 1 2 ; do
Josh Coalson8fac5d62002-12-12 03:57:47 +0000502 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
Josh Coalson463d0f82002-12-10 06:41:27 +0000503 done
504 fi
505 for n in 0 1 2 ; do
506 rm -f file${n}x.$suffix file${n}x.wav
507 done
508}
509
510echo "Testing multiple files without verify..."
511test_multifile flac no_sector_align ""
512
513echo "Testing multiple files with verify..."
514test_multifile flac no_sector_align "--verify"
515
516echo "Testing multiple files with --sector-align, without verify..."
517test_multifile flac sector_align ""
518
519echo "Testing multiple files with --sector-align, with verify..."
520test_multifile flac sector_align "--verify"
521
522if [ $has_ogg = "yes" ] ; then
523 echo "Testing multiple files with --ogg, without verify..."
524 test_multifile ogg no_sector_align ""
525
526 echo "Testing multiple files with --ogg, with verify..."
527 test_multifile ogg no_sector_align "--verify"
528
529 echo "Testing multiple files with --ogg and --sector-align, without verify..."
530 test_multifile ogg sector_align ""
531
532 echo "Testing multiple files with --ogg and --sector-align, with verify..."
533 test_multifile sector_align ogg "--verify"
534
535 echo "Testing multiple files with --ogg and --serial-number, with verify..."
536 test_multifile ogg no_sector_align "--serial-number=321 --verify"
537fi