mergerfs/tests/run-tests

47 lines
1.1 KiB
Text
Raw Permalink Normal View History

2019-03-21 21:31:27 -04:00
#!/usr/bin/env python3
import os
import sys
import subprocess
SKIP = 77
2019-03-21 21:31:27 -04:00
if len(sys.argv) != 2:
print('usage: run-tests <mountpoint>\n', file=sys.stderr)
2019-03-21 21:31:27 -04:00
sys.exit(1)
test_path = os.path.realpath(sys.argv[0])
test_path = os.path.dirname(test_path)
failed = False
2019-03-21 21:31:27 -04:00
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, stderr=subprocess.STDOUT)
output, _ = rv.communicate(timeout=120)
if rv.returncode == SKIP:
print('SKIP - {}'.format(output.decode(errors='replace')))
elif rv.returncode:
print('FAIL - {}'.format(output.decode(errors='replace')))
failed = True
2019-03-21 21:31:27 -04:00
else:
print('PASS')
except subprocess.TimeoutExpired:
rv.kill()
rv.wait()
print('FAIL - timeout')
failed = True
2019-03-21 21:31:27 -04:00
except Exception as e:
print('FAIL - {}'.format(e))
failed = True
sys.exit(1 if failed else 0)