1*600f14f4SXin Li#!/bin/sh -e 2*600f14f4SXin Li 3*600f14f4SXin Li# FLAC - Free Lossless Audio Codec 4*600f14f4SXin Li# Copyright (C) 2004-2009 Josh Coalson 5*600f14f4SXin Li# Copyright (C) 2011-2023 Xiph.Org Foundation 6*600f14f4SXin Li# 7*600f14f4SXin Li# This file is part the FLAC project. FLAC is comprised of several 8*600f14f4SXin Li# components distributed under different licenses. The codec libraries 9*600f14f4SXin Li# are distributed under Xiph.Org's BSD-like license (see the file 10*600f14f4SXin Li# COPYING.Xiph in this distribution). All other programs, libraries, and 11*600f14f4SXin Li# plugins are distributed under the GPL (see COPYING.GPL). The documentation 12*600f14f4SXin Li# is distributed under the Gnu FDL (see COPYING.FDL). Each file in the 13*600f14f4SXin Li# FLAC distribution contains at the top the terms under which it may be 14*600f14f4SXin Li# distributed. 15*600f14f4SXin Li# 16*600f14f4SXin Li# Since this particular file is relevant to all components of FLAC, 17*600f14f4SXin Li# it may be distributed under the Xiph.Org license, which is the least 18*600f14f4SXin Li# restrictive of those mentioned above. See the file COPYING.Xiph in this 19*600f14f4SXin Li# distribution. 20*600f14f4SXin Li 21*600f14f4SXin Li. ./common.sh 22*600f14f4SXin Li 23*600f14f4SXin LiPATH=../src/flac:$PATH 24*600f14f4SXin LiPATH=../src/metaflac:$PATH 25*600f14f4SXin LiPATH=../src/test_seeking:$PATH 26*600f14f4SXin LiPATH=../src/test_streams:$PATH 27*600f14f4SXin LiPATH=../objs/$BUILD/bin:$PATH 28*600f14f4SXin Li 29*600f14f4SXin Liif [ -z "$FLAC__TEST_LEVEL" ] ; then 30*600f14f4SXin Li FLAC__TEST_LEVEL=1 31*600f14f4SXin Lifi 32*600f14f4SXin Li 33*600f14f4SXin Liflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find flac executable" 34*600f14f4SXin Limetaflac${EXE} --help 1>/dev/null 2>/dev/null || die "ERROR can't find metaflac executable" 35*600f14f4SXin Li 36*600f14f4SXin Lirun_flac () 37*600f14f4SXin Li{ 38*600f14f4SXin Li if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then 39*600f14f4SXin Li echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_seeking.valgrind.log 40*600f14f4SXin Li 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 41*600f14f4SXin Li else 42*600f14f4SXin Li flac${EXE} --no-error-on-compression-fail $* 43*600f14f4SXin Li fi 44*600f14f4SXin Li} 45*600f14f4SXin Li 46*600f14f4SXin Lirun_metaflac () 47*600f14f4SXin Li{ 48*600f14f4SXin Li if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then 49*600f14f4SXin Li echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 metaflac $*" >>test_seeking.valgrind.log 50*600f14f4SXin Li valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 metaflac${EXE} $* 4>>test_seeking.valgrind.log 51*600f14f4SXin Li else 52*600f14f4SXin Li metaflac${EXE} $* 53*600f14f4SXin Li fi 54*600f14f4SXin Li} 55*600f14f4SXin Li 56*600f14f4SXin Lirun_test_seeking () 57*600f14f4SXin Li{ 58*600f14f4SXin Li if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then 59*600f14f4SXin Li echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_seeking $*" >>test_seeking.valgrind.log 60*600f14f4SXin Li valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_seeking $* 4>>test_seeking.valgrind.log 61*600f14f4SXin Li else 62*600f14f4SXin Li test_seeking${EXE} $* 63*600f14f4SXin Li fi 64*600f14f4SXin Li} 65*600f14f4SXin Li 66*600f14f4SXin Liecho $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C 67*600f14f4SXin Liif 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 68*600f14f4SXin Li has_ogg=yes; 69*600f14f4SXin Lielse 70*600f14f4SXin Li has_ogg=no; 71*600f14f4SXin Lifi 72*600f14f4SXin Liecho ${has_ogg} 73*600f14f4SXin Li 74*600f14f4SXin Liecho "Generating streams..." 75*600f14f4SXin Liif [ ! -f noise.raw ] ; then 76*600f14f4SXin Li test_streams || die "ERROR during test_streams" 77*600f14f4SXin Lifi 78*600f14f4SXin Li 79*600f14f4SXin Liecho "generating FLAC files for seeking:" 80*600f14f4SXin Lirun_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" 81*600f14f4SXin Lirun_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" 82*600f14f4SXin Lirun_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" 83*600f14f4SXin Lirun_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" 84*600f14f4SXin Li 85*600f14f4SXin Litiny_samples="$(metaflac${EXE} --show-total-samples tiny.flac)" 86*600f14f4SXin Lismall_samples="$(metaflac${EXE} --show-total-samples small.flac)" 87*600f14f4SXin Li 88*600f14f4SXin Litiny_seek_count=100 89*600f14f4SXin Liif [ "$FLAC__TEST_LEVEL" -gt 1 ] ; then 90*600f14f4SXin Li small_seek_count=10000 91*600f14f4SXin Lielse 92*600f14f4SXin Li small_seek_count=100 93*600f14f4SXin Lifi 94*600f14f4SXin Li 95*600f14f4SXin Lifor suffix in '' '-s' ; do 96*600f14f4SXin Li echo "testing tiny$suffix.flac:" 97*600f14f4SXin Li if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 98*600f14f4SXin Li die "ERROR: during test_seeking" 99*600f14f4SXin Li fi 100*600f14f4SXin Li 101*600f14f4SXin Li echo "testing small$suffix.flac:" 102*600f14f4SXin Li if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else 103*600f14f4SXin Li die "ERROR: during test_seeking" 104*600f14f4SXin Li fi 105*600f14f4SXin Li 106*600f14f4SXin Li echo "removing sample count from tiny$suffix.flac and small$suffix.flac:" 107*600f14f4SXin Li if run_metaflac --no-filename --set-total-samples=0 tiny$suffix.flac small$suffix.flac ; then : ; else 108*600f14f4SXin Li die "ERROR: during metaflac" 109*600f14f4SXin Li fi 110*600f14f4SXin Li 111*600f14f4SXin Li echo "testing tiny$suffix.flac with total_samples=0:" 112*600f14f4SXin Li if run_test_seeking tiny$suffix.flac $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 113*600f14f4SXin Li die "ERROR: during test_seeking" 114*600f14f4SXin Li fi 115*600f14f4SXin Li 116*600f14f4SXin Li echo "testing small$suffix.flac with total_samples=0:" 117*600f14f4SXin Li if run_test_seeking small$suffix.flac $small_seek_count $small_samples noise.raw ; then : ; else 118*600f14f4SXin Li die "ERROR: during test_seeking" 119*600f14f4SXin Li fi 120*600f14f4SXin Lidone 121*600f14f4SXin Li 122*600f14f4SXin Liif [ $has_ogg = "yes" ] ; then 123*600f14f4SXin Li 124*600f14f4SXin Li echo "generating Ogg FLAC files for seeking:" 125*600f14f4SXin Li 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*600f14f4SXin Li 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" 127*600f14f4SXin Li # seek tables are not used in Ogg FLAC 128*600f14f4SXin Li 129*600f14f4SXin Li echo "testing tiny.oga:" 130*600f14f4SXin Li if run_test_seeking tiny.oga $tiny_seek_count $tiny_samples noise8m32.raw ; then : ; else 131*600f14f4SXin Li die "ERROR: during test_seeking" 132*600f14f4SXin Li fi 133*600f14f4SXin Li 134*600f14f4SXin Li echo "testing small.oga:" 135*600f14f4SXin Li if run_test_seeking small.oga $small_seek_count $small_samples noise.raw ; then : ; else 136*600f14f4SXin Li die "ERROR: during test_seeking" 137*600f14f4SXin Li fi 138*600f14f4SXin Li 139*600f14f4SXin Lifi 140*600f14f4SXin Li 141*600f14f4SXin Lirm -f tiny.flac tiny.oga small.flac small.oga tiny-s.flac small-s.flac 142