annotate tests/test-summaries.sh @ 51:c30b9720bde0

Add proper support and tests for window type parameter (requires latest update to Vamp host SDK)
author Chris Cannam
date Tue, 21 Jun 2011 15:41:52 +0100
parents 94d988cef54e
children 52b9d58edb78
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@0 3 mypath=`dirname $0`
Chris@42 4 r=$mypath/../sonic-annotator
Chris@0 5
Chris@0 6 infile=$mypath/audio/3clicks8.wav
Chris@0 7 tmpfile=$mypath/tmp_1_$$
Chris@0 8 tmpcanonical=$mypath/tmp_2_$$
Chris@16 9 tmpcmp1=$mypath/tmp_3_$$
Chris@16 10 tmpcmp2=$mypath/tmp_4_$$
Chris@0 11
Chris@16 12 trap "rm -f $tmpfile $tmpcanonical $tmpcmp1 $tmpcmp2" 0
Chris@0 13
Chris@28 14 . test-include.sh
Chris@28 15
Chris@28 16 faildiff() {
Chris@0 17 echo "Test failed: $1"
Chris@0 18 if [ -n "$2" -a -n "$3" ]; then
Chris@0 19 echo "Output follows:"
Chris@0 20 echo "--"
Chris@0 21 cat $2
Chris@0 22 echo "--"
Chris@0 23 echo "Expected output follows:"
Chris@0 24 echo "--"
Chris@0 25 cat $3
Chris@0 26 echo "--"
Chris@0 27 echo "Diff:"
Chris@0 28 echo "--"
Chris@28 29 sdiff -w78 $2 $3
Chris@0 30 echo "--"
Chris@0 31 fi
Chris@0 32 exit 1
Chris@0 33 }
Chris@0 34
Chris@16 35 compare() {
Chris@16 36 a=$1
Chris@16 37 b=$2
Chris@16 38 sort $a > $tmpcmp1
Chris@16 39 sort $b > $tmpcmp2
Chris@28 40 csvcompare $tmpcmp1 $tmpcmp2
Chris@16 41 }
Chris@16 42
Chris@0 43 # transform to which we have to add summarisation on command line
Chris@0 44 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3
Chris@0 45 expected=$mypath/expected/transforms-summaries-percussiononsets
Chris@0 46
Chris@0 47 stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3
Chris@0 48 sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf
Chris@0 49
Chris@0 50 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 51 fail "Fails to run transform $transform"
Chris@0 52
Chris@16 53 compare $tmpfile ${expected}.csv || \
Chris@28 54 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv
Chris@0 55
Chris@0 56 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
Chris@0 57 fail "Fails to run transform $transform with summary type mean"
Chris@0 58
Chris@16 59 compare $tmpfile ${expected}-with-mean.csv || \
Chris@28 60 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
Chris@0 61
Chris@0 62 $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 || \
Chris@0 63 fail "Fails to run transform $transform with all summary types and summary-only"
Chris@0 64
Chris@16 65 compare $tmpfile ${expected}-all-summaries-only.csv || \
Chris@28 66 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
Chris@0 67
Chris@0 68 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 69 fail "Fails to run transform $stransform with CSV output"
Chris@0 70
Chris@16 71 compare $tmpfile ${sexpected}.csv || \
Chris@28 72 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
Chris@0 73
Chris@0 74 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 75 fail "Fails to run transform $stransform with RDF output"
Chris@0 76
Chris@3 77 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
Chris@0 78 fail "Fails to produce parseable RDF/TTL for transform $stransform"
Chris@0 79
Chris@16 80 compare $tmpcanonical ${sexpected}.n3 || \
Chris@28 81 faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3
Chris@0 82
Chris@0 83 exit 0
Chris@0 84