blob: 3af2741db8ca74bfd9f158db79ac8e5999018536 [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 Lopo6a5fe432016-12-05 06:35:39 +11005# Copyright (C) 2011-2016 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 Coalsoncb908a62002-11-23 02:21:48 +000050########################################################################
51#
Josh Coalsonea869122006-11-17 07:46:09 +000052# test_picture
53#
54########################################################################
55
56log=picture.log
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110057picture_dir=${top_srcdir}/test/pictures
Josh Coalsonea869122006-11-17 07:46:09 +000058
59echo "Running test_picture..."
60
61rm -f $log
62
63run_test_picture $picture_dir >> $log 2>&1
64
65if [ $is_win = yes ] ; then
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110066 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 +000067else
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110068 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 +000069fi
70
71echo "PASSED (results are in $log)"
72
73########################################################################
74#
Josh Coalsoncb908a62002-11-23 02:21:48 +000075# test_cuesheet
76#
77########################################################################
78
79log=cuesheet.log
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110080bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue
81good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue
Josh Coalsoncb908a62002-11-23 02:21:48 +000082good_leadout=`expr 80 \* 60 \* 44100`
83bad_leadout=`expr $good_leadout + 1`
84
Josh Coalsonea869122006-11-17 07:46:09 +000085echo "Running test_cuesheet..."
86
Josh Coalsoncb908a62002-11-23 02:21:48 +000087rm -f $log
88
89#
90# negative tests
91#
92for cuesheet in $bad_cuesheets ; do
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +110093 echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
Martijn van Beurden163b7342014-03-03 14:17:56 +010094 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$?
Josh Coalsoncb908a62002-11-23 02:21:48 +000095 if [ "$exit_code" = 255 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +000096 die "Error: test script is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +000097 fi
98 cuesheet_pass1=${cuesheet}.1
99 cuesheet_pass2=${cuesheet}.2
100 rm -f $cuesheet_pass1 $cuesheet_pass2
101done
102
103#
luz.paz01eb1972018-05-22 10:17:53 -0400104# positive tests
Josh Coalsoncb908a62002-11-23 02:21:48 +0000105#
106for cuesheet in $good_cuesheets ; do
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100107 echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
Josh Coalsonc9ed2382009-01-07 07:03:17 +0000108 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1
Josh Coalsoncb908a62002-11-23 02:21:48 +0000109 exit_code=$?
110 if [ "$exit_code" = 255 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000111 die "Error: test script is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000112 elif [ "$exit_code" != 0 ] ; then
Josh Coalson6218b342002-12-12 03:58:18 +0000113 die "Error: good cuesheet is broken"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000114 fi
Erik de Castro Lopo29db3fb2015-02-23 19:42:30 +1100115 cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||")
116 cuesheet_pass1=${cuesheet_out}.1
117 cuesheet_pass2=${cuesheet_out}.2
Josh Coalson6218b342002-12-12 03:58:18 +0000118 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
Josh Coalsoncb908a62002-11-23 02:21:48 +0000119 rm -f $cuesheet_pass1 $cuesheet_pass2
120done
121
Josh Coalson8f6bdf22006-10-03 01:03:12 +0000122if [ $is_win = yes ] ; then
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100123 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 +0000124else
Erik de Castro Lopo7c3cd3d2015-02-15 14:31:30 +1100125 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 +0000126fi
Josh Coalsonc3cc5b42002-12-13 05:36:34 +0000127
128echo "PASSED (results are in $log)"