rename metaflac *-vc-* options to *-tag-* ones, only ones remain but deprecated
[platform/upstream/flac.git] / test / test_metaflac.sh
index 9fb4633..6c5c353 100755 (executable)
@@ -1,38 +1,54 @@
 #!/bin/sh
 
 #  FLAC - Free Lossless Audio Codec
-#  Copyright (C) 2002  Josh Coalson
+#  Copyright (C) 2002,2003,2004  Josh Coalson
 #
-#  This program is part of FLAC; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
+#  This file is part the FLAC project.  FLAC is comprised of several
+#  components distributed under difference licenses.  The codec libraries
+#  are distributed under Xiph.Org's BSD-like license (see the file
+#  COPYING.Xiph in this distribution).  All other programs, libraries, and
+#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
+#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
+#  FLAC distribution contains at the top the terms under which it may be
+#  distributed.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#  Since this particular file is relevant to all components of FLAC,
+#  it may be distributed under the Xiph.Org license, which is the least
+#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
+#  distribution.
+
+die ()
+{
+       echo $* 1>&2
+       exit 1
+}
 
 LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
 export LD_LIBRARY_PATH
-PATH=../src/flac:../src/metaflac:../obj/release/b:../obj/debug/bin:$PATH
+PATH=../src/flac:../src/metaflac:../obj/release/bin:../obj/debug/bin:$PATH
 
 flacfile=metaflac.flac
 
-flac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find flac executable" 1>&2 && exit 1)
-if [ $? != 0 ] ; then exit 1 ; fi
+flac --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
+metaflac --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
 
-metaflac --help 1>/dev/null 2>/dev/null || (echo "ERROR can't find metaflac executable" 1>&2 && exit 1)
-if [ $? != 0 ] ; then exit 1 ; fi
+run_flac ()
+{
+       if [ x"$FLAC__VALGRIND" = xyes ] ; then
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 flac $* 4>>test_metaflac.valgrind.log
+       else
+               flac $*
+       fi
+}
 
-#FLAC="valgrind --leak-check=yes --show-reachable=yes flac"
-FLAC=flac
-#METAFLAC="valgrind --leak-check=yes --show-reachable=yes metaflac"
-METAFLAC=metaflac
+run_metaflac ()
+{
+       if [ x"$FLAC__VALGRIND" = xyes ] ; then
+               valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 metaflac $* 4>>test_metaflac.valgrind.log
+       else
+               metaflac $*
+       fi
+}
 
 echo "Generating stream..."
 if [ -f /bin/sh.exe ] ; then
@@ -40,37 +56,30 @@ if [ -f /bin/sh.exe ] ; then
 else
        inputfile=/bin/sh
 fi
-if $FLAC --verify -0 --output-name=$flacfile --force-raw-format --endian=big --sign=signed --channels=1 --bps=8 --sample-rate=44100 $inputfile ; then
+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
        chmod +w $flacfile
 else
-       echo "ERROR during generation" 1>&2
-       exit 1
+       die "ERROR during generation"
 fi
 
 check_exit ()
 {
        exit_code=$?
-       if [ $exit_code != 0 ] ; then
-               echo "ERROR, exit code = $exit_code" 1>&2
-               exit 1
-       fi
+       [ $exit_code = 0 ] || die "ERROR, exit code = $exit_code"
 }
 
 check_flac ()
 {
-       if $FLAC --silent --test $flacfile ; then : ; else
-               echo "ERROR in $flacfile" 1>&2
-               exit 1
-       fi
+       run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
 }
 
 check_flac
 
-(set -x && $METAFLAC --list $flacfile)
+(set -x && run_metaflac --list $flacfile)
 check_exit
 
 (set -x &&
-$METAFLAC \
+run_metaflac \
        --show-md5sum \
        --show-min-blocksize \
        --show-max-blocksize \
@@ -84,193 +93,193 @@ $METAFLAC \
 )
 check_exit
 
-(set -x && $METAFLAC --preserve-modtime --add-padding=12345 $flacfile)
+(set -x && run_metaflac --preserve-modtime --add-padding=12345 $flacfile)
 check_exit
 check_flac
 
 # some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore:
-(set -x && $METAFLAC --set-vc-field="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
+(set -x && run_metaflac --set-tag="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --set-vc-field="ARTIST=Chuck_Woolery" $flacfile)
+(set -x && run_metaflac --set-tag="ARTIST=Chuck_Woolery" $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --set-vc-field="ARTIST=Vern" $flacfile)
+(set -x && run_metaflac --set-tag="ARTIST=Vern" $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --set-vc-field="TITLE=He_who_smelt_it_dealt_it" $flacfile)
+(set -x && run_metaflac --set-tag="TITLE=He_who_smelt_it_dealt_it" $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --show-vc-vendor --show-vc-field=ARTIST $flacfile)
+(set -x && run_metaflac --show-vendor-tag --show-tag=ARTIST $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-firstfield=ARTIST $flacfile)
+(set -x && run_metaflac --remove-first-tag=ARTIST $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-field=ARTIST $flacfile)
+(set -x && run_metaflac --remove-tag=ARTIST $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --list --block-number=0 $flacfile)
+(set -x && run_metaflac --list --block-number=0 $flacfile)
 check_exit
 
-(set -x && $METAFLAC --list --block-number=1,2,999 $flacfile)
+(set -x && run_metaflac --list --block-number=1,2,999 $flacfile)
 check_exit
 
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
 check_exit
 
-(set -x && $METAFLAC --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
 check_exit
 
-(set -x && $METAFLAC --add-padding=4321 $flacfile $flacfile)
+(set -x && run_metaflac --add-padding=4321 $flacfile $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --merge-padding $flacfile)
+(set -x && run_metaflac --merge-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --add-padding=0 $flacfile)
+(set -x && run_metaflac --add-padding=0 $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --sort-padding $flacfile)
+(set -x && run_metaflac --sort-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --add-padding=0 $flacfile)
+(set -x && run_metaflac --add-padding=0 $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove-vc-all $flacfile)
+(set -x && run_metaflac --remove-all-tags $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove --block-number=1,99 --dont-use-padding $flacfile)
+(set -x && run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove --block-number=99 --dont-use-padding $flacfile)
+(set -x && run_metaflac --remove --block-number=99 --dont-use-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove --block-type=PADDING $flacfile)
+(set -x && run_metaflac --remove --block-type=PADDING $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove --block-type=PADDING --dont-use-padding $flacfile)
+(set -x && run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --add-padding=0 $flacfile $flacfile)
+(set -x && run_metaflac --add-padding=0 $flacfile $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove --except-block-type=PADDING $flacfile)
+(set -x && run_metaflac --remove --except-block-type=PADDING $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove-all $flacfile)
+(set -x && run_metaflac --remove-all $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove-all --dont-use-padding $flacfile)
+(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --remove-all --dont-use-padding $flacfile)
+(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
 check_exit
 check_flac
 
-(set -x && $METAFLAC --set-vc-field="f=0123456789abcdefghij" $flacfile)
+(set -x && run_metaflac --set-tag="f=0123456789abcdefghij" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcde" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcde" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghi" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && $METAFLAC --remove-vc-all --set-vc-field="f=0123456789abcdefghij" $flacfile)
+(set -x && run_metaflac --remove-all-tags --set-tag="f=0123456789abcdefghij" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --except-block-type=STREAMINFO $flacfile)
+(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
 check_exit
 
-(set -x && echo "TITLE=Tittle" | $METAFLAC --import-vc-from=- $flacfile)
+(set -x && echo "TITLE=Tittle" | run_metaflac --import-tags-from=- $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
 cat > vc.txt << EOF
 artist=Fartist
 artist=artits
 EOF
-(set -x && $METAFLAC --import-vc-from=vc.txt $flacfile)
+(set -x && run_metaflac --import-tags-from=vc.txt $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --list --block-type=VORBIS_COMMENT $flacfile)
+(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
 check_exit
 
 rm vc.txt
@@ -278,26 +287,34 @@ rm vc.txt
 cs_in=cuesheets/good.000.cue
 cs_out=metaflac.cue
 cs_out2=metaflac2.cue
-(set -x && $METAFLAC --import-cuesheet-from="$cs_in" $flacfile)
+(set -x && run_metaflac --import-cuesheet-from="$cs_in" $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --export-cuesheet-to=$cs_out $flacfile)
+(set -x && run_metaflac --export-cuesheet-to=$cs_out $flacfile)
 check_exit
-(set -x && $METAFLAC --remove --block-type=CUESHEET $flacfile)
+(set -x && run_metaflac --remove --block-type=CUESHEET $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --import-cuesheet-from=$cs_out $flacfile)
+(set -x && run_metaflac --import-cuesheet-from=$cs_out $flacfile)
 check_exit
 check_flac
-(set -x && $METAFLAC --export-cuesheet-to=$cs_out2 $flacfile)
+(set -x && run_metaflac --export-cuesheet-to=$cs_out2 $flacfile)
 check_exit
 echo "comparing cuesheets:"
-if diff $cs_out $cs_out2 ; then : ; else
-       echo "ERROR, cuesheets should be identical"
-       exit 1
-fi
+diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
 echo identical
 
 rm -f $cs_out $cs_out2
 
+(set -x && run_metaflac --add-replay-gain $flacfile)
+check_exit
+check_flac
+
+echo -n "Testing FLAC file with unknown metadata... "
+cp -p metaflac.flac.in $flacfile
+# remove the VORBIS_COMMENT block so vendor string changes don't interfere with the comparison:
+run_metaflac --remove --block-type=VORBIS_COMMENT --dont-use-padding $flacfile
+cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
+echo OK
+
 exit 0