1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

python/tests: Fix nlink test in smb3unix on btrfs filesystem

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Tue May 14 13:37:53 UTC 2024 on atb-devel-224
This commit is contained in:
Pavel Filipenský 2024-05-13 12:13:38 +02:00 committed by Pavel Filipensky
parent 1ca6fb563b
commit 833c3f26b4

View File

@ -24,6 +24,7 @@ from samba.dcerpc import smb3posix
from samba.ndr import ndr_unpack
from samba.dcerpc.security import dom_sid
import os
import subprocess
def posix_context(mode):
return (libsmb.SMB2_CREATE_TAG_POSIX, mode.to_bytes(4, 'little'))
@ -34,6 +35,9 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
super().setUp()
self.samsid = os.environ["SAMSID"]
prefix_abs = os.environ["PREFIX_ABS"]
p = subprocess.run(['stat', '-f', '-c', '%T', prefix_abs], capture_output=True, text=True)
self.fstype = p.stdout.strip().lower()
def connections(self, share1=None, posix1=False, share2=None, posix2=True):
if not share1:
@ -303,7 +307,11 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
self.assertEqual(found_files[fname]['attrib'],
libsmb.FILE_ATTRIBUTE_ARCHIVE)
else:
self.assertEqual(found_files[fname]['nlink'], 2)
# Note: btrfs always reports the link count of directories as one.
if self.fstype == "btrfs":
self.assertEqual(found_files[fname]['nlink'], 1)
else:
self.assertEqual(found_files[fname]['nlink'], 2)
self.assertEqual(found_files[fname]['attrib'],
libsmb.FILE_ATTRIBUTE_DIRECTORY)
@ -368,9 +376,11 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
cc = ndr_unpack(smb3posix.smb3_posix_cc_info, cc_out[0][1])
# Note: this fails on btrfs which always reports the link
# count of directories as one.
self.assertEqual(cc.nlinks, 2)
# Note: btrfs always reports the link count of directories as one.
if self.fstype == "btrfs":
self.assertEqual(cc.nlinks, 1)
else:
self.assertEqual(cc.nlinks, 2)
self.assertEqual(cc.reparse_tag, libsmb.IO_REPARSE_TAG_RESERVED_ZERO)
self.assertEqual(cc.posix_perms, 0o700)