Set version to 1.3.1pre1.
[flac.git] / test / test_grabbag.sh
blobaa77c83edd986bba7455931bd003c49b6732d9a4
1 #!/bin/bash -e
3 # FLAC - Free Lossless Audio Codec
4 # Copyright (C) 2001-2009 Josh Coalson
5 # Copyright (C) 2011-2014 Xiph.Org Foundation
7 # This file is part the FLAC project. FLAC is comprised of several
8 # components distributed under different licenses. The codec libraries
9 # are distributed under Xiph.Org's BSD-like license (see the file
10 # COPYING.Xiph in this distribution). All other programs, libraries, and
11 # plugins are distributed under the GPL (see COPYING.GPL). The documentation
12 # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
13 # FLAC distribution contains at the top the terms under which it may be
14 # distributed.
16 # Since this particular file is relevant to all components of FLAC,
17 # it may be distributed under the Xiph.Org license, which is the least
18 # restrictive of those mentioned above. See the file COPYING.Xiph in this
19 # distribution.
21 source common.sh
23 PATH=../src/test_grabbag/cuesheet:$PATH
24 PATH=../src/test_grabbag/picture:$PATH
25 PATH=../objs/$BUILD/bin:$PATH
27 test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
28 test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
30 run_test_cuesheet ()
32 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
33 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log
34 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log
35 else
36 test_cuesheet${EXE} $*
40 run_test_picture ()
42 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
43 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log
44 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log
45 else
46 test_picture${EXE} $*
50 if [ `env | grep -ic '^comspec='` != 0 ] ; then
51 is_win=yes
52 else
53 is_win=no
56 ########################################################################
58 # test_picture
60 ########################################################################
62 log=picture.log
63 picture_dir=pictures
65 echo "Running test_picture..."
67 rm -f $log
69 run_test_picture $picture_dir >> $log 2>&1
71 if [ $is_win = yes ] ; then
72 diff -w picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
73 else
74 diff picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
77 echo "PASSED (results are in $log)"
79 ########################################################################
81 # test_cuesheet
83 ########################################################################
85 log=cuesheet.log
86 bad_cuesheets=cuesheets/bad.*.cue
87 good_cuesheets=cuesheets/good.*.cue
88 good_leadout=`expr 80 \* 60 \* 44100`
89 bad_leadout=`expr $good_leadout + 1`
91 echo "Running test_cuesheet..."
93 rm -f $log
96 # negative tests
98 for cuesheet in $bad_cuesheets ; do
99 echo "NEGATIVE $cuesheet" >> $log 2>&1
100 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$?
101 if [ "$exit_code" = 255 ] ; then
102 die "Error: test script is broken"
104 cuesheet_pass1=${cuesheet}.1
105 cuesheet_pass2=${cuesheet}.2
106 rm -f $cuesheet_pass1 $cuesheet_pass2
107 done
110 # positve tests
112 for cuesheet in $good_cuesheets ; do
113 echo "POSITIVE $cuesheet" >> $log 2>&1
114 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1
115 exit_code=$?
116 if [ "$exit_code" = 255 ] ; then
117 die "Error: test script is broken"
118 elif [ "$exit_code" != 0 ] ; then
119 die "Error: good cuesheet is broken"
121 cuesheet_pass1=${cuesheet}.1
122 cuesheet_pass2=${cuesheet}.2
123 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
124 rm -f $cuesheet_pass1 $cuesheet_pass2
125 done
127 if [ $is_win = yes ] ; then
128 diff -w cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
129 else
130 diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
133 echo "PASSED (results are in $log)"