annotate tests/test-rdf-destinations.sh @ 33:44dc87d1059d

* No audioio any more
author Chris Cannam
date Fri, 21 May 2010 10:21:33 +0000
parents 03a02c1f0a9f
children 94d988cef54e
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@0 3 mypath=`dirname $0`
Chris@3 4 r=$mypath/../runner/sonic-annotator
Chris@0 5
Chris@0 6 infile1=$mypath/audio/3clicks8.wav
Chris@0 7 infile2=$mypath/audio/6clicks8.wav
Chris@0 8
Chris@0 9 outfile1=$mypath/audio/3clicks8.n3
Chris@0 10 outfile2=$mypath/audio/6clicks8.n3
Chris@0 11
Chris@0 12 outfile3=$mypath/audio/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3
Chris@0 13 outfile4=$mypath/audio/3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3
Chris@0 14 outfile5=$mypath/audio/6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3
Chris@0 15 outfile6=$mypath/audio/6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3
Chris@0 16
Chris@0 17 testplug=vamp:vamp-example-plugins:percussiononsets
Chris@0 18 tmpttl=$mypath/tmp_1_$$.ttl
Chris@0 19
Chris@0 20 trap "rm -f $tmpttl $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6" 0
Chris@0 21
Chris@0 22 fail() {
Chris@0 23 echo "Test failed: $1"
Chris@0 24 exit 1
Chris@0 25 }
Chris@0 26
Chris@0 27 transformpfx=$mypath/transforms/transforms-rdf-writer-percussiononsets
Chris@0 28
Chris@0 29 check_rdf() {
Chris@0 30 test -f $1 || \
Chris@0 31 fail "Fails to write output to expected location $1 for $2"
Chris@0 32 rapper -i turtle $1 >/dev/null 2>&1 || \
Chris@0 33 fail "Fails to produce parseable RDF/TTL for $2"
Chris@0 34 rapper -i turtle -c $1 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' || \
Chris@0 35 fail "RDF output contains no triples (?) for $2"
Chris@0 36 rm -f $1
Chris@0 37 }
Chris@0 38
Chris@0 39
Chris@0 40 ctx="onsets transform, one audio file, default RDF writer destination"
Chris@0 41
Chris@0 42 rm -f $outfile1
Chris@0 43
Chris@0 44 $r -t $transformpfx-onsets.n3 -w rdf $infile1 2>/dev/null || \
Chris@0 45 fail "Fails to run with $ctx"
Chris@0 46
Chris@0 47 check_rdf $outfile1 "$ctx"
Chris@0 48
Chris@0 49
Chris@0 50 ctx="onsets and df transforms, one audio file, default RDF writer destination"
Chris@0 51
Chris@0 52 rm -f $outfile1
Chris@0 53
Chris@0 54 $r -t $transformpfx-onsets.n3 -t $transformpfx-detectionfunction.n3 -w rdf $infile1 2>/dev/null || \
Chris@0 55 fail "Fails to run with $ctx"
Chris@0 56
Chris@0 57 check_rdf $outfile1 "$ctx"
Chris@0 58
Chris@0 59
Chris@0 60 ctx="onsets transform, two audio files, default RDF writer destination"
Chris@0 61
Chris@0 62 rm -f $outfile1
Chris@0 63 rm -f $outfile2
Chris@0 64
Chris@0 65 $r -t $transformpfx-onsets.n3 -w rdf $infile1 $infile2 2>/dev/null || \
Chris@0 66 fail "Fails to run with $ctx"
Chris@0 67
Chris@0 68 check_rdf $outfile1 "$ctx"
Chris@0 69 check_rdf $outfile2 "$ctx"
Chris@0 70
Chris@0 71
Chris@0 72 ctx="onsets transform, two audio files, one-file RDF writer"
Chris@0 73
Chris@0 74 $r -t $transformpfx-onsets.n3 -w rdf --rdf-one-file $tmpttl $infile1 $infile2 2>/dev/null || \
Chris@0 75 fail "Fails to run with $ctx"
Chris@0 76
Chris@0 77 check_rdf $tmpttl "$ctx"
Chris@0 78
Chris@0 79
Chris@0 80 ctx="onsets transform, two audio files, stdout RDF writer"
Chris@0 81
Chris@0 82 $r -t $transformpfx-onsets.n3 -w rdf --rdf-stdout $infile1 $infile2 2>/dev/null >$tmpttl || \
Chris@0 83 fail "Fails to run with $ctx"
Chris@0 84
Chris@0 85 check_rdf $tmpttl "$ctx"
Chris@0 86
Chris@0 87
Chris@0 88 ctx="onsets transform, one audio file, many-files RDF writer"
Chris@0 89
Chris@0 90 rm -f $outfile3
Chris@0 91
Chris@0 92 $r -t $transformpfx-onsets.n3 -w rdf --rdf-many-files $infile1 2>/dev/null || \
Chris@0 93 fail "Fails to run with $ctx"
Chris@0 94
Chris@0 95 check_rdf $outfile3 "$ctx"
Chris@0 96
Chris@0 97
Chris@0 98 ctx="onsets transform, two audio files, many-files RDF writer"
Chris@0 99
Chris@0 100 rm -f $outfile3
Chris@0 101 rm -f $outfile5
Chris@0 102
Chris@0 103 $r -t $transformpfx-onsets.n3 -w rdf --rdf-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 104 fail "Fails to run with $ctx"
Chris@0 105
Chris@0 106 check_rdf $outfile3 "$ctx"
Chris@0 107 check_rdf $outfile5 "$ctx"
Chris@0 108
Chris@0 109
Chris@0 110 ctx="onsets and df transforms, two audio files, many-files RDF writer"
Chris@0 111
Chris@0 112 rm -f $outfile3
Chris@0 113 rm -f $outfile4
Chris@0 114 rm -f $outfile5
Chris@0 115 rm -f $outfile6
Chris@0 116
Chris@0 117 $r -t $transformpfx-onsets.n3 -t $transformpfx-detectionfunction.n3 -w rdf --rdf-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 118 fail "Fails to run with $ctx"
Chris@0 119
Chris@0 120 check_rdf $outfile3 "$ctx"
Chris@0 121 check_rdf $outfile4 "$ctx"
Chris@0 122 check_rdf $outfile5 "$ctx"
Chris@0 123 check_rdf $outfile6 "$ctx"
Chris@0 124
Chris@0 125
Chris@0 126 ctx="existing output file and no --rdf-force"
Chris@0 127
Chris@0 128 touch $outfile1
Chris@0 129
Chris@0 130 $r -t $transformpfx-onsets.n3 -w rdf $infile1 2>/dev/null && \
Chris@0 131 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
Chris@0 132
Chris@0 133
Chris@0 134 ctx="existing output file and --rdf-force"
Chris@0 135
Chris@0 136 touch $outfile1
Chris@0 137
Chris@0 138 $r -t $transformpfx-onsets.n3 -w rdf --rdf-force $infile1 2>/dev/null || \
Chris@0 139 fail "Fails to run with $ctx"
Chris@0 140
Chris@0 141 check_rdf $outfile1 "$ctx"
Chris@0 142
Chris@0 143
Chris@0 144 exit 0