LCOV - code coverage report
Current view: top level - source3/torture - test_case_insensitive.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 20 37 54.1 %
Date: 2024-02-28 12:06:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    reproducer for bug 8042
       4             :    Copyright (C) Volker Lendecke 2011
       5             : 
       6             :    This program is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU General Public License as published by
       8             :    the Free Software Foundation; either version 3 of the License, or
       9             :    (at your option) any later version.
      10             : 
      11             :    This program is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU General Public License
      17             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      18             : */
      19             : 
      20             : #include "includes.h"
      21             : #include "torture/proto.h"
      22             : #include "system/filesys.h"
      23             : #include "libsmb/libsmb.h"
      24             : 
      25             : /*
      26             :  * Regression test file creates on case insensitive file systems (e.g. OS/X)
      27             :  * https://bugzilla.samba.org/show_bug.cgi?id=8042
      28             :  */
      29             : 
      30           5 : bool run_case_insensitive_create(int dummy)
      31             : {
      32           0 :         struct cli_state *cli;
      33           0 :         uint16_t fnum;
      34           0 :         NTSTATUS status;
      35             : 
      36           5 :         printf("Starting case_insensitive_create\n");
      37             : 
      38           5 :         if (!torture_open_connection(&cli, 0)) {
      39           0 :                 return false;
      40             :         }
      41             : 
      42           5 :         status = cli_mkdir(cli, "x");
      43           5 :         if (!NT_STATUS_IS_OK(status)) {
      44           0 :                 printf("cli_mkdir failed: %s\n", nt_errstr(status));
      45           0 :                 goto done;
      46             :         }
      47           5 :         status = cli_chkpath(cli, "X");
      48           5 :         if (!NT_STATUS_IS_OK(status)) {
      49           0 :                 printf("cli_chkpath failed: %s\n", nt_errstr(status));
      50           0 :                 goto rmdir;
      51             :         }
      52           5 :         status = cli_openx(cli, "x\\y", O_RDWR|O_CREAT, 0, &fnum);
      53           5 :         if (!NT_STATUS_IS_OK(status)) {
      54           0 :                 printf("cli_openx failed: %s\n", nt_errstr(status));
      55             : 
      56           0 :                 if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
      57           0 :                         printf("Bug 8042 reappeared!!\n");
      58             :                 }
      59           0 :                 goto unlink;
      60             :         }
      61           5 :         status = cli_close(cli, fnum);
      62           5 :         if (!NT_STATUS_IS_OK(status)) {
      63           0 :                 printf("cli_close failed: %s\n", nt_errstr(status));
      64           0 :                 goto done;
      65             :         }
      66           5 : unlink:
      67           5 :         status = cli_unlink(cli, "x\\y", 0);
      68           5 :         if (!NT_STATUS_IS_OK(status)) {
      69           0 :                 printf("cli_unlink failed: %s\n", nt_errstr(status));
      70           0 :                 goto done;
      71             :         }
      72           5 : rmdir:
      73           5 :         status = cli_rmdir(cli, "x");
      74           5 :         if (!NT_STATUS_IS_OK(status)) {
      75           0 :                 printf("cli_close failed: %s\n", nt_errstr(status));
      76             :         }
      77           5 : done:
      78           5 :         torture_close_connection(cli);
      79           5 :         return NT_STATUS_IS_OK(status);
      80             : }

Generated by: LCOV version 1.14