update to match new getopt-based options
[platform/upstream/flac.git] / test / test_metaflac.sh
1 #!/bin/sh
2
3 #  FLAC - Free Lossless Audio Codec
4 #  Copyright (C) 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
20 LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/lib:$LD_LIBRARY_PATH
21 export LD_LIBRARY_PATH
22 PATH=../src/flac:../src/metaflac:../obj/bin:$PATH
23
24 flacfile=metaflac.flac
25
26 flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
27 if [ $? != 0 ] ; then exit 1 ; fi
28
29 metaflac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find metaflac executable" 1>&2 && exit 1)
30 if [ $? != 0 ] ; then exit 1 ; fi
31
32 echo "Generating stream..."
33 if flac --verify -0 --output-name=$flacfile --force-raw-input --endian=big --channels=1 --bps=8 --sample-rate=44100 /bin/sh ; then
34         chmod +w $flacfile
35 else
36         echo "ERROR during generation" 1>&2
37         exit 1
38 fi
39
40 check_exit ()
41 {
42         exit_code=$?
43         if [ $exit_code != 0 ] ; then
44                 echo "ERROR, exit code = $exit_code" 1>&2
45                 exit 1
46         fi
47 }
48
49 check_flac ()
50 {
51         if flac --silent --test $flacfile ; then : ; else
52                 echo "ERROR in $flacfile" 1>&2
53                 exit 1
54         fi
55 }
56
57 check_flac
58
59 (set -x && metaflac --list $flacfile)
60 check_exit
61
62 (set -x &&
63 metaflac \
64         --show-md5sum \
65         --show-min-blocksize \
66         --show-max-blocksize \
67         --show-min-framesize \
68         --show-max-framesize \
69         --show-sample-rate \
70         --show-channels \
71         --show-bps \
72         --show-total-samples \
73         $flacfile
74 )
75 check_exit
76
77 (set -x && metaflac --preserve-modtime --add-padding=12345 $flacfile)
78 check_exit
79 check_flac
80
81 # some flavors of /bin/sh (e.g. Darwin's) won't handle even quoted spaces, so we underscore:
82 (set -x && metaflac --set-vc-field="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
83 check_exit
84 check_flac
85
86 (set -x && metaflac --set-vc-field="ARTIST=Chuck_Woolery" $flacfile)
87 check_exit
88 check_flac
89
90 (set -x && metaflac --set-vc-field="ARTIST=Vern" $flacfile)
91 check_exit
92 check_flac
93
94 (set -x && metaflac --set-vc-field="TITLE=He_who_smelt_it_dealt_it" $flacfile)
95 check_exit
96 check_flac
97
98 (set -x && metaflac --show-vc-vendor --show-vc-field=ARTIST $flacfile)
99 check_exit
100
101 (set -x && metaflac --remove-vc-firstfield=ARTIST $flacfile)
102 check_exit
103 check_flac
104
105 (set -x && metaflac --remove-vc-field=ARTIST $flacfile)
106 check_exit
107 check_flac
108
109 (set -x && metaflac --list --block-number=0 $flacfile)
110 check_exit
111
112 (set -x && metaflac --list --block-number=1,2,999 $flacfile)
113 check_exit
114
115 (set -x && metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
116 check_exit
117
118 (set -x && metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
119 check_exit
120
121 (set -x && metaflac --add-padding=4321 $flacfile $flacfile)
122 check_exit
123 check_flac
124
125 (set -x && metaflac --merge-padding $flacfile)
126 check_exit
127 check_flac
128
129 (set -x && metaflac --add-padding=0 $flacfile)
130 check_exit
131 check_flac
132
133 (set -x && metaflac --sort-padding $flacfile)
134 check_exit
135 check_flac
136
137 (set -x && metaflac --add-padding=0 $flacfile)
138 check_exit
139 check_flac
140
141 (set -x && metaflac --remove-vc-all $flacfile)
142 check_exit
143 check_flac
144
145 (set -x && metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
146 check_exit
147 check_flac
148
149 (set -x && metaflac --remove --block-number=99 --dont-use-padding $flacfile)
150 check_exit
151 check_flac
152
153 (set -x && metaflac --remove --block-type=PADDING $flacfile)
154 check_exit
155 check_flac
156
157 (set -x && metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
158 check_exit
159 check_flac
160
161 (set -x && metaflac --add-padding=0 $flacfile $flacfile)
162 check_exit
163 check_flac
164
165 (set -x && metaflac --remove --except-block-type=PADDING $flacfile)
166 check_exit
167 check_flac
168
169 (set -x && metaflac --remove-all $flacfile)
170 check_exit
171 check_flac
172
173 (set -x && metaflac --remove-all --dont-use-padding $flacfile)
174 check_exit
175 check_flac
176
177 (set -x && metaflac --remove-all --dont-use-padding $flacfile)
178 check_exit
179 check_flac
180
181 (set -x && metaflac --set-vc-field="f=0123456789abcdefghij" $flacfile)
182 check_exit
183 check_flac
184 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
185 check_exit
186
187 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
188 check_exit
189 check_flac
190 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
191 check_exit
192
193 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789abcde" $flacfile)
194 check_exit
195 check_flac
196 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
197 check_exit
198
199 (set -x && metaflac --remove-vc-all --set-vc-field="f=0" $flacfile)
200 check_exit
201 check_flac
202 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
203 check_exit
204
205 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
206 check_exit
207 check_flac
208 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
209 check_exit
210
211 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
212 check_exit
213 check_flac
214 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
215 check_exit
216
217 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
218 check_exit
219 check_flac
220 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
221 check_exit
222
223 (set -x && metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghij" $flacfile)
224 check_exit
225 check_flac
226 (set -x && metaflac --list --except-block-type=STREAMINFO $flacfile)
227 check_exit
228
229 exit 0