add test_picture to grabbag tests
[platform/upstream/flac.git] / test / test_grabbag.sh
1 #!/bin/sh
2
3 #  FLAC - Free Lossless Audio Codec
4 #  Copyright (C) 2001,2002,2003,2004,2005,2006  Josh Coalson
5 #
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.
14 #
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.
19
20 die ()
21 {
22         echo $* 1>&2
23         exit 1
24 }
25
26 if [ x = x"$1" ] ; then 
27         BUILD=debug
28 else
29         BUILD="$1"
30 fi
31
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
40
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"
43
44 run_test_cuesheet ()
45 {
46         if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
47                 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log
48         else
49                 test_cuesheet $*
50         fi
51 }
52
53 run_test_picture ()
54 {
55         if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
56                 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_picture $* 4>>test_grabbag.valgrind.log
57         else
58                 test_picture $*
59         fi
60 }
61
62 if [ `env | grep -ic '^comspec='` != 0 ] ; then
63         is_win=yes
64 else
65         is_win=no
66 fi
67
68 ########################################################################
69 #
70 # test_picture
71 #
72 ########################################################################
73
74 log=picture.log
75 picture_dir=pictures
76
77 echo "Running test_picture..."
78
79 rm -f $log
80
81 run_test_picture $picture_dir >> $log 2>&1
82
83 if [ $is_win = yes ] ; then
84         diff -w picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
85 else
86         diff picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
87 fi
88
89 echo "PASSED (results are in $log)"
90
91 ########################################################################
92 #
93 # test_cuesheet
94 #
95 ########################################################################
96
97 log=cuesheet.log
98 bad_cuesheets=cuesheets/bad.*.cue
99 good_cuesheets=cuesheets/good.*.cue
100 good_leadout=`expr 80 \* 60 \* 44100`
101 bad_leadout=`expr $good_leadout + 1`
102
103 echo "Running test_cuesheet..."
104
105 rm -f $log
106
107 #
108 # negative tests
109 #
110 for cuesheet in $bad_cuesheets ; do
111         echo "NEGATIVE $cuesheet" >> $log 2>&1
112         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
113         exit_code=$?
114         if [ "$exit_code" = 255 ] ; then
115                 die "Error: test script is broken"
116         fi
117         cuesheet_pass1=${cuesheet}.1
118         cuesheet_pass2=${cuesheet}.2
119         rm -f $cuesheet_pass1 $cuesheet_pass2
120 done
121
122 #
123 # positve tests
124 #
125 for cuesheet in $good_cuesheets ; do
126         echo "POSITIVE $cuesheet" >> $log 2>&1
127         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
128         exit_code=$?
129         if [ "$exit_code" = 255 ] ; then
130                 die "Error: test script is broken"
131         elif [ "$exit_code" != 0 ] ; then
132                 die "Error: good cuesheet is broken"
133         fi
134         cuesheet_pass1=${cuesheet}.1
135         cuesheet_pass2=${cuesheet}.2
136         diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
137         rm -f $cuesheet_pass1 $cuesheet_pass2
138 done
139
140 if [ $is_win = yes ] ; then
141         diff -w cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
142 else
143         diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
144 fi
145
146 echo "PASSED (results are in $log)"