From f891ff694b84304ba34ec3b6367e52b30d77be59 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 Aug 2004 07:36:16 +0000 Subject: r2105: added a TestSleep() operation to the echo pipe and extended the RPC-ECHO test to use it to test asynchronous rpc operations. (This used to be commit a5eb6cad5050928fab593e1f9a82fbfba589120c) --- source4/librpc/idl/echo.idl | 4 +++ source4/rpc_server/echo/rpc_echo.c | 5 ++++ source4/torture/rpc/echo.c | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) (limited to 'source4') diff --git a/source4/librpc/idl/echo.idl b/source4/librpc/idl/echo.idl index 85b86c310e..f8cc734513 100644 --- a/source4/librpc/idl/echo.idl +++ b/source4/librpc/idl/echo.idl @@ -88,4 +88,8 @@ interface rpcecho [in] uint16 level, [out,switch_is(level)] echo_Info *info ); + + uint32 echo_TestSleep( + [in] uint32 seconds + ); } diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index c4e1256841..066bb2cdc1 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -105,6 +105,11 @@ static NTSTATUS echo_TestCall2(struct dcesrv_call_state *dce_call, TALLOC_CTX *m return NT_STATUS_OK; } +static long echo_TestSleep(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_TestSleep *r) +{ + sleep(r->in.seconds); + return r->in.seconds; +} /* include the generated boilerplate */ #include "librpc/gen_ndr/ndr_echo_s.c" diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index 625447705a..925b483288 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -207,6 +207,57 @@ static BOOL test_testcall2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return ret; } + +/* + test the TestSleep interface +*/ +static BOOL test_sleep(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + int i; + NTSTATUS status; +#define ASYNC_COUNT 5 + struct rpc_request *req[ASYNC_COUNT]; + struct echo_TestSleep r[ASYNC_COUNT]; + int done[ASYNC_COUNT]; + struct event_context *ctx; + int total_done = 0; + BOOL ret = True; + + printf("\nTesting TestSleep\n"); + + for (i=0;istate == RPC_REQUEST_DONE) { + total_done++; + done[i] = 1; + status = dcerpc_ndr_request_recv(req[i]); + if (!NT_STATUS_IS_OK(status)) { + printf("TestSleep(%d) failed - %s\n", + i, nt_errstr(status)); + ret = False; + } else { + printf("Sleep for %d seconds\n", + r[i].out.result); + } + } + } + } + + return ret; +} + BOOL torture_rpc_echo(int dummy) { NTSTATUS status; @@ -250,6 +301,10 @@ BOOL torture_rpc_echo(int dummy) ret = False; } + if (!test_sleep(p, mem_ctx)) { + ret = False; + } + printf("\n"); talloc_destroy(mem_ctx); -- cgit