comparison test/test-vampipe-server.sh @ 67:db17657ac875

Validation fixes
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 05 Oct 2016 13:53:08 +0100
parents 6f160dee1192
children a5ba837bca28
comparison
equal deleted inserted replaced
66:6f160dee1192 67:db17657ac875
18 18
19 validate_request() { 19 validate_request() {
20 local json="$1" 20 local json="$1"
21 echo "$json" > "$reqfile" 21 echo "$json" > "$reqfile"
22 validate "$reqfile" "request" 22 validate "$reqfile" "request"
23 type=$(grep '"type":' "$reqfile" | sed 's/^.*"type": *"\([^"]*\)".*$/\1/')
24 if [ "$type" == "configure" ]; then type=configuration; fi
25 if [ "$type" != "list" ]; then
26 echo "$json" |
27 sed 's/^.*"content"://' |
28 sed 's/}}$/}/' > "$reqfile"
29 validate "$reqfile" "${type}request"
30 fi
31 } 23 }
32 24
33 validate_response() { 25 validate_response() {
34 local json="$1" 26 local json="$1"
35 echo "$json" > "$respfile" 27 echo "$json" > "$respfile"
36 validate "$respfile" "response" 28 validate "$respfile" "response"
37 type=$(grep '"type":' "$respfile" | sed 's/^.*"type": "\([^"]*\)".*$/\1/')
38 if [ "$type" == "configure" ]; then type=configuration; fi
39 echo "$json" |
40 sed 's/^.*"content"://' |
41 sed 's/, "error.*$//' |
42 sed 's/, "success.*$//' > "$respfile"
43 validate "$respfile" "${type}response"
44 } 29 }
45 30
46 ( while read request ; do 31 ( while read request ; do
47 validate_request "$request" 32 validate_request "$request"
48 echo "$request" 33 echo "$request"
52 bin/vampipe-convert response -i capnp -o json | 37 bin/vampipe-convert response -i capnp -o json |
53 while read response ; do 38 while read response ; do
54 validate_response "$response" 39 validate_response "$response"
55 done 40 done
56 ) <<EOF 41 ) <<EOF
57 {"type":"list"} 42 {"method":"list"}
58 {"type":"load","content": {"pluginKey":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}} 43 {"method":"load","params": {"pluginKey":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}}
59 {"type":"configure","content":{"pluginHandle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}} 44 {"method":"configure","params":{"pluginHandle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}}
60 {"type":"process","content": {"pluginHandle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}} 45 {"method":"process","params": {"pluginHandle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}}
61 {"type":"finish","content": {"pluginHandle": 1}} 46 {"method":"finish","params": {"pluginHandle": 1}}
62 EOF 47 EOF