add 2206 to copyright notice
[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=../obj/$BUILD/bin:$PATH
39
40 test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
41
42 run_test_cuesheet ()
43 {
44         if [ x"$FLAC__VALGRIND" = xyes ] ; then
45                 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log
46         else
47                 test_cuesheet $*
48         fi
49 }
50
51 ########################################################################
52 #
53 # test_cuesheet
54 #
55 ########################################################################
56
57 log=cuesheet.log
58 bad_cuesheets=cuesheets/bad.*.cue
59 good_cuesheets=cuesheets/good.*.cue
60 good_leadout=`expr 80 \* 60 \* 44100`
61 bad_leadout=`expr $good_leadout + 1`
62
63 rm -f $log
64
65 #
66 # negative tests
67 #
68 for cuesheet in $bad_cuesheets ; do
69         echo "NEGATIVE $cuesheet" >> $log 2>&1
70         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
71         exit_code=$?
72         if [ "$exit_code" = 255 ] ; then
73                 die "Error: test script is broken"
74         fi
75         cuesheet_pass1=${cuesheet}.1
76         cuesheet_pass2=${cuesheet}.2
77         rm -f $cuesheet_pass1 $cuesheet_pass2
78 done
79
80 #
81 # positve tests
82 #
83 for cuesheet in $good_cuesheets ; do
84         echo "POSITIVE $cuesheet" >> $log 2>&1
85         run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
86         exit_code=$?
87         if [ "$exit_code" = 255 ] ; then
88                 die "Error: test script is broken"
89         elif [ "$exit_code" != 0 ] ; then
90                 die "Error: good cuesheet is broken"
91         fi
92         cuesheet_pass1=${cuesheet}.1
93         cuesheet_pass2=${cuesheet}.2
94         diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
95         rm -f $cuesheet_pass1 $cuesheet_pass2
96 done
97
98 diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
99
100 echo "PASSED (results are in $log)"