annotate tests/test-rdf-destinations.sh @ 47:91d20795a109

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