2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Rafal Szczesniak 2006
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "torture/torture.h"
26 #include "lib/events/events.h"
27 #include "libcli/composite/composite.h"
28 #include "librpc/gen_ndr/ndr_lsa.h"
29 #include "lib/cmdline/popt_common.h"
30 #include "librpc/rpc/dcerpc.h"
31 #include "torture/rpc/rpc.h"
34 This test initiates multiple rpc bind requests and verifies
35 whether all of them are served.
39 BOOL torture_async_bind(struct torture_context *torture)
43 struct event_context *evt_ctx;
45 const char *binding_string;
46 struct cli_credentials *creds;
47 extern int torture_numasync;
49 struct composite_context **bind_req;
50 struct dcerpc_pipe **pipe;
51 const struct dcerpc_interface_table **table;
53 if (!torture_setting_bool(torture, "async", False)) {
54 printf("async bind test disabled - enable async tests to use\n");
58 binding_string = torture_setting_string(torture, "binding", NULL);
61 mem_ctx = talloc_init("torture_async_bind");
62 if (mem_ctx == NULL) return False;
64 bind_req = talloc_array(torture, struct composite_context*, torture_numasync);
65 if (bind_req == NULL) return False;
66 pipe = talloc_array(torture, struct dcerpc_pipe*, torture_numasync);
67 if (pipe == NULL) return False;
68 table = talloc_array(torture, const struct dcerpc_interface_table*, torture_numasync);
69 if (table == NULL) return False;
72 evt_ctx = event_context_init(mem_ctx);
73 if (evt_ctx == NULL) return False;
76 creds = cmdline_credentials;
78 /* send bind requests */
79 for (i = 0; i < torture_numasync; i++) {
80 table[i] = &dcerpc_table_lsarpc;
81 bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
82 table[i], creds, evt_ctx);
85 /* recv bind requests */
86 for (i = 0; i < torture_numasync; i++) {
87 status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]);
88 if (!NT_STATUS_IS_OK(status)) {
89 printf("async rpc connection failed: %s\n", nt_errstr(status));