Chris@438
|
1 #!/bin/bash
|
Chris@438
|
2
|
Chris@438
|
3 set -eu
|
Chris@438
|
4
|
Chris@438
|
5 MYDIR=$(dirname "$0")
|
Chris@438
|
6
|
Chris@438
|
7 TEST_PLUGIN_DIR="$MYDIR/../../vamp-test-plugin"
|
Chris@438
|
8 HOST_DIR="$MYDIR/../host"
|
Chris@438
|
9 HOST="$HOST_DIR/vamp-simple-host"
|
Chris@439
|
10 #TEST_FILE="$MYDIR/20sec-silence.wav"
|
Chris@439
|
11 TEST_FILE="/tmp/test.wav"
|
Chris@438
|
12
|
Chris@438
|
13 mkdir -p "$MYDIR/obtained"
|
Chris@438
|
14 mkdir -p "$MYDIR/failures"
|
Chris@438
|
15
|
Chris@438
|
16 echo "Rebuilding SDK and simple host..." 1>&2
|
Chris@438
|
17 ( cd "$MYDIR/.." && ./configure && make clean && make )
|
Chris@438
|
18
|
Chris@438
|
19 if [ ! -d "$TEST_PLUGIN_DIR" ]; then
|
Chris@438
|
20 echo "Can't find test plugin dir at $TEST_PLUGIN_DIR" 1>&2
|
Chris@438
|
21 exit 1
|
Chris@438
|
22 fi
|
Chris@438
|
23
|
Chris@438
|
24 if [ ! -x "$HOST" ]; then
|
Chris@438
|
25 echo "Can't find host at $HOST" 1>&2
|
Chris@438
|
26 exit 1
|
Chris@438
|
27 fi
|
Chris@438
|
28
|
Chris@438
|
29 echo "Rebuilding test plugin..." 1>&2
|
Chris@438
|
30 ( cd "$TEST_PLUGIN_DIR" && make -f Makefile.linux clean && make -f Makefile.linux )
|
Chris@438
|
31
|
Chris@438
|
32 export VAMP_PATH="$TEST_PLUGIN_DIR"
|
Chris@438
|
33
|
Chris@438
|
34 # check that the two expected test plugin ids are present:
|
Chris@438
|
35
|
Chris@438
|
36 ids=$("$HOST" --list-ids)
|
Chris@438
|
37
|
Chris@438
|
38 expected="vamp:vamp-test-plugin:vamp-test-plugin
|
Chris@438
|
39 vamp:vamp-test-plugin:vamp-test-plugin-freq"
|
Chris@438
|
40
|
Chris@438
|
41 if [ "$ids" != "$expected" ]; then
|
Chris@438
|
42 echo "Unexpected id list: $ids" 1>&2
|
Chris@438
|
43 echo "Expected: $expected" 1>&2
|
Chris@438
|
44 exit 1
|
Chris@438
|
45 fi
|
Chris@438
|
46
|
Chris@438
|
47 some_failed=nope
|
Chris@438
|
48 echo
|
Chris@438
|
49
|
Chris@438
|
50 for test in $("$HOST" --list-outputs | sed 's/^vamp://') ; do
|
Chris@438
|
51
|
Chris@438
|
52 filename="$(echo "$test.txt" | sed 's/^[^:]*://' | sed 's/:/_/g')"
|
Chris@438
|
53 expected="$MYDIR/expected/$filename"
|
Chris@438
|
54 obtained="$MYDIR/obtained/$filename"
|
Chris@438
|
55 failure="$MYDIR/failures/$filename"
|
Chris@438
|
56
|
Chris@438
|
57 rm -f "$failure"
|
Chris@438
|
58 echo "=== $test" > "$obtained"
|
Chris@438
|
59 "$HOST" "$test" "$TEST_FILE" >> "$obtained" 2>/dev/null
|
Chris@438
|
60
|
Chris@438
|
61 if cmp -s "$expected" "$obtained" ; then
|
Chris@438
|
62 echo "$test: ok"
|
Chris@438
|
63 else
|
Chris@438
|
64 sdiff "$expected" "$obtained" > "$failure" || true # avoid exit-on-failure
|
Chris@438
|
65 echo "*** $test: FAILED, see $failure for diff"
|
Chris@438
|
66 some_failed=yup
|
Chris@438
|
67 fi
|
Chris@438
|
68
|
Chris@438
|
69 done
|
Chris@438
|
70
|
Chris@438
|
71 if [ "$some_failed" != "nope" ]; then
|
Chris@438
|
72 echo; echo "*** Some tests failed!"; echo
|
Chris@438
|
73 fi
|
Chris@438
|
74
|