precursor to valgrind support
[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 #FLAC="valgrind --leak-check=yes --show-reachable=yes flac"
33 FLAC=flac
34 #METAFLAC="valgrind --leak-check=yes --show-reachable=yes metaflac"
35 METAFLAC=metaflac
36
37 echo "Generating stream..."
38 if [ -f /bin/sh.exe ] ; then
39         inputfile=/bin/sh.exe
40 else
41         inputfile=/bin/sh
42 fi
43 if $FLAC --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 $inputfile ; then
44         chmod +w $flacfile
45 else
46         echo "ERROR during generation" 1>&2
47         exit 1
48 fi
49
50 check_exit ()
51 {
52         exit_code=$?
53         if [ $exit_code != 0 ] ; then
54                 echo "ERROR, exit code = $exit_code" 1>&2
55                 exit 1
56         fi
57 }
58
59 check_flac ()
60 {
61         if $FLAC --silent --test $flacfile ; then : ; else
62                 echo "ERROR in $flacfile" 1>&2
63                 exit 1
64         fi
65 }
66
67 check_flac
68
69 (set -x && $METAFLAC --list $flacfile)
70 check_exit
71
72 (set -x &&
73 $METAFLAC \
74         --show-md5sum \
75         --show-min-blocksize \
76         --show-max-blocksize \
77         --show-min-framesize \
78         --show-max-framesize \
79         --show-sample-rate \
80         --show-channels \
81         --show-bps \
82         --show-total-samples \
83         $flacfile
84 )
85 check_exit
86
87 (set -x && $METAFLAC --preserve-modtime --add-padding=12345 $flacfile)
88 check_exit
89 check_flac
90
91 # some flavors of /bin/sh (e.g. Darwin's) won't handle even quoted spaces, so we underscore:
92 (set -x && $METAFLAC --set-vc-field="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
93 check_exit
94 check_flac
95
96 (set -x && $METAFLAC --set-vc-field="ARTIST=Chuck_Woolery" $flacfile)
97 check_exit
98 check_flac
99
100 (set -x && $METAFLAC --set-vc-field="ARTIST=Vern" $flacfile)
101 check_exit
102 check_flac
103
104 (set -x && $METAFLAC --set-vc-field="TITLE=He_who_smelt_it_dealt_it" $flacfile)
105 check_exit
106 check_flac
107
108 (set -x && $METAFLAC --show-vc-vendor --show-vc-field=ARTIST $flacfile)
109 check_exit
110
111 (set -x && $METAFLAC --remove-vc-firstfield=ARTIST $flacfile)
112 check_exit
113 check_flac
114
115 (set -x && $METAFLAC --remove-vc-field=ARTIST $flacfile)
116 check_exit
117 check_flac
118
119 (set -x && $METAFLAC --list --block-number=0 $flacfile)
120 check_exit
121
122 (set -x && $METAFLAC --list --block-number=1,2,999 $flacfile)
123 check_exit
124
125 (set -x && $METAFLAC --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
126 check_exit
127
128 (set -x && $METAFLAC --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
129 check_exit
130
131 (set -x && $METAFLAC --add-padding=4321 $flacfile $flacfile)
132 check_exit
133 check_flac
134
135 (set -x && $METAFLAC --merge-padding $flacfile)
136 check_exit
137 check_flac
138
139 (set -x && $METAFLAC --add-padding=0 $flacfile)
140 check_exit
141 check_flac
142
143 (set -x && $METAFLAC --sort-padding $flacfile)
144 check_exit
145 check_flac
146
147 (set -x && $METAFLAC --add-padding=0 $flacfile)
148 check_exit
149 check_flac
150
151 (set -x && $METAFLAC --remove-vc-all $flacfile)
152 check_exit
153 check_flac
154
155 (set -x && $METAFLAC --remove --block-number=1,99 --dont-use-padding $flacfile)
156 check_exit
157 check_flac
158
159 (set -x && $METAFLAC --remove --block-number=99 --dont-use-padding $flacfile)
160 check_exit
161 check_flac
162
163 (set -x && $METAFLAC --remove --block-type=PADDING $flacfile)
164 check_exit
165 check_flac
166
167 (set -x && $METAFLAC --remove --block-type=PADDING --dont-use-padding $flacfile)
168 check_exit
169 check_flac
170
171 (set -x && $METAFLAC --add-padding=0 $flacfile $flacfile)
172 check_exit
173 check_flac
174
175 (set -x && $METAFLAC --remove --except-block-type=PADDING $flacfile)
176 check_exit
177 check_flac
178
179 (set -x && $METAFLAC --remove-all $flacfile)
180 check_exit
181 check_flac
182
183 (set -x && $METAFLAC --remove-all --dont-use-padding $flacfile)
184 check_exit
185 check_flac
186
187 (set -x && $METAFLAC --remove-all --dont-use-padding $flacfile)
188 check_exit
189 check_flac
190
191 (set -x && $METAFLAC --set-vc-field="f=0123456789abcdefghij" $flacfile)
192 check_exit
193 check_flac
194 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
195 check_exit
196
197 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
198 check_exit
199 check_flac
200 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
201 check_exit
202
203 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcde" $flacfile)
204 check_exit
205 check_flac
206 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
207 check_exit
208
209 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0" $flacfile)
210 check_exit
211 check_flac
212 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
213 check_exit
214
215 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
216 check_exit
217 check_flac
218 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
219 check_exit
220
221 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
222 check_exit
223 check_flac
224 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
225 check_exit
226
227 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
228 check_exit
229 check_flac
230 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
231 check_exit
232
233 (set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghij" $flacfile)
234 check_exit
235 check_flac
236 (set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
237 check_exit
238
239 (set -x && echo "TITLE=Tittle" | $METAFLAC --import-vc-from=- $flacfile)
240 check_exit
241 check_flac
242 (set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
243 check_exit
244
245 cat > vc.txt << EOF
246 artist=Fartist
247 artist=artits
248 EOF
249 (set -x && $METAFLAC --import-vc-from=vc.txt $flacfile)
250 check_exit
251 check_flac
252 (set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
253 check_exit
254
255 rm vc.txt
256
257 exit 0