test_metaflac.sh
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:9k
源码类别:

Windows CE

开发平台:

C/C++

  1. #!/bin/sh
  2. #  FLAC - Free Lossless Audio Codec
  3. #  Copyright (C) 2002,2003,2004,2005  Josh Coalson
  4. #
  5. #  This file is part the FLAC project.  FLAC is comprised of several
  6. #  components distributed under difference licenses.  The codec libraries
  7. #  are distributed under Xiph.Org's BSD-like license (see the file
  8. #  COPYING.Xiph in this distribution).  All other programs, libraries, and
  9. #  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
  10. #  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
  11. #  FLAC distribution contains at the top the terms under which it may be
  12. #  distributed.
  13. #
  14. #  Since this particular file is relevant to all components of FLAC,
  15. #  it may be distributed under the Xiph.Org license, which is the least
  16. #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
  17. #  distribution.
  18. die ()
  19. {
  20. echo $* 1>&2
  21. exit 1
  22. }
  23. if [ x = x"$1" ] ; then 
  24. BUILD=debug
  25. else
  26. BUILD="$1"
  27. fi
  28. LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
  29. LD_LIBRARY_PATH=../src/libOggFLAC/.libs:$LD_LIBRARY_PATH
  30. LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
  31. LD_LIBRARY_PATH=../src/share/getopt/.libs:$LD_LIBRARY_PATH
  32. LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
  33. LD_LIBRARY_PATH=../src/share/replaygain_synthesis/.libs:$LD_LIBRARY_PATH
  34. LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
  35. LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
  36. export LD_LIBRARY_PATH
  37. PATH=../src/flac:$PATH
  38. PATH=../src/metaflac:$PATH
  39. PATH=../obj/$BUILD/bin:$PATH
  40. flacfile=metaflac.flac
  41. flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
  42. metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
  43. run_flac ()
  44. {
  45. if [ x"$FLAC__VALGRIND" = xyes ] ; then
  46. valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_metaflac.valgrind.log
  47. else
  48. flac $*
  49. fi
  50. }
  51. run_metaflac ()
  52. {
  53. if [ x"$FLAC__VALGRIND" = xyes ] ; then
  54. valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_metaflac.valgrind.log
  55. else
  56. metaflac $*
  57. fi
  58. }
  59. echo "Generating stream..."
  60. if [ -f /bin/sh.exe ] ; then
  61. inputfile=/bin/sh.exe
  62. else
  63. inputfile=/bin/sh
  64. fi
  65. if run_flac --force --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 $inputfile ; then
  66. chmod +w $flacfile
  67. else
  68. die "ERROR during generation"
  69. fi
  70. check_exit ()
  71. {
  72. exit_code=$?
  73. [ $exit_code = 0 ] || die "ERROR, exit code = $exit_code"
  74. }
  75. check_flac ()
  76. {
  77. run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
  78. }
  79. check_flac
  80. (set -x && run_metaflac --list $flacfile)
  81. check_exit
  82. (set -x &&
  83. run_metaflac 
  84. --show-md5sum 
  85. --show-min-blocksize 
  86. --show-max-blocksize 
  87. --show-min-framesize 
  88. --show-max-framesize 
  89. --show-sample-rate 
  90. --show-channels 
  91. --show-bps 
  92. --show-total-samples 
  93. $flacfile
  94. )
  95. check_exit
  96. (set -x && run_metaflac --preserve-modtime --add-padding=12345 $flacfile)
  97. check_exit
  98. check_flac
  99. # some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore:
  100. (set -x && run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
  101. check_exit
  102. check_flac
  103. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  104. check_exit
  105. (set -x && run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile)
  106. check_exit
  107. check_flac
  108. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  109. check_exit
  110. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  111. check_exit
  112. (set -x && run_metaflac --set-tag="ARTIST=Vern" $flacfile)
  113. check_exit
  114. check_flac
  115. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  116. check_exit
  117. (set -x && run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile)
  118. check_exit
  119. check_flac
  120. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  121. check_exit
  122. (set -x && run_metaflac --show-vendor-tag --show-tag=ARTIST $flacfile)
  123. check_exit
  124. (set -x && run_metaflac --remove-first-tag=ARTIST $flacfile)
  125. check_exit
  126. check_flac
  127. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  128. check_exit
  129. (set -x && run_metaflac --remove-tag=ARTIST $flacfile)
  130. check_exit
  131. check_flac
  132. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  133. check_exit
  134. (set -x && run_metaflac --list --block-number=0 $flacfile)
  135. check_exit
  136. (set -x && run_metaflac --list --block-number=1,2,999 $flacfile)
  137. check_exit
  138. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
  139. check_exit
  140. (set -x && run_metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
  141. check_exit
  142. (set -x && run_metaflac --add-padding=4321 $flacfile $flacfile)
  143. check_exit
  144. check_flac
  145. (set -x && run_metaflac --merge-padding $flacfile)
  146. check_exit
  147. check_flac
  148. (set -x && run_metaflac --add-padding=0 $flacfile)
  149. check_exit
  150. check_flac
  151. (set -x && run_metaflac --sort-padding $flacfile)
  152. check_exit
  153. check_flac
  154. (set -x && run_metaflac --add-padding=0 $flacfile)
  155. check_exit
  156. check_flac
  157. (set -x && run_metaflac --remove-all-tags $flacfile)
  158. check_exit
  159. check_flac
  160. (set -x && run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
  161. check_exit
  162. check_flac
  163. (set -x && run_metaflac --remove --block-number=99 --dont-use-padding $flacfile)
  164. check_exit
  165. check_flac
  166. (set -x && run_metaflac --remove --block-type=PADDING $flacfile)
  167. check_exit
  168. check_flac
  169. (set -x && run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
  170. check_exit
  171. check_flac
  172. (set -x && run_metaflac --add-padding=0 $flacfile $flacfile)
  173. check_exit
  174. check_flac
  175. (set -x && run_metaflac --remove --except-block-type=PADDING $flacfile)
  176. check_exit
  177. check_flac
  178. (set -x && run_metaflac --remove-all $flacfile)
  179. check_exit
  180. check_flac
  181. (set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
  182. check_exit
  183. check_flac
  184. (set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
  185. check_exit
  186. check_flac
  187. (set -x && run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile)
  188. check_exit
  189. check_flac
  190. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  191. check_exit
  192. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
  193. check_exit
  194. check_flac
  195. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  196. check_exit
  197. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile)
  198. check_exit
  199. check_flac
  200. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  201. check_exit
  202. (set -x && run_metaflac --remove-all-tags --set-tag="f=0" $flacfile)
  203. check_exit
  204. check_flac
  205. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  206. check_exit
  207. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
  208. check_exit
  209. check_flac
  210. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  211. check_exit
  212. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
  213. check_exit
  214. check_flac
  215. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  216. check_exit
  217. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
  218. check_exit
  219. check_flac
  220. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  221. check_exit
  222. (set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile)
  223. check_exit
  224. check_flac
  225. (set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
  226. check_exit
  227. (set -x && echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile)
  228. check_exit
  229. check_flac
  230. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  231. check_exit
  232. cat > vc.txt << EOF
  233. artist=Fartist
  234. artist=artits
  235. EOF
  236. (set -x && run_metaflac --import-tags-from=vc.txt $flacfile)
  237. check_exit
  238. check_flac
  239. (set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
  240. check_exit
  241. rm vc.txt
  242. cs_in=cuesheets/good.000.cue
  243. cs_out=metaflac.cue
  244. cs_out2=metaflac2.cue
  245. (set -x && run_metaflac --import-cuesheet-from="$cs_in" $flacfile)
  246. check_exit
  247. check_flac
  248. (set -x && run_metaflac --export-cuesheet-to=$cs_out $flacfile)
  249. check_exit
  250. (set -x && run_metaflac --remove --block-type=CUESHEET $flacfile)
  251. check_exit
  252. check_flac
  253. (set -x && run_metaflac --import-cuesheet-from=$cs_out $flacfile)
  254. check_exit
  255. check_flac
  256. (set -x && run_metaflac --export-cuesheet-to=$cs_out2 $flacfile)
  257. check_exit
  258. echo "comparing cuesheets:"
  259. diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
  260. echo identical
  261. rm -f $cs_out $cs_out2
  262. (set -x && run_metaflac --add-replay-gain $flacfile)
  263. check_exit
  264. check_flac
  265. echo -n "Testing FLAC file with unknown metadata... "
  266. cp -p metaflac.flac.in $flacfile
  267. # remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison:
  268. run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile
  269. cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
  270. echo OK
  271. exit 0