LCOV - code coverage report
Current view: top level - source4/torture/local - torture.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 30 33 90.9 %
Date: 2021-09-23 10:06:22 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    local testing of torture
       5             : 
       6             :    Copyright (C) Jelmer Vernooij 2006
       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 "system/wait.h"
      24             : #include "libcli/raw/libcliraw.h"
      25             : #include "torture/util.h"
      26             : #include "torture/local/proto.h"
      27             : #include "param/provision.h"
      28             : 
      29           1 : static bool test_tempdir(struct torture_context *tctx)
      30             : {
      31           1 :         char *location = NULL;
      32           1 :         TALLOC_CTX *mem_ctx = tctx;
      33             :         
      34           1 :         torture_assert_ntstatus_ok(tctx, torture_temp_dir(mem_ctx, "tempdir", &location), 
      35             :                                                                 "torture_temp_dir should return NT_STATUS_OK" );
      36             : 
      37           1 :         torture_assert(tctx, directory_exist(location), 
      38             :                                    "created dir doesn't exist");
      39           0 :         return true;
      40             : }
      41             : 
      42           1 : static bool test_provision(struct torture_context *tctx)
      43             : {
      44             :         NTSTATUS status;
      45           1 :         struct provision_settings *settings = talloc_zero(tctx, struct provision_settings);
      46             :         struct provision_result result;
      47           1 :         char *targetdir = NULL;
      48             : 
      49           1 :         torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &targetdir), 
      50             :                                    "torture_temp_dir should return NT_STATUS_OK" );
      51           1 :         settings->targetdir = talloc_steal(settings, targetdir);
      52             : 
      53           1 :         settings->site_name = "SOME-SITE-NAME";
      54           1 :         settings->root_dn_str = "DC=EXAMPLE,DC=COM";
      55           1 :         settings->domain_dn_str = "DC=EXAMPLE,DC=COM";
      56           1 :         settings->config_dn_str = NULL;
      57           1 :         settings->schema_dn_str = NULL;
      58           1 :         settings->invocation_id = NULL;
      59           0 :         settings->netbios_name = "FOO";
      60           1 :         settings->realm = "EXAMPLE.COM";
      61           1 :         settings->domain = "EXAMPLE";
      62           1 :         settings->netbios_name = "torture";
      63           1 :         settings->ntds_dn_str = NULL;
      64           1 :         settings->machine_password = "geheim";
      65           1 :         settings->use_ntvfs = true;
      66             : 
      67           1 :         status = provision_bare(settings, tctx->lp_ctx, settings, &result);
      68             :                         
      69           1 :         torture_assert_ntstatus_ok(tctx, status, "provision");
      70             : 
      71           1 :         torture_assert_str_equal(tctx, result.domaindn, "DC=EXAMPLE,DC=COM", 
      72             :                                  "domaindn incorrect");
      73             : 
      74           0 :         return true;
      75             : }
      76             : 
      77        2355 : struct torture_suite *torture_local_torture(TALLOC_CTX *mem_ctx)
      78             : {
      79        2355 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "torture");
      80             : 
      81        2355 :         torture_suite_add_simple_test(suite, "tempdir", test_tempdir);
      82        2355 :         torture_suite_add_simple_test(suite, "provision", test_provision);
      83             : 
      84        2355 :         return suite;
      85             : }

Generated by: LCOV version 1.13