test_grabbag.sh 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/sh -e
  2. # FLAC - Free Lossless Audio Codec
  3. # Copyright (C) 2001-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/test_grabbag/cuesheet:$PATH
  21. PATH=../src/test_grabbag/picture:$PATH
  22. PATH=../objs/$BUILD/bin:$PATH
  23. test_cuesheet -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_cuesheet executable"
  24. test_picture -h 1>/dev/null 2>/dev/null || die "ERROR can't find test_picture executable"
  25. run_test_cuesheet ()
  26. {
  27. if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
  28. echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_cuesheet $*" >>test_grabbag.valgrind.log
  29. valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_cuesheet${EXE} $* 4>>test_grabbag.valgrind.log
  30. else
  31. test_cuesheet${EXE} $*
  32. fi
  33. }
  34. run_test_picture ()
  35. {
  36. if [ "$FLAC__TEST_WITH_VALGRIND" = yes ] ; then
  37. echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 test_picture $*" >>test_grabbag.valgrind.log
  38. valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 test_picture${EXE} $* 4>>test_grabbag.valgrind.log
  39. else
  40. test_picture${EXE} $*
  41. fi
  42. }
  43. ########################################################################
  44. #
  45. # test_picture
  46. #
  47. ########################################################################
  48. log=picture.log
  49. picture_dir=${top_srcdir}/test/pictures
  50. echo "Running test_picture..."
  51. rm -f $log
  52. run_test_picture $picture_dir >> $log 2>&1
  53. if [ $is_win = yes ] ; then
  54. diff -w ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
  55. else
  56. diff ${top_srcdir}/test/picture.ok $log > picture.diff || die "Error: .log file does not match .ok file, see picture.diff"
  57. fi
  58. echo "PASSED (results are in $log)"
  59. ########################################################################
  60. #
  61. # test_cuesheet
  62. #
  63. ########################################################################
  64. log=cuesheet.log
  65. bad_cuesheets=${top_srcdir}/test/cuesheets/bad.*.cue
  66. good_cuesheets=${top_srcdir}/test/cuesheets/good.*.cue
  67. good_leadout=$((80 * 60 * 44100))
  68. bad_leadout=$((good_leadout + 1))
  69. echo "Running test_cuesheet..."
  70. rm -f $log
  71. #
  72. # negative tests
  73. #
  74. for cuesheet in $bad_cuesheets ; do
  75. echo "NEGATIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
  76. run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1 || exit_code=$?
  77. if [ "$exit_code" = 255 ] ; then
  78. die "Error: test script is broken"
  79. fi
  80. cuesheet_pass1=${cuesheet}.1
  81. cuesheet_pass2=${cuesheet}.2
  82. rm -f $cuesheet_pass1 $cuesheet_pass2
  83. done
  84. #
  85. # positive tests
  86. #
  87. for cuesheet in $good_cuesheets ; do
  88. echo "POSITIVE $cuesheet" | sed "s|${top_srcdir}/test/||" >> $log 2>&1
  89. run_test_cuesheet $cuesheet $good_leadout 44100 cdda >> $log 2>&1
  90. exit_code=$?
  91. if [ "$exit_code" = 255 ] ; then
  92. die "Error: test script is broken"
  93. elif [ "$exit_code" != 0 ] ; then
  94. die "Error: good cuesheet is broken"
  95. fi
  96. cuesheet_out=$(echo $cuesheet | sed "s|${top_srcdir}/test/||")
  97. cuesheet_pass1=${cuesheet_out}.1
  98. cuesheet_pass2=${cuesheet_out}.2
  99. diff $cuesheet_pass1 $cuesheet_pass2 >> $log 2>&1 || die "Error: pass1 and pass2 output differ"
  100. rm -f $cuesheet_pass1 $cuesheet_pass2
  101. done
  102. if [ $is_win = yes ] ; then
  103. diff -w ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
  104. else
  105. diff ${top_srcdir}/test/cuesheet.ok $log > cuesheet.diff || die "Error: .log file does not match .ok file, see cuesheet.diff"
  106. fi
  107. echo "PASSED (results are in $log)"