comparison test/test-server.sh @ 133:74a7c2a8d6b6

Merge from branch listargs
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 04 Nov 2016 10:43:49 +0000
parents 3ae0335cfe60
children a9be6f1e680d
comparison
equal deleted inserted replaced
126:2004ec2b653e 133:74a7c2a8d6b6
42 validate "$respfile" "rpcresponse" 42 validate "$respfile" "rpcresponse"
43 } 43 }
44 44
45 cat > "$input" <<EOF 45 cat > "$input" <<EOF
46 {"method":"list"} 46 {"method":"list"}
47 {"method":"list","params": {"from":["vamp-example-plugins","something-nonexistent"]}}
48 {"method":"list","params": {"from":["something-nonexistent"]}}
47 {"method":"load","id":6,"params": {"key":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}} 49 {"method":"load","id":6,"params": {"key":"vamp-example-plugins:percussiononsets","inputSampleRate":44100,"adapterFlags":["AdaptInputDomain","AdaptBufferSize"]}}
48 {"method":"configure","id":"weevil","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}} 50 {"method":"configure","id":"weevil","params":{"handle":1,"configuration":{"blockSize": 8, "channelCount": 1, "parameterValues": {"sensitivity": 40, "threshold": 3}, "stepSize": 8}}}
49 {"method":"process","params": {"handle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}} 51 {"method":"process","params": {"handle": 1, "processInput": { "timestamp": {"s": 0, "n": 0}, "inputBuffers": [ [1,2,3,4,5,6,7,8] ]}}}
50 {"method":"finish","params": {"handle": 1}} 52 {"method":"finish","params": {"handle": 1}}
51 EOF 53 EOF
61 63
62 # We run the whole test twice, once with the server in Capnp mode 64 # We run the whole test twice, once with the server in Capnp mode
63 # (converting to JSON using piper-convert) and once with it directly 65 # (converting to JSON using piper-convert) and once with it directly
64 # in JSON mode 66 # in JSON mode
65 67
66 for format in capnp json ; do 68 for format in json capnp ; do
67 69
68 ( export VAMP_PATH="$vampsdkdir"/examples ; 70 ( export VAMP_PATH="$vampsdkdir"/examples ;
69 while read request ; do 71 while read request ; do
70 validate_request "$request" 72 validate_request "$request"
71 echo "$request" 73 echo "$request"
81 echo "$response" >> "$allrespfile" 83 echo "$response" >> "$allrespfile"
82 validate_response "$response" 84 validate_response "$response"
83 done 85 done
84 ) < "$input" 86 ) < "$input"
85 87
86 # Skip plugin list 88 # Skip plugin lists
87 tail -n +2 "$allrespfile" > "$obtained" 89 tail -n +4 "$allrespfile" > "$obtained"
88 90
89 echo "Checking response contents against expected contents..." 91 echo "Checking response contents against expected contents..."
90 if ! cmp "$obtained" "$expected"; then 92 if ! cmp "$obtained" "$expected"; then
91 diff -u1 "$obtained" "$expected" 93 diff -u1 "$obtained" "$expected"
92 else 94 else
93 echo "OK" 95 echo "OK"
94 fi 96 fi
95 97
98 echo "Checking plugin counts from list responses..."
99
100 # Now check the plugin lists, but as the descriptions etc are
101 # probably a bit fragile, let's just count the number of plugins
102
103 # First, with no "from" arg to the list call
104 list_no_from=$(head -n +1 "$allrespfile" | fmt -1 | grep '"key"' | wc -l)
105
106 # Now with a "from" arg that includes the library that exists
107 list_with_good_from=$(tail -n +2 "$allrespfile" | head -n +1 | fmt -1 |
108 grep '"key"' | wc -l)
109
110 # Now with a "from" arg that doesn't include any real library
111 list_with_bad_from=$(tail -n +3 "$allrespfile" | head -n +1 | fmt -1 |
112 grep '"key"' | wc -l)
113
114 if [ "$list_no_from" != "6" ]; then
115 echo "Wrong number of plugins from list response without \"from\" arg"
116 echo "Expected 6, obtained $list_no_from"
117 false
118 fi
119 if [ "$list_with_good_from" != "6" ]; then
120 echo "Wrong number of plugins from list response with good \"from\" arg"
121 echo "Expected 6, obtained $list_with_good_from"
122 false
123 fi
124 if [ "$list_with_bad_from" != "0" ]; then
125 echo "Wrong number of plugins from list response with bad \"from\" arg"
126 echo "Expected 0, obtained $list_with_bad_from"
127 false
128 fi
129 echo OK
130
96 rm "$allrespfile" 131 rm "$allrespfile"
97 132
98 done 133 done
134
135 echo "Tests succeeded" # set -e at top should ensure we don't get here otherwise