cannam@86: #!/bin/sh cannam@86: cannam@86: # FLAC - Free Lossless Audio Codec cannam@86: # Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson cannam@86: # cannam@86: # This file is part the FLAC project. FLAC is comprised of several cannam@86: # components distributed under difference licenses. The codec libraries cannam@86: # are distributed under Xiph.Org's BSD-like license (see the file cannam@86: # COPYING.Xiph in this distribution). All other programs, libraries, and cannam@86: # plugins are distributed under the GPL (see COPYING.GPL). The documentation cannam@86: # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the cannam@86: # FLAC distribution contains at the top the terms under which it may be cannam@86: # distributed. cannam@86: # cannam@86: # Since this particular file is relevant to all components of FLAC, cannam@86: # it may be distributed under the Xiph.Org license, which is the least cannam@86: # restrictive of those mentioned above. See the file COPYING.Xiph in this cannam@86: # distribution. cannam@86: cannam@86: die () cannam@86: { cannam@86: echo $* 1>&2 cannam@86: exit 1 cannam@86: } cannam@86: cannam@86: if [ x = x"$1" ] ; then cannam@86: BUILD=debug cannam@86: else cannam@86: BUILD="$1" cannam@86: fi cannam@86: cannam@86: LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH cannam@86: LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH cannam@86: LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH cannam@86: LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH cannam@86: export LD_LIBRARY_PATH cannam@86: PATH=../src/test_grabbag/cuesheet:$PATH cannam@86: PATH=../src/test_grabbag/picture:$PATH cannam@86: PATH=../obj/$BUILD/bin:$PATH cannam@86: cannam@86: test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable" cannam@86: test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable" cannam@86: cannam@86: run_test_cuesheet () cannam@86: { cannam@86: if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then cannam@86: echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_cuesheet $*" >>test_grabbag.valgrind.log cannam@86: valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log cannam@86: else cannam@86: test_cuesheet $* cannam@86: fi cannam@86: } cannam@86: cannam@86: run_test_picture () cannam@86: { cannam@86: if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then cannam@86: echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_picture $*" >>test_grabbag.valgrind.log cannam@86: valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 test_picture $* 4>>test_grabbag.valgrind.log cannam@86: else cannam@86: test_picture $* cannam@86: fi cannam@86: } cannam@86: cannam@86: if [ `env | grep -ic '^comspec='` != 0 ] ; then cannam@86: is_win=yes cannam@86: else cannam@86: is_win=no cannam@86: fi cannam@86: cannam@86: ######################################################################## cannam@86: # cannam@86: # test_picture cannam@86: # cannam@86: ######################################################################## cannam@86: cannam@86: log=picture.log cannam@86: picture_dir=pictures cannam@86: cannam@86: echo "Running test_picture..." cannam@86: cannam@86: rm -f $log cannam@86: cannam@86: run_test_picture $picture_dir >> $log 2>&1 cannam@86: cannam@86: if [ $is_win = yes ] ; then cannam@86: diff -w picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" cannam@86: else cannam@86: diff picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" cannam@86: fi cannam@86: cannam@86: echo "PASSED (results are in $log)" cannam@86: cannam@86: ######################################################################## cannam@86: # cannam@86: # test_cuesheet cannam@86: # cannam@86: ######################################################################## cannam@86: cannam@86: log=cuesheet.log cannam@86: bad_cuesheets=cuesheets/bad.*.cue cannam@86: good_cuesheets=cuesheets/good.*.cue cannam@86: good_leadout=`expr 80 \* 60 \* 44100` cannam@86: bad_leadout=`expr $good_leadout + 1` cannam@86: cannam@86: echo "Running test_cuesheet..." cannam@86: cannam@86: rm -f $log cannam@86: cannam@86: # cannam@86: # negative tests cannam@86: # cannam@86: for cuesheet in $bad_cuesheets ; do cannam@86: echo "NEGATIVE $cuesheet" >> $log 2>&1 cannam@86: run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1 cannam@86: exit_code=$? cannam@86: if [ "$exit_code" = 255 ] ; then cannam@86: die "Error: test script is broken" cannam@86: fi cannam@86: cuesheet_pass1=${cuesheet}.1 cannam@86: cuesheet_pass2=${cuesheet}.2 cannam@86: rm -f $cuesheet_pass1 $cuesheet_pass2 cannam@86: done cannam@86: cannam@86: # cannam@86: # positve tests cannam@86: # cannam@86: for cuesheet in $good_cuesheets ; do cannam@86: echo "POSITIVE $cuesheet" >> $log 2>&1 cannam@86: run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1 cannam@86: exit_code=$? cannam@86: if [ "$exit_code" = 255 ] ; then cannam@86: die "Error: test script is broken" cannam@86: elif [ "$exit_code" != 0 ] ; then cannam@86: die "Error: good cuesheet is broken" cannam@86: fi cannam@86: cuesheet_pass1=${cuesheet}.1 cannam@86: cuesheet_pass2=${cuesheet}.2 cannam@86: diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ" cannam@86: rm -f $cuesheet_pass1 $cuesheet_pass2 cannam@86: done cannam@86: cannam@86: if [ $is_win = yes ] ; then cannam@86: diff -w cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" cannam@86: else cannam@86: diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" cannam@86: fi cannam@86: cannam@86: echo "PASSED (results are in $log)"