1 AT_BANNER([JSON-RPC - C])
3 AT_SETUP([JSON-RPC request and successful reply])
4 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
5 AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
6 AT_CHECK([test -s pid])
7 AT_CHECK([kill -0 `cat pid`])
9 [[test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0],
10 [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
11 ]], [], [test ! -e pid || kill `cat pid`])
12 AT_CHECK([kill `cat pid`])
15 AT_SETUP([JSON-RPC request and error reply])
16 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
17 AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
18 AT_CHECK([test -s pid])
19 AT_CHECK([kill -0 `cat pid`])
21 [[test-jsonrpc request unix:socket bad-request '[]']], [0],
22 [[{"error":{"error":"unknown method"},"id":0,"result":null}
23 ]], [], [test ! -e pid || kill `cat pid`])
24 AT_CHECK([kill `cat pid`])
27 AT_SETUP([JSON-RPC notification])
28 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
29 AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
30 AT_CHECK([test -s pid])
31 # When a daemon dies it deletes its pidfile, so make a copy.
32 AT_CHECK([cp pid pid2])
33 AT_CHECK([kill -0 `cat pid2`])
34 AT_CHECK([[test-jsonrpc notify unix:socket shutdown '[]']], [0], [],
35 [], [kill `cat pid2`])
38 # First try a quick sleep, so that the test completes very quickly
39 # in the normal case. POSIX doesn't require fractional times to
40 # work, so this might not work.
41 sleep 0.1; if kill -0 $pid; then :; else echo success; exit 0; fi
42 # Then wait up to 2 seconds.
43 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
44 sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
45 echo failure; exit 1], [0], [success
47 AT_CHECK([test ! -e pid])