mergerfs/tests/TEST_use_futimens_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

41 lines
No EOL
970 B
Python
Executable file

#!/usr/bin/env python3
import os
import sys
import tempfile
def main():
atime = 1234
mtime = 5678
(fd, filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.utime(fd, (atime, mtime))
st1 = os.fstat(fd)
if st1.st_atime != atime or st1.st_mtime != mtime:
os.close(fd)
os.unlink(filepath)
print("futimens before unlink: expected atime={} mtime={}, got atime={} mtime={}".format(
atime, mtime, st1.st_atime, st1.st_mtime), end='')
return 1
os.unlink(filepath)
atime2 = 9999
mtime2 = 8888
os.utime(fd, (atime2, mtime2))
st2 = os.fstat(fd)
if st2.st_atime != atime2 or st2.st_mtime != mtime2:
os.close(fd)
print("futimens after unlink: expected atime={} mtime={}, got atime={} mtime={}".format(
atime2, mtime2, st2.st_atime, st2.st_mtime), end='')
return 1
os.close(fd)
return 0
if __name__ == "__main__":
raise SystemExit(main())