Mercurial > hg > sonic-annotator
comparison tests/test-summaries/test-summaries.sh @ 119:7a31201dc42d test-reorg
Split out tests into individual directories, with simpler naming therein
author | Chris Cannam |
---|---|
date | Wed, 08 Oct 2014 15:08:57 +0100 |
parents | tests/test-summaries.sh@0fe5abb56a6e |
children | 11a9ce2fa331 |
comparison
equal
deleted
inserted
replaced
118:0fe5abb56a6e | 119:7a31201dc42d |
---|---|
1 #!/bin/bash | |
2 | |
3 . ../include.sh | |
4 | |
5 infile=$audiopath/3clicks8.wav | |
6 infile2=$audiopath/6clicks8.wav | |
7 tmpfile=$mypath/tmp_1_$$ | |
8 tmpcanonical=$mypath/tmp_2_$$ | |
9 expcanonical=$mypath/tmp_exp_2_$$ | |
10 tmpcmp1=$mypath/tmp_3_$$ | |
11 tmpcmp2=$mypath/tmp_4_$$ | |
12 | |
13 trap "rm -f $tmpfile $tmpcanonical $expcanonical $tmpcmp1 $tmpcmp2" 0 | |
14 | |
15 compare() { | |
16 a=$1 | |
17 b=$2 | |
18 sort $a > $tmpcmp1 | |
19 sort $b > $tmpcmp2 | |
20 csvcompare $tmpcmp1 $tmpcmp2 | |
21 } | |
22 | |
23 # transform to which we have to add summarisation on command line | |
24 transform=$mypath/transforms/detectionfunction-nosummaries.n3 | |
25 expected=$mypath/expected/summaries | |
26 | |
27 stransform=$mypath/transforms/detectionfunction.n3 | |
28 sexpected=$mypath/expected/summaries-from-rdf | |
29 | |
30 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ | |
31 fail "Fails to run transform $transform" | |
32 | |
33 compare $tmpfile ${expected}.csv || \ | |
34 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv | |
35 | |
36 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \ | |
37 fail "Fails to run transform $transform with summary type mean" | |
38 | |
39 compare $tmpfile ${expected}-with-mean.csv || \ | |
40 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv | |
41 | |
42 $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 || \ | |
43 fail "Fails to run transform $transform with all summary types and summary-only" | |
44 | |
45 compare $tmpfile ${expected}-all-summaries-only.csv || \ | |
46 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv | |
47 | |
48 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ | |
49 fail "Fails to run transform $stransform with CSV output" | |
50 | |
51 compare $tmpfile ${sexpected}.csv || \ | |
52 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv | |
53 | |
54 $r -t $stransform -w csv --csv-stdout --summary-only $infile > $tmpfile 2>/dev/null || \ | |
55 fail "Fails to run transform $stransform with CSV output and summary-only" | |
56 | |
57 compare $tmpfile ${expected}-from-rdf-summaries-only.csv || \ | |
58 faildiff "Output mismatch for transform $stransform with summary-only" $tmpfile ${expected}-from-rdf-summaries-only.csv | |
59 | |
60 $r -t $transform -w csv --csv-stdout --summary-only -S median --segments 0,9.9 $infile2 > $tmpfile 2>/dev/null || \ | |
61 fail "Fails to run transform $stransform with CSV output and segments" | |
62 | |
63 compare $tmpfile ${expected}-segments.csv || \ | |
64 faildiff "Output mismatch for transform $stransform with segments" $tmpfile ${expected}-segments.csv | |
65 | |
66 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \ | |
67 fail "Fails to run transform $stransform with RDF output" | |
68 | |
69 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical || | |
70 fail "Fails to produce parseable RDF/TTL for transform $stransform" | |
71 | |
72 rapper -i turtle ${sexpected}.n3 -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $expcanonical || | |
73 fail "Internal error: Failed to canonicalise expected output file $expected.n3" | |
74 | |
75 compare $tmpcanonical $expcanonical || \ | |
76 faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical $expcanonical | |
77 | |
78 exit 0 | |
79 |