blob: 316d3db3b723f201e08aa61eff3485edea698662 [file] [log] [blame]
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +11001#!/bin/sh -e
Josh Coalsonb42b0ee2004-11-09 01:27:12 +00002
3# FLAC - Free Lossless Audio Codec
Erik de Castro Lopob1982fb2013-05-25 17:11:19 +10004# Copyright (C) 2004-2009 Josh Coalson
Erik de Castro Lopo6a5fe432016-12-05 06:35:39 +11005# Copyright (C) 2011-2016 Xiph.Org Foundation
Josh Coalsonb42b0ee2004-11-09 01:27:12 +00006#
7# 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 Coalsonb42b0ee2004-11-09 01:27:12 +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.
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
Erik de Castro Lopo1a7c3fa2014-11-27 13:03:13 +110021. ./common.sh
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000022
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000023PATH=../src/flac:$PATH
Josh Coalson450572f2005-01-26 03:48:06 +000024PATH=../src/metaflac:$PATH
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000025PATH=../src/test_seeking:$PATH
26PATH=../src/test_streams:$PATH
Erik de Castro Lopo85d5c532013-01-02 22:37:42 +110027PATH=../objs/$BUILD/bin:$PATH
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000028
Josh Coalson5c24bb82007-06-16 00:43:15 +000029if [ x"$FLAC__TEST_LEVEL" = x ] ; then
30 FLAC__TEST_LEVEL=1
31fi
32
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100033flac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable"
34metaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable"
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000035
36run_flac ()
37{
Josh Coalsonde9091e2006-05-25 02:48:22 +000038 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020039 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100040 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} --no-error-on-compression-fail $* 4>>test_seeking.valgrind.log
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000041 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100042 flac${EXE} --no-error-on-compression-fail $*
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000043 fi
44}
45
Josh Coalson450572f2005-01-26 03:48:06 +000046run_metaflac ()
47{
Josh Coalsonde9091e2006-05-25 02:48:22 +000048 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020049 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100050 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log
Josh Coalson450572f2005-01-26 03:48:06 +000051 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100052 metaflac${EXE} $*
Josh Coalson450572f2005-01-26 03:48:06 +000053 fi
54}
55
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000056run_test_seeking ()
57{
Josh Coalsonde9091e2006-05-25 02:48:22 +000058 if [ x"$FLAC__TEST_WITH_VALGRIND" = xyes ] ; then
Martijn van Beurdenf6585b02013-04-21 23:12:16 +020059 echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log
60 valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000061 else
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100062 test_seeking${EXE} $*
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000063 fi
64}
65
Erik de Castro Lopoefaab3c2015-10-04 09:43:33 +110066echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100067if flac${EXE} --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
Josh Coalson7ffd7e42005-02-01 01:49:11 +000068 has_ogg=yes;
Josh Coalson7ffd7e42005-02-01 01:49:11 +000069else
70 has_ogg=no;
Josh Coalson7ffd7e42005-02-01 01:49:11 +000071fi
Erik de Castro Lopod6fa2902013-09-15 19:58:35 +100072echo ${has_ogg}
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000073
74echo "Generating streams..."
75if [ ! -f noise.raw ] ; then
76 test_streams || die "ERROR during test_streams"
77fi
78
79echo "generating FLAC files for seeking:"
Josh Coalson6b21f662006-09-13 01:42:27 +000080run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S- --output-name=tiny.flac noise8m32.raw || die "ERROR generating FLAC file"
81run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S- --output-name=small.flac noise.raw || die "ERROR generating FLAC file"
82run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 -S10x --output-name=tiny-s.flac noise8m32.raw || die "ERROR generating FLAC file"
83run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 -S10x --output-name=small-s.flac noise.raw || die "ERROR generating FLAC file"
Josh Coalsonb42b0ee2004-11-09 01:27:12 +000084
Erik de Castro Lopoa9712a22013-09-16 19:55:11 +100085tiny_samples=`metaflac${EXE} --show-total-samples tiny.flac`
86small_samples=`metaflac${EXE} --show-total-samples small.flac`
Josh Coalsonf8d544f2006-11-16 01:22:33 +000087
Josh Coalson5c24bb82007-06-16 00:43:15 +000088tiny_seek_count=100
89if [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then
90 small_seek_count=10000
91else
Erik de Castro Lopo774e0772012-02-26 12:19:39 +110092 small_seek_count=100
Josh Coalson5c24bb82007-06-16 00:43:15 +000093fi
94
Josh Coalson6b21f662006-09-13 01:42:27 +000095for suffix in '' '-s' ; do
96 echo "testing tiny$suffix.flac:"
Josh Coalson5c24bb82007-06-16 00:43:15 +000097 if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +000098 die "ERROR: during test_seeking"
99 fi
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000100
Josh Coalson6b21f662006-09-13 01:42:27 +0000101 echo "testing small$suffix.flac:"
Josh Coalson5c24bb82007-06-16 00:43:15 +0000102 if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000103 die "ERROR: during test_seeking"
104 fi
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000105
Josh Coalson6b21f662006-09-13 01:42:27 +0000106 echo "removing sample count from tiny$suffix.flac and small$suffix.flac:"
107 if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else
108 die "ERROR: during metaflac"
109 fi
Josh Coalson450572f2005-01-26 03:48:06 +0000110
Josh Coalson6b21f662006-09-13 01:42:27 +0000111 echo "testing tiny$suffix.flac with total_samples=0:"
Josh Coalson5c24bb82007-06-16 00:43:15 +0000112 if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000113 die "ERROR: during test_seeking"
114 fi
Josh Coalson450572f2005-01-26 03:48:06 +0000115
Josh Coalson6b21f662006-09-13 01:42:27 +0000116 echo "testing small$suffix.flac with total_samples=0:"
Josh Coalson5c24bb82007-06-16 00:43:15 +0000117 if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else
Josh Coalson6b21f662006-09-13 01:42:27 +0000118 die "ERROR: during test_seeking"
119 fi
120done
Josh Coalson450572f2005-01-26 03:48:06 +0000121
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000122if [ $has_ogg = "yes" ] ; then
123
Josh Coalson461899f2005-09-03 02:16:07 +0000124 echo "generating Ogg FLAC files for seeking:"
Josh Coalson12d3a412007-08-01 03:02:00 +0000125 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=8 --channels=1 --blocksize=576 --output-name=tiny.oga --ogg noise8m32.raw || die "ERROR generating Ogg FLAC file"
126 run_flac --verify --force --silent --force-raw-format --endian=big --sign=signed --sample-rate=44100 --bps=16 --channels=2 --blocksize=576 --output-name=small.oga --ogg noise.raw || die "ERROR generating Ogg FLAC file"
Josh Coalson0b9442c2006-10-16 16:18:34 +0000127 # seek tables are not used in Ogg FLAC
Josh Coalson461899f2005-09-03 02:16:07 +0000128
Josh Coalson12d3a412007-08-01 03:02:00 +0000129 echo "testing tiny.oga:"
130 if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000131 die "ERROR: during test_seeking"
132 fi
133
Josh Coalson12d3a412007-08-01 03:02:00 +0000134 echo "testing small.oga:"
135 if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else
Josh Coalson7ffd7e42005-02-01 01:49:11 +0000136 die "ERROR: during test_seeking"
137 fi
138
Josh Coalsonb42b0ee2004-11-09 01:27:12 +0000139fi
140
Josh Coalson12d3a412007-08-01 03:02:00 +0000141rm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac