File: test-common.sh.in

package info (click to toggle)
audiowmark 0.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,168 kB
  • sloc: cpp: 10,571; sh: 1,867; makefile: 107; python: 34
file content (70 lines) | stat: -rw-r--r-- 1,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# program locations

AUDIOWMARK=@top_builddir@/src/audiowmark
TEST_MSG=f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0
TOP_BUILDDIR=@top_builddir@

## abort on error

set -eo pipefail

# common shell functions

die()
{
  echo >&2 "$0: $@"
  exit 1
}

audiowmark()
{
  if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
    AUDIOWMARK_Q="-q"
  else
    echo >&2 ==== audiowmark "$@" ====
  fi
  $AUDIOWMARK $AUDIOWMARK_Q --strict "$@" || die "failed to run audiowmark $@"
}

audiowmark_add()
{
  if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
    AUDIOWMARK_Q="-q"
  else
    echo >&2 ==== audiowmark add "$@" ====
  fi
  $AUDIOWMARK $AUDIOWMARK_Q --strict add "$@" || die "failed to watermark $@"
}

audiowmark_cmp()
{
  if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
    AUDIOWMARK_OUT="/dev/null"
  else
    AUDIOWMARK_OUT="/dev/stdout"
    echo >&2 ==== audiowmark cmp "$@" ====
  fi
  $AUDIOWMARK --strict cmp "$@" > $AUDIOWMARK_OUT || die "failed to detect watermark $@"
}

check_length()
{
  local in1="$($AUDIOWMARK test-info $1 frames)"
  local in2="$($AUDIOWMARK test-info $2 frames)"

  [ "x$in1" != "x" ] || die "length of '$1' could not be detected"
  [ "x$in1" == "x$in2" ] || die "length of '$1' ($in1) and '$2' ($in2) differs"
}

check_snr()
{
  local snr="$($AUDIOWMARK test-snr $1 $2)"
  if [ "x$Q" == "x1" ] && [ -z "$V" ]; then
    :
  else
    echo >&2 "==== snr of $1 and $2 is $snr (expected $3) ===="
  fi
  [ "x$snr" != "x" ] || die "snr of '$1' and '$2' could not be detected"
  [ "x$3" != "x" ] || die "need snr bound"
  awk "BEGIN {exit !($snr >= $3)}" || die "snr of '$1' and '$2' is worse than $3"
}