2010-08-25 10:26:40 -07:00
|
|
|
AT_BANNER([JSON-RPC - C])
|
2009-10-26 15:04:05 -07:00
|
|
|
|
|
|
|
AT_SETUP([JSON-RPC request and successful reply])
|
2013-02-08 12:37:18 -08:00
|
|
|
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
|
2012-08-14 13:18:03 -07:00
|
|
|
AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK([test -s pid])
|
|
|
|
AT_CHECK([kill -0 `cat pid`])
|
|
|
|
AT_CHECK(
|
|
|
|
[[test-jsonrpc request unix:socket echo '[{"a": "b", "x": null}]']], [0],
|
|
|
|
[[{"error":null,"id":0,"result":[{"a":"b","x":null}]}
|
2011-04-29 10:44:58 -07:00
|
|
|
]], [], [test ! -e pid || kill `cat pid`])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK([kill `cat pid`])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([JSON-RPC request and error reply])
|
2013-02-08 12:37:18 -08:00
|
|
|
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
|
2012-08-14 13:18:03 -07:00
|
|
|
AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK([test -s pid])
|
|
|
|
AT_CHECK([kill -0 `cat pid`])
|
|
|
|
AT_CHECK(
|
|
|
|
[[test-jsonrpc request unix:socket bad-request '[]']], [0],
|
|
|
|
[[{"error":{"error":"unknown method"},"id":0,"result":null}
|
2011-04-29 10:44:58 -07:00
|
|
|
]], [], [test ! -e pid || kill `cat pid`])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK([kill `cat pid`])
|
|
|
|
AT_CLEANUP
|
|
|
|
|
|
|
|
AT_SETUP([JSON-RPC notification])
|
2013-02-08 12:37:18 -08:00
|
|
|
OVS_RUNDIR=`pwd`; export OVS_RUNDIR
|
2012-08-14 13:18:03 -07:00
|
|
|
AT_CHECK([test-jsonrpc --detach --no-chdir --pidfile="`pwd`"/pid listen punix:socket])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK([test -s pid])
|
|
|
|
# When a daemon dies it deletes its pidfile, so make a copy.
|
|
|
|
AT_CHECK([cp pid pid2])
|
|
|
|
AT_CHECK([kill -0 `cat pid2`])
|
2010-02-01 14:04:25 -08:00
|
|
|
AT_CHECK([[test-jsonrpc notify unix:socket shutdown '[]']], [0], [],
|
2011-04-29 10:44:58 -07:00
|
|
|
[], [kill `cat pid2`])
|
2009-10-26 15:04:05 -07:00
|
|
|
AT_CHECK(
|
|
|
|
[pid=`cat pid2`
|
|
|
|
# First try a quick sleep, so that the test completes very quickly
|
|
|
|
# in the normal case. POSIX doesn't require fractional times to
|
|
|
|
# work, so this might not work.
|
|
|
|
sleep 0.1; if kill -0 $pid; then :; else echo success; exit 0; fi
|
|
|
|
# Then wait up to 2 seconds.
|
|
|
|
sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
|
|
|
|
sleep 1; if kill -0 $pid; then :; else echo success; exit 0; fi
|
|
|
|
echo failure; exit 1], [0], [success
|
|
|
|
], [ignore])
|
|
|
|
AT_CHECK([test ! -e pid])
|
|
|
|
AT_CLEANUP
|