1#!/bin/sh -e
2
3#  FLAC - Free Lossless Audio Codec
4#  Copyright (C) 2001-2009  Josh Coalson
5#  Copyright (C) 2011-2016  Xiph.Org Foundation
6#
7#  This file is part the FLAC project.  FLAC is comprised of several
8#  components distributed under different licenses.  The codec libraries
9#  are distributed under Xiph.Org's BSD-like license (see the file
10#  COPYING.Xiph in this distribution).  All other programs, libraries, and
11#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
12#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
13#  FLAC distribution contains at the top the terms under which it may be
14#  distributed.
15#
16#  Since this particular file is relevant to all components of FLAC,
17#  it may be distributed under the Xiph.Org license, which is the least
18#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
19#  distribution.
20
21. ./common.sh
22
23# we use '.' as decimal separator in --skip/--until tests
24export LANG=C LC_ALL=C
25
26dddie="die ERROR: creating files with dd"
27
28PATH=`pwd`/../src/flac:$PATH
29PATH=`pwd`/../src/metaflac:$PATH
30PATH=`pwd`/../src/test_streams:$PATH
31PATH=`pwd`/../objs/$BUILD/bin:$PATH
32
33flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
34
35run_flac ()
36{
37	if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
38		echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log
39		valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* 4>>test_flac.valgrind.log
40	else
41		flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $*
42	fi
43}
44
45run_metaflac ()
46{
47	if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
48		echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_flac.valgrind.log
49		valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_flac.valgrind.log
50	else
51		metaflac${EXE} $*
52	fi
53}
54
55md5cmp ()
56{
57	n=`( [ -f "$1" ] && [ -f "$2" ] && metaflac${EXE} --show-md5sum --no-filename "$1" "$2" 2>/dev/null || exit 1 ) | uniq | wc -l`
58	[ "$n" != "" ] && [ $n = 1 ]
59}
60
61echo "Checking for --ogg support in flac..."
62if flac${EXE} --ogg $TOTTALY_SILENT --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
63	has_ogg=yes;
64	echo "flac --ogg works"
65else
66	has_ogg=no;
67	echo "flac --ogg doesn't work"
68fi
69
70echo "Generating streams..."
71if [ ! -f wacky1.wav ] ; then
72	test_streams || die "ERROR during test_streams"
73fi
74
75############################################################################
76# test that flac doesn't automatically overwrite files unless -f is used
77############################################################################
78
79echo "Try encoding to a file that exists; should fail"
80cp wacky1.wav exist.wav
81touch exist.flac
82if run_flac -0 exist.wav ; then
83	die "ERROR: it should have failed but didn't"
84else
85	echo "OK, it failed as it should"
86fi
87
88echo "Try encoding with -f to a file that exists; should succeed"
89if run_flac -0 --force exist.wav ; then
90	echo "OK, it succeeded as it should"
91else
92	die "ERROR: it should have succeeded but didn't"
93fi
94
95echo "Try decoding to a file that exists; should fail"
96if run_flac -d exist.flac ; then
97	die "ERROR: it should have failed but didn't"
98else
99	echo "OK, it failed as it should"
100fi
101
102echo "Try decoding with -f to a file that exists; should succeed"
103if run_flac -d -f exist.flac ; then
104	echo "OK, it succeeded as it should"
105else
106	die "ERROR: it should have succeeded but didn't"
107fi
108
109rm -f exist.wav exist.flac
110
111############################################################################
112# test fractional block sizes
113############################################################################
114
115test_fractional ()
116{
117	blocksize=$1
118	samples=$2
119	dd if=noise.raw ibs=4 count=$samples of=pbs.raw 2>/dev/null || $dddie
120	echo $ECHO_N "fractional block size test (blocksize=$blocksize samples=$samples) encode... " $ECHO_C
121	run_flac --force --verify --force-raw-format --endian=little --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=$blocksize --no-padding --lax -o pbs.flac pbs.raw || die "ERROR"
122	echo $ECHO_N "decode... " $ECHO_C
123	run_flac --force --decode --force-raw-format --endian=little --sign=signed -o pbs.cmp pbs.flac || die "ERROR"
124	echo $ECHO_N "compare... " $ECHO_C
125	cmp pbs.raw pbs.cmp || die "ERROR: file mismatch"
126	echo "OK"
127	rm -f pbs.raw pbs.flac pbs.cmp
128}
129
130# The special significance of 2048 is it's the # of samples that flac calls
131# FLAC__stream_encoder_process() on.
132#
133# We're trying to make sure the 1-sample overread logic in the stream encoder
134# (used for last-block checking) works; these values probe around common
135# multiples of the flac sample chunk size (2048) and the blocksize.
136for samples in 31 32 33 34 35 2046 2047 2048 2049 2050 ; do
137	test_fractional 33 $samples
138done
139for samples in 254 255 256 257 258 510 511 512 513 514 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
140	test_fractional 256 $samples
141done
142for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 ; do
143	test_fractional 2048 $samples
144done
145for samples in 1022 1023 1024 1025 1026 2046 2047 2048 2049 2050 4094 4095 4096 4097 4098 4606 4607 4608 4609 4610 8190 8191 8192 8193 8194 16382 16383 16384 16385 16386 ; do
146	test_fractional 4608 $samples
147done
148
149############################################################################
150# basic 'round-trip' tests of various kinds of streams
151############################################################################
152
153rt_test_raw ()
154{
155	f="$1"
156	extra="$2"
157	channels=`echo $f | awk -F- '{print $2}'`
158	bps=`echo $f | awk -F- '{print $3}'`
159	sign=`echo $f | awk -F- '{print $4}'`
160
161	echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
162	run_flac --force --verify --force-raw-format --endian=little --sign=$sign --sample-rate=44100 --bps=$bps --channels=$channels --no-padding --lax -o rt.flac $extra $f || die "ERROR"
163	echo $ECHO_N "decode... " $ECHO_C
164	run_flac --force --decode --force-raw-format --endian=little --sign=$sign -o rt.raw $extra rt.flac || die "ERROR"
165	echo $ECHO_N "compare... " $ECHO_C
166	cmp $f rt.raw || die "ERROR: file mismatch"
167	echo "OK"
168	rm -f rt.flac rt.raw
169}
170
171rt_test_wav ()
172{
173	f="$1"
174	extra="$2"
175	echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
176	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
177	echo $ECHO_N "decode... " $ECHO_C
178	run_flac --force --decode --channel-map=none -o rt.wav $extra rt.flac || die "ERROR"
179	echo $ECHO_N "compare... " $ECHO_C
180	cmp $f rt.wav || die "ERROR: file mismatch"
181	echo "OK"
182	rm -f rt.flac rt.wav
183}
184
185rt_test_w64 ()
186{
187	f="$1"
188	extra="$2"
189	echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
190	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
191	echo $ECHO_N "decode... " $ECHO_C
192	run_flac --force --decode --channel-map=none -o rt.w64 $extra rt.flac || die "ERROR"
193	echo $ECHO_N "compare... " $ECHO_C
194	cmp $f rt.w64 || die "ERROR: file mismatch"
195	echo "OK"
196	rm -f rt.flac rt.w64
197}
198
199rt_test_rf64 ()
200{
201	f="$1"
202	extra="$2"
203	echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
204	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
205	echo $ECHO_N "decode... " $ECHO_C
206	run_flac --force --decode --channel-map=none -o rt.rf64 $extra rt.flac || die "ERROR"
207	echo $ECHO_N "compare... " $ECHO_C
208	cmp $f rt.rf64 || die "ERROR: file mismatch"
209	echo "OK"
210	rm -f rt.flac rt.rf64
211}
212
213rt_test_aiff ()
214{
215	f="$1"
216	extra="$2"
217	echo $ECHO_N "round-trip test ($f) encode... " $ECHO_C
218	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
219	echo $ECHO_N "decode... " $ECHO_C
220	run_flac --force --decode --channel-map=none -o rt.aiff $extra rt.flac || die "ERROR"
221	echo $ECHO_N "compare... " $ECHO_C
222	cmp $f rt.aiff || die "ERROR: file mismatch"
223	echo "OK"
224	rm -f rt.flac rt.aiff
225}
226
227# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
228rt_test_flac ()
229{
230	f="$1"
231	extra="$2"
232	echo $ECHO_N "round-trip test ($f->flac->flac->wav) encode... " $ECHO_C
233	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.flac $extra $f || die "ERROR"
234	echo $ECHO_N "re-encode... " $ECHO_C
235	run_flac --force --verify --lax -o rt2.flac rt.flac || die "ERROR"
236	echo $ECHO_N "decode... " $ECHO_C
237	run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.flac || die "ERROR"
238	echo $ECHO_N "compare... " $ECHO_C
239	cmp $f rt.wav || die "ERROR: file mismatch"
240	echo "OK"
241	rm -f rt.wav rt.flac rt2.flac
242}
243
244# assumes input file is WAVE; does not check the metadata-preserving features of flac-to-flac; that is checked later
245rt_test_ogg_flac ()
246{
247	f="$1"
248	extra="$2"
249	echo $ECHO_N "round-trip test ($f->oggflac->oggflac->wav) encode... " $ECHO_C
250	run_flac --force --verify --channel-map=none --no-padding --lax -o rt.oga --ogg $extra $f || die "ERROR"
251	echo $ECHO_N "re-encode... " $ECHO_C
252	run_flac --force --verify --lax -o rt2.oga --ogg rt.oga || die "ERROR"
253	echo $ECHO_N "decode... " $ECHO_C
254	run_flac --force --decode --channel-map=none -o rt.wav $extra rt2.oga || die "ERROR"
255	echo $ECHO_N "compare... " $ECHO_C
256	cmp $f rt.wav || die "ERROR: file mismatch"
257	echo "OK"
258	rm -f rt.wav rt.oga rt2.oga
259}
260
261for f in rt-*.raw ; do
262	rt_test_raw $f
263done
264for f in rt-*.wav ; do
265	rt_test_wav $f
266done
267for f in rt-*.w64 ; do
268	rt_test_w64 $f
269done
270for f in rt-*.rf64 ; do
271	rt_test_rf64 $f
272done
273for f in rt-*.aiff ; do
274	rt_test_aiff $f
275done
276for f in rt-*.wav ; do
277	rt_test_flac $f
278done
279if [ $has_ogg = yes ] ; then
280	for f in rt-*.wav ; do
281		rt_test_ogg_flac $f
282	done
283fi
284
285############################################################################
286# test --skip and --until
287############################################################################
288
289#
290# first make some chopped-up raw files
291#
292echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
293dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
294dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
295dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
296dd if=master.raw ibs=1 skip=20 count=30 of=50c.skip20.raw 2>/dev/null || $dddie
297dd if=master.raw ibs=1 skip=30 count=20 of=50c.skip30.raw 2>/dev/null || $dddie
298dd if=master.raw ibs=1 skip=40 count=10 of=50c.skip40.raw 2>/dev/null || $dddie
299dd if=master.raw ibs=1 count=10 of=50c.until10.raw 2>/dev/null || $dddie
300dd if=master.raw ibs=1 count=20 of=50c.until20.raw 2>/dev/null || $dddie
301dd if=master.raw ibs=1 count=30 of=50c.until30.raw 2>/dev/null || $dddie
302dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
303dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
304dd if=master.raw ibs=1 skip=10 count=20 of=50c.skip10.until30.raw 2>/dev/null || $dddie
305dd if=master.raw ibs=1 skip=10 count=29 of=50c.skip10.until39.raw 2>/dev/null || $dddie
306dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
307dd if=master.raw ibs=1 skip=20 count=10 of=50c.skip20.until30.raw 2>/dev/null || $dddie
308dd if=master.raw ibs=1 skip=20 count=20 of=50c.skip20.until40.raw 2>/dev/null || $dddie
309
310wav_eopt="--force --verify --no-padding --lax"
311wav_dopt="--force --decode"
312
313raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
314raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
315
316#
317# convert them to WAVE/AIFF/Ogg FLAC files
318#
319convert_to_wav ()
320{
321	run_flac "$2" $1.raw || die "ERROR converting $1.raw to WAVE"
322	run_flac "$3" $1.flac || die "ERROR converting $1.raw to WAVE"
323}
324convert_to_wav 50c "$raw_eopt" "$wav_dopt"
325convert_to_wav 50c.skip10 "$raw_eopt" "$wav_dopt"
326convert_to_wav 50c.skip11 "$raw_eopt" "$wav_dopt"
327convert_to_wav 50c.skip20 "$raw_eopt" "$wav_dopt"
328convert_to_wav 50c.skip30 "$raw_eopt" "$wav_dopt"
329convert_to_wav 50c.skip40 "$raw_eopt" "$wav_dopt"
330convert_to_wav 50c.until10 "$raw_eopt" "$wav_dopt"
331convert_to_wav 50c.until20 "$raw_eopt" "$wav_dopt"
332convert_to_wav 50c.until30 "$raw_eopt" "$wav_dopt"
333convert_to_wav 50c.until39 "$raw_eopt" "$wav_dopt"
334convert_to_wav 50c.until40 "$raw_eopt" "$wav_dopt"
335convert_to_wav 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
336convert_to_wav 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
337convert_to_wav 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
338convert_to_wav 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
339convert_to_wav 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
340
341convert_to_aiff ()
342{
343	run_flac "$2" $1.raw || die "ERROR converting $1.raw to AIFF"
344	run_flac "$3" $1.flac -o $1.aiff || die "ERROR converting $1.raw to AIFF"
345}
346convert_to_aiff 50c "$raw_eopt" "$wav_dopt"
347convert_to_aiff 50c.skip10 "$raw_eopt" "$wav_dopt"
348convert_to_aiff 50c.skip11 "$raw_eopt" "$wav_dopt"
349convert_to_aiff 50c.skip20 "$raw_eopt" "$wav_dopt"
350convert_to_aiff 50c.skip30 "$raw_eopt" "$wav_dopt"
351convert_to_aiff 50c.skip40 "$raw_eopt" "$wav_dopt"
352convert_to_aiff 50c.until10 "$raw_eopt" "$wav_dopt"
353convert_to_aiff 50c.until20 "$raw_eopt" "$wav_dopt"
354convert_to_aiff 50c.until30 "$raw_eopt" "$wav_dopt"
355convert_to_aiff 50c.until39 "$raw_eopt" "$wav_dopt"
356convert_to_aiff 50c.until40 "$raw_eopt" "$wav_dopt"
357convert_to_aiff 50c.skip10.until30 "$raw_eopt" "$wav_dopt"
358convert_to_aiff 50c.skip10.until39 "$raw_eopt" "$wav_dopt"
359convert_to_aiff 50c.skip10.until40 "$raw_eopt" "$wav_dopt"
360convert_to_aiff 50c.skip20.until30 "$raw_eopt" "$wav_dopt"
361convert_to_aiff 50c.skip20.until40 "$raw_eopt" "$wav_dopt"
362
363convert_to_ogg ()
364{
365	run_flac "$wav_eopt" --ogg $1.wav || die "ERROR converting $1.raw to Ogg FLAC"
366}
367if [ $has_ogg = yes ] ; then
368	convert_to_ogg 50c
369	convert_to_ogg 50c.skip10
370	convert_to_ogg 50c.skip11
371	convert_to_ogg 50c.skip20
372	convert_to_ogg 50c.skip30
373	convert_to_ogg 50c.skip40
374	convert_to_ogg 50c.until10
375	convert_to_ogg 50c.until20
376	convert_to_ogg 50c.until30
377	convert_to_ogg 50c.until39
378	convert_to_ogg 50c.until40
379	convert_to_ogg 50c.skip10.until30
380	convert_to_ogg 50c.skip10.until39
381	convert_to_ogg 50c.skip10.until40
382	convert_to_ogg 50c.skip20.until30
383	convert_to_ogg 50c.skip20.until40
384fi
385
386test_skip_until ()
387{
388	in_fmt=$1
389	out_fmt=$2
390
391	[ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
392
393	[ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
394
395	if [ $in_fmt = raw ] ; then
396		eopt="$raw_eopt"
397		dopt="$raw_dopt"
398	else
399		eopt="$wav_eopt"
400		dopt="$wav_dopt"
401	fi
402
403	if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
404		CMP=md5cmp
405	else
406		CMP=cmp
407	fi
408
409	if [ $out_fmt = ogg ] ; then
410		eopt="--ogg $eopt"
411	fi
412
413	#
414	# test --skip when encoding
415	#
416
417	desc="($in_fmt<->$out_fmt)"
418
419	echo $ECHO_N "testing --skip=# (encode) $desc... " $ECHO_C
420	run_flac $eopt --skip=10 -o z50c.skip10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
421	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.$in_fmt z50c.skip10.$out_fmt || die "ERROR decoding FLAC file $desc"
422	$CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (encode) $desc"
423	rm -f z50c.skip10.$out_fmt z50c.skip10.$in_fmt
424	echo OK
425
426	echo $ECHO_N "testing --skip=mm:ss (encode) $desc... " $ECHO_C
427	run_flac $eopt --skip=0:01 -o z50c.skip0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
428
429	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.$in_fmt z50c.skip0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
430	$CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (encode) $desc"
431	rm -f z50c.skip0_01.$out_fmt z50c.skip0_01.$in_fmt
432	echo OK
433
434	echo $ECHO_N "testing --skip=mm:ss.sss (encode) $desc... " $ECHO_C
435	run_flac $eopt --skip=0:01.1001 -o z50c.skip0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
436	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip0_01.1001.$in_fmt z50c.skip0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
437	$CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) $desc"
438	rm -f z50c.skip0_01.1001.$out_fmt z50c.skip0_01.1001.$in_fmt
439	echo OK
440
441	#
442	# test --skip when decoding
443	#
444
445	if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
446
447	echo $ECHO_N "testing --skip=# (decode) $desc... " $ECHO_C
448	run_flac $dopt --skip=10 -o z50c.skip10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
449	$CMP 50c.skip10.$in_fmt z50c.skip10.$in_fmt || die "ERROR: file mismatch for --skip=10 (decode) $desc"
450	rm -f z50c.skip10.$in_fmt
451	echo OK
452
453	echo $ECHO_N "testing --skip=mm:ss (decode) $desc... " $ECHO_C
454	run_flac $dopt --skip=0:01 -o z50c.skip0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
455	$CMP 50c.skip10.$in_fmt z50c.skip0_01.$in_fmt || die "ERROR: file mismatch for --skip=0:01 (decode) $desc"
456	rm -f z50c.skip0_01.$in_fmt
457	echo OK
458
459	echo $ECHO_N "testing --skip=mm:ss.sss (decode) $desc... " $ECHO_C
460	run_flac $dopt --skip=0:01.1001 -o z50c.skip0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
461	$CMP 50c.skip11.$in_fmt z50c.skip0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) $desc"
462	rm -f z50c.skip0_01.1001.$in_fmt
463	echo OK
464
465	rm -f z50c.$out_fmt
466
467	#
468	# test --until when encoding
469	#
470
471	echo $ECHO_N "testing --until=# (encode) $desc... " $ECHO_C
472	run_flac $eopt --until=40 -o z50c.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
473	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until40.$in_fmt z50c.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
474	$CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (encode) $desc"
475	rm -f z50c.until40.$out_fmt z50c.until40.$in_fmt
476	echo OK
477
478	echo $ECHO_N "testing --until=mm:ss (encode) $desc... " $ECHO_C
479	run_flac $eopt --until=0:04 -o z50c.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
480	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_04.$in_fmt z50c.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc"
481	$CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (encode) $desc"
482	rm -f z50c.until0_04.$out_fmt z50c.until0_04.$in_fmt
483	echo OK
484
485	echo $ECHO_N "testing --until=mm:ss.sss (encode) $desc... " $ECHO_C
486	run_flac $eopt --until=0:03.9001 -o z50c.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
487	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until0_03.9001.$in_fmt z50c.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
488	$CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) $desc"
489	rm -f z50c.until0_03.9001.$out_fmt z50c.until0_03.9001.$in_fmt
490	echo OK
491
492	echo $ECHO_N "testing --until=-# (encode) $desc... " $ECHO_C
493	run_flac $eopt --until=-10 -o z50c.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
494	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-10.$in_fmt z50c.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
495	$CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (encode) $desc"
496	rm -f z50c.until-10.$out_fmt z50c.until-10.$in_fmt
497	echo OK
498
499	echo $ECHO_N "testing --until=-mm:ss (encode) $desc... " $ECHO_C
500	run_flac $eopt --until=-0:01 -o z50c.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
501	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.$in_fmt z50c.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
502	$CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (encode) $desc"
503	rm -f z50c.until-0_01.$out_fmt z50c.until-0_01.$in_fmt
504	echo OK
505
506	echo $ECHO_N "testing --until=-mm:ss.sss (encode) $desc... " $ECHO_C
507	run_flac $eopt --until=-0:01.1001 -o z50c.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
508	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.until-0_01.1001.$in_fmt z50c.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
509	$CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) $desc"
510	rm -f z50c.until-0_01.1001.$out_fmt z50c.until-0_01.1001.$in_fmt
511	echo OK
512
513	#
514	# test --until when decoding
515	#
516
517	if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
518
519	echo $ECHO_N "testing --until=# (decode) $desc... " $ECHO_C
520	run_flac $dopt --until=40 -o z50c.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
521	$CMP 50c.until40.$in_fmt z50c.until40.$in_fmt || die "ERROR: file mismatch for --until=40 (decode) $desc"
522	rm -f z50c.until40.$in_fmt
523	echo OK
524
525	echo $ECHO_N "testing --until=mm:ss (decode) $desc... " $ECHO_C
526	run_flac $dopt --until=0:04 -o z50c.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
527	$CMP 50c.until40.$in_fmt z50c.until0_04.$in_fmt || die "ERROR: file mismatch for --until=0:04 (decode) $desc"
528	rm -f z50c.until0_04.$in_fmt
529	echo OK
530
531	echo $ECHO_N "testing --until=mm:ss.sss (decode) $desc... " $ECHO_C
532	run_flac $dopt --until=0:03.9001 -o z50c.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
533	$CMP 50c.until39.$in_fmt z50c.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) $desc"
534	rm -f z50c.until0_03.9001.$in_fmt
535	echo OK
536
537	echo $ECHO_N "testing --until=-# (decode) $desc... " $ECHO_C
538	run_flac $dopt --until=-10 -o z50c.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
539	$CMP 50c.until40.$in_fmt z50c.until-10.$in_fmt || die "ERROR: file mismatch for --until=-10 (decode) $desc"
540	rm -f z50c.until-10.$in_fmt
541	echo OK
542
543	echo $ECHO_N "testing --until=-mm:ss (decode) $desc... " $ECHO_C
544	run_flac $dopt --until=-0:01 -o z50c.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
545	$CMP 50c.until40.$in_fmt z50c.until-0_01.$in_fmt || die "ERROR: file mismatch for --until=-0:01 (decode) $desc"
546	rm -f z50c.until-0_01.$in_fmt
547	echo OK
548
549	echo $ECHO_N "testing --until=-mm:ss.sss (decode) $desc... " $ECHO_C
550	run_flac $dopt --until=-0:01.1001 -o z50c.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
551	$CMP 50c.until39.$in_fmt z50c.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) $desc"
552	rm -f z50c.until-0_01.1001.$in_fmt
553	echo OK
554
555	rm -f z50c.$out_fmt
556
557	#
558	# test --skip and --until when encoding
559	#
560
561	echo $ECHO_N "testing --skip=10 --until=# (encode) $desc... " $ECHO_C
562	run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
563	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until40.$in_fmt z50c.skip10.until40.$out_fmt || die "ERROR decoding FLAC file $desc"
564	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) $desc"
565	rm -f z50c.skip10.until40.$out_fmt z50c.skip10.until40.$in_fmt
566	echo OK
567
568	echo $ECHO_N "testing --skip=10 --until=mm:ss (encode) $desc... " $ECHO_C
569	run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
570	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_04.$in_fmt z50c.skip10.until0_04.$out_fmt || die "ERROR decoding FLAC file $desc"
571	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) $desc"
572	rm -f z50c.skip10.until0_04.$out_fmt z50c.skip10.until0_04.$in_fmt
573	echo OK
574
575	echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (encode) $desc... " $ECHO_C
576	run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
577	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until0_03.9001.$in_fmt z50c.skip10.until0_03.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
578	$CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) $desc"
579	rm -f z50c.skip10.until0_03.9001.$out_fmt z50c.skip10.until0_03.9001.$in_fmt
580	echo OK
581
582	echo $ECHO_N "testing --skip=10 --until=+# (encode) $desc... " $ECHO_C
583	run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
584	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+30.$in_fmt z50c.skip10.until+30.$out_fmt || die "ERROR decoding FLAC file $desc"
585	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+30.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) $desc"
586	rm -f z50c.skip10.until+30.$out_fmt z50c.skip10.until+30.$in_fmt
587	echo OK
588
589	echo $ECHO_N "testing --skip=10 --until=+mm:ss (encode) $desc... " $ECHO_C
590	run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0_03.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
591	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_03.$in_fmt z50c.skip10.until+0_03.$out_fmt || die "ERROR decoding FLAC file $desc"
592	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until+0_03.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) $desc"
593	rm -f z50c.skip10.until+0_03.$out_fmt z50c.skip10.until+0_03.$in_fmt
594	echo OK
595
596	echo $ECHO_N "testing --skip=10 --until=+mm:ss.sss (encode) $desc... " $ECHO_C
597	run_flac $eopt --skip=10 --until=+0:02.9001 -o z50c.skip10.until+0_02.9001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
598	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until+0_02.9001.$in_fmt z50c.skip10.until+0_02.9001.$out_fmt || die "ERROR decoding FLAC file $desc"
599	$CMP 50c.skip10.until39.$in_fmt z50c.skip10.until+0_02.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=+0:02.9001 (encode) $desc"
600	rm -f z50c.skip10.until+0_02.9001.$out_fmt z50c.skip10.until+0_02.9001.$in_fmt
601	echo OK
602
603	echo $ECHO_N "testing --skip=10 --until=-# (encode) $desc... " $ECHO_C
604	run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
605	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-10.$in_fmt z50c.skip10.until-10.$out_fmt || die "ERROR decoding FLAC file $desc"
606	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) $desc"
607	rm -f z50c.skip10.until-10.$out_fmt z50c.skip10.until-10.$in_fmt
608	echo OK
609
610	echo $ECHO_N "testing --skip=10 --until=-mm:ss (encode) $desc... " $ECHO_C
611	run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
612	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.$in_fmt z50c.skip10.until-0_01.$out_fmt || die "ERROR decoding FLAC file $desc"
613	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) $desc"
614	rm -f z50c.skip10.until-0_01.$out_fmt z50c.skip10.until-0_01.$in_fmt
615	echo OK
616
617	echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (encode) $desc... " $ECHO_C
618	run_flac $eopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
619	[ $in_fmt = $out_fmt ] || run_flac $dopt -o z50c.skip10.until-0_01.1001.$in_fmt z50c.skip10.until-0_01.1001.$out_fmt || die "ERROR decoding FLAC file $desc"
620	$CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (encode) $desc"
621	rm -f z50c.skip10.until-0_01.1001.$out_fmt z50c.skip10.until-0_01.1001.$in_fmt
622	echo OK
623
624	#
625	# test --skip and --until when decoding
626	#
627
628	if [ $in_fmt != $out_fmt ] ; then run_flac $eopt -o z50c.$out_fmt 50c.$in_fmt ; else cp -f 50c.$in_fmt z50c.$out_fmt ; fi || die "ERROR generating FLAC file $desc"
629
630
631	echo $ECHO_N "testing --skip=10 --until=# (decode) $desc... " $ECHO_C
632	run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
633	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until40.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) $desc"
634	rm -f z50c.skip10.until40.$in_fmt
635	echo OK
636
637	echo $ECHO_N "testing --skip=10 --until=mm:ss (decode) $desc... " $ECHO_C
638	run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0_04.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
639	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until0_04.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) $desc"
640	rm -f z50c.skip10.until0_04.$in_fmt
641	echo OK
642
643	echo $ECHO_N "testing --skip=10 --until=mm:ss.sss (decode) $desc... " $ECHO_C
644	run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0_03.9001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
645	$CMP 50c.skip10.until39.$in_fmt z50c.skip10.until0_03.9001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) $desc"
646	rm -f z50c.skip10.until0_03.9001.$in_fmt
647	echo OK
648
649	echo $ECHO_N "testing --skip=10 --until=-# (decode) $desc... " $ECHO_C
650	run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
651	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-10.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) $desc"
652	rm -f z50c.skip10.until-10.$in_fmt
653	echo OK
654
655	echo $ECHO_N "testing --skip=10 --until=-mm:ss (decode) $desc... " $ECHO_C
656	run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0_01.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
657	$CMP 50c.skip10.until40.$in_fmt z50c.skip10.until-0_01.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) $desc"
658	rm -f z50c.skip10.until-0_01.$in_fmt
659	echo OK
660
661	echo $ECHO_N "testing --skip=10 --until=-mm:ss.sss (decode) $desc... " $ECHO_C
662	run_flac $dopt --skip=10 --until=-0:01.1001 -o z50c.skip10.until-0_01.1001.$in_fmt z50c.$out_fmt || die "ERROR decoding FLAC file $desc"
663	$CMP 50c.skip10.until39.$in_fmt z50c.skip10.until-0_01.1001.$in_fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01.1001 (decode) $desc"
664	rm -f z50c.skip10.until-0_01.1001.$in_fmt
665	echo OK
666
667	rm -f z50c.$out_fmt
668}
669
670test_skip_until raw flac
671test_skip_until wav flac
672test_skip_until aiff flac
673test_skip_until flac flac
674#@@@if [ $has_ogg = yes ] ; then
675#@@@	#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
676#@@@	test_skip_until ogg flac
677#@@@fi
678
679if [ $has_ogg = yes ] ; then
680	test_skip_until raw ogg
681	test_skip_until wav ogg
682	test_skip_until aiff ogg
683	#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
684	#@@@test_skip_until flac ogg
685	#@@@test_skip_until ogg ogg
686fi
687
688echo "testing seek extremes:"
689
690run_flac --verify --force --no-padding --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 noise.raw || die "ERROR generating FLAC file"
691
692if [ $is_win = no ] ; then
693	total_noise_cdda_samples=`run_metaflac --show-total-samples noise.flac`
694	[ $? = 0 ] || die "ERROR getting total sample count from noise.flac"
695else
696	# some flavors of cygwin don't seem to treat the \x0d as a word
697	# separator, so we hard code it.  we'll just have to fix it later
698	# if we change the way noise.flac is made.
699	total_noise_cdda_samples=393216
700fi
701
702echo $ECHO_N "testing --skip=0... " $ECHO_C
703run_flac $wav_dopt --skip=0 -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
704echo OK
705
706for delta in 2 1 ; do
707	n=`expr $total_noise_cdda_samples - $delta`
708	echo $ECHO_N "testing --skip=$n... " $ECHO_C
709	run_flac $wav_dopt --skip=$n -o z.wav noise.flac || die "ERROR decoding FLAC file noise.flac"
710	echo OK
711done
712
713rm noise.flac z.wav
714
715############################################################################
716# test --input-size
717############################################################################
718
719#@@@ cat will not work on old cygwin, need to fix
720if [ $is_win = no ] ; then
721	echo $ECHO_N "testing --input-size=50 --skip=10... " $ECHO_C
722	cat 50c.raw | run_flac $raw_eopt --input-size=50 --skip=10 -o z50c.skip10.flac - || die "ERROR generating FLAC file"
723	run_flac $raw_dopt -o z50c.skip10.raw z50c.skip10.flac || die "ERROR decoding FLAC file"
724	cmp 50c.skip10.raw z50c.skip10.raw || die "ERROR: file mismatch for --input-size=50 --skip=10"
725	rm -f z50c.skip10.raw z50c.skip10.flac
726	echo OK
727fi
728
729############################################################################
730# test --output-prefix
731############################################################################
732
733in_dir=./tmp_in
734out_dir=./tmp_out
735mkdir $in_dir $out_dir || die "ERROR failed to create temp directories"
736
737cp 50c.raw 50c.flac $in_dir
738
739#
740# test --output-prefix when encoding
741#
742
743echo $ECHO_N "testing --output-prefix=$out_dir/ (encode)... " $ECHO_C
744run_flac $raw_eopt --output-prefix=$out_dir/ $in_dir/50c.raw || die "ERROR generating FLAC file in $out_dir (encode)"
745[ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (encode)"
746run_flac $raw_dopt $out_dir/50c.flac || die "ERROR decoding FLAC file (encode)"
747[ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (encode)"
748cmp 50c.raw $out_dir/50c.raw || die "ERROR: file mismatch for --output-prefix=$out_dir (encode)"
749rm -f $out_dir/50c.flac $out_dir/50c.raw
750echo OK
751
752#
753# test --ouput-prefix when decoding
754#
755
756echo $ECHO_N "testing --output-prefix=$out_dir/ (decode)... " $ECHO_C
757run_flac $raw_dopt --output-prefix=$out_dir/ $in_dir/50c.flac || die "ERROR deocding FLAC file in $out_dir (decode)"
758[ -f $out_dir/50c.raw ] || die "ERROR RAW file not in $out_dir (decode)"
759run_flac $raw_eopt $out_dir/50c.raw || die "ERROR generating FLAC file (decode)"
760[ -f $out_dir/50c.flac ] || die "ERROR FLAC file not in $out_dir (decode)"
761cmp 50c.flac $out_dir/50c.flac || die "ERROR: file mismatch for --output-prefix=$out_dir (decode)"
762rm -f $out_dir/50c.flac $out_dir/50c.raw
763echo OK
764
765rm -rf $in_dir $out_dir
766
767############################################################################
768# test --cue
769############################################################################
770
771#
772# create the cue sheet
773#
774cuesheet=cuetest.cue
775cat > $cuesheet << EOF
776CATALOG 1234567890123
777FILE "blah" WAVE
778  TRACK 01 AUDIO
779    INDEX 01 0
780    INDEX 02 10
781    INDEX 03 20
782  TRACK 02 AUDIO
783    INDEX 01 30
784  TRACK 04 AUDIO
785    INDEX 01 40
786EOF
787
788test_cue ()
789{
790	in_fmt=$1
791	out_fmt=$2
792
793	[ "$in_fmt" = wav ] || [ "$in_fmt" = aiff ] || [ "$in_fmt" = raw ] || [ "$in_fmt" = flac ] || [ "$in_fmt" = ogg ] || die "ERROR: internal error, bad 'in' format '$in_fmt'"
794
795	[ "$out_fmt" = flac ] || [ "$out_fmt" = ogg ] || die "ERROR: internal error, bad 'out' format '$out_fmt'"
796
797	if [ $in_fmt = raw ] ; then
798		eopt="$raw_eopt"
799		dopt="$raw_dopt"
800	else
801		eopt="$wav_eopt"
802		dopt="$wav_dopt"
803	fi
804
805	if ( [ $in_fmt = flac ] || [ $in_fmt = ogg ] ) && ( [ $out_fmt = flac ] || [ $out_fmt = ogg ] ) ; then
806		CMP=md5cmp
807	else
808		CMP=cmp
809	fi
810
811	if [ $out_fmt = ogg ] ; then
812		eopt="--ogg $eopt"
813	fi
814
815	desc="($in_fmt<->$out_fmt)"
816
817	#
818	# for this we need just need just one FLAC file; --cue only works while decoding
819	#
820	run_flac $eopt --cuesheet=$cuesheet -o z50c.cue.$out_fmt 50c.$in_fmt || die "ERROR generating FLAC file $desc"
821
822	# To make it easy to translate from cue point to sample numbers, the
823	# file has a sample rate of 10 Hz and a cuesheet like so:
824	#
825	# TRACK 01, INDEX 01 : 0:00.00 -> sample 0
826	# TRACK 01, INDEX 02 : 0:01.00 -> sample 10
827	# TRACK 01, INDEX 03 : 0:02.00 -> sample 20
828	# TRACK 02, INDEX 01 : 0:03.00 -> sample 30
829	# TRACK 04, INDEX 01 : 0:04.00 -> sample 40
830	#
831	echo $ECHO_N "testing --cue=- $desc... " $ECHO_C
832	run_flac $dopt -o z50c.cued.$in_fmt --cue=- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
833	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=- $desc"
834	rm -f z50c.cued.$in_fmt
835	echo OK
836
837	echo $ECHO_N "testing --cue=1.0 $desc... " $ECHO_C
838	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
839	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0 $desc"
840	rm -f z50c.cued.$in_fmt
841	echo OK
842
843	echo $ECHO_N "testing --cue=1.0- $desc... " $ECHO_C
844	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
845	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0- $desc"
846	rm -f z50c.cued.$in_fmt
847	echo OK
848
849	echo $ECHO_N "testing --cue=1.1 $desc... " $ECHO_C
850	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
851	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1 $desc"
852	rm -f z50c.cued.$in_fmt
853	echo OK
854
855	echo $ECHO_N "testing --cue=1.1- $desc... " $ECHO_C
856	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
857	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1- $desc"
858	rm -f z50c.cued.$in_fmt
859	echo OK
860
861	echo $ECHO_N "testing --cue=1.2 $desc... " $ECHO_C
862	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
863	$CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2 $desc"
864	rm -f z50c.cued.$in_fmt
865	echo OK
866
867	echo $ECHO_N "testing --cue=1.2- $desc... " $ECHO_C
868	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
869	$CMP 50c.skip10.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2- $desc"
870	rm -f z50c.cued.$in_fmt
871	echo OK
872
873	echo $ECHO_N "testing --cue=1.4 $desc... " $ECHO_C
874	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
875	$CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4 $desc"
876	rm -f z50c.cued.$in_fmt
877	echo OK
878
879	echo $ECHO_N "testing --cue=1.4- $desc... " $ECHO_C
880	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4- z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
881	$CMP 50c.skip20.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4- $desc"
882	rm -f z50c.cued.$in_fmt
883	echo OK
884
885	echo $ECHO_N "testing --cue=-5.0 $desc... " $ECHO_C
886	run_flac $dopt -o z50c.cued.$in_fmt --cue=-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
887	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-5.0 $desc"
888	rm -f z50c.cued.$in_fmt
889	echo OK
890
891	echo $ECHO_N "testing --cue=-4.1 $desc... " $ECHO_C
892	run_flac $dopt -o z50c.cued.$in_fmt --cue=-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
893	$CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-4.1 $desc"
894	rm -f z50c.cued.$in_fmt
895	echo OK
896
897	echo $ECHO_N "testing --cue=-3.1 $desc... " $ECHO_C
898	run_flac $dopt -o z50c.cued.$in_fmt --cue=-3.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
899	$CMP 50c.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-3.1 $desc"
900	rm -f z50c.cued.$in_fmt
901	echo OK
902
903	echo $ECHO_N "testing --cue=-1.4 $desc... " $ECHO_C
904	run_flac $dopt -o z50c.cued.$in_fmt --cue=-1.4 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
905	$CMP 50c.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=-1.4 $desc"
906	rm -f z50c.cued.$in_fmt
907	echo OK
908
909	echo $ECHO_N "testing --cue=1.0-5.0 $desc... " $ECHO_C
910	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.0-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
911	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.0-5.0 $desc"
912	rm -f z50c.cued.$in_fmt
913	echo OK
914
915	echo $ECHO_N "testing --cue=1.1-5.0 $desc... " $ECHO_C
916	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.1-5.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
917	$CMP 50c.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.1-5.0 $desc"
918	rm -f z50c.cued.$in_fmt
919	echo OK
920
921	echo $ECHO_N "testing --cue=1.2-4.1 $desc... " $ECHO_C
922	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.2-4.1 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
923	$CMP 50c.skip10.until40.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.2-4.1 $desc"
924	rm -f z50c.cued.$in_fmt
925	echo OK
926
927	echo $ECHO_N "testing --cue=1.4-2.0 $desc... " $ECHO_C
928	run_flac $dopt -o z50c.cued.$in_fmt --cue=1.4-2.0 z50c.cue.$out_fmt || die "ERROR decoding FLAC file $desc"
929	$CMP 50c.skip20.until30.$in_fmt z50c.cued.$in_fmt || die "ERROR: file mismatch for --cue=1.4-2.0 $desc"
930	rm -f z50c.cued.$in_fmt
931	echo OK
932
933	rm -f z50c.cue.$out_fmt
934}
935
936test_cue raw flac
937test_cue wav flac
938test_cue aiff flac
939test_cue flac flac
940#@@@if [ $has_ogg = yes ] ; then
941#@@@	#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
942#@@@	test_cue ogg flac
943#@@@fi
944
945if [ $has_ogg = yes ] ; then
946	test_cue raw ogg
947	test_cue wav ogg
948	test_cue aiff ogg
949	#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
950	#@@@test_cue flac ogg
951	#@@@test_cue ogg ogg
952fi
953
954############################################################################
955# test 'fixup' code that happens when a FLAC file with total_samples == 0
956# in the STREAMINFO block is converted to WAVE or AIFF, requiring the
957# decoder go back and fix up the chunk headers
958############################################################################
959
960echo $ECHO_N "WAVE fixup test... " $ECHO_C
961
962echo $ECHO_N "prepare... " $ECHO_C
963convert_to_wav noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference WAVE"
964
965echo $ECHO_N "encode... " $ECHO_C
966# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
967# binary-mode stdin problem, so we use an undocumented option to metaflac to
968# set the total sample count to 0
969if [ $is_win = yes ] ; then
970	run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
971	run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
972else
973	cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
974fi
975
976echo $ECHO_N "decode... " $ECHO_C
977run_flac $wav_dopt fixup.flac -o fixup.wav || die "ERROR decoding FLAC file"
978
979echo $ECHO_N "compare... " $ECHO_C
980cmp noise.wav fixup.wav || die "ERROR: file mismatch"
981
982echo OK
983rm -f noise.wav fixup.wav fixup.flac
984
985echo $ECHO_N "AIFF fixup test... " $ECHO_C
986
987echo $ECHO_N "prepare... " $ECHO_C
988convert_to_aiff noise "$raw_eopt" "$wav_dopt" || die "ERROR creating reference AIFF"
989
990echo $ECHO_N "encode... " $ECHO_C
991# the pipe from 'cat' to 'flac' does not work on cygwin because of the EOF/
992# binary-mode stdin problem, so we use an undocumented option to metaflac to
993# set the total sample count to 0
994if [ $is_win = yes ] ; then
995	run_flac $raw_eopt noise.raw -o fixup.flac || die "ERROR generating FLAC file"
996	run_metaflac --set-total-samples=0 fixup.flac 2> /dev/null
997else
998	cat noise.raw | run_flac $raw_eopt - -c > fixup.flac || die "ERROR generating FLAC file"
999fi
1000
1001echo $ECHO_N "decode... " $ECHO_C
1002run_flac $wav_dopt fixup.flac -o fixup.aiff || die "ERROR decoding FLAC file"
1003
1004echo $ECHO_N "compare... " $ECHO_C
1005cmp noise.aiff fixup.aiff || die "ERROR: file mismatch"
1006
1007echo OK
1008rm -f noise.aiff fixup.aiff fixup.flac
1009
1010
1011############################################################################
1012# multi-file tests
1013############################################################################
1014
1015echo "Generating multiple input files from noise..."
1016multifile_format_decode="--endian=big --sign=signed"
1017multifile_format_encode="$multifile_format_decode --sample-rate=44100 --bps=16 --channels=2 --no-padding"
1018short_noise_cdda_samples=`expr $total_noise_cdda_samples / 8`
1019run_flac --verify --force --force-raw-format $multifile_format_encode --until=$short_noise_cdda_samples -o shortnoise.flac noise.raw || die "ERROR generating FLAC file"
1020run_flac --decode --force shortnoise.flac -o shortnoise.raw --force-raw-format $multifile_format_decode || die "ERROR generating RAW file"
1021run_flac --decode --force shortnoise.flac || die "ERROR generating WAVE file"
1022run_flac --decode --force shortnoise.flac -o shortnoise.aiff || die "ERROR generating AIFF file"
1023cp shortnoise.flac file0.flac
1024cp shortnoise.flac file1.flac
1025cp shortnoise.flac file2.flac
1026rm -f shortnoise.flac
1027cp shortnoise.wav file0.wav
1028cp shortnoise.wav file1.wav
1029cp shortnoise.wav file2.wav
1030rm -f shortnoise.wav
1031cp shortnoise.aiff file0.aiff
1032cp shortnoise.aiff file1.aiff
1033cp shortnoise.aiff file2.aiff
1034rm -f shortnoise.aiff
1035cp shortnoise.raw file0.raw
1036cp shortnoise.raw file1.raw
1037cp shortnoise.raw file2.raw
1038rm -f shortnoise.raw
1039# create authoritative sector-aligned files for comparison
1040file0_samples=`expr \( $short_noise_cdda_samples / 588 \) \* 588`
1041file0_remainder=`expr $short_noise_cdda_samples - $file0_samples`
1042file1_samples=`expr \( \( $file0_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
1043file1_remainder=`expr $file0_remainder + $short_noise_cdda_samples - $file1_samples`
1044file1_samples=`expr $file1_samples - $file0_remainder`
1045file2_samples=`expr \( \( $file1_remainder + $short_noise_cdda_samples \) / 588 \) \* 588`
1046file2_remainder=`expr $file1_remainder + $short_noise_cdda_samples - $file2_samples`
1047file2_samples=`expr $file2_samples - $file1_remainder`
1048if [ $file2_remainder != '0' ] ; then
1049	file2_samples=`expr $file2_samples + $file2_remainder`
1050	file2_remainder=`expr 588 - $file2_remainder`
1051fi
1052
1053dd if=file0.raw ibs=4 count=$file0_samples of=file0s.raw 2>/dev/null || $dddie
1054dd if=file0.raw ibs=4 count=$file0_remainder of=file1s.raw skip=$file0_samples 2>/dev/null || $dddie
1055dd if=file1.raw ibs=4 count=$file1_samples of=z.raw 2>/dev/null || $dddie
1056cat z.raw >> file1s.raw || die "ERROR: cat-ing sector-aligned files"
1057dd if=file1.raw ibs=4 count=$file1_remainder of=file2s.raw skip=$file1_samples 2>/dev/null || $dddie
1058dd if=file2.raw ibs=4 count=$file2_samples of=z.raw 2>/dev/null || $dddie
1059cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
1060dd if=/dev/zero ibs=4 count=$file2_remainder of=z.raw 2>/dev/null || $dddie
1061cat z.raw >> file2s.raw || die "ERROR: cat-ing sector-aligned files"
1062rm -f z.raw
1063
1064convert_to_wav file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
1065convert_to_wav file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
1066convert_to_wav file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned WAVE"
1067
1068convert_to_aiff file0s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
1069convert_to_aiff file1s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
1070convert_to_aiff file2s "$multifile_format_encode --force --force-raw-format" "$SILENT --force --decode" || die "ERROR creating authoritative sector-aligned AIFF"
1071
1072test_multifile ()
1073{
1074	input_type=$1
1075	streamtype=$2
1076	sector_align=$3
1077	encode_options="$4"
1078
1079	extra_encode_options=""
1080	extra_decode_options=""
1081	if [ $input_type = "raw" ] ; then
1082		extra_encode_options="--force-raw-format $multifile_format_encode"
1083		extra_decode_options="--force-raw-format $multifile_format_decode"
1084	else
1085		if [ $input_type = "aiff" ] ; then
1086			extra_decode_options="--force-aiff-format"
1087		fi
1088	fi
1089
1090	if [ $streamtype = ogg ] ; then
1091		suffix=oga
1092		encode_options="$encode_options --ogg"
1093	else
1094		suffix=flac
1095	fi
1096
1097	if [ $sector_align = sector_align ] ; then
1098		encode_options="$encode_options --sector-align"
1099	fi
1100
1101	if [ $input_type = flac ] || [ $input_type = ogg ] ; then
1102		CMP=md5cmp
1103	else
1104		CMP=cmp
1105	fi
1106
1107	for n in 0 1 2 ; do
1108		cp file$n.$input_type file${n}x.$input_type
1109	done
1110	run_flac --force $encode_options $extra_encode_options file0x.$input_type file1x.$input_type file2x.$input_type || die "ERROR"
1111	run_flac --force --decode $extra_decode_options file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
1112	if [ $sector_align != sector_align ] ; then
1113		for n in 0 1 2 ; do
1114			$CMP file$n.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
1115		done
1116	else
1117		for n in 0 1 2 ; do
1118			$CMP file${n}s.$input_type file${n}x.$input_type || die "ERROR: file mismatch on file #$n"
1119		done
1120	fi
1121	for n in 0 1 2 ; do
1122		rm -f file${n}x.$suffix file${n}x.$input_type
1123	done
1124}
1125
1126input_types="raw wav aiff flac"
1127#@@@ doesn't work yet because md5cmp doesn't work because metaflac doesn't work on ogg flac yet
1128#@@@if [ $has_ogg = yes ] ; then
1129#@@@	input_types="$input_types ogg"
1130#@@@fi
1131for input_type in $input_types ; do
1132	echo "Testing multiple $input_type files without verify..."
1133	test_multifile $input_type flac no_sector_align ""
1134
1135	echo "Testing multiple $input_type files with verify..."
1136	test_multifile $input_type flac no_sector_align "--verify"
1137
1138	if [ $input_type != flac ] && [ $input_type != ogg ] ; then # --sector-align not supported for FLAC input
1139		echo "Testing multiple $input_type files with --sector-align, without verify..."
1140		test_multifile $input_type flac sector_align ""
1141
1142		echo "Testing multiple $input_type files with --sector-align, with verify..."
1143		test_multifile $input_type flac sector_align "--verify"
1144	fi
1145
1146	if [ $has_ogg = yes ] ; then
1147		echo "Testing multiple $input_type files with --ogg, without verify..."
1148		test_multifile $input_type ogg no_sector_align ""
1149
1150		echo "Testing multiple $input_type files with --ogg, with verify..."
1151		test_multifile $input_type ogg no_sector_align "--verify"
1152
1153		if [ $input_type != flac ] ; then # --sector-align not supported for FLAC input
1154			echo "Testing multiple $input_type files with --ogg and --sector-align, without verify..."
1155			test_multifile $input_type ogg sector_align ""
1156
1157			echo "Testing multiple $input_type files with --ogg and --sector-align, with verify..."
1158			test_multifile $input_type ogg sector_align "--verify"
1159		fi
1160
1161		echo "Testing multiple $input_type files with --ogg and --serial-number, with verify..."
1162		test_multifile $input_type ogg no_sector_align "--serial-number=321 --verify"
1163	fi
1164done
1165
1166
1167############################################################################
1168# test --keep-foreign-metadata
1169############################################################################
1170
1171echo "Testing --keep-foreign-metadata..."
1172
1173rt_test_wav wacky1.wav '--keep-foreign-metadata'
1174rt_test_wav wacky2.wav '--keep-foreign-metadata'
1175rt_test_w64 wacky1.w64 '--keep-foreign-metadata'
1176rt_test_w64 wacky2.w64 '--keep-foreign-metadata'
1177rt_test_rf64 wacky1.rf64 '--keep-foreign-metadata'
1178rt_test_rf64 wacky2.rf64 '--keep-foreign-metadata'
1179
1180
1181############################################################################
1182# test the metadata-handling properties of flac-to-flac encoding
1183############################################################################
1184
1185echo "Testing the metadata-handling properties of flac-to-flac encoding..."
1186
1187testdatadir=${top_srcdir}/test/flac-to-flac-metadata-test-files
1188
1189filter ()
1190{
1191	# minor danger, changing vendor strings might change the length of the
1192	# VORBIS_COMMENT block, but if we add "^  length: " to the patterns,
1193	# we lose info about PADDING size that we need
1194	grep -Ev '^  vendor string: |^  m..imum .....size: ' | sed -e 's/, stream_offset.*//'
1195}
1196flac2flac ()
1197{
1198	file="$testdatadir/$1"
1199	case="$testdatadir/$2"
1200	args="$3"
1201	expect="$case-expect.meta"
1202	echo $ECHO_N "$2... " $ECHO_C
1203	# The 'make distcheck' target needs this.
1204	chmod u+w $file
1205	run_flac -f -o out.flac $args $file || die "ERROR encoding FLAC file"
1206	run_metaflac --list out.flac | filter > out1.meta || die "ERROR listing metadata of output FLAC file"
1207    # Ignore lengths which can be affected by the version string.
1208    sed "s/length:.*/length: XXX/" out1.meta > out.meta
1209	diff -q -w $expect out.meta 2>/dev/null || die "ERROR: metadata does not match expected $expect"
1210	echo OK
1211}
1212
1213#filter=', stream_offset.*|^  vendor string: |^  length: |^  m..imum .....size: '
1214
1215# case 00a: no alterations on a file with all metadata types, keep all metadata, in same order
1216flac2flac input-SCVAUP.flac case00a ""
1217# case 01a: on file with multiple PADDING blocks, they should be aggregated into one at the end
1218flac2flac input-SCVPAP.flac case01a ""
1219# case 01b: on file with multiple PADDING blocks and --no-padding specified, they should all be deleted
1220flac2flac input-SCVPAP.flac case01b "--no-padding"
1221# case 01c: on file with multiple PADDING blocks and -P specified, they should all be overwritten with -P value
1222flac2flac input-SCVPAP.flac case01c "-P 1234"
1223# case 01d: on file with no PADDING blocks, use -P setting
1224flac2flac input-SCVA.flac case01d "-P 1234"
1225# case 01e: on file with no PADDING blocks and no -P given, use default padding
1226flac2flac input-SCVA.flac case01e ""
1227# case 02a: on file with no VORBIS_COMMENT block, add new VORBIS_COMMENT
1228flac2flac input-SCPAP.flac case02a ""
1229# case 02b: on file with no VORBIS_COMMENT block and --tag, add new VORBIS_COMMENT with tags
1230flac2flac input-SCPAP.flac case02b "--tag=artist=0"
1231# case 02c: on file with VORBIS_COMMENT block and --tag, replace existing VORBIS_COMMENT with new tags
1232flac2flac input-SCVAUP.flac case02c "--tag=artist=0"
1233# case 03a: on file with no CUESHEET block and --cuesheet specified, add it
1234flac2flac input-SVAUP.flac case03a "--cuesheet=$testdatadir/input0.cue"
1235# case 03b: on file with CUESHEET block and --cuesheet specified, overwrite existing CUESHEET
1236flac2flac input-SCVAUP.flac case03b "--cuesheet=$testdatadir/input0.cue"
1237# case 03c: on file with CUESHEET block and size-changing option specified, drop existing CUESHEET
1238flac2flac input-SCVAUP.flac case03c "--skip=1"
1239# case 04a: on file with no SEEKTABLE block and --no-seektable specified, no SEEKTABLE
1240flac2flac input-VA.flac case04a "--no-padding --no-seektable"
1241# case 04b: on file with no SEEKTABLE block and -S specified, new SEEKTABLE
1242flac2flac input-VA.flac case04b "--no-padding -S 5x"
1243# case 04c: on file with no SEEKTABLE block and no seektable options specified, new SEEKTABLE with default points
1244flac2flac input-VA.flac case04c "--no-padding"
1245# case 04d: on file with SEEKTABLE block and --no-seektable specified, drop existing SEEKTABLE
1246flac2flac input-SCVA.flac case04d "--no-padding --no-seektable"
1247# case 04e: on file with SEEKTABLE block and -S specified, overwrite existing SEEKTABLE
1248flac2flac input-SCVA.flac case04e "--no-padding -S 5x"
1249# case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points
1250#(already covered by case03c)
1251
1252rm -f out.flac out.meta out1.meta
1253
1254#@@@ when metaflac handles ogg flac, duplicate flac2flac tests here
1255
1256cd ..
1257