LCOV - code coverage report
Current view: top level - source4/torture/rpc - async_bind.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 4 34 11.8 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       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 "librpc/gen_ndr/ndr_lsa.h"
      25             : #include "lib/cmdline/cmdline.h"
      26             : #include "torture/rpc/torture_rpc.h"
      27             : 
      28             : /*
      29             :   This test initiates multiple rpc bind requests and verifies
      30             :   whether all of them are served.
      31             : */
      32             : 
      33             : 
      34          15 : bool torture_async_bind(struct torture_context *torture)
      35             : {
      36           0 :         NTSTATUS status;
      37           0 :         TALLOC_CTX *mem_ctx;
      38           0 :         int i;
      39           0 :         const char *binding_string;
      40           0 :         struct cli_credentials *creds;
      41           0 :         extern int torture_numasync;
      42             : 
      43           0 :         struct composite_context **bind_req;
      44           0 :         struct dcerpc_pipe **pipes;
      45           0 :         const struct ndr_interface_table **table;
      46             : 
      47          15 :         if (!torture_setting_bool(torture, "async", false)) {
      48          15 :                 printf("async bind test disabled - enable async tests to use\n");
      49          15 :                 return true;
      50             :         }
      51             :         
      52           0 :         binding_string = torture_setting_string(torture, "binding", NULL);
      53             : 
      54             :         /* talloc context */
      55           0 :         mem_ctx = talloc_init("torture_async_bind");
      56           0 :         if (mem_ctx == NULL) return false;
      57             : 
      58           0 :         bind_req = talloc_array(torture, struct composite_context*, torture_numasync);
      59           0 :         if (bind_req == NULL) return false;
      60           0 :         pipes    = talloc_array(torture, struct dcerpc_pipe*, torture_numasync);
      61           0 :         if (pipes == NULL) return false;
      62           0 :         table    = talloc_array(torture, const struct ndr_interface_table*, torture_numasync);
      63           0 :         if (table == NULL) return false;
      64             :         
      65             :         /* credentials */
      66           0 :         creds = samba_cmdline_get_creds();
      67             : 
      68             :         /* send bind requests */
      69           0 :         for (i = 0; i < torture_numasync; i++) {
      70           0 :                 table[i] = &ndr_table_lsarpc;
      71           0 :                 bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
      72           0 :                                                        table[i], creds, torture->ev, torture->lp_ctx);
      73             :         }
      74             : 
      75             :         /* recv bind requests */
      76           0 :         for (i = 0; i < torture_numasync; i++) {
      77           0 :                 status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipes[i]);
      78           0 :                 if (!NT_STATUS_IS_OK(status)) {
      79           0 :                         printf("async rpc connection failed: %s\n", nt_errstr(status));
      80           0 :                         return false;
      81             :                 }
      82             :         }
      83             : 
      84           0 :         talloc_free(mem_ctx);
      85           0 :         return true;
      86             : }

Generated by: LCOV version 1.14