mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 12:57:12 -05:00
Add more integration tests
This commit is contained in:
parent
a78aef36e0
commit
f4b602340b
34 changed files with 3202 additions and 0 deletions
59
tests/TEST_posix_syncfs
Executable file
59
tests/TEST_posix_syncfs
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import ctypes
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from posix_parity import compare_calls
|
||||
from posix_parity import fail
|
||||
from posix_parity import join
|
||||
from posix_parity import touch
|
||||
|
||||
|
||||
libc = ctypes.CDLL(None, use_errno=True)
|
||||
libc.syncfs.argtypes = [ctypes.c_int]
|
||||
libc.syncfs.restype = ctypes.c_int
|
||||
|
||||
|
||||
def syncfs_fd(fd):
|
||||
ctypes.set_errno(0)
|
||||
rv = libc.syncfs(fd)
|
||||
if rv == 0:
|
||||
return 0
|
||||
err = ctypes.get_errno()
|
||||
raise OSError(err, os.strerror(err))
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("usage: TEST_posix_syncfs <mountpoint>", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
mount = sys.argv[1]
|
||||
|
||||
with tempfile.TemporaryDirectory() as native:
|
||||
merge_file = join(mount, "posix-syncfs/file")
|
||||
native_file = join(native, "posix-syncfs/file")
|
||||
touch(merge_file, b"x")
|
||||
touch(native_file, b"x")
|
||||
|
||||
mfd = os.open(merge_file, os.O_RDONLY)
|
||||
nfd = os.open(native_file, os.O_RDONLY)
|
||||
try:
|
||||
err = compare_calls("syncfs success", lambda: syncfs_fd(mfd), lambda: syncfs_fd(nfd))
|
||||
if err:
|
||||
return fail(err)
|
||||
finally:
|
||||
os.close(mfd)
|
||||
os.close(nfd)
|
||||
|
||||
err = compare_calls("syncfs EBADF", lambda: syncfs_fd(-1), lambda: syncfs_fd(-1))
|
||||
if err:
|
||||
return fail(err)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue