Chris@0: #!/bin/bash Chris@0: Chris@0: mypath=`dirname $0` Chris@3: r=$mypath/../runner/sonic-annotator Chris@0: Chris@0: infile=$mypath/audio/3clicks8.wav Chris@0: tmpfile=$mypath/tmp_1_$$ Chris@0: tmpcanonical=$mypath/tmp_2_$$ Chris@16: tmpcmp1=$mypath/tmp_3_$$ Chris@16: tmpcmp2=$mypath/tmp_4_$$ Chris@0: Chris@16: trap "rm -f $tmpfile $tmpcanonical $tmpcmp1 $tmpcmp2" 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@16: compare() { Chris@16: a=$1 Chris@16: b=$2 Chris@16: sort $a > $tmpcmp1 Chris@16: sort $b > $tmpcmp2 Chris@16: cmp -s $tmpcmp1 $tmpcmp2 Chris@16: } Chris@16: 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@16: compare $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@16: compare $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@16: compare $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@16: compare $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@3: rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical || Chris@0: fail "Fails to produce parseable RDF/TTL for transform $stransform" Chris@0: Chris@16: compare $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: