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 3 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, see <http://www.gnu.org/licenses/>.
24 #include "torture/torture.h"
25 #include "lib/events/events.h"
26 #include "libcli/composite/composite.h"
27 #include "librpc/gen_ndr/ndr_lsa.h"
28 #include "lib/cmdline/popt_common.h"
29 #include "librpc/rpc/dcerpc.h"
30 #include "torture/rpc/rpc.h"
33 This test initiates multiple rpc bind requests and verifies
34 whether all of them are served.
38 BOOL torture_async_bind(struct torture_context *torture)
42 struct event_context *evt_ctx;
44 const char *binding_string;
45 struct cli_credentials *creds;
46 extern int torture_numasync;
48 struct composite_context **bind_req;
49 struct dcerpc_pipe **pipe;
50 const struct ndr_interface_table **table;
52 if (!torture_setting_bool(torture, "async", False)) {
53 printf("async bind test disabled - enable async tests to use\n");
57 binding_string = torture_setting_string(torture, "binding", NULL);
60 mem_ctx = talloc_init("torture_async_bind");
61 if (mem_ctx == NULL) return False;
63 bind_req = talloc_array(torture, struct composite_context*, torture_numasync);
64 if (bind_req == NULL) return False;
65 pipe = talloc_array(torture, struct dcerpc_pipe*, torture_numasync);
66 if (pipe == NULL) return False;
67 table = talloc_array(torture, const struct ndr_interface_table*, torture_numasync);
68 if (table == NULL) return False;
71 creds = cmdline_credentials;
74 evt_ctx = cli_credentials_get_event_context(creds);
75 if (evt_ctx == NULL) return False;
77 /* send bind requests */
78 for (i = 0; i < torture_numasync; i++) {
79 table[i] = &ndr_table_lsarpc;
80 bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
81 table[i], creds, evt_ctx);
84 /* recv bind requests */
85 for (i = 0; i < torture_numasync; i++) {
86 status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]);
87 if (!NT_STATUS_IS_OK(status)) {
88 printf("async rpc connection failed: %s\n", nt_errstr(status));