MCPcopy
hub / github.com/borgbackup/borg / test_fuse_mount_hardlinks

Function test_fuse_mount_hardlinks

src/borg/testsuite/archiver/mount_cmds_test.py:30–64  ·  view source on GitHub ↗
(archivers, request)

Source from the content-addressed store, hash-verified

28@requires_hardlinks
29@pytest.mark.skipif(not has_any_fuse, reason="FUSE not available")
30def test_fuse_mount_hardlinks(archivers, request):
31 archiver = request.getfixturevalue(archivers)
32 _extract_hardlinks_setup(archiver)
33 mountpoint = os.path.join(archiver.tmpdir, "mountpoint")
34 # we need to get rid of permissions checking because fakeroot causes issues with it.
35 # On all platforms, borg defaults to "default_permissions" and we need to get rid of it via "ignore_permissions".
36 # On macOS (darwin), we additionally need "defer_permissions" to switch off the checks in osxfuse.
37 if sys.platform == "darwin":
38 ignore_perms = ["-o", "ignore_permissions,defer_permissions"]
39 else:
40 ignore_perms = ["-o", "ignore_permissions"]
41 with (
42 fuse_mount(archiver, mountpoint, "-a", "test", "--strip-components=2", *ignore_perms),
43 changedir(os.path.join(mountpoint, "test")),
44 ):
45 assert os.stat("hardlink").st_nlink == 2
46 assert os.stat("subdir/hardlink").st_nlink == 2
47 assert open("subdir/hardlink", "rb").read() == b"123456"
48 assert os.stat("aaaa").st_nlink == 2
49 assert os.stat("source2").st_nlink == 2
50 with (
51 fuse_mount(archiver, mountpoint, "input/dir1", "-a", "test", *ignore_perms),
52 changedir(os.path.join(mountpoint, "test")),
53 ):
54 assert os.stat("input/dir1/hardlink").st_nlink == 2
55 assert os.stat("input/dir1/subdir/hardlink").st_nlink == 2
56 assert open("input/dir1/subdir/hardlink", "rb").read() == b"123456"
57 assert os.stat("input/dir1/aaaa").st_nlink == 2
58 assert os.stat("input/dir1/source2").st_nlink == 2
59 with fuse_mount(archiver, mountpoint, "-a", "test", *ignore_perms), changedir(os.path.join(mountpoint, "test")):
60 assert os.stat("input/source").st_nlink == 4
61 assert os.stat("input/abba").st_nlink == 4
62 assert os.stat("input/dir1/hardlink").st_nlink == 4
63 assert os.stat("input/dir1/subdir/hardlink").st_nlink == 4
64 assert open("input/dir1/subdir/hardlink", "rb").read() == b"123456"
65
66
67@pytest.mark.skipif(not has_any_fuse, reason="FUSE not available")

Callers

nothing calls this directly

Calls 4

_extract_hardlinks_setupFunction · 0.85
fuse_mountFunction · 0.85
changedirFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected