comparison tests/test-summaries.sh @ 16:0f7c8b9410ef sonic-annotator-0.2

* update tests
author Chris Cannam
date Fri, 20 Mar 2009 17:31:40 +0000
parents 03a02c1f0a9f
children 102bb1729184
comparison
equal deleted inserted replaced
15:b742272097ca 16:0f7c8b9410ef
4 r=$mypath/../runner/sonic-annotator 4 r=$mypath/../runner/sonic-annotator
5 5
6 infile=$mypath/audio/3clicks8.wav 6 infile=$mypath/audio/3clicks8.wav
7 tmpfile=$mypath/tmp_1_$$ 7 tmpfile=$mypath/tmp_1_$$
8 tmpcanonical=$mypath/tmp_2_$$ 8 tmpcanonical=$mypath/tmp_2_$$
9 tmpcmp1=$mypath/tmp_3_$$
10 tmpcmp2=$mypath/tmp_4_$$
9 11
10 trap "rm -f $tmpfile $tmpcanonical" 0 12 trap "rm -f $tmpfile $tmpcanonical $tmpcmp1 $tmpcmp2" 0
11 13
12 fail() { 14 fail() {
13 echo "Test failed: $1" 15 echo "Test failed: $1"
14 if [ -n "$2" -a -n "$3" ]; then 16 if [ -n "$2" -a -n "$3" ]; then
15 echo "Output follows:" 17 echo "Output follows:"
26 echo "--" 28 echo "--"
27 fi 29 fi
28 exit 1 30 exit 1
29 } 31 }
30 32
33 compare() {
34 a=$1
35 b=$2
36 sort $a > $tmpcmp1
37 sort $b > $tmpcmp2
38 cmp -s $tmpcmp1 $tmpcmp2
39 }
40
31 # transform to which we have to add summarisation on command line 41 # transform to which we have to add summarisation on command line
32 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3 42 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3
33 expected=$mypath/expected/transforms-summaries-percussiononsets 43 expected=$mypath/expected/transforms-summaries-percussiononsets
34 44
35 stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3 45 stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3
36 sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf 46 sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf
37 47
38 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ 48 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
39 fail "Fails to run transform $transform" 49 fail "Fails to run transform $transform"
40 50
41 cmp -s $tmpfile ${expected}.csv || \ 51 compare $tmpfile ${expected}.csv || \
42 fail "Output mismatch for transform $transform" $tmpfile ${expected}.csv 52 fail "Output mismatch for transform $transform" $tmpfile ${expected}.csv
43 53
44 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \ 54 $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" 55 fail "Fails to run transform $transform with summary type mean"
46 56
47 cmp -s $tmpfile ${expected}-with-mean.csv || \ 57 compare $tmpfile ${expected}-with-mean.csv || \
48 fail "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv 58 fail "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
49 59
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 || \ 60 $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" 61 fail "Fails to run transform $transform with all summary types and summary-only"
52 62
53 cmp -s $tmpfile ${expected}-all-summaries-only.csv || \ 63 compare $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 64 fail "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
55 65
56 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ 66 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
57 fail "Fails to run transform $stransform with CSV output" 67 fail "Fails to run transform $stransform with CSV output"
58 68
59 cmp -s $tmpfile ${sexpected}.csv || \ 69 compare $tmpfile ${sexpected}.csv || \
60 fail "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv 70 fail "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
61 71
62 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \ 72 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
63 fail "Fails to run transform $stransform with RDF output" 73 fail "Fails to run transform $stransform with RDF output"
64 74
65 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical || 75 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
66 fail "Fails to produce parseable RDF/TTL for transform $stransform" 76 fail "Fails to produce parseable RDF/TTL for transform $stransform"
67 77
68 cmp -s $tmpcanonical ${sexpected}.n3 || \ 78 compare $tmpcanonical ${sexpected}.n3 || \
69 fail "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3 79 fail "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3
70 80
71 exit 0 81 exit 0
72 82