1 AT_BANNER([JSON-RPC - Python])
3 AT_SETUP([JSON-RPC request and successful reply - Python])
4 AT_SKIP_IF([test $HAVE_PYTHON = no])
5 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile-name=$PWD/pid listen punix:socket])
6 AT_CHECK([test -s pid])
7 AT_CHECK([kill -0 `cat pid`])
9 [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket echo '[{"a": "b", "x": null}]']], [0],
10 [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
11 ]], [ignore], [test ! -e pid || kill `cat pid`])
12 AT_CHECK([kill `cat pid`])
15 AT_SETUP([JSON-RPC request and error reply - Python])
16 AT_SKIP_IF([test $HAVE_PYTHON = no])
17 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile-name=$PWD/pid listen punix:socket])
18 AT_CHECK([test -s pid])
19 AT_CHECK([kill -0 `cat pid`])
21 [[$PYTHON $srcdir/test-jsonrpc.py request unix:socket bad-request '[]']], [0],
22 [[{"error":{"error":"unknown method"},"id":0,"result":null}
23 ]], [ignore], [test ! -e pid || kill `cat pid`])
24 AT_CHECK([kill `cat pid`])
27 AT_SETUP([JSON-RPC notification - Python])
28 AT_SKIP_IF([test $HAVE_PYTHON = no])
29 AT_CHECK([$PYTHON $srcdir/test-jsonrpc.py --detach --pidfile-name=$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([[$PYTHON $srcdir/test-jsonrpc.py notify unix:socket shutdown '[]']], [0], [],
35 [ignore], [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])