2025-06-05 23:47:42 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
import tempfile
|
2025-06-05 23:47:42 -05:00
|
|
|
import os
|
|
|
|
|
import sys
|
2026-05-07 20:43:42 -05:00
|
|
|
|
|
|
|
|
from posix_parity import mergerfs_mount
|
2025-06-05 23:47:42 -05:00
|
|
|
|
|
|
|
|
|
2026-04-29 17:44:22 -05:00
|
|
|
def main():
|
2026-05-07 20:43:42 -05:00
|
|
|
try:
|
|
|
|
|
with mergerfs_mount() as (mount, _):
|
|
|
|
|
(fd, filepath) = tempfile.mkstemp(dir=mount)
|
2025-06-05 23:47:42 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
times = (1234567890, 9876543210)
|
|
|
|
|
os.utime(fd, times=times)
|
2025-06-05 23:47:42 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
st1 = os.fstat(fd)
|
|
|
|
|
if st1.st_atime != times[0] or st1.st_mtime != times[1]:
|
|
|
|
|
os.close(fd)
|
|
|
|
|
os.unlink(filepath)
|
|
|
|
|
print("futimens before unlink: expected atime={} mtime={}, got atime={} mtime={}".format(
|
|
|
|
|
times[0], times[1], st1.st_atime, st1.st_mtime), end='')
|
|
|
|
|
return 1
|
2025-06-05 23:47:42 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
os.unlink(filepath)
|
2026-04-29 17:44:22 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
times2 = (1111111111, 2222222222)
|
|
|
|
|
os.utime(fd, times=times2)
|
2026-04-29 17:44:22 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
st2 = os.fstat(fd)
|
|
|
|
|
if st2.st_atime != times2[0] or st2.st_mtime != times2[1]:
|
|
|
|
|
os.close(fd)
|
|
|
|
|
print("futimens after unlink: expected atime={} mtime={}, got atime={} mtime={}".format(
|
|
|
|
|
times2[0], times2[1], st2.st_atime, st2.st_mtime), end='')
|
|
|
|
|
return 1
|
2026-04-29 17:44:22 -05:00
|
|
|
|
2026-05-07 20:43:42 -05:00
|
|
|
os.close(fd)
|
|
|
|
|
return 0
|
|
|
|
|
except RuntimeError as exc:
|
|
|
|
|
print(str(exc), end="")
|
|
|
|
|
return 77
|
2026-04-29 17:44:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2026-05-07 20:43:42 -05:00
|
|
|
raise SystemExit(main())
|