blob: b22d49a5c0a9cc1644d77b3f6ce02f3c990e2252 [file] [log] [blame]
Josh Coalson463d0f82002-12-10 06:41:27 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
4# Copyright (C) 2001,2002 Josh Coalson
5#
6# This program is part of FLAC; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
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{
34 if [ "$FLAC__VALGRIND" = yes ] ; then
35 valgrind --leak-check=yes --show-reachable=yes --num-callers=10 --logfile-fd=4 flac $* 4>>valgrind.log
36 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 Coalson8fac5d62002-12-12 03:57:47 +000050############################################################################
51# test --skip and --until
52############################################################################
53
Josh Coalson463d0f82002-12-10 06:41:27 +000054#
Josh Coalson8232e292002-12-14 06:22:22 +000055# first make some chopped-up raw files
Josh Coalson463d0f82002-12-10 06:41:27 +000056#
Josh Coalson8fac5d62002-12-12 03:57:47 +000057echo "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMN" > master.raw
58dddie="die ERROR: creating files for --skip/--until tests"
59dd if=master.raw ibs=1 count=50 of=50c.raw 2>/dev/null || $dddie
60dd if=master.raw ibs=1 skip=10 count=40 of=50c.skip10.raw 2>/dev/null || $dddie
61dd if=master.raw ibs=1 skip=11 count=39 of=50c.skip11.raw 2>/dev/null || $dddie
62dd if=master.raw ibs=1 count=40 of=50c.until40.raw 2>/dev/null || $dddie
63dd if=master.raw ibs=1 count=39 of=50c.until39.raw 2>/dev/null || $dddie
64dd if=master.raw ibs=1 skip=10 count=30 of=50c.skip10.until40.raw 2>/dev/null || $dddie
65dd 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 +000066
Josh Coalson8232e292002-12-14 06:22:22 +000067wav_eopt="--silent --verify --lax"
68wav_dopt="--silent --decode"
69
70raw_eopt="$wav_eopt --force-raw-format --endian=big --sign=signed --sample-rate=10 --bps=8 --channels=1"
71raw_dopt="$wav_dopt --force-raw-format --endian=big --sign=signed"
Josh Coalson8fac5d62002-12-12 03:57:47 +000072
73#
Josh Coalson8232e292002-12-14 06:22:22 +000074# convert them to WAVE files
Josh Coalson8fac5d62002-12-12 03:57:47 +000075#
Josh Coalson8232e292002-12-14 06:22:22 +000076convert_to_wav ()
77{
78 run_flac $raw_eopt $1.raw || die "ERROR converting $1.raw to WAVE"
79 run_flac $wav_dopt $1.flac || die "ERROR converting $1.raw to WAVE"
80}
81convert_to_wav 50c
82convert_to_wav 50c.skip10
83convert_to_wav 50c.skip11
84convert_to_wav 50c.until40
85convert_to_wav 50c.until39
86convert_to_wav 50c.skip10.until40
87convert_to_wav 50c.skip10.until39
Josh Coalson8fac5d62002-12-12 03:57:47 +000088
Josh Coalson8232e292002-12-14 06:22:22 +000089test_skip_until ()
90{
91 fmt=$1
Josh Coalson463d0f82002-12-10 06:41:27 +000092
Josh Coalson8232e292002-12-14 06:22:22 +000093 [ $fmt = wav ] || [ $fmt = raw ] || die "ERROR: internal error, bad format '$fmt'"
Josh Coalson463d0f82002-12-10 06:41:27 +000094
Josh Coalson8232e292002-12-14 06:22:22 +000095 if [ $fmt = raw ] ; then
96 eopt="$raw_eopt"
97 dopt="$raw_dopt"
98 else
99 eopt="$wav_eopt"
100 dopt="$wav_dopt"
101 fi
Josh Coalson463d0f82002-12-10 06:41:27 +0000102
Josh Coalson8232e292002-12-14 06:22:22 +0000103 #
104 # test --skip when encoding
105 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000106
Josh Coalson8232e292002-12-14 06:22:22 +0000107 echo -n "testing --skip=# (encode) ($fmt)... "
108 run_flac $eopt --skip=10 -o z50c.skip10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
109 run_flac $dopt -o z50c.skip10.$fmt z50c.skip10.flac || die "ERROR decoding FLAC file ($fmt)"
110 cmp 50c.skip10.$fmt z50c.skip10.$fmt || die "ERROR: file mismatch for --skip=10 (encode) ($fmt)"
111 rm -f z50c.skip10.flac z50c.skip10.$fmt
112 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000113
Josh Coalson8232e292002-12-14 06:22:22 +0000114 echo -n "testing --skip=mm:ss (encode) ($fmt)... "
115 run_flac $eopt --skip=0:01 -o z50c.skip0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
116 run_flac $dopt -o z50c.skip0:01.$fmt z50c.skip0:01.flac || die "ERROR decoding FLAC file ($fmt)"
117 cmp 50c.skip10.$fmt z50c.skip0:01.$fmt || die "ERROR: file mismatch for --skip=0:01 (encode) ($fmt)"
118 rm -f z50c.skip0:01.flac z50c.skip0:01.$fmt
119 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000120
Josh Coalson8232e292002-12-14 06:22:22 +0000121 echo -n "testing --skip=mm:ss.sss (encode) ($fmt)... "
122 run_flac $eopt --skip=0:01.1001 -o z50c.skip0:01.1001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
123 run_flac $dopt -o z50c.skip0:01.1001.$fmt z50c.skip0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
124 cmp 50c.skip11.$fmt z50c.skip0:01.1001.$fmt || die "ERROR: file mismatch for --skip=0:01.1001 (encode) ($fmt)"
125 rm -f z50c.skip0:01.1001.flac z50c.skip0:01.1001.$fmt
126 echo OK
Josh Coalson463d0f82002-12-10 06:41:27 +0000127
Josh Coalson8232e292002-12-14 06:22:22 +0000128 #
129 # test --skip when decoding
130 #
Josh Coalson463d0f82002-12-10 06:41:27 +0000131
Josh Coalson8232e292002-12-14 06:22:22 +0000132 echo -n "testing --skip=# (decode) ($fmt)... "
133 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
134 run_flac $dopt --skip=10 -o z50c.skip10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
135 cmp 50c.skip10.$fmt z50c.skip10.$fmt || die "ERROR: file mismatch for --skip=10 (decode) ($fmt)"
136 rm -f z50c.skip10.$fmt
137 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000138
Josh Coalson8232e292002-12-14 06:22:22 +0000139 echo -n "testing --skip=mm:ss (decode) ($fmt)... "
140 run_flac $dopt --skip=0:01 -o z50c.skip0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
141 cmp 50c.skip10.$fmt z50c.skip0:01.$fmt || die "ERROR: file mismatch for --skip=0:01 (decode) ($fmt)"
142 rm -f z50c.skip0:01.$fmt
143 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000144
Josh Coalson8232e292002-12-14 06:22:22 +0000145 echo -n "testing --skip=mm:ss.sss (decode) ($fmt)... "
146 run_flac $dopt --skip=0:01.1001 -o z50c.skip0:01.1001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
147 cmp 50c.skip11.$fmt z50c.skip0:01.1001.$fmt || die "ERROR: file mismatch for --skip=0:01.1001 (decode) ($fmt)"
148 rm -f z50c.skip0:01.1001.$fmt
149 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000150
Josh Coalson8232e292002-12-14 06:22:22 +0000151 rm -f z50c.flac
Josh Coalson8fac5d62002-12-12 03:57:47 +0000152
Josh Coalson8232e292002-12-14 06:22:22 +0000153 #
154 # test --until when encoding
155 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000156
Josh Coalson8232e292002-12-14 06:22:22 +0000157 echo -n "testing --until=# (encode) ($fmt)... "
158 run_flac $eopt --until=40 -o z50c.until40.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
159 run_flac $dopt -o z50c.until40.$fmt z50c.until40.flac || die "ERROR decoding FLAC file ($fmt)"
160 cmp 50c.until40.$fmt z50c.until40.$fmt || die "ERROR: file mismatch for --until=40 (encode) ($fmt)"
161 rm -f z50c.until40.flac z50c.until40.$fmt
162 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000163
Josh Coalson8232e292002-12-14 06:22:22 +0000164 echo -n "testing --until=mm:ss (encode) ($fmt)... "
165 run_flac $eopt --until=0:04 -o z50c.until0:04.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
166 run_flac $dopt -o z50c.until0:04.$fmt z50c.until0:04.flac || die "ERROR decoding FLAC file ($fmt)"
167 cmp 50c.until40.$fmt z50c.until0:04.$fmt || die "ERROR: file mismatch for --until=0:04 (encode) ($fmt)"
168 rm -f z50c.until0:04.flac z50c.until0:04.$fmt
169 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000170
Josh Coalson8232e292002-12-14 06:22:22 +0000171 echo -n "testing --until=mm:ss.sss (encode) ($fmt)... "
172 run_flac $eopt --until=0:03.9001 -o z50c.until0:03.9001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
173 run_flac $dopt -o z50c.until0:03.9001.$fmt z50c.until0:03.9001.flac || die "ERROR decoding FLAC file ($fmt)"
174 cmp 50c.until39.$fmt z50c.until0:03.9001.$fmt || die "ERROR: file mismatch for --until=0:03.9001 (encode) ($fmt)"
175 rm -f z50c.until0:03.9001.flac z50c.until0:03.9001.$fmt
176 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000177
Josh Coalson8232e292002-12-14 06:22:22 +0000178 echo -n "testing --until=-# (encode) ($fmt)... "
179 run_flac $eopt --until=-10 -o z50c.until-10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
180 run_flac $dopt -o z50c.until-10.$fmt z50c.until-10.flac || die "ERROR decoding FLAC file ($fmt)"
181 cmp 50c.until40.$fmt z50c.until-10.$fmt || die "ERROR: file mismatch for --until=-10 (encode) ($fmt)"
182 rm -f z50c.until-10.flac z50c.until-10.$fmt
183 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000184
Josh Coalson8232e292002-12-14 06:22:22 +0000185 echo -n "testing --until=-mm:ss (encode) ($fmt)... "
186 run_flac $eopt --until=-0:01 -o z50c.until-0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
187 run_flac $dopt -o z50c.until-0:01.$fmt z50c.until-0:01.flac || die "ERROR decoding FLAC file ($fmt)"
188 cmp 50c.until40.$fmt z50c.until-0:01.$fmt || die "ERROR: file mismatch for --until=-0:01 (encode) ($fmt)"
189 rm -f z50c.until-0:01.flac z50c.until-0:01.$fmt
190 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000191
Josh Coalson8232e292002-12-14 06:22:22 +0000192 echo -n "testing --until=-mm:ss.sss (encode) ($fmt)... "
193 run_flac $eopt --until=-0:01.1001 -o z50c.until-0:01.1001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
194 run_flac $dopt -o z50c.until-0:01.1001.$fmt z50c.until-0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
195 cmp 50c.until39.$fmt z50c.until-0:01.1001.$fmt || die "ERROR: file mismatch for --until=-0:01.1001 (encode) ($fmt)"
196 rm -f z50c.until-0:01.1001.flac z50c.until-0:01.1001.$fmt
197 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000198
Josh Coalson8232e292002-12-14 06:22:22 +0000199 #
200 # test --until when decoding
201 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000202
Josh Coalson8232e292002-12-14 06:22:22 +0000203 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000204
Josh Coalson8232e292002-12-14 06:22:22 +0000205 echo -n "testing --until=# (decode) ($fmt)... "
206 run_flac $dopt --until=40 -o z50c.until40.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
207 cmp 50c.until40.$fmt z50c.until40.$fmt || die "ERROR: file mismatch for --until=40 (decode) ($fmt)"
208 rm -f z50c.until40.$fmt
209 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000210
Josh Coalson8232e292002-12-14 06:22:22 +0000211 echo -n "testing --until=mm:ss (decode) ($fmt)... "
212 run_flac $dopt --until=0:04 -o z50c.until0:04.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
213 cmp 50c.until40.$fmt z50c.until0:04.$fmt || die "ERROR: file mismatch for --until=0:04 (decode) ($fmt)"
214 rm -f z50c.until0:04.$fmt
215 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000216
Josh Coalson8232e292002-12-14 06:22:22 +0000217 echo -n "testing --until=mm:ss.sss (decode) ($fmt)... "
218 run_flac $dopt --until=0:03.9001 -o z50c.until0:03.9001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
219 cmp 50c.until39.$fmt z50c.until0:03.9001.$fmt || die "ERROR: file mismatch for --until=0:03.9001 (decode) ($fmt)"
220 rm -f z50c.until0:03.9001.$fmt
221 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000222
Josh Coalson8232e292002-12-14 06:22:22 +0000223 echo -n "testing --until=-# (decode) ($fmt)... "
224 run_flac $dopt --until=-10 -o z50c.until-10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
225 cmp 50c.until40.$fmt z50c.until-10.$fmt || die "ERROR: file mismatch for --until=-10 (decode) ($fmt)"
226 rm -f z50c.until-10.$fmt
227 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000228
Josh Coalson8232e292002-12-14 06:22:22 +0000229 echo -n "testing --until=-mm:ss (decode) ($fmt)... "
230 run_flac $dopt --until=-0:01 -o z50c.until-0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
231 cmp 50c.until40.$fmt z50c.until-0:01.$fmt || die "ERROR: file mismatch for --until=-0:01 (decode) ($fmt)"
232 rm -f z50c.until-0:01.$fmt
233 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000234
Josh Coalson8232e292002-12-14 06:22:22 +0000235 echo -n "testing --until=-mm:ss.sss (decode) ($fmt)... "
236 run_flac $dopt --until=-0:01.1001 -o z50c.until-0:01.1001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
237 cmp 50c.until39.$fmt z50c.until-0:01.1001.$fmt || die "ERROR: file mismatch for --until=-0:01.1001 (decode) ($fmt)"
238 rm -f z50c.until-0:01.1001.$fmt
239 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000240
Josh Coalson8232e292002-12-14 06:22:22 +0000241 rm -f z50c.flac
Josh Coalson8fac5d62002-12-12 03:57:47 +0000242
Josh Coalson8232e292002-12-14 06:22:22 +0000243 #
244 # test --skip and --until when encoding
245 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000246
Josh Coalson8232e292002-12-14 06:22:22 +0000247 echo -n "testing --skip=10 --until=# (encode) ($fmt)... "
248 run_flac $eopt --skip=10 --until=40 -o z50c.skip10.until40.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
249 run_flac $dopt -o z50c.skip10.until40.$fmt z50c.skip10.until40.flac || die "ERROR decoding FLAC file ($fmt)"
250 cmp 50c.skip10.until40.$fmt z50c.skip10.until40.$fmt || die "ERROR: file mismatch for --skip=10 --until=40 (encode) ($fmt)"
251 rm -f z50c.skip10.until40.flac z50c.skip10.until40.$fmt
252 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000253
Josh Coalson8232e292002-12-14 06:22:22 +0000254 echo -n "testing --skip=10 --until=mm:ss (encode) ($fmt)... "
255 run_flac $eopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
256 run_flac $dopt -o z50c.skip10.until0:04.$fmt z50c.skip10.until0:04.flac || die "ERROR decoding FLAC file ($fmt)"
257 cmp 50c.skip10.until40.$fmt z50c.skip10.until0:04.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (encode) ($fmt)"
258 rm -f z50c.skip10.until0:04.flac z50c.skip10.until0:04.$fmt
259 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000260
Josh Coalson8232e292002-12-14 06:22:22 +0000261 echo -n "testing --skip=10 --until=mm:ss.sss (encode) ($fmt)... "
262 run_flac $eopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
263 run_flac $dopt -o z50c.skip10.until0:03.9001.$fmt z50c.skip10.until0:03.9001.flac || die "ERROR decoding FLAC file ($fmt)"
264 cmp 50c.skip10.until39.$fmt z50c.skip10.until0:03.9001.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (encode) ($fmt)"
265 rm -f z50c.skip10.until0:03.9001.flac z50c.skip10.until0:03.9001.$fmt
266 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000267
Josh Coalson8232e292002-12-14 06:22:22 +0000268 echo -n "testing --skip=10 --until=+# (encode) ($fmt)... "
269 run_flac $eopt --skip=10 --until=+30 -o z50c.skip10.until+30.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
270 run_flac $dopt -o z50c.skip10.until+30.$fmt z50c.skip10.until+30.flac || die "ERROR decoding FLAC file ($fmt)"
271 cmp 50c.skip10.until40.$fmt z50c.skip10.until+30.$fmt || die "ERROR: file mismatch for --skip=10 --until=+30 (encode) ($fmt)"
272 rm -f z50c.skip10.until+30.flac z50c.skip10.until+30.$fmt
273 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000274
Josh Coalson8232e292002-12-14 06:22:22 +0000275 echo -n "testing --skip=10 --until=+mm:ss (encode) ($fmt)... "
276 run_flac $eopt --skip=10 --until=+0:03 -o z50c.skip10.until+0:03.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
277 run_flac $dopt -o z50c.skip10.until+0:03.$fmt z50c.skip10.until+0:03.flac || die "ERROR decoding FLAC file ($fmt)"
278 cmp 50c.skip10.until40.$fmt z50c.skip10.until+0:03.$fmt || die "ERROR: file mismatch for --skip=10 --until=+0:03 (encode) ($fmt)"
279 rm -f z50c.skip10.until+0:03.flac z50c.skip10.until+0:03.$fmt
280 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000281
Josh Coalson8232e292002-12-14 06:22:22 +0000282 echo -n "testing --skip=10 --until=+mm:ss.sss (encode) ($fmt)... "
283 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)"
284 run_flac $dopt -o z50c.skip10.until+0:02.9001.$fmt z50c.skip10.until+0:02.9001.flac || die "ERROR decoding FLAC file ($fmt)"
285 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)"
286 rm -f z50c.skip10.until+0:02.9001.flac z50c.skip10.until+0:02.9001.$fmt
287 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000288
Josh Coalson8232e292002-12-14 06:22:22 +0000289 echo -n "testing --skip=10 --until=-# (encode) ($fmt)... "
290 run_flac $eopt --skip=10 --until=-10 -o z50c.skip10.until-10.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
291 run_flac $dopt -o z50c.skip10.until-10.$fmt z50c.skip10.until-10.flac || die "ERROR decoding FLAC file ($fmt)"
292 cmp 50c.skip10.until40.$fmt z50c.skip10.until-10.$fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (encode) ($fmt)"
293 rm -f z50c.skip10.until-10.flac z50c.skip10.until-10.$fmt
294 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000295
Josh Coalson8232e292002-12-14 06:22:22 +0000296 echo -n "testing --skip=10 --until=-mm:ss (encode) ($fmt)... "
297 run_flac $eopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
298 run_flac $dopt -o z50c.skip10.until-0:01.$fmt z50c.skip10.until-0:01.flac || die "ERROR decoding FLAC file ($fmt)"
299 cmp 50c.skip10.until40.$fmt z50c.skip10.until-0:01.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (encode) ($fmt)"
300 rm -f z50c.skip10.until-0:01.flac z50c.skip10.until-0:01.$fmt
301 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000302
Josh Coalson8232e292002-12-14 06:22:22 +0000303 echo -n "testing --skip=10 --until=-mm:ss.sss (encode) ($fmt)... "
304 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)"
305 run_flac $dopt -o z50c.skip10.until-0:01.1001.$fmt z50c.skip10.until-0:01.1001.flac || die "ERROR decoding FLAC file ($fmt)"
306 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)"
307 rm -f z50c.skip10.until-0:01.1001.flac z50c.skip10.until-0:01.1001.$fmt
308 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000309
Josh Coalson8232e292002-12-14 06:22:22 +0000310 #
311 # test --skip and --until when decoding
312 #
Josh Coalson8fac5d62002-12-12 03:57:47 +0000313
Josh Coalson8232e292002-12-14 06:22:22 +0000314 run_flac $eopt -o z50c.flac 50c.$fmt || die "ERROR generating FLAC file ($fmt)"
Josh Coalson8fac5d62002-12-12 03:57:47 +0000315
Josh Coalson8232e292002-12-14 06:22:22 +0000316 echo -n "testing --skip=10 --until=# (decode) ($fmt)... "
317 run_flac $dopt --skip=10 --until=40 -o z50c.skip10.until40.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
318 cmp 50c.skip10.until40.$fmt z50c.skip10.until40.$fmt || die "ERROR: file mismatch for --skip=10 --until=40 (decode) ($fmt)"
319 rm -f z50c.skip10.until40.$fmt
320 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000321
Josh Coalson8232e292002-12-14 06:22:22 +0000322 echo -n "testing --skip=10 --until=mm:ss (decode) ($fmt)... "
323 run_flac $dopt --skip=10 --until=0:04 -o z50c.skip10.until0:04.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
324 cmp 50c.skip10.until40.$fmt z50c.skip10.until0:04.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:04 (decode) ($fmt)"
325 rm -f z50c.skip10.until0:04.$fmt
326 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000327
Josh Coalson8232e292002-12-14 06:22:22 +0000328 echo -n "testing --skip=10 --until=mm:ss.sss (decode) ($fmt)... "
329 run_flac $dopt --skip=10 --until=0:03.9001 -o z50c.skip10.until0:03.9001.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
330 cmp 50c.skip10.until39.$fmt z50c.skip10.until0:03.9001.$fmt || die "ERROR: file mismatch for --skip=10 --until=0:03.9001 (decode) ($fmt)"
331 rm -f z50c.skip10.until0:03.9001.$fmt
332 echo OK
Josh Coalson8fac5d62002-12-12 03:57:47 +0000333
Josh Coalson8232e292002-12-14 06:22:22 +0000334 echo -n "testing --skip=10 --until=-# (decode) ($fmt)... "
335 run_flac $dopt --skip=10 --until=-10 -o z50c.skip10.until-10.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
336 cmp 50c.skip10.until40.$fmt z50c.skip10.until-10.$fmt || die "ERROR: file mismatch for --skip=10 --until=-10 (decode) ($fmt)"
337 rm -f z50c.skip10.until-10.$fmt
338 echo OK
339
340 echo -n "testing --skip=10 --until=-mm:ss (decode) ($fmt)... "
341 run_flac $dopt --skip=10 --until=-0:01 -o z50c.skip10.until-0:01.$fmt z50c.flac || die "ERROR decoding FLAC file ($fmt)"
342 cmp 50c.skip10.until40.$fmt z50c.skip10.until-0:01.$fmt || die "ERROR: file mismatch for --skip=10 --until=-0:01 (decode) ($fmt)"
343 rm -f z50c.skip10.until-0:01.$fmt
344 echo OK
345
346 echo -n "testing --skip=10 --until=-mm:ss.sss (decode) ($fmt)... "
347 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)"
348 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)"
349 rm -f z50c.skip10.until-0:01.1001.$fmt
350 echo OK
351
352 rm -f z50c.flac
353}
354
355test_skip_until raw
356test_skip_until wav
Josh Coalson463d0f82002-12-10 06:41:27 +0000357
358#
359# multi-file tests
360#
361
362echo "Generating streams..."
363if [ ! -f wacky1.wav ] ; then
Josh Coalson8fac5d62002-12-12 03:57:47 +0000364 test_streams || die "ERROR during test_streams"
Josh Coalson463d0f82002-12-10 06:41:27 +0000365fi
366
367echo "Generating multiple input files from noise..."
Josh Coalson8fac5d62002-12-12 03:57:47 +0000368run_flac --verify --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 noise.raw || die "ERROR generating FLAC file"
369run_flac --decode --silent noise.flac || die "ERROR generating WAVE file"
Josh Coalson463d0f82002-12-10 06:41:27 +0000370rm -f noise.flac
371mv noise.wav file0.wav
372cp file0.wav file1.wav
373cp file1.wav file2.wav
374
375test_multifile ()
376{
377 streamtype=$1
378 sector_align=$2
379 encode_options="$3"
380
381 if [ $streamtype = ogg ] ; then
382 suffix=ogg
383 encode_options="$encode_options --ogg"
384 else
385 suffix=flac
386 fi
387
388 if [ $sector_align = sector_align ] ; then
389 encode_options="$encode_options --sector-align"
390 fi
391
Josh Coalson8fac5d62002-12-12 03:57:47 +0000392 run_flac $encode_options file0.wav file1.wav file2.wav || die "ERROR"
Josh Coalson463d0f82002-12-10 06:41:27 +0000393 for n in 0 1 2 ; do
394 mv file$n.$suffix file${n}x.$suffix
395 done
Josh Coalson8fac5d62002-12-12 03:57:47 +0000396 run_flac --decode file0x.$suffix file1x.$suffix file2x.$suffix || die "ERROR"
Josh Coalson463d0f82002-12-10 06:41:27 +0000397 if [ $sector_align != sector_align ] ; then
398 for n in 0 1 2 ; do
Josh Coalson8fac5d62002-12-12 03:57:47 +0000399 cmp file$n.wav file${n}x.wav || die "ERROR: file mismatch on file #$n"
Josh Coalson463d0f82002-12-10 06:41:27 +0000400 done
401 fi
402 for n in 0 1 2 ; do
403 rm -f file${n}x.$suffix file${n}x.wav
404 done
405}
406
407echo "Testing multiple files without verify..."
408test_multifile flac no_sector_align ""
409
410echo "Testing multiple files with verify..."
411test_multifile flac no_sector_align "--verify"
412
413echo "Testing multiple files with --sector-align, without verify..."
414test_multifile flac sector_align ""
415
416echo "Testing multiple files with --sector-align, with verify..."
417test_multifile flac sector_align "--verify"
418
419if [ $has_ogg = "yes" ] ; then
420 echo "Testing multiple files with --ogg, without verify..."
421 test_multifile ogg no_sector_align ""
422
423 echo "Testing multiple files with --ogg, with verify..."
424 test_multifile ogg no_sector_align "--verify"
425
426 echo "Testing multiple files with --ogg and --sector-align, without verify..."
427 test_multifile ogg sector_align ""
428
429 echo "Testing multiple files with --ogg and --sector-align, with verify..."
430 test_multifile sector_align ogg "--verify"
431
432 echo "Testing multiple files with --ogg and --serial-number, with verify..."
433 test_multifile ogg no_sector_align "--serial-number=321 --verify"
434fi