changeset 178:353f842ed73f

Add a more relaxed comparision of JSON responses if the initial comparision fails. Some optional fields aren't populated from the JSON serialisation code.
author Lucas Thompson <dev@lucas.im>
date Tue, 31 Jan 2017 23:01:49 +0000
parents 1990dd9570d8
children 0e13b7b80464
files vamp-server/test.sh
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-server/test.sh	Tue Jan 31 22:58:38 2017 +0000
+++ b/vamp-server/test.sh	Tue Jan 31 23:01:49 2017 +0000
@@ -27,6 +27,7 @@
 allrespfile="$tmpdir/resp.all"
 input="$tmpdir/input"
 expected="$tmpdir/expected"
+expected_less_strict="$tmpdir/obtained-less-strict"
 obtained="$tmpdir/obtained"
 
 validate() {
@@ -82,9 +83,10 @@
 {"error": {"code": 0, "message": "error in finish request: unknown plugin handle supplied to finish"}, "id": "blah", "jsonrpc": "2.0", "method": "finish"}
 EOF
 
-# We run the whole test twice, once with the server in Capnp mode
-# (converting to JSON using piper-convert) and once with it directly
-# in JSON mode
+# We run the whole test three times, 
+# to cover (de)serialisation of json and capnp requests and responses
+# as well as exercising both server modes (json and capnp)
+# converting / reading from capnp requests is currently not tested
 
 #debugflag=-d
 debugflag=
@@ -120,10 +122,16 @@
     tail -n +4 "$allrespfile" > "$obtained"
 
     echo "Checking response contents against expected contents..."
-    if ! cmp "$obtained" "$expected"; then
-        diff -U 1 "$obtained" "$expected"
+    
+    # the expected configuration response is fragile, capnp fills in optional fields, 
+    # json doesn't - which is fine behaviour, but causes the test to fail - remove empty binCount and binNames  
+    expected_without_optional_fields=$( cat "$expected" | sed -E 's/\"(binCount|binNames)\": ?((\[\])|0),? ?//g')
+    echo "$expected_without_optional_fields" > "$expected_less_strict"
+
+    if cmp "$obtained" "$expected" -s || cmp "$obtained" "$expected_less_strict" -s; then
+      echo "OK"
     else
-        echo "OK"
+      diff -U 1 "$obtained" "$expected"
     fi
 
     echo "Checking plugin counts from list responses..."