1#!/bin/sh -e 2 3# FLAC - Free Lossless Audio Codec 4# Copyright (C) 2001-2009 Josh Coalson 5# Copyright (C) 2011-2016 Xiph.Org Foundation 6# 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. 15# 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. 20 21. ./common.sh 22 23PATH=../src/test_grabbag/cuesheet:$PATH 24PATH=../src/test_grabbag/picture:$PATH 25PATH=../objs/$BUILD/bin:$PATH 26 27test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable" 28test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable" 29 30run_test_cuesheet () 31{ 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} $* 37 fi 38} 39 40run_test_picture () 41{ 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} $* 47 fi 48} 49 50######################################################################## 51# 52# test_picture 53# 54######################################################################## 55 56log=picture.log 57picture_dir=${top_srcdir}/test/pictures 58 59echo "Running test_picture..." 60 61rm -f $log 62 63run_test_picture $picture_dir >> $log 2>&1 64 65if [ $is_win = yes ] ; then 66 diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" 67else 68 diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff" 69fi 70 71echo "PASSED (results are in $log)" 72 73######################################################################## 74# 75# test_cuesheet 76# 77######################################################################## 78 79log=cuesheet.log 80bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue 81good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue 82good_leadout=`expr 80 \* 60 \* 44100` 83bad_leadout=`expr $good_leadout + 1` 84 85echo "Running test_cuesheet..." 86 87rm -f $log 88 89# 90# negative tests 91# 92for cuesheet in $bad_cuesheets ; do 93 echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 94 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$? 95 if [ "$exit_code" = 255 ] ; then 96 die "Error: test script is broken" 97 fi 98 cuesheet_pass1=${cuesheet}.1 99 cuesheet_pass2=${cuesheet}.2 100 rm -f $cuesheet_pass1 $cuesheet_pass2 101done 102 103# 104# positive tests 105# 106for cuesheet in $good_cuesheets ; do 107 echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1 108 run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 109 exit_code=$? 110 if [ "$exit_code" = 255 ] ; then 111 die "Error: test script is broken" 112 elif [ "$exit_code" != 0 ] ; then 113 die "Error: good cuesheet is broken" 114 fi 115 cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||") 116 cuesheet_pass1=${cuesheet_out}.1 117 cuesheet_pass2=${cuesheet_out}.2 118 diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ" 119 rm -f $cuesheet_pass1 $cuesheet_pass2 120done 121 122if [ $is_win = yes ] ; then 123 diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" 124else 125 diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff" 126fi 127 128echo "PASSED (results are in $log)" 129