create integration tests

This commit is contained in:
Antonio SJ Musumeci 2019-03-21 21:31:27 -04:00
parent 4293cb7253
commit 374580a85d
5 changed files with 95 additions and 0 deletions

19
tests/TEST_no_fuse_hidden Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import os
import sys
import tempfile
(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
ino = os.fstat(fd).st_ino
os.unlink(filepath)
for entry in os.scandir(sys.argv[1]):
if entry.inode() == ino:
print("found .fuse_hidden file {}".format(entry.name),end='')
os.close(fd)
sys.exit(1)
os.close(fd)

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import sys
import tempfile
(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.fchmod(fd,0o777)
os.unlink(filepath)
os.fchmod(fd,0o777)
os.close(fd)

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import sys
import tempfile
(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.fchown(fd,os.getuid(),os.getgid())
os.unlink(filepath)
os.fchown(fd,os.getuid(),os.getgid())
os.close(fd)

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import sys
import tempfile
(fd,filepath) = tempfile.mkstemp(dir=sys.argv[1])
os.fstat(fd)
os.unlink(filepath)
os.fstat(fd)
os.close(fd)

31
tests/run-tests Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
if len(sys.argv) != 2:
print('usage: run-test <mergerfs-path>\n',file=sys.stderr)
sys.exit(1)
test_path = os.path.realpath(sys.argv[0])
test_path = os.path.dirname(test_path)
for entry in os.scandir(test_path):
if not entry.name.startswith('TEST_'):
continue
try:
print(entry.name + ': ',end='')
fullpath = os.path.join(test_path,entry.name)
args = [fullpath,sys.argv[1]]
rv = subprocess.Popen(args,stdout=subprocess.PIPE)
rv.wait(timeout=10000)
if rv.returncode:
output = rv.stdout.read().decode()
print('FAIL - {}'.format(output))
else:
print('PASS')
except Exception as e:
print('FAIL - {}'.format(e))