~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to source4/torture/rpc/async_bind.c

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
   Unix SMB/CIFS implementation.
 
3
 
 
4
   dcerpc torture tests
 
5
 
 
6
   Copyright (C) Andrew Tridgell 2003
 
7
   Copyright (C) Rafal Szczesniak 2006
 
8
 
 
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.
 
13
   
 
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.
 
18
   
 
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/>.
 
21
*/
 
22
 
 
23
#include "includes.h"
 
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"
 
31
 
 
32
/*
 
33
  This test initiates multiple rpc bind requests and verifies
 
34
  whether all of them are served.
 
35
*/
 
36
 
 
37
 
 
38
bool torture_async_bind(struct torture_context *torture)
 
39
{
 
40
        NTSTATUS status;
 
41
        TALLOC_CTX *mem_ctx;
 
42
        int i;
 
43
        const char *binding_string;
 
44
        struct cli_credentials *creds;
 
45
        extern int torture_numasync;
 
46
 
 
47
        struct composite_context **bind_req;
 
48
        struct dcerpc_pipe **pipe;
 
49
        const struct ndr_interface_table **table;
 
50
 
 
51
        if (!torture_setting_bool(torture, "async", false)) {
 
52
                printf("async bind test disabled - enable async tests to use\n");
 
53
                return true;
 
54
        }
 
55
        
 
56
        binding_string = torture_setting_string(torture, "binding", NULL);
 
57
 
 
58
        /* talloc context */
 
59
        mem_ctx = talloc_init("torture_async_bind");
 
60
        if (mem_ctx == NULL) return false;
 
61
 
 
62
        bind_req = talloc_array(torture, struct composite_context*, torture_numasync);
 
63
        if (bind_req == NULL) return false;
 
64
        pipe     = talloc_array(torture, struct dcerpc_pipe*, torture_numasync);
 
65
        if (pipe == NULL) return false;
 
66
        table    = talloc_array(torture, const struct ndr_interface_table*, torture_numasync);
 
67
        if (table == NULL) return false;
 
68
        
 
69
        /* credentials */
 
70
        creds = cmdline_credentials;
 
71
 
 
72
        /* send bind requests */
 
73
        for (i = 0; i < torture_numasync; i++) {
 
74
                table[i] = &ndr_table_lsarpc;
 
75
                bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
 
76
                                                       table[i], creds, torture->ev, torture->lp_ctx);
 
77
        }
 
78
 
 
79
        /* recv bind requests */
 
80
        for (i = 0; i < torture_numasync; i++) {
 
81
                status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]);
 
82
                if (!NT_STATUS_IS_OK(status)) {
 
83
                        printf("async rpc connection failed: %s\n", nt_errstr(status));
 
84
                        return false;
 
85
                }
 
86
        }
 
87
 
 
88
        talloc_free(mem_ctx);
 
89
        return true;
 
90
}