add more tests, fix check for needed binaries
[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 -V -0 -o $flacfile -fr -fb -fc 1 -fp 8 -fs 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 -s -t $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 (set -x && metaflac --set-vc-field="ARTIST=The artist formerly known as the artist..." $flacfile)
82 check_exit
83 check_flac
84
85 (set -x && metaflac --set-vc-field="ARTIST=Chuck Woolery" $flacfile)
86 check_exit
87 check_flac
88
89 (set -x && metaflac --set-vc-field="ARTIST=Vern" $flacfile)
90 check_exit
91 check_flac
92
93 (set -x && metaflac --set-vc-field="TITLE=He who smelt it dealt it" $flacfile)
94 check_exit
95 check_flac
96
97 (set -x && metaflac --show-vc-vendor --show-vc-field=ARTIST $flacfile)
98 check_exit
99
100 (set -x && metaflac --remove-vc-firstfield=ARTIST $flacfile)
101 check_exit
102 check_flac
103
104 (set -x && metaflac --remove-vc-field=ARTIST $flacfile)
105 check_exit
106 check_flac
107
108 (set -x && metaflac --list --block-number=0 $flacfile)
109 check_exit
110
111 (set -x && metaflac --list --block-number=1,2,999 $flacfile)
112 check_exit
113
114 (set -x && metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
115 check_exit
116
117 (set -x && metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
118 check_exit
119
120 (set -x && metaflac --add-padding=4321 $flacfile $flacfile)
121 check_exit
122 check_flac
123
124 (set -x && metaflac --merge-padding $flacfile)
125 check_exit
126 check_flac
127
128 (set -x && metaflac --add-padding=0 $flacfile)
129 check_exit
130 check_flac
131
132 (set -x && metaflac --sort-padding $flacfile)
133 check_exit
134 check_flac
135
136 (set -x && metaflac --add-padding=0 $flacfile)
137 check_exit
138 check_flac
139
140 (set -x && metaflac --remove-vc-all $flacfile)
141 check_exit
142 check_flac
143
144 (set -x && metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
145 check_exit
146 check_flac
147
148 (set -x && metaflac --remove --block-number=99 --dont-use-padding $flacfile)
149 check_exit
150 check_flac
151
152 (set -x && metaflac --remove --block-type=PADDING $flacfile)
153 check_exit
154 check_flac
155
156 (set -x && metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
157 check_exit
158 check_flac
159
160 (set -x && metaflac --add-padding=0 $flacfile $flacfile)
161 check_exit
162 check_flac
163
164 (set -x && metaflac --remove --except-block-type=PADDING $flacfile)
165 check_exit
166 check_flac
167
168 (set -x && metaflac --remove-all $flacfile)
169 check_exit
170 check_flac
171
172 (set -x && metaflac --remove-all --dont-use-padding $flacfile)
173 check_exit
174 check_flac
175
176 (set -x && metaflac --remove-all --dont-use-padding $flacfile)
177 check_exit
178 check_flac
179
180 exit 0
181