comparison tests/test-summaries.sh @ 0:581b1b150a4d

* copy to sonic-annotator
author Chris Cannam
date Thu, 11 Dec 2008 10:22:33 +0000
parents
children 03a02c1f0a9f
comparison
equal deleted inserted replaced
-1:000000000000 0:581b1b150a4d
1 #!/bin/bash
2
3 mypath=`dirname $0`
4 r=$mypath/../sonic-annotator
5
6 infile=$mypath/audio/3clicks8.wav
7 tmpfile=$mypath/tmp_1_$$
8 tmpcanonical=$mypath/tmp_2_$$
9
10 trap "rm -f $tmpfile $tmpcanonical" 0
11
12 fail() {
13 echo "Test failed: $1"
14 if [ -n "$2" -a -n "$3" ]; then
15 echo "Output follows:"
16 echo "--"
17 cat $2
18 echo "--"
19 echo "Expected output follows:"
20 echo "--"
21 cat $3
22 echo "--"
23 echo "Diff:"
24 echo "--"
25 diff -u $2 $3
26 echo "--"
27 fi
28 exit 1
29 }
30
31 # transform to which we have to add summarisation on command line
32 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3
33 expected=$mypath/expected/transforms-summaries-percussiononsets
34
35 stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3
36 sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf
37
38 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
39 fail "Fails to run transform $transform"
40
41 cmp -s $tmpfile ${expected}.csv || \
42 fail "Output mismatch for transform $transform" $tmpfile ${expected}.csv
43
44 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
45 fail "Fails to run transform $transform with summary type mean"
46
47 cmp -s $tmpfile ${expected}-with-mean.csv || \
48 fail "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
49
50 $r -t $transform -w csv --csv-stdout -S min -S max -S mean -S median -S mode -S sum -S variance -S sd -S count --summary-only $infile > $tmpfile 2>/dev/null || \
51 fail "Fails to run transform $transform with all summary types and summary-only"
52
53 cmp -s $tmpfile ${expected}-all-summaries-only.csv || \
54 fail "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
55
56 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
57 fail "Fails to run transform $stransform with CSV output"
58
59 cmp -s $tmpfile ${sexpected}.csv || \
60 fail "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
61
62 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
63 fail "Fails to run transform $stransform with RDF output"
64
65 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' > $tmpcanonical ||
66 fail "Fails to produce parseable RDF/TTL for transform $stransform"
67
68 cmp -s $tmpcanonical ${sexpected}.n3 || \
69 fail "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3
70
71 exit 0
72