source4/torture/rpc/echo.c test_bytepipeout
authorStefan Metzmacher <metze@samba.org>
Fri, 20 Sep 2013 21:12:25 +0000 (23:12 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 4 Jun 2019 11:15:20 +0000 (13:15 +0200)
source4/torture/rpc/echo.c

index eb49aa9eb9a1756f41a305d85bbe8f7301efd7a8..c4e82d09f06a2db282e6e84a148e7fdae0c075ba 100644 (file)
@@ -443,6 +443,57 @@ static bool test_bytepipein(struct torture_context *tctx,
        return true;
 }
 
+static bool test_bytepipeout(struct torture_context *tctx,
+                            struct dcerpc_pipe *p)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct echo_TestBytePipeOut r;
+       struct echo_BytePipe_chunk *chunk;
+       struct echo_BytePipe *out_pipe;
+       struct tevent_req *subreq1;
+       struct tevent_req *subreq2;
+       size_t i;
+       uint8_t bytes[0x8];
+       NTSTATUS status;
+
+       out_pipe = dcerpc_echo_BytePipe_create(tctx);
+
+       ZERO_STRUCT(r);
+       r.in.num_chunks = 1;
+       r.in.chunk_size = sizeof(bytes);
+       r.out.out_pipe = out_pipe;
+
+       ZERO_STRUCT(chunk);
+
+       subreq1 = dcerpc_echo_TestBytePipeOut_r_send(tctx, tctx->ev, b, &r);
+       for (i=0; ; i++) {
+               struct timeval tv = timeval_current_ofs(0, 100);
+
+               //subreq2 = tevent_wakeup_send(tctx, tctx->ev, tv);
+               //tevent_req_poll(subreq2, tctx->ev);
+               //tevent_wakeup_recv(subreq2);
+               //TALLOC_FREE(subreq2);
+
+               subreq2 = dcerpc_echo_BytePipe_chunk_pull_send(tctx, tctx->ev, out_pipe);
+               tevent_req_poll(subreq2, tctx->ev);
+               status = dcerpc_echo_BytePipe_chunk_pull_recv(subreq2, tctx, &chunk);
+               TALLOC_FREE(subreq2);
+               torture_assert_ntstatus_ok(tctx, status, __location__);
+               torture_comment(tctx, "chunk[%u] count[%u]\n", (unsigned)i, (unsigned)chunk->count);
+               if (chunk->count == 0) {
+                       TALLOC_FREE(chunk);
+                       break;
+               }
+               TALLOC_FREE(chunk);
+       }
+
+       tevent_req_poll(subreq1, tctx->ev);
+       status = dcerpc_echo_TestBytePipeOut_r_recv(subreq1, tctx);
+       TALLOC_FREE(subreq1);
+       torture_assert_ntstatus_ok(tctx, status, __location__);
+
+       return true;
+}
 /*
   test request timeouts
 */
@@ -521,6 +572,7 @@ struct torture_suite *torture_rpc_echo(TALLOC_CTX *mem_ctx)
        //torture_rpc_tcase_add_test(tcase, "doublepointer", test_doublepointer);
        //torture_rpc_tcase_add_test(tcase, "sleep", test_sleep);
        torture_rpc_tcase_add_test(tcase, "bytepipein", test_bytepipein);
+       torture_rpc_tcase_add_test(tcase, "bytepipeout", test_bytepipeout);
 #if 0 /* this test needs fixing to work over ncacn_np */
        torture_rpc_tcase_add_test(tcase, "timeout", test_timeout);
 #endif