From dc8961ad42eedc4f9b26a93fb267e491a1e2af0e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 23:28:24 +0000 Subject: r7656: added testing of rpc request timeouts and destruction (This used to be commit eddf41d5e4ca43073b96f96b96dbadf7b8b91df5) --- source4/torture/rpc/echo.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index ad09e00294..94400247a6 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -383,6 +383,67 @@ static BOOL test_doublepointer(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return ret; } + +/* + test request timeouts +*/ +static BOOL test_timeout(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +{ + NTSTATUS status; + struct rpc_request *req; + struct echo_TestSleep r; + int timeout_saved = p->request_timeout; + + if (!lp_parm_bool(-1, "torture", "echo_TestSleep", True)) { + printf("timeout testing disabled - use \"torture:echo_TestSleep=yes\" to enable\n"); + return True; + } + + printf("testing request timeouts\n"); + r.in.seconds = 2; + p->request_timeout = 1; + + req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); + if (!req) { + printf("Failed to send async sleep request\n"); + goto failed; + } + + status = dcerpc_ndr_request_recv(req); + if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { + printf("request should have timed out - %s\n", nt_errstr(status)); + goto failed; + } + + printf("testing request destruction\n"); + req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); + if (!req) { + printf("Failed to send async sleep request\n"); + goto failed; + } + talloc_free(req); + + req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); + if (!req) { + printf("Failed to send async sleep request\n"); + goto failed; + } + status = dcerpc_ndr_request_recv(req); + if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { + printf("request should have timed out - %s\n", nt_errstr(status)); + goto failed; + } + + + p->request_timeout = timeout_saved; + return True; + +failed: + p->request_timeout = timeout_saved; + return False; +} + + BOOL torture_rpc_echo(void) { NTSTATUS status; @@ -411,6 +472,7 @@ BOOL torture_rpc_echo(void) ret &= test_surrounding(p, mem_ctx); ret &= test_doublepointer(p, mem_ctx); ret &= test_sleep(p, mem_ctx); + ret &= test_timeout(p, mem_ctx); printf("\n"); -- cgit