netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / tests / jsonrpc.at
1 AT_BANNER([JSON-RPC - C])
2
3 AT_SETUP([JSON-RPC request and successful reply])
4 AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
5 AT_CHECK([test -s pid])
6 AT_CHECK([kill -0 `cat pid`])
7 AT_CHECK(
8   [[ovstest test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0],
9   [[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
10 ]], [], [test ! -e pid || kill `cat pid`])
11 AT_CHECK([kill `cat pid`])
12 AT_CLEANUP
13
14 AT_SETUP([JSON-RPC request and error reply])
15 AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
16 AT_CHECK([test -s pid])
17 AT_CHECK([kill -0 `cat pid`])
18 AT_CHECK(
19   [[ovstest test-jsonrpc request unix:socket bad-request '[]']], [0],
20   [[{"error":{"error":"unknown method"},"id":0,"result":null}
21 ]], [], [test ! -e pid || kill `cat pid`])
22 AT_CHECK([kill `cat pid`])
23 AT_CLEANUP
24
25 AT_SETUP([JSON-RPC notification])
26 AT_CHECK([ovstest test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
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`])
31 AT_CHECK([[ovstest test-jsonrpc notify unix:socket shutdown '[]']], [0], [],
32   [], [kill `cat pid2`])
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