LCOV - code coverage report
Current view: top level - source3/modules - test_vfs_gpfs.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 34 34 100.0 %
Date: 2024-04-21 15:09:00 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *
       4             :  *  Unit test for vfs_gpfs module.
       5             :  *
       6             :  *  Copyright (C) Christof Schmitt 2020
       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 "vfs_gpfs.c"
      23             : #include <cmocka.h>
      24             : 
      25           1 : static void test_share_deny_mapping(void **state)
      26             : {
      27           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_NONE),
      28             :                          GPFS_DENY_READ|GPFS_DENY_WRITE|GPFS_DENY_DELETE);
      29           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_READ),
      30             :                          GPFS_DENY_WRITE|GPFS_DENY_DELETE);
      31           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_WRITE),
      32             :                          GPFS_DENY_READ|GPFS_DENY_DELETE);
      33           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_DELETE),
      34             :                          GPFS_DENY_READ|GPFS_DENY_WRITE);
      35           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(
      36             :                                  FILE_SHARE_READ|FILE_SHARE_DELETE),
      37             :                          GPFS_DENY_WRITE);
      38           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(
      39             :                                  FILE_SHARE_WRITE|FILE_SHARE_DELETE),
      40             :                          GPFS_DENY_READ);
      41           1 :         assert_int_equal(vfs_gpfs_share_access_to_deny(
      42             :                                  FILE_SHARE_READ|FILE_SHARE_WRITE),
      43             :                          0); /* GPFS limitation, cannot deny only delete. */
      44           1 : }
      45             : 
      46             : #ifdef HAVE_KERNEL_OPLOCKS_LINUX
      47           1 : static void test_gpfs_lease_mapping(void **state)
      48             : {
      49           1 :         assert_int_equal(lease_type_to_gpfs(F_RDLCK), GPFS_LEASE_READ);
      50           1 :         assert_int_equal(lease_type_to_gpfs(F_WRLCK), GPFS_LEASE_WRITE);
      51           1 :         assert_int_equal(lease_type_to_gpfs(F_UNLCK), GPFS_LEASE_NONE);
      52           1 : }
      53             : #endif /* #ifdef HAVE_KERNEL_OPLOCKS_LINUX */
      54             : 
      55           1 : static void test_gpfs_winattrs_to_dosmode(void **state)
      56             : {
      57           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_ARCHIVE),
      58             :                          FILE_ATTRIBUTE_ARCHIVE);
      59           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_READONLY),
      60             :                          FILE_ATTRIBUTE_READONLY);
      61           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_HIDDEN),
      62             :                          FILE_ATTRIBUTE_HIDDEN);
      63           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_OFFLINE),
      64             :                          FILE_ATTRIBUTE_OFFLINE);
      65           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SPARSE_FILE),
      66             :                          FILE_ATTRIBUTE_SPARSE);
      67           1 :         assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SYSTEM),
      68             :                          FILE_ATTRIBUTE_SYSTEM);
      69           1 : }
      70             : 
      71           1 : static void test_dosmode_to_gpfs_winattrs(void **state)
      72             : {
      73           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_ARCHIVE),
      74             :                          GPFS_WINATTR_ARCHIVE);
      75           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_HIDDEN),
      76             :                          GPFS_WINATTR_HIDDEN);
      77           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_OFFLINE),
      78             :                          GPFS_WINATTR_OFFLINE);
      79           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_READONLY),
      80             :                          GPFS_WINATTR_READONLY);
      81           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SPARSE),
      82             :                          GPFS_WINATTR_SPARSE_FILE);
      83           1 :         assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SYSTEM),
      84             :                          GPFS_WINATTR_SYSTEM);
      85           1 : }
      86             : 
      87           1 : int main(int argc, char **argv)
      88             : {
      89           1 :         const struct CMUnitTest tests[] = {
      90             :                 cmocka_unit_test(test_share_deny_mapping),
      91             : #ifdef HAVE_KERNEL_OPLOCKS_LINUX
      92             :                 cmocka_unit_test(test_gpfs_lease_mapping),
      93             : #endif /* #ifdef HAVE_KERNEL_OPLOCKS_LINUX */
      94             :                 cmocka_unit_test(test_gpfs_winattrs_to_dosmode),
      95             :                 cmocka_unit_test(test_dosmode_to_gpfs_winattrs),
      96             :         };
      97             : 
      98           1 :         cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
      99             : 
     100           1 :         return cmocka_run_group_tests(tests, NULL, NULL);
     101             : }

Generated by: LCOV version 1.14