annotate tests/test-summaries/test-summaries.sh @ 376:a2d3a0dfcefa

AppImage seems to insist on having an icon
author Chris Cannam
date Fri, 05 Jun 2020 12:58:13 +0100
parents a0d093495a1f
children
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@119 3 . ../include.sh
Chris@0 4
Chris@119 5 infile=$audiopath/3clicks8.wav
Chris@119 6 infile2=$audiopath/6clicks8.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@16 15 compare() {
Chris@16 16 a=$1
Chris@16 17 b=$2
Chris@16 18 sort $a > $tmpcmp1
Chris@16 19 sort $b > $tmpcmp2
Chris@28 20 csvcompare $tmpcmp1 $tmpcmp2
Chris@16 21 }
Chris@16 22
Chris@0 23 # transform to which we have to add summarisation on command line
Chris@119 24 transform=$mypath/transforms/detectionfunction-nosummaries.n3
Chris@119 25 expected=$mypath/expected/summaries
Chris@0 26
Chris@119 27 stransform=$mypath/transforms/detectionfunction.n3
Chris@119 28 sexpected=$mypath/expected/summaries-from-rdf
Chris@0 29
Chris@182 30 seglist=$mypath/transforms/segmentlist
Chris@182 31
Chris@0 32 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 33 fail "Fails to run transform $transform"
Chris@0 34
Chris@16 35 compare $tmpfile ${expected}.csv || \
Chris@28 36 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv
Chris@0 37
Chris@0 38 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
Chris@0 39 fail "Fails to run transform $transform with summary type mean"
Chris@0 40
Chris@16 41 compare $tmpfile ${expected}-with-mean.csv || \
Chris@28 42 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
Chris@0 43
Chris@0 44 $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 45 fail "Fails to run transform $transform with all summary types and summary-only"
Chris@0 46
Chris@16 47 compare $tmpfile ${expected}-all-summaries-only.csv || \
Chris@28 48 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
Chris@0 49
Chris@0 50 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 51 fail "Fails to run transform $stransform with CSV output"
Chris@0 52
Chris@16 53 compare $tmpfile ${sexpected}.csv || \
Chris@28 54 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
Chris@0 55
Chris@102 56 $r -t $stransform -w csv --csv-stdout --summary-only $infile > $tmpfile 2>/dev/null || \
Chris@102 57 fail "Fails to run transform $stransform with CSV output and summary-only"
Chris@102 58
Chris@102 59 compare $tmpfile ${expected}-from-rdf-summaries-only.csv || \
Chris@102 60 faildiff "Output mismatch for transform $stransform with summary-only" $tmpfile ${expected}-from-rdf-summaries-only.csv
Chris@102 61
Chris@105 62 $r -t $transform -w csv --csv-stdout --summary-only -S median --segments 0,9.9 $infile2 > $tmpfile 2>/dev/null || \
Chris@105 63 fail "Fails to run transform $stransform with CSV output and segments"
Chris@105 64
Chris@105 65 compare $tmpfile ${expected}-segments.csv || \
Chris@105 66 faildiff "Output mismatch for transform $stransform with segments" $tmpfile ${expected}-segments.csv
Chris@105 67
Chris@182 68 $r -t $transform -w csv --csv-stdout --summary-only -S median --segments-from $seglist $infile2 > $tmpfile 2>/dev/null || \
Chris@182 69 fail "Fails to run transform $stransform with CSV output and segments from segment list"
Chris@182 70
Chris@182 71 compare $tmpfile ${expected}-segments.csv || \
Chris@182 72 faildiff "Output mismatch for transform $stransform with segments from segment list" $tmpfile ${expected}-segments.csv
Chris@182 73
Chris@0 74 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
Chris@0 75 fail "Fails to run transform $stransform with RDF output"
Chris@0 76
Chris@3 77 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
Chris@0 78 fail "Fails to produce parseable RDF/TTL for transform $stransform"
Chris@0 79
Chris@59 80 rapper -i turtle ${sexpected}.n3 -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $expcanonical ||
Chris@209 81 fail "Internal error: Failed to canonicalise expected output file $sexpected.n3"
Chris@59 82
Chris@59 83 compare $tmpcanonical $expcanonical || \
Chris@209 84 faildiff "Output mismatch against expected $sexpected.n3 for canonicalised version of transform $stransform" $tmpcanonical $expcanonical
Chris@0 85
Chris@236 86 bash "$mypath/test-summaries-testplugin.sh"
Chris@0 87
Chris@236 88