[SCM] Samba Shared Repository - branch master updated

Christof Schmitt cs at samba.org
Tue Sep 8 22:58:02 UTC 2020


The branch, master has been updated
       via  b65fbade02f test_vfs_gpfs: Add test for file id generation
       via  c94ea50b241 test_vfs_gpfs: Add test for winattr mappings
       via  5cfe884b393 test_vfs_gpfs: Add test for lease mapping function
       via  fd7b77f4d29 selftest: Add unit test for vfs_gpfs
       via  80add26b5f6 selftest: Add function for checking whether a module is enabled
       via  99565d2a8d9 wscript: Make list of shared modules available in STRING_SHARED_MODULES
      from  0022cd94587 lib/replace: move lib/replace/closefrom.c from ROKEN_HOSTCC_SOURCE to REPLACE_HOSTCC_SOURCE

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b65fbade02fa128c80cc5cd7ba6dd5b53ded0e20
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Aug 18 14:54:09 2020 -0700

    test_vfs_gpfs: Add test for file id generation
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Christof Schmitt <cs at samba.org>
    Autobuild-Date(master): Tue Sep  8 22:57:03 UTC 2020 on sn-devel-184

commit c94ea50b24141ae79a606c353f66eed1eea68b26
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Aug 18 14:17:32 2020 -0700

    test_vfs_gpfs: Add test for winattr mappings
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5cfe884b39327d5208d4d7059b242e9c3dd881e5
Author: Christof Schmitt <cs at samba.org>
Date:   Tue Aug 18 13:54:07 2020 -0700

    test_vfs_gpfs: Add test for lease mapping function
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fd7b77f4d29f3306f08f25e1f4a62f3bd89dc6e9
Author: Christof Schmitt <cs at samba.org>
Date:   Fri Feb 21 16:52:08 2020 +0100

    selftest: Add unit test for vfs_gpfs
    
    The mapping functions of the vfs_gpfs module can be easily unit tested.
    Begin a cmocka test to cover those.
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 80add26b5f6866210d6a2c63d1086e92d83ca3df
Author: Christof Schmitt <cs at samba.org>
Date:   Wed Aug 19 11:54:43 2020 -0700

    selftest: Add function for checking whether a module is enabled
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 99565d2a8d9fa22433698d6c2af87ea5b7fae5e6
Author: Christof Schmitt <cs at samba.org>
Date:   Wed Aug 19 11:48:55 2020 -0700

    wscript: Make list of shared modules available in STRING_SHARED_MODULES
    
    Signed-off-by: Christof Schmitt <cs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/test_vfs_gpfs.c | 151 ++++++++++++++++++++++++++++++++++++++++
 source3/modules/wscript_build   |   7 ++
 source3/selftest/tests.py       |  10 +++
 source3/wscript                 |   1 +
 4 files changed, 169 insertions(+)
 create mode 100644 source3/modules/test_vfs_gpfs.c


Changeset truncated at 500 lines:

diff --git a/source3/modules/test_vfs_gpfs.c b/source3/modules/test_vfs_gpfs.c
new file mode 100644
index 00000000000..58f3c41934a
--- /dev/null
+++ b/source3/modules/test_vfs_gpfs.c
@@ -0,0 +1,151 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *
+ *  Unit test for vfs_gpfs module.
+ *
+ *  Copyright (C) Christof Schmitt 2020
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "vfs_gpfs.c"
+#include <cmocka.h>
+
+static void test_share_deny_mapping(void **state)
+{
+	assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_NONE),
+			 GPFS_DENY_READ|GPFS_DENY_WRITE|GPFS_DENY_DELETE);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_READ),
+			 GPFS_DENY_WRITE|GPFS_DENY_DELETE);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_WRITE),
+			 GPFS_DENY_READ|GPFS_DENY_DELETE);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(FILE_SHARE_DELETE),
+			 GPFS_DENY_READ|GPFS_DENY_WRITE);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(
+				 FILE_SHARE_READ|FILE_SHARE_DELETE),
+			 GPFS_DENY_WRITE);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(
+				 FILE_SHARE_WRITE|FILE_SHARE_DELETE),
+			 GPFS_DENY_READ);
+	assert_int_equal(vfs_gpfs_share_access_to_deny(
+				 FILE_SHARE_READ|FILE_SHARE_WRITE),
+			 0); /* GPFS limitation, cannot deny only delete. */
+}
+
+static void test_gpfs_lease_mapping(void **state)
+{
+	assert_int_equal(lease_type_to_gpfs(F_RDLCK), GPFS_LEASE_READ);
+	assert_int_equal(lease_type_to_gpfs(F_WRLCK), GPFS_LEASE_WRITE);
+	assert_int_equal(lease_type_to_gpfs(F_UNLCK), GPFS_LEASE_NONE);
+}
+
+static void test_gpfs_winattrs_to_dosmode(void **state)
+{
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_ARCHIVE),
+			 FILE_ATTRIBUTE_ARCHIVE);
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_READONLY),
+			 FILE_ATTRIBUTE_READONLY);
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_HIDDEN),
+			 FILE_ATTRIBUTE_HIDDEN);
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_OFFLINE),
+			 FILE_ATTRIBUTE_OFFLINE);
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SPARSE_FILE),
+			 FILE_ATTRIBUTE_SPARSE);
+	assert_int_equal(vfs_gpfs_winattrs_to_dosmode(GPFS_WINATTR_SYSTEM),
+			 FILE_ATTRIBUTE_SYSTEM);
+}
+
+static void test_dosmode_to_gpfs_winattrs(void **state)
+{
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_ARCHIVE),
+			 GPFS_WINATTR_ARCHIVE);
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_HIDDEN),
+			 GPFS_WINATTR_HIDDEN);
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_OFFLINE),
+			 GPFS_WINATTR_OFFLINE);
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_READONLY),
+			 GPFS_WINATTR_READONLY);
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SPARSE),
+			 GPFS_WINATTR_SPARSE_FILE);
+	assert_int_equal(vfs_gpfs_dosmode_to_winattrs(FILE_ATTRIBUTE_SYSTEM),
+			 GPFS_WINATTR_SYSTEM);
+}
+
+static void test_gpfs_get_file_id(void **state)
+{
+	struct gpfs_iattr64 iattr;
+	uint64_t fileid1, fileid2;
+	NTSTATUS status;
+
+	/*
+	 * Ensure that the generated fileid only depends on the
+	 * ia_inode, ia_gen and ia_modsnapid fields in struct
+	 * gpfs_iattr64 and any changes to these fields result in a
+	 * different file id.
+	 */
+
+	memset(&iattr, 1, sizeof(iattr));
+	iattr.ia_inode = 0x11;
+	iattr.ia_gen = 0x22;
+	iattr.ia_modsnapid = 0x33;
+	status = vfs_gpfs_get_file_id(&iattr, &fileid1);
+	assert_true(NT_STATUS_IS_OK(status));
+
+	memset(&iattr, 2, sizeof(iattr));
+	iattr.ia_inode = 0x11;
+	iattr.ia_gen = 0x22;
+	iattr.ia_modsnapid = 0x33;
+	status = vfs_gpfs_get_file_id(&iattr, &fileid2);
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_int_equal(fileid1, fileid2);
+
+	iattr.ia_inode = 0x44;
+	iattr.ia_gen = 0x22;
+	iattr.ia_modsnapid = 0x33;
+	status = vfs_gpfs_get_file_id(&iattr, &fileid2);
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_int_not_equal(fileid1, fileid2);
+
+	iattr.ia_inode = 0x11;
+	iattr.ia_gen = 0x44;
+	iattr.ia_modsnapid = 0x33;
+	status = vfs_gpfs_get_file_id(&iattr, &fileid2);
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_int_not_equal(fileid1, fileid2);
+
+	iattr.ia_inode = 0x11;
+	iattr.ia_gen = 0x22;
+	iattr.ia_modsnapid = 0x44;
+	status = vfs_gpfs_get_file_id(&iattr, &fileid2);
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_true(NT_STATUS_IS_OK(status));
+	assert_int_not_equal(fileid1, fileid2);
+}
+
+int main(int argc, char **argv)
+{
+	const struct CMUnitTest tests[] = {
+		cmocka_unit_test(test_share_deny_mapping),
+		cmocka_unit_test(test_gpfs_lease_mapping),
+		cmocka_unit_test(test_gpfs_winattrs_to_dosmode),
+		cmocka_unit_test(test_dosmode_to_gpfs_winattrs),
+		cmocka_unit_test(test_gpfs_get_file_id),
+	};
+
+	cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
+
+	return cmocka_run_group_tests(tests, NULL, NULL);
+}
diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build
index 2b1f264bab5..c4f3db22296 100644
--- a/source3/modules/wscript_build
+++ b/source3/modules/wscript_build
@@ -370,6 +370,13 @@ bld.SAMBA3_MODULE('vfs_gpfs',
                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs'),
                  includes=bld.CONFIG_GET('CPPPATH_GPFS'))
 
+bld.SAMBA3_BINARY('test_vfs_gpfs',
+                  source='test_vfs_gpfs.c',
+                  deps='NFS4_ACLS non_posix_acls gpfswrap cmocka',
+                  for_selftest=True,
+                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_gpfs'),
+                  includes=bld.CONFIG_GET('CPPPATH_GPFS'))
+
 bld.SAMBA3_MODULE('vfs_readahead',
                  subsystem='vfs',
                  source='vfs_readahead.c',
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 556b50c38f5..a8e8be8eb87 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -70,6 +70,12 @@ have_inotify = ("HAVE_INOTIFY" in config_hash)
 have_ldwrap = ("HAVE_LDWRAP" in config_hash)
 with_pthreadpool = ("WITH_PTHREADPOOL" in config_hash)
 
+def is_module_enabled(module):
+    if module in config_hash["STRING_SHARED_MODULES"]:
+        return True
+    if module in config_hash["STRING_STATIC_MODULES"]:
+        return True
+    return False
 
 plantestsuite("samba3.blackbox.success", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/test_success.sh")])
 plantestsuite("samba3.blackbox.failure", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/test_failure.sh")])
@@ -565,6 +571,10 @@ plantestsuite("samba3.test_vfs_posixacl", "none",
               [os.path.join(bindir(), "test_vfs_posixacl"),
                "$SMB_CONF_PATH"])
 
+if is_module_enabled("vfs_gpfs"):
+    plantestsuite("samba3.test_vfs_gpfs", "none",
+                  [os.path.join(bindir(), "test_vfs_gpfs")])
+
 plantestsuite(
     "samba3.resolvconf", "none",
     [os.path.join(samba3srcdir, "script/tests/test_resolvconf.sh")])
diff --git a/source3/wscript b/source3/wscript
index 4ad7a883701..840ed430c0f 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -2093,6 +2093,7 @@ main() {
     conf.env['shared_modules'] = final_shared_modules
 
     conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
+    conf.DEFINE('STRING_SHARED_MODULES', ' '.join(final_shared_modules), quote=True)
 
     static_list = {}
     shared_list = {}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list