blob: 4ba38f3356585da73d2bf30eacd0f6d030b0a01c [file] [log] [blame]
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +11001#!/bin/sh -e
Josh Coalsoncb908a62002-11-23 02:21:48 +00002
3# FLAC - Free Lossless Audio Codec
Erik de Castro Lopob1982fb2013-05-25 17:11:19 +10004# Copyright (C) 2001-2009 Josh Coalson
Erik de Castro Lopo14373912014-11-24 22:07:15 +11005# Copyright (C) 2011-2014 Xiph.Org Foundation
Josh Coalsoncb908a62002-11-23 02:21:48 +00006#
Josh Coalsone8a76012003-02-07 00:14:32 +00007# This file is part the FLAC project. FLAC is comprised of several
Ulrich Klauercd4ddab2013-05-26 22:53:43 +02008# components distributed under different licenses. The codec libraries
Josh Coalsone8a76012003-02-07 00:14:32 +00009# 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.
Josh Coalsoncb908a62002-11-23 02:21:48 +000015#
Josh Coalsone8a76012003-02-07 00:14:32 +000016# 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.
Josh Coalsoncb908a62002-11-23 02:21:48 +000020
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +110021. ./common.sh
Josh Coalson6218b342002-12-12 03:58:18 +000022
Josh Coalsonb43d3cb2004-11-09 01:28:05 +000023PATH=../src/test_grabbag/cuesheet:$PATH
Josh Coalsonea869122006-11-17 07:46:09 +000024PATH=../src/test_grabbag/picture:$PATH
Erik de Castro Lopo85d5c532013-01-02 22:37:42 +110025PATH=../objs/$BUILD/bin:$PATH
Josh Coalsoncb908a62002-11-23 02:21:48 +000026
Josh Coalson6218b342002-12-12 03:58:18 +000027test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
Josh Coalsonea869122006-11-17 07:46:09 +000028test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
Josh Coalsoncb908a62002-11-23 02:21:48 +000029
Josh Coalson34c1ea82002-12-04 04:57:33 +000030run_test_cuesheet ()
31{
Josh Coalsonde9091e2006-05-25 02:48:22 +000032 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020033 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100034 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log
Josh Coalson34c1ea82002-12-04 04:57:33 +000035 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100036 test_cuesheet${EXE} $*
Josh Coalson34c1ea82002-12-04 04:57:33 +000037 fi
38}
39
Josh Coalsonea869122006-11-17 07:46:09 +000040run_test_picture ()
41{
42 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020043 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100044 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log
Josh Coalsonea869122006-11-17 07:46:09 +000045 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100046 test_picture${EXE} $*
Josh Coalsonea869122006-11-17 07:46:09 +000047 fi
48}
49
Josh Coalson8f6bdf22006-10-03 01:03:12 +000050if [ `env | grep -ic '^comspec='` != 0 ] ; then
51 is_win=yes
52else
53 is_win=no
54fi
55
Josh Coalsoncb908a62002-11-23 02:21:48 +000056########################################################################
57#
Josh Coalsonea869122006-11-17 07:46:09 +000058# test_picture
59#
60########################################################################
61
62log=picture.log
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110063picture_dir=${top_srcdir}/test/pictures
Josh Coalsonea869122006-11-17 07:46:09 +000064
65echo "Running test_picture..."
66
67rm -f $log
68
69run_test_picture $picture_dir >> $log 2>&1
70
71if [ $is_win = yes ] ; then
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110072 diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
Josh Coalsonea869122006-11-17 07:46:09 +000073else
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110074 diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
Josh Coalsonea869122006-11-17 07:46:09 +000075fi
76
77echo "PASSED (results are in $log)"
78
79########################################################################
80#
Josh Coalsoncb908a62002-11-23 02:21:48 +000081# test_cuesheet
82#
83########################################################################
84
85log=cuesheet.log
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110086bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue
87good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue
Josh Coalsoncb908a62002-11-23 02:21:48 +000088good_leadout=`expr 80 \* 60 \* 44100`
89bad_leadout=`expr $good_leadout + 1`
90
Josh Coalsonea869122006-11-17 07:46:09 +000091echo "Running test_cuesheet..."
92
Josh Coalsoncb908a62002-11-23 02:21:48 +000093rm -f $log
94
95#
96# negative tests
97#
98for cuesheet in $bad_cuesheets ; do
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110099 echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
Martijn van Beurden163b7342014-03-03 14:17:56 +0100100 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$?
Josh Coalsoncb908a62002-11-23 02:21:48 +0000101 if [ "$exit_code" = 255 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000102 die "Error: test script is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000103 fi
104 cuesheet_pass1=${cuesheet}.1
105 cuesheet_pass2=${cuesheet}.2
106 rm -f $cuesheet_pass1 $cuesheet_pass2
107done
108
109#
110# positve tests
111#
112for cuesheet in $good_cuesheets ; do
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100113 echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
Josh Coalsonc9ed2382009-01-07 07:03:17 +0000114 run_test_cuesheet $cuesheet $good_leadout 44100 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 elif [ "$exit_code" != 0 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000119 die "Error: good cuesheet is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000120 fi
Erik de Castro Lopo29db3fb2015-02-23 19:42:30 +1100121 cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||")
122 cuesheet_pass1=${cuesheet_out}.1
123 cuesheet_pass2=${cuesheet_out}.2
Josh Coalson6218b342002-12-12 03:58:18 +0000124 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000125 rm -f $cuesheet_pass1 $cuesheet_pass2
126done
127
Josh Coalson8f6bdf22006-10-03 01:03:12 +0000128if [ $is_win = yes ] ; then
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100129 diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
Josh Coalson8f6bdf22006-10-03 01:03:12 +0000130else
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100131 diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
Josh Coalson8f6bdf22006-10-03 01:03:12 +0000132fi
Josh Coalsonc3cc5b42002-12-13 05:36:34 +0000133
134echo "PASSED (results are in $log)"