2 * Unix SMB/CIFS implementation.
4 * Unit test for vfs_gpfs module.
6 * Copyright (C) Christof Schmitt 2020
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.
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.
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/>.
25 static void test_share_deny_mapping(void **state
)
27 assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_NONE
),
28 GPFS_DENY_READ
|GPFS_DENY_WRITE
|GPFS_DENY_DELETE
);
29 assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_READ
),
30 GPFS_DENY_WRITE
|GPFS_DENY_DELETE
);
31 assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_WRITE
),
32 GPFS_DENY_READ
|GPFS_DENY_DELETE
);
33 assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_DELETE
),
34 GPFS_DENY_READ
|GPFS_DENY_WRITE
);
35 assert_int_equal(vfs_gpfs_share_access_to_deny(
36 FILE_SHARE_READ
|FILE_SHARE_DELETE
),
38 assert_int_equal(vfs_gpfs_share_access_to_deny(
39 FILE_SHARE_WRITE
|FILE_SHARE_DELETE
),
41 assert_int_equal(vfs_gpfs_share_access_to_deny(
42 FILE_SHARE_READ
|FILE_SHARE_WRITE
),
43 0); /* GPFS limitation, cannot deny only delete. */
46 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
47 static void test_gpfs_lease_mapping(void **state
)
49 assert_int_equal(lease_type_to_gpfs(F_RDLCK
), GPFS_LEASE_READ
);
50 assert_int_equal(lease_type_to_gpfs(F_WRLCK
), GPFS_LEASE_WRITE
);
51 assert_int_equal(lease_type_to_gpfs(F_UNLCK
), GPFS_LEASE_NONE
);
53 #endif /* #ifdef HAVE_KERNEL_OPLOCKS_LINUX */
55 static void test_gpfs_winattrs_to_dosmode(void **state
)
57 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_ARCHIVE
),
58 FILE_ATTRIBUTE_ARCHIVE
);
59 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_READONLY
),
60 FILE_ATTRIBUTE_READONLY
);
61 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_HIDDEN
),
62 FILE_ATTRIBUTE_HIDDEN
);
63 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_OFFLINE
),
64 FILE_ATTRIBUTE_OFFLINE
);
65 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SPARSE_FILE
),
66 FILE_ATTRIBUTE_SPARSE
);
67 assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SYSTEM
),
68 FILE_ATTRIBUTE_SYSTEM
);
71 static void test_dosmode_to_gpfs_winattrs(void **state
)
73 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_ARCHIVE
),
74 GPFS_WINATTR_ARCHIVE
);
75 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_HIDDEN
),
77 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_OFFLINE
),
78 GPFS_WINATTR_OFFLINE
);
79 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_READONLY
),
80 GPFS_WINATTR_READONLY
);
81 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SPARSE
),
82 GPFS_WINATTR_SPARSE_FILE
);
83 assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SYSTEM
),
87 int main(int argc
, char **argv
)
89 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
),
98 cmocka_set_message_output(CM_OUTPUT_SUBUNIT
);
100 return cmocka_run_group_tests(tests
, NULL
, NULL
);