annotate tests/test-summaries.sh @ 2:475f4623feba

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