Chris@0: #!/bin/bash Chris@0: Chris@0: mypath=`dirname $0` Chris@0: r=$mypath/../sonic-annotator Chris@0: Chris@0: infile=$mypath/audio/3clicks8.wav Chris@0: tmpfile=$mypath/tmp_1_$$ Chris@0: tmpcanonical=$mypath/tmp_2_$$ Chris@0: Chris@0: trap "rm -f $tmpfile $tmpcanonical" 0 Chris@0: Chris@0: fail() { Chris@0: echo "Test failed: $1" Chris@0: if [ -n "$2" -a -n "$3" ]; then Chris@0: echo "Output follows:" Chris@0: echo "--" Chris@0: cat $2 Chris@0: echo "--" Chris@0: echo "Expected output follows:" Chris@0: echo "--" Chris@0: cat $3 Chris@0: echo "--" Chris@0: echo "Diff:" Chris@0: echo "--" Chris@0: diff -u $2 $3 Chris@0: echo "--" Chris@0: fi Chris@0: exit 1 Chris@0: } Chris@0: Chris@0: # transform to which we have to add summarisation on command line Chris@0: transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3 Chris@0: expected=$mypath/expected/transforms-summaries-percussiononsets Chris@0: Chris@0: stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3 Chris@0: sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf Chris@0: Chris@0: $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ Chris@0: fail "Fails to run transform $transform" Chris@0: Chris@0: cmp -s $tmpfile ${expected}.csv || \ Chris@0: fail "Output mismatch for transform $transform" $tmpfile ${expected}.csv Chris@0: Chris@0: $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \ Chris@0: fail "Fails to run transform $transform with summary type mean" Chris@0: Chris@0: cmp -s $tmpfile ${expected}-with-mean.csv || \ Chris@0: fail "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv Chris@0: Chris@0: $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: fail "Fails to run transform $transform with all summary types and summary-only" Chris@0: Chris@0: cmp -s $tmpfile ${expected}-all-summaries-only.csv || \ Chris@0: fail "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv Chris@0: Chris@0: $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ Chris@0: fail "Fails to run transform $stransform with CSV output" Chris@0: Chris@0: cmp -s $tmpfile ${sexpected}.csv || \ Chris@0: fail "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv Chris@0: Chris@0: $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \ Chris@0: fail "Fails to run transform $stransform with RDF output" Chris@0: Chris@0: rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' > $tmpcanonical || Chris@0: fail "Fails to produce parseable RDF/TTL for transform $stransform" Chris@0: Chris@0: cmp -s $tmpcanonical ${sexpected}.n3 || \ Chris@0: fail "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3 Chris@0: Chris@0: exit 0 Chris@0: