Files
mergerfs/tests/TEST_use_fchmod_after_unlink
Antonio SJ Musumeci 943f91ff98 Strengthen mergerfs integration tests
- Make the test runner fail on failed tests and report explicit skips
- Strengthen assertions for O_DIRECT, LUP policy, EXDEV fallback, and xattrs
- Fix cleanup and file descriptor handling across test scripts
2026-04-29 20:25:20 -04:00

36 lines
770 B
Python
Executable File

#!/usr/bin/env python3
import os
import stat
import sys
import tempfile
def main():
(fd, filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.fchmod(fd, 0o700)
st1 = os.fstat(fd)
if stat.S_IMODE(st1.st_mode) != 0o700:
os.close(fd)
os.unlink(filepath)
print("fchmod before unlink: expected mode 0o700, got 0o{:o}".format(stat.S_IMODE(st1.st_mode)), end='')
return 1
os.unlink(filepath)
os.fchmod(fd, 0o755)
st2 = os.fstat(fd)
if stat.S_IMODE(st2.st_mode) != 0o755:
os.close(fd)
print("fchmod after unlink: expected mode 0o755, got 0o{:o}".format(stat.S_IMODE(st2.st_mode)), end='')
return 1
os.close(fd)
return 0
if __name__ == "__main__":
raise SystemExit(main())