mergerfs/tests/TEST_mount_lifecycle

34 lines
828 B
Text
Raw Permalink Normal View History

2026-03-21 12:53:54 -05:00
#!/usr/bin/env python3
import os
import sys
from posix_parity import fail
from posix_parity import find_fusermount
from posix_parity import find_mergerfs
from posix_parity import mergerfs_mount
2026-03-21 12:53:54 -05:00
def main():
if os.geteuid() != 0:
return 0
if find_mergerfs() is None:
2026-03-21 12:53:54 -05:00
return 0
if find_fusermount() is None:
2026-03-21 12:53:54 -05:00
return 0
try:
with mergerfs_mount() as (mount, _):
with open(os.path.join(mount, "lifecycle-file"), "wb") as fp:
2026-03-21 12:53:54 -05:00
fp.write(b"ok")
if not os.path.exists(os.path.join(mount, "lifecycle-file")):
2026-03-21 12:53:54 -05:00
return fail("mount lifecycle: expected created file to exist")
return 0
except RuntimeError as exc:
print(str(exc), end="")
return 77
2026-03-21 12:53:54 -05:00
if __name__ == "__main__":
raise SystemExit(main())