1#!/bin/bash 2# 3# Requires pip install autobahntestsuite 4# 5# you should run this from ./build, after building with 6# cmake .. -DLWS_WITH_MINIMAL_EXAMPLES=1 7# 8# It will use the minimal echo client and server to run 9# autobahn ws tests as both client and server. 10 11set -u 12 13PARALLEL=2 14N=1 15OS=`uname` 16 17CLIE=bin/lws-minimal-ws-client-echo 18SERV=bin/lws-minimal-ws-server-echo 19 20RESULT=0 21 22which wstest 2>/dev/null 23if [ $? -ne 0 ]; then 24 echo "wstest is not installed" 25 exit 8 26fi 27 28killall wstest 2>/dev/null 29 30# 31# 2.10 / 2.11: There is no requirement to handle multiple PING / PONG 32# in flight on a single connection in RFC6455. lws doesn't 33# waste memory on supporting it since it is useless. 34 35cat << EOF >fuzzingclient.json 36{ 37 "outdir": "./reports/servers", 38 "servers": [ 39 { 40 "url": "ws://127.0.0.1:9001" 41 } 42 ], 43 "cases": [ "*" ], 44 "exclude-cases": ["2.10", "2.11" ], 45 "exclude-agent-cases": {} 46} 47EOF 48 49echo 50echo "----------------------------------------------" 51echo "------- tests: autobahn as server" 52echo 53 54$SERV -p 9001 -d3 & 55wstest -m fuzzingclient 56R=$? 57echo "Autobahn client exit $R" 58 59killall lws-minimal-ws-server-echo 60sleep 1s 61 62# repeat the client results 63 64R=`cat /tmp/ji | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | wc -l` 65echo -n "AUTOBAHN SERVER / LWS CLIENT: Total tests: " `cat /tmp/ji | wc -l` " : " 66if [ "$R" == "0" ] ;then 67 echo "All pass" 68else 69 RESULT=1 70 echo -n "$R FAIL : " 71 cat /tmp/ji | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | cut -d\" -f2 | tr '\n' ',' 72 echo 73fi 74 75# and then the server results 76 77cat reports/servers/index.json | tr '\n' '!' | sed "s|\},\!|\n|g" | tr '!' ' ' | tr -s ' ' > /tmp/jis 78R=`cat /tmp/jis | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | wc -l` 79 80echo -n "AUTOBAHN CLIENT / LWS SERVER: Total tests: " `cat /tmp/jis | wc -l` " : " 81if [ "$R" == "0" ] ;then 82 echo "All pass" 83else 84 RESULT=$(( $RESULT + 2 )) 85 echo -n "$R FAIL : " 86 cat /tmp/jis | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | cut -d\" -f2 | tr '\n' ',' 87 echo 88fi 89 90echo $RESULT 91exit $RESULT 92 93