~ubuntu-branches/ubuntu/feisty/flac/feisty

« back to all changes in this revision

Viewing changes to test/test_flac.sh

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-04-16 15:14:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040416151431-eyloggqxpwbwpogz
Tags: 1.1.0-11
Ensure that libFLAC is linked with -lm on all architectures, and
regardless of whether nasm is present

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#  FLAC - Free Lossless Audio Codec
 
4
#  Copyright (C) 2001,2002,2003  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
 
 
20
die ()
 
21
{
 
22
        echo $* 1>&2
 
23
        exit 1
 
24
}
 
25
 
 
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
 
29
 
 
30
flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
 
31
 
 
32
run_flac ()
 
33
{
 
34
        if [ x"$FLAC__VALGRIND" = xyes ] ; then
 
35
                valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_flac.valgrind.log
 
36
        else
 
37
                flac $*
 
38
        fi
 
39
}
 
40
 
 
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
 
43
        has_ogg=yes;
 
44
        echo "flac --ogg works"
 
45
else
 
46
        has_ogg=no;
 
47
        echo "flac --ogg doesn't work"
 
48
fi
 
49
 
 
50
 
 
51
echo "Generating streams..."
 
52
if [ ! -f wacky1.wav ] ; then
 
53
        test_streams || die "ERROR during test_streams"
 
54
fi
 
55
 
 
56
############################################################################
 
57
# basic 'round-trip' tests of various kinds of streams
 
58
############################################################################
 
59
 
 
60
rt_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
 
 
76
rt_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
 
 
89
rt_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
 
 
102
for f in rt-*.raw ; do
 
103
        rt_test_raw $f
 
104
done
 
105
for f in rt-*.wav ; do
 
106
        rt_test_wav $f
 
107
done
 
108
for f in rt-*.aiff ; do
 
109
        rt_test_aiff $f
 
110
done
 
111
 
 
112
############################################################################
 
113
# test --skip and --until
 
114
############################################################################
 
115
 
 
116
#
 
117
# first make some chopped-up raw files
 
118
#
 
119
echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
 
120
dddie="die ERROR: creating files for --skip/--until tests"
 
121
dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
 
122
dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
 
123
dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
 
124
dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
 
125
dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
 
126
dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
 
127
dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
 
128
 
 
129
wav_eopt="--silent --verify --lax"
 
130
wav_dopt="--silent --decode"
 
131
 
 
132
raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
 
133
raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
 
134
 
 
135
#
 
136
# convert them to WAVE and AIFF files
 
137
#
 
138
convert_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
}
 
143
convert_to_wav 50c
 
144
convert_to_wav 50c.skip10
 
145
convert_to_wav 50c.skip11
 
146
convert_to_wav 50c.until40
 
147
convert_to_wav 50c.until39
 
148
convert_to_wav 50c.skip10.until40
 
149
convert_to_wav 50c.skip10.until39
 
150
 
 
151
convert_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
}
 
156
convert_to_aiff 50c
 
157
convert_to_aiff 50c.skip10
 
158
convert_to_aiff 50c.skip11
 
159
convert_to_aiff 50c.until40
 
160
convert_to_aiff 50c.until39
 
161
convert_to_aiff 50c.skip10.until40
 
162
convert_to_aiff 50c.skip10.until39
 
163
 
 
164
test_skip_until ()
 
165
{
 
166
        fmt=$1
 
167
 
 
168
        [ $fmt = wav ] || [ $fmt = aiff ] || [ $fmt = raw ] || die "ERROR: internal error, bad format '$fmt'"
 
169
 
 
170
        if [ $fmt = raw ] ; then
 
171
                eopt="$raw_eopt"
 
172
                dopt="$raw_dopt"
 
173
        else
 
174
                eopt="$wav_eopt"
 
175
                dopt="$wav_dopt"
 
176
        fi
 
177
 
 
178
        #
 
179
        # test --skip when encoding
 
180
        #
 
181
 
 
182
        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
 
188
 
 
189
        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
 
195
 
 
196
        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
 
202
 
 
203
        #
 
204
        # test --skip when decoding
 
205
        #
 
206
 
 
207
        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
 
213
 
 
214
        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
 
219
 
 
220
        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
 
225
 
 
226
        rm -f z50c.flac
 
227
 
 
228
        #
 
229
        # test --until when encoding
 
230
        #
 
231
 
 
232
        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
 
238
 
 
239
        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
 
245
 
 
246
        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
 
252
 
 
253
        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
 
259
 
 
260
        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
 
266
 
 
267
        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
 
273
 
 
274
        #
 
275
        # test --until when decoding
 
276
        #
 
277
 
 
278
        run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
 
279
 
 
280
        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
 
285
 
 
286
        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
 
291
 
 
292
        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
 
297
 
 
298
        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
 
303
 
 
304
        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
 
309
 
 
310
        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
 
315
 
 
316
        rm -f z50c.flac
 
317
 
 
318
        #
 
319
        # test --skip and --until when encoding
 
320
        #
 
321
 
 
322
        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
 
328
 
 
329
        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
 
335
 
 
336
        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
 
342
 
 
343
        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
 
349
 
 
350
        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
 
356
 
 
357
        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
 
363
 
 
364
        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
 
370
 
 
371
        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
 
377
 
 
378
        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
 
384
 
 
385
        #
 
386
        # test --skip and --until when decoding
 
387
        #
 
388
 
 
389
        run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
 
390
 
 
391
        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
 
396
 
 
397
        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
 
402
 
 
403
        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
 
408
 
 
409
        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
 
 
430
test_skip_until raw
 
431
test_skip_until wav
 
432
test_skip_until aiff
 
433
 
 
434
 
 
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
 
 
441
echo -n "WAVE fixup test... "
 
442
echo -n "prepare... "
 
443
convert_to_wav noise || die "ERROR creating reference WAVE"
 
444
echo -n "encode... "
 
445
cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
 
446
echo -n "decode... "
 
447
run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
 
448
echo -n "compare... "
 
449
cmp noise.wav fixup.wav || die "ERROR: file mismatch"
 
450
echo OK
 
451
rm -f noise.wav fixup.wav fixup.flac
 
452
 
 
453
echo -n "AIFF fixup test... "
 
454
echo -n "prepare... "
 
455
convert_to_aiff noise || die "ERROR creating reference AIFF"
 
456
echo -n "encode... "
 
457
cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
 
458
echo -n "decode... "
 
459
run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
 
460
echo -n "compare... "
 
461
cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
 
462
echo OK
 
463
rm -f noise.aiff fixup.aiff fixup.flac
 
464
 
 
465
 
 
466
############################################################################
 
467
# multi-file tests
 
468
############################################################################
 
469
 
 
470
echo "Generating multiple input files from noise..."
 
471
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"
 
472
run_flac --decode --silent noise.flac || die "ERROR generating WAVE file"
 
473
rm -f noise.flac
 
474
mv noise.wav file0.wav
 
475
cp file0.wav file1.wav
 
476
cp file1.wav file2.wav
 
477
 
 
478
test_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
 
 
495
        run_flac $encode_options file0.wav file1.wav file2.wav || die "ERROR"
 
496
        for n in 0 1 2 ; do
 
497
                mv file$n.$suffix file${n}x.$suffix
 
498
        done
 
499
        run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
 
500
        if [ $sector_align != sector_align ] ; then
 
501
                for n in 0 1 2 ; do
 
502
                        cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
 
503
                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
 
 
510
echo "Testing multiple files without verify..."
 
511
test_multifile flac no_sector_align ""
 
512
 
 
513
echo "Testing multiple files with verify..."
 
514
test_multifile flac no_sector_align "--verify"
 
515
 
 
516
echo "Testing multiple files with --sector-align, without verify..."
 
517
test_multifile flac sector_align ""
 
518
 
 
519
echo "Testing multiple files with --sector-align, with verify..."
 
520
test_multifile flac sector_align "--verify"
 
521
 
 
522
if [ $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"
 
537
fi