Mercurial > hg > sonic-annotator
annotate tests/include.sh @ 126:e6379b2e1c5c
Normalisation test
author | Chris Cannam |
---|---|
date | Thu, 09 Oct 2014 12:27:17 +0100 |
parents | 7a31201dc42d |
children | f0df07da6f46 |
rev | line source |
---|---|
Chris@118 | 1 |
Chris@118 | 2 mypath=`dirname $0` |
Chris@119 | 3 |
Chris@119 | 4 testdir=$mypath/.. |
Chris@119 | 5 r=$testdir/../sonic-annotator |
Chris@119 | 6 |
Chris@119 | 7 audiopath=$testdir/audio |
Chris@118 | 8 |
Chris@118 | 9 percplug=vamp:vamp-example-plugins:percussiononsets |
Chris@126 | 10 amplplug=vamp:vamp-example-plugins:amplitudefollower |
Chris@118 | 11 testplug=vamp:vamp-test-plugin:vamp-test-plugin |
Chris@30 | 12 |
Chris@30 | 13 fail() { |
Chris@30 | 14 echo "Test failed: $1" |
Chris@30 | 15 exit 1 |
Chris@30 | 16 } |
Chris@30 | 17 |
Chris@30 | 18 csvcompare() { |
Chris@30 | 19 # permit some fuzz in final few digits |
Chris@30 | 20 a="$1" |
Chris@30 | 21 b="$2" |
Chris@30 | 22 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$a" > "${a}__" |
Chris@30 | 23 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$b" > "${b}__" |
Chris@30 | 24 cmp -s "${a}__" "${b}__" |
Chris@30 | 25 rv=$? |
Chris@30 | 26 rm "${a}__" "${b}__" |
Chris@30 | 27 return $rv |
Chris@30 | 28 } |
Chris@30 | 29 |
Chris@75 | 30 csvcompare_ignorefirst() { |
Chris@75 | 31 # a bit like the above, but ignoring first column (and without temp files) |
Chris@75 | 32 out=`cat "$1" "$2" | cut -d, -f2- | perl -p -e 's/(\d+\.\d{6})\d+/$1/' | sort | uniq -c | grep -v ' 2 '` |
Chris@75 | 33 return `[ -z "$out" ]` |
Chris@75 | 34 } |
Chris@75 | 35 |
Chris@108 | 36 faildiff() { |
Chris@108 | 37 echo "Test failed: $1" |
Chris@108 | 38 if [ -n "$2" -a -n "$3" ]; then |
Chris@108 | 39 echo "Output follows:" |
Chris@108 | 40 echo "--" |
Chris@108 | 41 cat $2 |
Chris@108 | 42 echo "--" |
Chris@108 | 43 echo "Expected output follows:" |
Chris@108 | 44 echo "--" |
Chris@108 | 45 cat $3 |
Chris@108 | 46 echo "--" |
Chris@108 | 47 echo "Diff:" |
Chris@108 | 48 echo "--" |
Chris@108 | 49 sdiff -w78 $2 $3 |
Chris@108 | 50 echo "--" |
Chris@108 | 51 fi |
Chris@108 | 52 exit 1 |
Chris@108 | 53 } |
Chris@75 | 54 |
Chris@108 | 55 |