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