instrument for valgrind
[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 LD_LIBRARY_PATH=../src/libFLAC/.libs:../src/share/grabbag/.libs:../obj/release/lib:../obj/debug/lib:$LD_LIBRARY_PATH
21 export LD_LIBRARY_PATH
22 PATH=../src/test_grabbag/cuesheet:../obj/release/bin:../obj/debug/bin:$PATH
23
24 test_cuesheet -h 1>/dev/null 2>/dev/null || (echo "ERROR can't find test_cuesheet executable" 1>&2 && exit 1)
25 if [ $? != 0 ] ; then exit 1 ; fi
26
27 run_test_cuesheet ()
28 {
29         if [ "$FLAC__VALGRIND" = yes ] ; then
30                 valgrind --leak-check=yes --show-reachable=yes --num-callers=10 --logfile-fd=4 test_cuesheet $* 4>>valgrind.log
31         else
32                 test_cuesheet $*
33         fi
34 }
35
36 ########################################################################
37 #
38 # test_cuesheet
39 #
40 ########################################################################
41
42 log=cuesheet.log
43 bad_cuesheets=cuesheets/bad.*.cue
44 good_cuesheets=cuesheets/good.*.cue
45 good_leadout=`expr 80 \* 60 \* 44100`
46 bad_leadout=`expr $good_leadout + 1`
47
48 rm -f $log
49
50 #
51 # negative tests
52 #
53 for cuesheet in $bad_cuesheets ; do
54         echo "NEGATIVE $cuesheet" >> $log 2>&1
55         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
56         exit_code=$?
57         if [ "$exit_code" = 255 ] ; then
58                 echo "Error: test script is broken"
59                 exit 1
60         fi
61         cuesheet_pass1=${cuesheet}.1
62         cuesheet_pass2=${cuesheet}.2
63         rm -f $cuesheet_pass1 $cuesheet_pass2
64 done
65
66 #
67 # positve tests
68 #
69 for cuesheet in $good_cuesheets ; do
70         echo "POSITIVE $cuesheet" >> $log 2>&1
71         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
72         exit_code=$?
73         if [ "$exit_code" = 255 ] ; then
74                 echo "Error: test script is broken"
75                 exit 1
76         elif [ "$exit_code" != 0 ] ; then
77                 echo "Error: good cuesheet is broken"
78                 exit 1
79         fi
80         cuesheet_pass1=${cuesheet}.1
81         cuesheet_pass2=${cuesheet}.2
82         diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1
83         if [ $? != 0 ] ; then
84                 echo "Error: pass1 and pass2 output differ"
85                 exit 1
86         fi
87         rm -f $cuesheet_pass1 $cuesheet_pass2
88 done
89
90 diff cuesheet.ok $log > cuesheet.diff
91 if [ $? != 0 ] ; then
92         echo "Error: .log file does not match .ok file, see cuesheet.diff"
93         exit 1
94 fi