flac/test/test_metaflac.sh

321 lines
8.3 KiB
Bash
Raw Normal View History

2002-06-14 06:31:35 +00:00
#!/bin/sh
# FLAC - Free Lossless Audio Codec
2004-01-17 04:14:43 +00:00
# Copyright (C) 2002,2003,2004 Josh Coalson
2002-06-14 06:31:35 +00:00
#
2003-02-07 00:14:32 +00:00
# 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.
2002-06-14 06:31:35 +00:00
#
2003-02-07 00:14:32 +00:00
# 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.
2002-06-14 06:31:35 +00:00
die ()
{
echo $* 1>&2
exit 1
}
LD_LIBRARY_PATH=../src/libFLAC/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
2002-06-14 06:31:35 +00:00
export LD_LIBRARY_PATH
2002-12-04 04:57:33 +00:00
PATH=../src/flac:../src/metaflac:../obj/release/bin:../obj/debug/bin:$PATH
2002-06-14 06:31:35 +00:00
flacfile=metaflac.flac
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"
2002-12-04 04:57:33 +00:00
run_flac ()
{
2003-01-14 09:00:25 +00:00
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
2002-12-04 04:57:33 +00:00
else
flac $*
fi
}
run_metaflac ()
{
2003-01-14 09:00:25 +00:00
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
2002-12-04 04:57:33 +00:00
else
metaflac $*
fi
}
2002-10-11 06:22:43 +00:00
echo "Generating stream..."
2002-08-21 05:27:01 +00:00
if [ -f /bin/sh.exe ] ; then
inputfile=/bin/sh.exe
else
inputfile=/bin/sh
fi
2002-12-04 04:57:33 +00:00
if run_flac --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
die "ERROR during generation"
2002-06-14 06:31:35 +00:00
fi
check_exit ()
{
exit_code=$?
[ $exit_code = 0 ] || die "ERROR, exit code = $exit_code"
2002-06-14 06:31:35 +00:00
}
check_flac ()
{
run_flac --silent --test $flacfile || die "ERROR in $flacfile" 1>&2
2002-06-14 06:31:35 +00:00
}
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list $flacfile)
check_exit
(set -x &&
2002-12-04 04:57:33 +00:00
run_metaflac \
--show-md5sum \
--show-min-blocksize \
--show-max-blocksize \
--show-min-framesize \
--show-max-framesize \
--show-sample-rate \
--show-channels \
--show-bps \
--show-total-samples \
$flacfile
)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --preserve-modtime --add-padding=12345 $flacfile)
check_exit
check_flac
2002-10-26 04:28:11 +00:00
# some flavors of /bin/sh (e.g. Darwin's) won't even handle quoted spaces, so we underscore:
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --set-vc-field="ARTIST=The_artist_formerly_known_as_the_artist..." $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --set-vc-field="ARTIST=Chuck_Woolery" $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --set-vc-field="ARTIST=Vern" $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --set-vc-field="TITLE=He_who_smelt_it_dealt_it" $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --show-vc-vendor --show-vc-field=ARTIST $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-firstfield=ARTIST $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-field=ARTIST $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-10-26 04:28:11 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-number=0 $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-number=1,2,999 $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT,PADDING $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=SEEKTABLE,VORBIS_COMMENT $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --add-padding=4321 $flacfile $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --merge-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --add-padding=0 $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --sort-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --add-padding=0 $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --block-number=1,99 --dont-use-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --block-number=99 --dont-use-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --block-type=PADDING $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --block-type=PADDING --dont-use-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --add-padding=0 $flacfile $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --except-block-type=PADDING $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-all $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-all --dont-use-padding $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --set-vc-field="f=0123456789abcdefghij" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789abcde" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghi" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove-vc-all --set-vc-field="f=0123456789abcdefghij" $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --except-block-type=STREAMINFO $flacfile)
2002-06-18 05:25:41 +00:00
check_exit
2002-12-04 04:57:33 +00:00
(set -x && echo "TITLE=Tittle" | run_metaflac --import-vc-from=- $flacfile)
2002-09-05 05:38:22 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-09-05 05:38:22 +00:00
check_exit
cat > vc.txt << EOF
artist=Fartist
artist=artits
EOF
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --import-vc-from=vc.txt $flacfile)
2002-09-05 05:38:22 +00:00
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --list --block-type=VORBIS_COMMENT $flacfile)
2002-09-05 05:38:22 +00:00
check_exit
rm vc.txt
cs_in=cuesheets/good.000.cue
cs_out=metaflac.cue
cs_out2=metaflac2.cue
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --import-cuesheet-from="$cs_in" $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --export-cuesheet-to=$cs_out $flacfile)
check_exit
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --remove --block-type=CUESHEET $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --import-cuesheet-from=$cs_out $flacfile)
check_exit
check_flac
2002-12-04 04:57:33 +00:00
(set -x && run_metaflac --export-cuesheet-to=$cs_out2 $flacfile)
check_exit
echo "comparing cuesheets:"
diff $cs_out $cs_out2 || die "ERROR, cuesheets should be identical"
echo identical
rm -f $cs_out $cs_out2
2003-12-16 18:47:26 +00:00
(set -x && run_metaflac --add-replay-gain $flacfile)
check_exit
check_flac
2003-01-11 06:23:16 +00:00
echo -n "Testing FLAC file with unknown metadata... "
cp -p metaflac.flac.in $flacfile
2003-01-16 07:21:20 +00:00
# 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
2003-01-11 06:23:16 +00:00
cmp $flacfile metaflac.flac.ok || die "ERROR, $flacfile and metaflac.flac.ok differ"
echo OK
2002-06-18 05:25:41 +00:00
exit 0