annotate tests/test-summaries.sh @ 83:e3b4bac5b114

Add sv-dependency-builds subdir for dependencies (may or may not exist)
author Chris Cannam
date Thu, 09 May 2013 10:34:52 +0100
parents 52b9d58edb78
children fae326c22df5
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@59 9 expcanonical=$mypath/tmp_exp_2_$$
Chris@16 10 tmpcmp1=$mypath/tmp_3_$$
Chris@16 11 tmpcmp2=$mypath/tmp_4_$$
Chris@0 12
Chris@59 13 trap "rm -f $tmpfile $tmpcanonical $expcanonical $tmpcmp1 $tmpcmp2" 0
Chris@0 14
Chris@28 15 . test-include.sh
Chris@28 16
Chris@28 17 faildiff() {
Chris@0 18 echo "Test failed: $1"
Chris@0 19 if [ -n "$2" -a -n "$3" ]; then
Chris@0 20 echo "Output follows:"
Chris@0 21 echo "--"
Chris@0 22 cat $2
Chris@0 23 echo "--"
Chris@0 24 echo "Expected output follows:"
Chris@0 25 echo "--"
Chris@0 26 cat $3
Chris@0 27 echo "--"
Chris@0 28 echo "Diff:"
Chris@0 29 echo "--"
Chris@28 30 sdiff -w78 $2 $3
Chris@0 31 echo "--"
Chris@0 32 fi
Chris@0 33 exit 1
Chris@0 34 }
Chris@0 35
Chris@16 36 compare() {
Chris@16 37 a=$1
Chris@16 38 b=$2
Chris@16 39 sort $a > $tmpcmp1
Chris@16 40 sort $b > $tmpcmp2
Chris@28 41 csvcompare $tmpcmp1 $tmpcmp2
Chris@16 42 }
Chris@16 43
Chris@0 44 # transform to which we have to add summarisation on command line
Chris@0 45 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3
Chris@0 46 expected=$mypath/expected/transforms-summaries-percussiononsets
Chris@0 47
Chris@0 48 stransform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3
Chris@0 49 sexpected=$mypath/expected/transforms-summaries-percussiononsets-from-rdf
Chris@0 50
Chris@0 51 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 52 fail "Fails to run transform $transform"
Chris@0 53
Chris@16 54 compare $tmpfile ${expected}.csv || \
Chris@28 55 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv
Chris@0 56
Chris@0 57 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
Chris@0 58 fail "Fails to run transform $transform with summary type mean"
Chris@0 59
Chris@16 60 compare $tmpfile ${expected}-with-mean.csv || \
Chris@28 61 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
Chris@0 62
Chris@0 63 $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 64 fail "Fails to run transform $transform with all summary types and summary-only"
Chris@0 65
Chris@16 66 compare $tmpfile ${expected}-all-summaries-only.csv || \
Chris@28 67 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
Chris@0 68
Chris@0 69 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 70 fail "Fails to run transform $stransform with CSV output"
Chris@0 71
Chris@16 72 compare $tmpfile ${sexpected}.csv || \
Chris@28 73 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
Chris@0 74
Chris@0 75 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 76 fail "Fails to run transform $stransform with RDF output"
Chris@0 77
Chris@3 78 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
Chris@0 79 fail "Fails to produce parseable RDF/TTL for transform $stransform"
Chris@0 80
Chris@59 81 rapper -i turtle ${sexpected}.n3 -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $expcanonical ||
Chris@59 82 fail "Internal error: Failed to canonicalise expected output file $expected.n3"
Chris@59 83
Chris@59 84 compare $tmpcanonical $expcanonical || \
Chris@59 85 faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical $expcanonical
Chris@0 86
Chris@0 87 exit 0
Chris@0 88