LCOV - code coverage report
Current view: top level - source4/torture/rpc - initshutdown.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 8 46 17.4 %
Date: 2021-09-23 10:06:22 Functions: 1 6 16.7 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             :    test suite for initshutdown operations
       4             : 
       5             :    Copyright (C) Tim Potter 2003
       6             :    Copyright (C) Jelmer Vernooij 2004-2005
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "librpc/gen_ndr/ndr_initshutdown_c.h"
      24             : #include "torture/rpc/torture_rpc.h"
      25             : 
      26           0 : static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
      27             : {
      28           0 :         name->string = s;
      29           0 : }
      30             : 
      31             : 
      32           0 : static bool test_Abort(struct torture_context *tctx, 
      33             :                                            struct dcerpc_pipe *p)
      34             : {
      35             :         struct initshutdown_Abort r;
      36             :         NTSTATUS status;
      37           0 :         uint16_t server = 0x0;
      38           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
      39             : 
      40           0 :         r.in.server = &server;
      41             :         
      42           0 :         status = dcerpc_initshutdown_Abort_r(b, tctx, &r);
      43             : 
      44           0 :         torture_assert_ntstatus_ok(tctx, status, 
      45             :                                                            "initshutdown_Abort failed");
      46             : 
      47           0 :         torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Abort failed");
      48             : 
      49           0 :         return true;
      50             : }
      51             : 
      52           0 : static bool test_Init(struct torture_context *tctx, 
      53             :                       struct dcerpc_pipe *p)
      54             : {
      55             :         struct initshutdown_Init r;
      56             :         NTSTATUS status;
      57           0 :         uint16_t hostname = 0x0;
      58           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
      59             : 
      60           0 :         r.in.hostname = &hostname;
      61           0 :         r.in.message = talloc(tctx, struct lsa_StringLarge);
      62           0 :         init_lsa_StringLarge(r.in.message, "spottyfood");
      63           0 :         r.in.force_apps = 1;
      64           0 :         r.in.timeout = 30;
      65           0 :         r.in.do_reboot = 1;
      66             : 
      67           0 :         status = dcerpc_initshutdown_Init_r(b, tctx, &r);
      68             : 
      69           0 :         torture_assert_ntstatus_ok(tctx, status, "initshutdown_Init failed");
      70           0 :         torture_assert_werr_ok(tctx, r.out.result, "initshutdown_Init failed");
      71             : 
      72           0 :         return test_Abort(tctx, p);
      73             : }
      74             : 
      75           0 : static bool test_InitEx(struct torture_context *tctx, 
      76             :                                                 struct dcerpc_pipe *p)
      77             : {
      78             :         struct initshutdown_InitEx r;
      79             :         NTSTATUS status;
      80           0 :         uint16_t hostname = 0x0;
      81           0 :         struct dcerpc_binding_handle *b = p->binding_handle;
      82             : 
      83           0 :         r.in.hostname = &hostname;
      84           0 :         r.in.message = talloc(tctx, struct lsa_StringLarge);
      85           0 :         init_lsa_StringLarge(r.in.message, "spottyfood");
      86           0 :         r.in.force_apps = 1;
      87           0 :         r.in.timeout = 30;
      88           0 :         r.in.do_reboot = 1;
      89           0 :         r.in.reason = 0;
      90             : 
      91           0 :         status = dcerpc_initshutdown_InitEx_r(b, tctx, &r);
      92             : 
      93           0 :         torture_assert_ntstatus_ok(tctx, status, "initshutdown_InitEx failed");
      94             : 
      95           0 :         torture_assert_werr_ok(tctx, r.out.result, "initshutdown_InitEx failed");
      96             : 
      97           0 :         return test_Abort(tctx, p);
      98             : }
      99             : 
     100             : 
     101        2355 : struct torture_suite *torture_rpc_initshutdown(TALLOC_CTX *mem_ctx)
     102             : {
     103        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "initshutdown");
     104             :         struct torture_rpc_tcase *tcase;
     105             :         struct torture_test *test;
     106             : 
     107        2355 :         tcase = torture_suite_add_rpc_iface_tcase(suite, "initshutdown", 
     108             :                                                   &ndr_table_initshutdown);
     109             : 
     110        2355 :         test = torture_rpc_tcase_add_test(tcase, "Init", test_Init);
     111        2355 :         test->dangerous = true;
     112        2355 :         test = torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx);
     113        2355 :         test->dangerous = true;
     114             : 
     115        2355 :         return suite;
     116             : }

Generated by: LCOV version 1.13