test-common.sh.in 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # program locations
  2. AUDIOWMARK=@top_builddir@/src/audiowmark
  3. TEST_MSG=f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0
  4. TOP_BUILDDIR=@top_builddir@
  5. # common shell functions
  6. die()
  7. {
  8. echo >&2 "$0: $@"
  9. exit 1
  10. }
  11. audiowmark()
  12. {
  13. if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
  14. AUDIOWMARK_Q="-q"
  15. else
  16. echo >&2 ==== audiowmark "$@" ====
  17. fi
  18. $AUDIOWMARK $AUDIOWMARK_Q --strict "$@" || die "failed to run audiowmark $@"
  19. }
  20. audiowmark_add()
  21. {
  22. if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
  23. AUDIOWMARK_Q="-q"
  24. else
  25. echo >&2 ==== audiowmark add "$@" ====
  26. fi
  27. $AUDIOWMARK $AUDIOWMARK_Q --strict add "$@" || die "failed to watermark $@"
  28. }
  29. audiowmark_cmp()
  30. {
  31. if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
  32. AUDIOWMARK_OUT="/dev/null"
  33. else
  34. AUDIOWMARK_OUT="/dev/stdout"
  35. echo >&2 ==== audiowmark cmp "$@" ====
  36. fi
  37. $AUDIOWMARK --strict cmp "$@" > $AUDIOWMARK_OUT || die "failed to detect watermark $@"
  38. }
  39. check_length()
  40. {
  41. local in1="$($AUDIOWMARK test-info $1 frames)"
  42. local in2="$($AUDIOWMARK test-info $2 frames)"
  43. [ "x$in1" != "x" ] || die "length of '$1' could not be detected"
  44. [ "x$in1" == "x$in2" ] || die "length of '$1' ($in1) and '$2' ($in2) differs"
  45. }
  46. check_snr()
  47. {
  48. local snr="$($AUDIOWMARK test-snr $1 $2)"
  49. if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
  50. :
  51. else
  52. echo >&2 "==== snr of $1 and $2 is $snr (expected $3) ===="
  53. fi
  54. [ "x$snr" != "x" ] || die "snr of '$1' and '$2' could not be detected"
  55. [ "x$3" != "x" ] || die "need snr bound"
  56. awk "BEGIN {exit !($snr >= $3)}" || die "snr of '$1' and '$2' is worse than $3"
  57. }