comparison test/test-vampipe-server.sh @ 73:7bfc07576830

Ensure id is passed through properly in convert and in server
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 10 Oct 2016 15:03:47 +0100
parents a5ba837bca28
children
comparison
equal deleted inserted replaced
72:16acd7d24b1a 73:7bfc07576830
2 2
3 set -eu 3 set -eu
4 4
5 reqfile="/tmp/$$.req.json" 5 reqfile="/tmp/$$.req.json"
6 respfile="/tmp/$$.resp.json" 6 respfile="/tmp/$$.resp.json"
7 trap "rm -f $reqfile $respfile" 0 7 allrespfile="/tmp/$$.resp.all"
8 expected="/tmp/$$.expected"
9 obtained="/tmp/$$.obtained"
10 trap "rm -f $reqfile $respfile $allrespfile $obtained $expected" 0
8 11
9 schema=vamp-json-schema/schema 12 schema=vamp-json-schema/schema
10 13
11 validate() { 14 validate() {
12 local file="$1" 15 local file="$1"
34 done | 37 done |
35 bin/vampipe-convert request -i json -o capnp | 38 bin/vampipe-convert request -i json -o capnp |
36 VAMP_PATH=./vamp-plugin-sdk/examples bin/vampipe-server | 39 VAMP_PATH=./vamp-plugin-sdk/examples bin/vampipe-server |
37 bin/vampipe-convert response -i capnp -o json | 40 bin/vampipe-convert response -i capnp -o json |
38 while read response ; do 41 while read response ; do
42 echo "$response" >> "$allrespfile"
39 validate_response "$response" 43 validate_response "$response"
40 done 44 done
41 ) <<EOF 45 ) <<EOF
42 {"method":"list"} 46 {"method":"list"}
43 {"method":"load","params": {"key":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}} 47 {"method":"load","id":6,"params": {"key":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}}
44 {"method":"configure","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}} 48 {"method":"configure","id":"weevil","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}}
45 {"method":"process","params": {"handle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}} 49 {"method":"process","params": {"handle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}}
46 {"method":"finish","params": {"handle": 1}} 50 {"method":"finish","params": {"handle": 1}}
47 EOF 51 EOF
52
53 # Expected output, apart from the plugin list which seems a bit
54 # fragile to check here
55 cat > "$expected" <<EOF
56 {"id": 6, "jsonrpc": "2.0", "method": "load", "result": {"defaultConfiguration": {"blockSize": 1024, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 1024}, "handle": 1, "staticData": {"basic": {"description": "Detect percussive note onsets by identifying broadband energy rises", "identifier": "percussiononsets", "name": "Simple Percussion Onset Detector"}, "basicOutputInfo": [{"description": "Percussive note onset locations", "identifier": "onsets", "name": "Onsets"}, {"description": "Broadband energy rise detection function", "identifier": "detectionfunction", "name": "Detection Function"}], "category": ["Time", "Onsets"], "copyright": "Code copyright 2006 Queen Mary, University of London, after Dan Barry et al 2005. Freely redistributable (BSD license)", "inputDomain": "TimeDomain", "key": "vamp-example-plugins:percussiononsets", "maker": "Vamp SDK Example Plugins", "maxChannelCount": 1, "minChannelCount": 1, "parameters": [{"basic": {"description": "Energy rise within a frequency bin necessary to count toward broadband total", "identifier": "threshold", "name": "Energy rise threshold"}, "defaultValue": 3, "extents": {"max": 20, "min": 0}, "unit": "dB", "valueNames": []}, {"basic": {"description": "Sensitivity of peak detector applied to broadband detection function", "identifier": "sensitivity", "name": "Sensitivity"}, "defaultValue": 40, "extents": {"max": 100, "min": 0}, "unit": "%", "valueNames": []}], "programs": [], "version": 2}}}
57 {"id": "weevil", "jsonrpc": "2.0", "method": "configure", "result": {"handle": 1, "outputList": [{"basic": {"description": "Percussive note onset locations", "identifier": "onsets", "name": "Onsets"}, "configured": {"binCount": 0, "binNames": [], "hasDuration": false, "sampleRate": 44100, "sampleType": "VariableSampleRate", "unit": ""}}, {"basic": {"description": "Broadband energy rise detection function", "identifier": "detectionfunction", "name": "Detection Function"}, "configured": {"binCount": 1, "binNames": [""], "hasDuration": false, "quantizeStep": 1, "sampleRate": 86.1328125, "sampleType": "FixedSampleRate", "unit": ""}}]}}
58 {"jsonrpc": "2.0", "method": "process", "result": {"features": {}, "handle": 1}}
59 {"jsonrpc": "2.0", "method": "finish", "result": {"features": {"detectionfunction": [{"featureValues": [0], "timestamp": {"n": 11609977, "s": 0}}]}, "handle": 1}}
60 EOF
61
62 # Skip plugin list
63 tail -n +2 "$allrespfile" > "$obtained"
64
65 echo "Checking response contents against expected contents..."
66 if ! cmp "$obtained" "$expected"; then
67 diff -u1 "$obtained" "$expected"
68 else
69 echo "OK"
70 fi
71