Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 1 | #!/bin/sh -e |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 2 | |
| 3 | # FLAC - Free Lossless Audio Codec |
Erik de Castro Lopo | b1982fb | 2013-05-25 17:11:19 +1000 | [diff] [blame] | 4 | # Copyright (C) 2001-2009 Josh Coalson |
Erik de Castro Lopo | 1437391 | 2014-11-24 22:07:15 +1100 | [diff] [blame] | 5 | # Copyright (C) 2011-2014 Xiph.Org Foundation |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 6 | # |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 7 | # This file is part the FLAC project. FLAC is comprised of several |
Ulrich Klauer | cd4ddab | 2013-05-26 22:53:43 +0200 | [diff] [blame] | 8 | # components distributed under different licenses. The codec libraries |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 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. |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 15 | # |
Josh Coalson | e8a7601 | 2003-02-07 00:14:32 +0000 | [diff] [blame] | 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. |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 20 | |
Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 21 | . ./common.sh |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 22 | |
Josh Coalson | b43d3cb | 2004-11-09 01:28:05 +0000 | [diff] [blame] | 23 | PATH=../src/test_grabbag/cuesheet:$PATH |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 24 | PATH=../src/test_grabbag/picture:$PATH |
Erik de Castro Lopo | 85d5c53 | 2013-01-02 22:37:42 +1100 | [diff] [blame] | 25 | PATH=../objs/$BUILD/bin:$PATH |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 26 | |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 27 | test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable" |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 28 | test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable" |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 29 | |
Josh Coalson | 34c1ea8 | 2002-12-04 04:57:33 +0000 | [diff] [blame] | 30 | run_test_cuesheet () |
| 31 | { |
Josh Coalson | de9091e | 2006-05-25 02:48:22 +0000 | [diff] [blame] | 32 | if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then |
Martijn van Beurden | f6585b0 | 2013-04-21 23:12:16 +0200 | [diff] [blame] | 33 | echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 34 | valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log |
Josh Coalson | 34c1ea8 | 2002-12-04 04:57:33 +0000 | [diff] [blame] | 35 | else |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 36 | test_cuesheet${EXE} $* |
Josh Coalson | 34c1ea8 | 2002-12-04 04:57:33 +0000 | [diff] [blame] | 37 | fi |
| 38 | } |
| 39 | |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 40 | run_test_picture () |
| 41 | { |
| 42 | if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then |
Martijn van Beurden | f6585b0 | 2013-04-21 23:12:16 +0200 | [diff] [blame] | 43 | echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 44 | valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 45 | else |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 46 | test_picture${EXE} $* |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 47 | fi |
| 48 | } |
| 49 | |
Josh Coalson | 8f6bdf2 | 2006-10-03 01:03:12 +0000 | [diff] [blame] | 50 | if [ `env | grep -ic '^comspec='` != 0 ] ; then |
| 51 | is_win=yes |
| 52 | else |
| 53 | is_win=no |
| 54 | fi |
| 55 | |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 56 | ######################################################################## |
| 57 | # |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 58 | # test_picture |
| 59 | # |
| 60 | ######################################################################## |
| 61 | |
| 62 | log=picture.log |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 63 | picture_dir=${top_srcdir}/test/pictures |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 64 | |
| 65 | echo "Running test_picture..." |
| 66 | |
| 67 | rm -f $log |
| 68 | |
| 69 | run_test_picture $picture_dir >> $log 2>&1 |
| 70 | |
| 71 | if [ $is_win = yes ] ; then |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 72 | diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 73 | else |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 74 | diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 75 | fi |
| 76 | |
| 77 | echo "PASSED (results are in $log)" |
| 78 | |
| 79 | ######################################################################## |
| 80 | # |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 81 | # test_cuesheet |
| 82 | # |
| 83 | ######################################################################## |
| 84 | |
| 85 | log=cuesheet.log |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 86 | bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue |
| 87 | good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 88 | good_leadout=`expr 80 \* 60 \* 44100` |
| 89 | bad_leadout=`expr $good_leadout + 1` |
| 90 | |
Josh Coalson | ea86912 | 2006-11-17 07:46:09 +0000 | [diff] [blame] | 91 | echo "Running test_cuesheet..." |
| 92 | |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 93 | rm -f $log |
| 94 | |
| 95 | # |
| 96 | # negative tests |
| 97 | # |
| 98 | for cuesheet in $bad_cuesheets ; do |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 99 | echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 |
Martijn van Beurden | 163b734 | 2014-03-03 14:17:56 +0100 | [diff] [blame] | 100 | run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$? |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 101 | if [ "$exit_code" = 255 ] ; then |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 102 | die "Error: test script is broken" |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 103 | fi |
| 104 | cuesheet_pass1=${cuesheet}.1 |
| 105 | cuesheet_pass2=${cuesheet}.2 |
| 106 | rm -f $cuesheet_pass1 $cuesheet_pass2 |
| 107 | done |
| 108 | |
| 109 | # |
| 110 | # positve tests |
| 111 | # |
| 112 | for cuesheet in $good_cuesheets ; do |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 113 | echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 |
Josh Coalson | c9ed238 | 2009-01-07 07:03:17 +0000 | [diff] [blame] | 114 | run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 115 | exit_code=$? |
| 116 | if [ "$exit_code" = 255 ] ; then |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 117 | die "Error: test script is broken" |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 118 | elif [ "$exit_code" != 0 ] ; then |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 119 | die "Error: good cuesheet is broken" |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 120 | fi |
Erik de Castro Lopo | 29db3fb | 2015-02-23 19:42:30 +1100 | [diff] [blame] | 121 | cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||") |
| 122 | cuesheet_pass1=${cuesheet_out}.1 |
| 123 | cuesheet_pass2=${cuesheet_out}.2 |
Josh Coalson | 6218b34 | 2002-12-12 03:58:18 +0000 | [diff] [blame] | 124 | diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ" |
Josh Coalson | cb908a6 | 2002-11-23 02:21:48 +0000 | [diff] [blame] | 125 | rm -f $cuesheet_pass1 $cuesheet_pass2 |
| 126 | done |
| 127 | |
Josh Coalson | 8f6bdf2 | 2006-10-03 01:03:12 +0000 | [diff] [blame] | 128 | if [ $is_win = yes ] ; then |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 129 | diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" |
Josh Coalson | 8f6bdf2 | 2006-10-03 01:03:12 +0000 | [diff] [blame] | 130 | else |
Erik de Castro Lopo | 7c3cd3d | 2015-02-15 14:31:30 +1100 | [diff] [blame] | 131 | diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" |
Josh Coalson | 8f6bdf2 | 2006-10-03 01:03:12 +0000 | [diff] [blame] | 132 | fi |
Josh Coalson | c3cc5b4 | 2002-12-13 05:36:34 +0000 | [diff] [blame] | 133 | |
| 134 | echo "PASSED (results are in $log)" |