tweak Valgrind invocation to show more callers
[platform/upstream/flac.git] / test / test_grabbag.sh
1 #!/bin/sh
2
3 #  FLAC - Free Lossless Audio Codec
4 #  Copyright (C) 2001,2002  Josh Coalson
5 #
6 #  This program is part of FLAC; you can redistribute it and/or
7 #  modify it under the terms of the GNU General Public License
8 #  as published by the Free Software Foundation; either version 2
9 #  of the License, or (at your option) any later version.
10 #
11 #  This program is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  GNU General Public License for more details.
15 #
16 #  You should have received a copy of the GNU General Public License
17 #  along with this program; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 die ()
21 {
22         echo $* 1>&2
23         exit 1
24 }
25
26 LD_LIBRARY_PATH=../src/libFLAC/.libs:../src/share/grabbag/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
27 export LD_LIBRARY_PATH
28 PATH=../src/test_grabbag/cuesheet:../obj/release/bin:../obj/debug/bin:$PATH
29
30 test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
31
32 run_test_cuesheet ()
33 {
34         if [ "$FLAC__VALGRIND" = yes ] ; then
35                 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_cuesheet $* 4>>valgrind.log
36         else
37                 test_cuesheet $*
38         fi
39 }
40
41 ########################################################################
42 #
43 # test_cuesheet
44 #
45 ########################################################################
46
47 log=cuesheet.log
48 bad_cuesheets=cuesheets/bad.*.cue
49 good_cuesheets=cuesheets/good.*.cue
50 good_leadout=`expr 80 \* 60 \* 44100`
51 bad_leadout=`expr $good_leadout + 1`
52
53 rm -f $log
54
55 #
56 # negative tests
57 #
58 for cuesheet in $bad_cuesheets ; do
59         echo "NEGATIVE $cuesheet" >> $log 2>&1
60         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
61         exit_code=$?
62         if [ "$exit_code" = 255 ] ; then
63                 die "Error: test script is broken"
64         fi
65         cuesheet_pass1=${cuesheet}.1
66         cuesheet_pass2=${cuesheet}.2
67         rm -f $cuesheet_pass1 $cuesheet_pass2
68 done
69
70 #
71 # positve tests
72 #
73 for cuesheet in $good_cuesheets ; do
74         echo "POSITIVE $cuesheet" >> $log 2>&1
75         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
76         exit_code=$?
77         if [ "$exit_code" = 255 ] ; then
78                 die "Error: test script is broken"
79         elif [ "$exit_code" != 0 ] ; then
80                 die "Error: good cuesheet is broken"
81         fi
82         cuesheet_pass1=${cuesheet}.1
83         cuesheet_pass2=${cuesheet}.2
84         diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
85         rm -f $cuesheet_pass1 $cuesheet_pass2
86 done
87
88 diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
89
90 echo "PASSED (results are in $log)"