Chris@0: #!/bin/bash Chris@0: Chris@0: mypath=`dirname $0` Chris@42: r=$mypath/../sonic-annotator Chris@0: Chris@0: infile=$mypath/audio/3clicks8.wav Chris@105: infile2=$mypath/audio/6clicks8.wav Chris@0: tmpfile=$mypath/tmp_1_$$ Chris@0: tmpcanonical=$mypath/tmp_2_$$ Chris@59: expcanonical=$mypath/tmp_exp_2_$$ Chris@16: tmpcmp1=$mypath/tmp_3_$$ Chris@16: tmpcmp2=$mypath/tmp_4_$$ Chris@0: Chris@59: trap "rm -f $tmpfile $tmpcanonical $expcanonical $tmpcmp1 $tmpcmp2" 0 Chris@0: Chris@28: . test-include.sh Chris@28: Chris@16: compare() { Chris@16: a=$1 Chris@16: b=$2 Chris@16: sort $a > $tmpcmp1 Chris@16: sort $b > $tmpcmp2 Chris@28: csvcompare $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@28: faildiff "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@28: faildiff "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@28: faildiff "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@28: faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv Chris@0: Chris@102: $r -t $stransform -w csv --csv-stdout --summary-only $infile > $tmpfile 2>/dev/null || \ Chris@102: fail "Fails to run transform $stransform with CSV output and summary-only" Chris@102: Chris@102: compare $tmpfile ${expected}-from-rdf-summaries-only.csv || \ Chris@102: faildiff "Output mismatch for transform $stransform with summary-only" $tmpfile ${expected}-from-rdf-summaries-only.csv Chris@102: Chris@105: $r -t $transform -w csv --csv-stdout --summary-only -S median --segments 0,9.9 $infile2 > $tmpfile 2>/dev/null || \ Chris@105: fail "Fails to run transform $stransform with CSV output and segments" Chris@105: Chris@105: compare $tmpfile ${expected}-segments.csv || \ Chris@105: faildiff "Output mismatch for transform $stransform with segments" $tmpfile ${expected}-segments.csv Chris@105: 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@59: rapper -i turtle ${sexpected}.n3 -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $expcanonical || Chris@59: fail "Internal error: Failed to canonicalise expected output file $expected.n3" Chris@59: Chris@59: compare $tmpcanonical $expcanonical || \ Chris@59: faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical $expcanonical Chris@0: Chris@0: exit 0 Chris@0: