]>
Commit | Line | Data |
---|---|---|
99155935 | 1 | AT_BANNER([JSON-RPC - C]) |
f2129093 BP |
2 | |
3 | AT_SETUP([JSON-RPC request and successful reply]) | |
2c487bc8 | 4 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
eadd1644 | 5 | AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket]) |
f2129093 BP |
6 | AT_CHECK([test -s pid]) |
7 | AT_CHECK([kill -0 `cat pid`]) | |
8 | AT_CHECK( | |
eadd1644 | 9 | [[ovstest test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0], |
f2129093 | 10 | [[{"error":null,"id":0,"result":[{"a":"b","x":null}]} |
7fcfe998 | 11 | ]], [], [test ! -e pid || kill `cat pid`]) |
f2129093 BP |
12 | AT_CHECK([kill `cat pid`]) |
13 | AT_CLEANUP | |
14 | ||
15 | AT_SETUP([JSON-RPC request and error reply]) | |
2c487bc8 | 16 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
eadd1644 | 17 | AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket]) |
f2129093 BP |
18 | AT_CHECK([test -s pid]) |
19 | AT_CHECK([kill -0 `cat pid`]) | |
20 | AT_CHECK( | |
eadd1644 | 21 | [[ovstest test-jsonrpc request unix:socket bad-request '[]']], [0], |
f2129093 | 22 | [[{"error":{"error":"unknown method"},"id":0,"result":null} |
7fcfe998 | 23 | ]], [], [test ! -e pid || kill `cat pid`]) |
f2129093 BP |
24 | AT_CHECK([kill `cat pid`]) |
25 | AT_CLEANUP | |
26 | ||
27 | AT_SETUP([JSON-RPC notification]) | |
2c487bc8 | 28 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
eadd1644 | 29 | AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket]) |
f2129093 BP |
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`]) | |
eadd1644 | 34 | AT_CHECK([[ovstest test-jsonrpc notify unix:socket shutdown '[]']], [0], [], |
7fcfe998 | 35 | [], [kill `cat pid2`]) |
f2129093 BP |
36 | AT_CHECK( |
37 | [pid=`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 | |
46 | ], [ignore]) | |
47 | AT_CHECK([test ! -e pid]) | |
48 | AT_CLEANUP |