blob: 68a1e2dff7082d34beccce273ed78dcd88dbeb90 [file] [log] [blame]
Josh Coalsoncb908a62002-11-23 02:21:48 +00001#!/bin/sh
2
3# FLAC - Free Lossless Audio Codec
Josh Coalsone74bd952007-02-02 06:58:19 +00004# Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
Josh Coalsoncb908a62002-11-23 02:21:48 +00005#
Josh Coalsone8a76012003-02-07 00:14:32 +00006# 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.
Josh Coalsoncb908a62002-11-23 02:21:48 +000014#
Josh Coalsone8a76012003-02-07 00:14:32 +000015# 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.
Josh Coalsoncb908a62002-11-23 02:21:48 +000019
Josh Coalson6218b342002-12-12 03:58:18 +000020die ()
21{
22 echo $* 1>&2
23 exit 1
24}
25
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000026if [ x = x"$1" ] ; then
27 BUILD=debug
28else
29 BUILD="$1"
30fi
31
32LD_LIBRARY_PATH=../src/libFLAC/.libs:$LD_LIBRARY_PATH
33LD_LIBRARY_PATH=../src/share/grabbag/.libs:$LD_LIBRARY_PATH
34LD_LIBRARY_PATH=../src/share/replaygain_analysis/.libs:$LD_LIBRARY_PATH
35LD_LIBRARY_PATH=../obj/$BUILD/lib:$LD_LIBRARY_PATH
Josh Coalsoncb908a62002-11-23 02:21:48 +000036export LD_LIBRARY_PATH
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000037PATH=../src/test_grabbag/cuesheet:$PATH
Josh Coalsonea869122006-11-17 07:46:09 +000038PATH=../src/test_grabbag/picture:$PATH
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000039PATH=../obj/$BUILD/bin:$PATH
Josh Coalsoncb908a62002-11-23 02:21:48 +000040
Josh Coalson6218b342002-12-12 03:58:18 +000041test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
Josh Coalsonea869122006-11-17 07:46:09 +000042test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
Josh Coalsoncb908a62002-11-23 02:21:48 +000043
Josh Coalson34c1ea82002-12-04 04:57:33 +000044run_test_cuesheet ()
45{
Josh Coalsonde9091e2006-05-25 02:48:22 +000046 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000047 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_cuesheet $*" >>test_grabbag.valgrind.log
Josh Coalson80936c52002-12-30 23:31:47 +000048 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_cuesheet $* 4>>test_grabbag.valgrind.log
Josh Coalson34c1ea82002-12-04 04:57:33 +000049 else
50 test_cuesheet $*
51 fi
52}
53
Josh Coalsonea869122006-11-17 07:46:09 +000054run_test_picture ()
55{
56 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Josh Coalson338a0b12006-11-20 05:39:34 +000057 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=100 test_picture $*" >>test_grabbag.valgrind.log
Josh Coalsonea869122006-11-17 07:46:09 +000058 valgrind --leak-check=yes --show-reachable=yes --num-callers=100 --logfile-fd=4 test_picture $* 4>>test_grabbag.valgrind.log
59 else
60 test_picture $*
61 fi
62}
63
Josh Coalson8f6bdf22006-10-03 01:03:12 +000064if [ `env | grep -ic '^comspec='` != 0 ] ; then
65 is_win=yes
66else
67 is_win=no
68fi
69
Josh Coalsoncb908a62002-11-23 02:21:48 +000070########################################################################
71#
Josh Coalsonea869122006-11-17 07:46:09 +000072# test_picture
73#
74########################################################################
75
76log=picture.log
77picture_dir=pictures
78
79echo "Running test_picture..."
80
81rm -f $log
82
83run_test_picture $picture_dir >> $log 2>&1
84
85if [ $is_win = yes ] ; then
86 diff -w picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
87else
88 diff picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
89fi
90
91echo "PASSED (results are in $log)"
92
93########################################################################
94#
Josh Coalsoncb908a62002-11-23 02:21:48 +000095# test_cuesheet
96#
97########################################################################
98
99log=cuesheet.log
100bad_cuesheets=cuesheets/bad.*.cue
101good_cuesheets=cuesheets/good.*.cue
102good_leadout=`expr 80 \* 60 \* 44100`
103bad_leadout=`expr $good_leadout + 1`
104
Josh Coalsonea869122006-11-17 07:46:09 +0000105echo "Running test_cuesheet..."
106
Josh Coalsoncb908a62002-11-23 02:21:48 +0000107rm -f $log
108
109#
110# negative tests
111#
112for cuesheet in $bad_cuesheets ; do
113 echo "NEGATIVE $cuesheet" >> $log 2>&1
Josh Coalson34c1ea82002-12-04 04:57:33 +0000114 run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
Josh Coalsoncb908a62002-11-23 02:21:48 +0000115 exit_code=$?
116 if [ "$exit_code" = 255 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000117 die "Error: test script is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000118 fi
119 cuesheet_pass1=${cuesheet}.1
120 cuesheet_pass2=${cuesheet}.2
121 rm -f $cuesheet_pass1 $cuesheet_pass2
122done
123
124#
125# positve tests
126#
127for cuesheet in $good_cuesheets ; do
128 echo "POSITIVE $cuesheet" >> $log 2>&1
Josh Coalson34c1ea82002-12-04 04:57:33 +0000129 run_test_cuesheet $cuesheet $good_leadout cdda >> $log 2>&1
Josh Coalsoncb908a62002-11-23 02:21:48 +0000130 exit_code=$?
131 if [ "$exit_code" = 255 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000132 die "Error: test script is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000133 elif [ "$exit_code" != 0 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000134 die "Error: good cuesheet is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000135 fi
136 cuesheet_pass1=${cuesheet}.1
137 cuesheet_pass2=${cuesheet}.2
Josh Coalson6218b342002-12-12 03:58:18 +0000138 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000139 rm -f $cuesheet_pass1 $cuesheet_pass2
140done
141
Josh Coalson8f6bdf22006-10-03 01:03:12 +0000142if [ $is_win = yes ] ; then
143 diff -w cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
144else
145 diff cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
146fi
Josh Coalsonc3cc5b42002-12-13 05:36:34 +0000147
148echo "PASSED (results are in $log)"