svn commit: samba r2105 - in branches/SAMBA_4_0/source: librpc/idl rpc_server/echo torture/rpc

tridge at samba.org tridge at samba.org
Mon Aug 30 07:36:19 GMT 2004


Author: tridge
Date: 2004-08-30 07:36:16 +0000 (Mon, 30 Aug 2004)
New Revision: 2105

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=2105&nolog=1

Log:
added a TestSleep() operation to the echo pipe and extended the
RPC-ECHO test to use it to test asynchronous rpc operations.



Modified:
   branches/SAMBA_4_0/source/librpc/idl/echo.idl
   branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c
   branches/SAMBA_4_0/source/torture/rpc/echo.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/echo.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/echo.idl	2004-08-30 06:14:18 UTC (rev 2104)
+++ branches/SAMBA_4_0/source/librpc/idl/echo.idl	2004-08-30 07:36:16 UTC (rev 2105)
@@ -88,4 +88,8 @@
 		     [in]                    uint16 level,
 		     [out,switch_is(level)]  echo_Info *info
 		);
+
+	uint32 echo_TestSleep(
+		[in] uint32 seconds
+		);
 }

Modified: branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2004-08-30 06:14:18 UTC (rev 2104)
+++ branches/SAMBA_4_0/source/rpc_server/echo/rpc_echo.c	2004-08-30 07:36:16 UTC (rev 2105)
@@ -105,6 +105,11 @@
 	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"

Modified: branches/SAMBA_4_0/source/torture/rpc/echo.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/echo.c	2004-08-30 06:14:18 UTC (rev 2104)
+++ branches/SAMBA_4_0/source/torture/rpc/echo.c	2004-08-30 07:36:16 UTC (rev 2105)
@@ -207,6 +207,57 @@
 	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;i<ASYNC_COUNT;i++) {
+		done[i] = 0;
+		r[i].in.seconds = ASYNC_COUNT-i;
+		req[i] = dcerpc_echo_TestSleep_send(p, mem_ctx, &r[i]);
+		if (!req[i]) {
+			printf("Failed to send async sleep request\n");
+			return False;
+		}
+	}
+
+	ctx = dcerpc_event_context(p);
+	while (total_done < ASYNC_COUNT) {
+		event_loop_once(ctx);
+		for (i=0;i<ASYNC_COUNT;i++) {
+			if (done[i] == 0 && req[i]->state == 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 @@
 		ret = False;
 	}
 
+	if (!test_sleep(p, mem_ctx)) {
+		ret = False;
+	}
+
 	printf("\n");
 	
 	talloc_destroy(mem_ctx);



More information about the samba-cvs mailing list