comparison vamp-server/test.sh @ 168:718dd5404855

Add case to exercise JSON responses.
author Lucas Thompson <dev@lucas.im>
date Tue, 31 Jan 2017 14:07:18 +0000
parents 2ada256e47e1
children 353f842ed73f
comparison
equal deleted inserted replaced
167:4a37daf5f8b4 168:718dd5404855
87 # in JSON mode 87 # in JSON mode
88 88
89 #debugflag=-d 89 #debugflag=-d
90 debugflag= 90 debugflag=
91 91
92 for format in json capnp ; do # nb must be json first: see comment at end of loop 92 for request_response_conversion in none json_to_json json_to_capnp ; do
93 93
94 ( export VAMP_PATH="$vampsdkdir"/examples ; 94 ( export VAMP_PATH="$vampsdkdir"/examples ;
95 while read request ; do 95 while read request ; do
96 validate_request "$request" 96 validate_request "$request"
97 echo "$request" 97 echo "$request"
98 done | 98 done |
99 if [ "$format" = "json" ]; then 99 if [ "$request_response_conversion" = "none" ]; then
100 "$bindir"/piper-vamp-simple-server $debugflag json 100 "$bindir"/piper-vamp-simple-server $debugflag json
101 elif [ "$request_response_conversion" = "json_to_json" ]; then
102 "$bindir"/piper-convert request -i json -o json |
103 "$bindir"/piper-vamp-simple-server $debugflag json |
104 "$bindir"/piper-convert response -i json -o json
101 else 105 else
106 # The capnp output doesn't preserve the method name in error
107 # responses, so replace those now that we've done the json tests
108 perl -i -p -e 's/(error.*"method": )"[^"]*"/$1"invalid"/' "$expected"
102 "$bindir"/piper-convert request -i json -o capnp | 109 "$bindir"/piper-convert request -i json -o capnp |
103 "$bindir"/piper-vamp-simple-server $debugflag capnp | 110 "$bindir"/piper-vamp-simple-server $debugflag capnp |
104 "$bindir"/piper-convert response -i capnp -o json 111 "$bindir"/piper-convert response -i capnp -o json
105 fi | 112 fi |
106 while read response ; do 113 while read response ; do
151 false 158 false
152 fi 159 fi
153 echo OK 160 echo OK
154 161
155 rm "$allrespfile" 162 rm "$allrespfile"
156
157 # The capnp output doesn't preserve the method name in error
158 # responses, so replace those now that we've done the json test
159 perl -i -p -e 's/(error.*"method": )"[^"]*"/$1"invalid"/' "$expected"
160 done 163 done
161 164
162 echo "Tests succeeded" # set -e at top should ensure we don't get here otherwise 165 echo "Tests succeeded" # set -e at top should ensure we don't get here otherwise