usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / flac / test / test_grabbag.sh
bloba18a9312a8e03df53c166a5383f06b2a8c9c57ed
1 #!/bin/sh
3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
6 # This file is part the FLAC project. FLAC is comprised of several
7 # components distributed under difference licenses. The codec libraries
8 # are distributed under Xiph.Org's BSD-like license (see the file
9 # COPYING.Xiph in this distribution). All other programs, libraries, and
10 # plugins are distributed under the GPL (see COPYING.GPL). The documentation
11 # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
12 # FLAC distribution contains at the top the terms under which it may be
13 # distributed.
15 # Since this particular file is relevant to all components of FLAC,
16 # it may be distributed under the Xiph.Org license, which is the least
17 # restrictive of those mentioned above. See the file COPYING.Xiph in this
18 # distribution.
20 die ()
22 echo $* 1>&2
23 exit 1
26 if [ x = x"$1" ] ; then
27 BUILD=debug
28 else
29 BUILD="$1"
32 LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
33 LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
34 LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
35 LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
36 export LD_LIBRARY_PATH
37 PATH=../src/test_grabbag/cuesheet:$PATH
38 PATH=../src/test_grabbag/picture:$PATH
39 PATH=../obj/$BUILD/bin:$PATH
41 test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
42 test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
44 run_test_cuesheet ()
46 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
47 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_cuesheet $*" >>test_grabbag.valgrind.log
48 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log
49 else
50 test_cuesheet $*
54 run_test_picture ()
56 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
57 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_picture $*" >>test_grabbag.valgrind.log
58 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --log-fd=4 test_picture $* 4>>test_grabbag.valgrind.log
59 else
60 test_picture $*
64 if [ `env | grep -ic '^comspec='` != 0 ] ; then
65 is_win=yes
66 else
67 is_win=no
70 ########################################################################
72 # test_picture
74 ########################################################################
76 log=picture.log
77 picture_dir=pictures
79 echo "Running test_picture..."
81 rm -f $log
83 run_test_picture $picture_dir >> $log 2>&1
85 if [ $is_win = yes ] ; then
86 diff -w picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
87 else
88 diff picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
91 echo "PASSED (results are in $log)"
93 ########################################################################
95 # test_cuesheet
97 ########################################################################
99 log=cuesheet.log
100 bad_cuesheets=cuesheets/bad.*.cue
101 good_cuesheets=cuesheets/good.*.cue
102 good_leadout=`expr 80 \* 60 \* 44100`
103 bad_leadout=`expr $good_leadout + 1`
105 echo "Running test_cuesheet..."
107 rm -f $log
110 # negative tests
112 for cuesheet in $bad_cuesheets ; do
113 echo "NEGATIVE $cuesheet" >> $log 2>&1
114 run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
115 exit_code=$?
116 if [ "$exit_code" = 255 ] ; then
117 die "Error: test script is broken"
119 cuesheet_pass1=${cuesheet}.1
120 cuesheet_pass2=${cuesheet}.2
121 rm -f $cuesheet_pass1 $cuesheet_pass2
122 done
125 # positve tests
127 for cuesheet in $good_cuesheets ; do
128 echo "POSITIVE $cuesheet" >> $log 2>&1
129 run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
130 exit_code=$?
131 if [ "$exit_code" = 255 ] ; then
132 die "Error: test script is broken"
133 elif [ "$exit_code" != 0 ] ; then
134 die "Error: good cuesheet is broken"
136 cuesheet_pass1=${cuesheet}.1
137 cuesheet_pass2=${cuesheet}.2
138 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
139 rm -f $cuesheet_pass1 $cuesheet_pass2
140 done
142 if [ $is_win = yes ] ; then
143 diff -w cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
144 else
145 diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
148 echo "PASSED (results are in $log)"