Imported Upstream version 3.2.0
[platform/upstream/libwebsockets.git] / scripts / autobahn-test-server.sh
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
11 set -u
12
13 PARALLEL=2
14 N=1
15 OS=`uname`
16
17 CLIE=bin/lws-minimal-ws-client-echo
18 SERV=bin/lws-minimal-ws-server-echo
19
20 RESULT=0
21
22 which wstest 2>/dev/null
23 if [ $? -ne 0 ]; then
24         echo "wstest is not installed"
25         exit 8
26 fi
27
28 killall 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
35 cat << EOF >fuzzingclient.json
36
37    "outdir": "./reports/servers",
38    "servers": [
39       {
40          "url": "ws://127.0.0.1:9001"
41       }
42    ],
43    "cases": [ "12.2.13" ],
44    "exclude-cases": ["2.10", "2.11" ],
45    "exclude-agent-cases": {}
46 }
47 EOF
48
49 echo
50 echo "----------------------------------------------"
51 echo "-------   tests: autobahn as server"
52 echo
53
54 $SERV -p 9001 -d3 &
55 wstest -m fuzzingclient
56 R=$?
57 echo "Autobahn client exit $R"
58
59 killall lws-minimal-ws-server-echo
60 sleep 1s
61
62 # repeat the client results
63
64 R=`cat /tmp/ji | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | wc -l`
65 echo -n "AUTOBAHN SERVER / LWS CLIENT: Total tests: " `cat /tmp/ji | wc -l` " : "
66 if [ "$R" == "0" ] ;then
67         echo "All pass"
68 else
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
73 fi
74
75 # and then the server results
76
77 cat reports/servers/index.json | tr '\n' '!' | sed "s|\},\!|\n|g" | tr '!' ' ' | tr -s ' ' > /tmp/jis
78 R=`cat /tmp/jis | grep -v '"behavior": "OK"' | grep -v '"behavior": "NON-STRICT"' | grep -v '"behavior": "INFORMATIONAL"' | wc -l`
79
80 echo -n "AUTOBAHN CLIENT / LWS SERVER: Total tests: " `cat /tmp/jis | wc -l` " : "
81 if [ "$R" == "0" ] ;then
82         echo "All pass"
83 else
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
88 fi
89
90 echo $RESULT
91 exit $RESULT
92