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