Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
netheril96 committed Mar 10, 2024
1 parent d21a842 commit 656d0af
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 44 deletions.
3 changes: 2 additions & 1 deletion sources/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,8 @@ class MountCommand : public _SinglePasswordCommandBase
#ifdef __APPLE__
if (native_xattr)
{
auto rc = OSService::get_default().listxattr(data_dir.getValue(), nullptr, 0);
auto rc
= OSService::get_default().listxattr(data_dir.getValue().c_str(), nullptr, 0);
if (rc < 0)
{
absl::FPrintF(stderr,
Expand Down
93 changes: 50 additions & 43 deletions test/simple_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,54 +342,61 @@ def unmount(cls):
securefs_unmount(cls.securefs_process, cls.mount_point)
cls.securefs_process = None

def test_long_name(self):
os.mkdir(os.path.join(self.mount_point, "k" * 200))
os.mkdir(os.path.join(self.mount_point, "k" * 200, "✅" * 70))
with open(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "c" * 222), "w"
) as f:
f.write("test" * 70)
os.rename(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "c" * 222),
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "d" * 222),
)
self.assertSetEqual(
set(os.listdir(os.path.join(self.mount_point, "k" * 200, "✅" * 70))),
{"d" * 222},
)
os.rename(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "d" * 222),
os.path.join(self.mount_point, "k" * 200, "🎈" * 70),
)
self.assertIn(
"🎈" * 70,
set(os.listdir(os.path.join(self.mount_point, "k" * 200))),
)
st = os.stat(os.path.join(self.mount_point, "k" * 200, "🎈" * 70))
self.assertEquals(st.st_size, 4 * 70)
os.rename(
os.path.join(self.mount_point, "k" * 200, "🎈" * 70),
os.path.join(self.mount_point, "k" * 200, "🎈" * 2),
)
if sys.platform != "win32":
os.symlink(
"/bcd" * 20, os.path.join(self.mount_point, "k" * 200, "🔼" * 64)
if version == 4:

def test_long_name(self):
os.mkdir(os.path.join(self.mount_point, "k" * 200))
os.mkdir(os.path.join(self.mount_point, "k" * 200, "✅" * 70))
with open(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "c" * 222), "w"
) as f:
f.write("test" * 70)
os.rename(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "c" * 222),
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "d" * 222),
)
self.assertEquals(
"/bcd" * 20,
os.readlink(os.path.join(self.mount_point, "k" * 200, "🔼" * 64)),
self.assertSetEqual(
set(
os.listdir(os.path.join(self.mount_point, "k" * 200, "✅" * 70))
),
{"d" * 222},
)
os.link(
os.rename(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "d" * 222),
os.path.join(self.mount_point, "k" * 200, "" * 60),
os.path.join(self.mount_point, "k" * 200, "🎈" * 70),
)
self.assertEquals(
os.stat(
os.path.join(self.mount_point, "k" * 200, "✅" * 60)
).st_nlink,
2,
self.assertIn(
"🎈" * 70,
set(os.listdir(os.path.join(self.mount_point, "k" * 200))),
)
shutil.rmtree(os.path.join(self.mount_point, "k" * 200))
st = os.stat(os.path.join(self.mount_point, "k" * 200, "🎈" * 70))
self.assertEqual(st.st_size, 4 * 70)
os.rename(
os.path.join(self.mount_point, "k" * 200, "🎈" * 70),
os.path.join(self.mount_point, "k" * 200, "🎈" * 2),
)
if sys.platform != "win32":
os.symlink(
"/bcd" * 20,
os.path.join(self.mount_point, "k" * 200, "🔼" * 64),
)
self.assertEqual(
"/bcd" * 20,
os.readlink(
os.path.join(self.mount_point, "k" * 200, "🔼" * 64)
),
)
os.link(
os.path.join(self.mount_point, "k" * 200, "✅" * 70, "d" * 222),
os.path.join(self.mount_point, "k" * 200, "✅" * 60),
)
self.assertEqual(
os.stat(
os.path.join(self.mount_point, "k" * 200, "✅" * 60)
).st_nlink,
2,
)
shutil.rmtree(os.path.join(self.mount_point, "k" * 200))

if xattr is not None:

Expand Down

0 comments on commit 656d0af

Please sign in to comment.