annotate tests/test-json-destinations/test-json-destinations.sh @ 151:a1300db6c63e jams

JSON well-formedness test (currently failing)
author Chris Cannam
date Tue, 14 Oct 2014 11:27:43 +0100
parents d86ef0a88fa4
children db83ea0e102d
rev   line source
Chris@0 1 #!/bin/bash
Chris@0 2
Chris@119 3 . ../include.sh
Chris@0 4
Chris@119 5 infile1=$audiopath/3clicks8.wav
Chris@119 6 infile2=$audiopath/6clicks8.wav
Chris@0 7
Chris@147 8 infile1dot=$audiopath/3.clicks.8.wav
Chris@0 9
Chris@150 10 outfile1=3clicks8.json
Chris@150 11 outfile2=6clicks8.json
Chris@44 12
Chris@150 13 outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.json
Chris@150 14 outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.json
Chris@150 15 outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.json
Chris@150 16 outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.json
Chris@147 17
Chris@150 18 outfile1dot=3.clicks.8.json
Chris@0 19
Chris@150 20 tmpjson=$mypath/tmp_1_$$.json
Chris@0 21
Chris@150 22 trap "rm -f $tmpjson $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0
Chris@0 23
Chris@119 24 transformdir=$mypath/transforms
Chris@0 25
Chris@150 26 check_json() {
Chris@0 27 test -f $1 || \
Chris@0 28 fail "Fails to write output to expected location $1 for $2"
Chris@151 29 cat $1 | json_verify || \
Chris@151 30 fail "Writes invalid JSON to location $1 for $2"
Chris@0 31 rm -f $1
Chris@0 32 }
Chris@0 33
Chris@0 34
Chris@150 35 ctx="onsets transform, one audio file, default JSON writer destination"
Chris@0 36
Chris@147 37 rm -f $audiopath/$outfile1
Chris@0 38
Chris@150 39 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null || \
Chris@0 40 fail "Fails to run with $ctx"
Chris@0 41
Chris@150 42 check_json $audiopath/$outfile1 "$ctx"
Chris@0 43
Chris@0 44
Chris@150 45 ctx="onsets transform, one audio file with dots in filename, default JSON writer destination"
Chris@44 46
Chris@147 47 rm -f $audiopath/$outfile1
Chris@44 48
Chris@44 49 cp $infile1 $infile1dot
Chris@44 50
Chris@150 51 $r -t $transformdir/onsets.n3 -w json $infile1dot 2>/dev/null || \
Chris@44 52 fail "Fails to run with $ctx"
Chris@44 53
Chris@150 54 check_json $audiopath/$outfile1dot "$ctx"
Chris@44 55
Chris@147 56 rm -f $infile1dot $audiopath/$outfile1dot
Chris@44 57
Chris@44 58
Chris@150 59 ctx="onsets and df transforms, one audio file, default JSON writer destination"
Chris@0 60
Chris@147 61 rm -f $audiopath/$outfile1
Chris@0 62
Chris@150 63 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json $infile1 2>/dev/null || \
Chris@0 64 fail "Fails to run with $ctx"
Chris@0 65
Chris@150 66 check_json $audiopath/$outfile1 "$ctx"
Chris@0 67
Chris@0 68
Chris@150 69 ctx="onsets transform, two audio files, default JSON writer destination"
Chris@0 70
Chris@147 71 rm -f $audiopath/$outfile1
Chris@147 72 rm -f $audiopath/$outfile2
Chris@0 73
Chris@150 74 $r -t $transformdir/onsets.n3 -w json $infile1 $infile2 2>/dev/null || \
Chris@0 75 fail "Fails to run with $ctx"
Chris@0 76
Chris@150 77 check_json $audiopath/$outfile1 "$ctx"
Chris@150 78 check_json $audiopath/$outfile2 "$ctx"
Chris@0 79
Chris@0 80
Chris@150 81 ctx="onsets transform, two audio files, one-file JSON writer"
Chris@0 82
Chris@150 83 # Does not support one file across all tracks
Chris@150 84
Chris@150 85 $r -t $transformdir/onsets.n3 -w json --json-one-file $tmpjson $infile1 $infile2 2>/dev/null && \
Chris@150 86 fail "Fails by completing successfully with $ctx"
Chris@150 87
Chris@150 88
Chris@150 89 ctx="onsets transform, two audio files, stdout JSON writer"
Chris@150 90
Chris@150 91 $r -t $transformdir/onsets.n3 -w json --json-stdout $infile1 $infile2 2>/dev/null >$tmpjson || \
Chris@0 92 fail "Fails to run with $ctx"
Chris@0 93
Chris@150 94 check_json $tmpjson "$ctx"
Chris@0 95
Chris@0 96
Chris@150 97 ctx="onsets transform, one audio file, many-files JSON writer"
Chris@0 98
Chris@147 99 rm -f $audiopath/$outfile3
Chris@0 100
Chris@150 101 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 2>/dev/null || \
Chris@0 102 fail "Fails to run with $ctx"
Chris@0 103
Chris@150 104 check_json $audiopath/$outfile3 "$ctx"
Chris@0 105
Chris@0 106
Chris@150 107 ctx="onsets transform, two audio files, many-files JSON writer"
Chris@0 108
Chris@147 109 rm -f $audiopath/$outfile3
Chris@147 110 rm -f $audiopath/$outfile5
Chris@0 111
Chris@150 112 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 113 fail "Fails to run with $ctx"
Chris@0 114
Chris@150 115 check_json $audiopath/$outfile3 "$ctx"
Chris@150 116 check_json $audiopath/$outfile5 "$ctx"
Chris@0 117
Chris@0 118
Chris@150 119 ctx="onsets and df transforms, two audio files, many-files JSON writer"
Chris@0 120
Chris@147 121 rm -f $audiopath/$outfile3
Chris@147 122 rm -f $audiopath/$outfile4
Chris@147 123 rm -f $audiopath/$outfile5
Chris@147 124 rm -f $audiopath/$outfile6
Chris@0 125
Chris@150 126 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \
Chris@0 127 fail "Fails to run with $ctx"
Chris@0 128
Chris@150 129 check_json $audiopath/$outfile3 "$ctx"
Chris@150 130 check_json $audiopath/$outfile4 "$ctx"
Chris@150 131 check_json $audiopath/$outfile5 "$ctx"
Chris@150 132 check_json $audiopath/$outfile6 "$ctx"
Chris@147 133
Chris@147 134
Chris@147 135 ctx="output base directory"
Chris@147 136
Chris@147 137 rm -f ./$outfile1
Chris@147 138
Chris@150 139 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-basedir . $infile1 2>/dev/null || \
Chris@147 140 fail "Fails to run with $ctx"
Chris@147 141
Chris@150 142 check_json ./$outfile1 "$ctx"
Chris@147 143
Chris@147 144
Chris@147 145 ctx="output base directory and many-files"
Chris@147 146
Chris@147 147 rm -f ./$outfile3
Chris@147 148 rm -f ./$outfile5
Chris@147 149
Chris@150 150 $r -t $transformdir/onsets.n3 -w json --json-basedir . --json-many-files $infile1 $infile2 2>/dev/null || \
Chris@147 151 fail "Fails to run with $ctx"
Chris@147 152
Chris@150 153 check_json ./$outfile3 "$ctx"
Chris@150 154 check_json ./$outfile5 "$ctx"
Chris@147 155
Chris@147 156
Chris@147 157 ctx="nonexistent output base directory"
Chris@147 158
Chris@150 159 $r -t $transformdir/onsets.n3 -w json --json-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \
Chris@147 160 fail "Fails with $ctx by completing successfully (should refuse and bail out)"
Chris@0 161
Chris@0 162
Chris@150 163 ctx="existing output file and no --json-force"
Chris@0 164
Chris@147 165 touch $audiopath/$outfile1
Chris@0 166
Chris@150 167 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null && \
Chris@0 168 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
Chris@0 169
Chris@0 170
Chris@150 171 ctx="existing output file and --json-force"
Chris@0 172
Chris@147 173 touch $audiopath/$outfile1
Chris@0 174
Chris@150 175 $r -t $transformdir/onsets.n3 -w json --json-force $infile1 2>/dev/null || \
Chris@0 176 fail "Fails to run with $ctx"
Chris@0 177
Chris@150 178 check_json $audiopath/$outfile1 "$ctx"
Chris@0 179
Chris@0 180
Chris@0 181 exit 0