test_seeking.sh 5.7 KB

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