-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestrunner.py
More file actions
executable file
·99 lines (72 loc) · 2.66 KB
/
testrunner.py
File metadata and controls
executable file
·99 lines (72 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python3
import subprocess
import os
import signal
import sys
import time
FSTEST_PATH = "./target/fstest"
def tabulate(table):
# [..., [name, counts, descs[]], ...]
if len(table[2]) == 0:
table[2] = ['']
status = False
for desc in table[-1]:
if not status:
print(table[0].ljust(15) + table[1].ljust(15) +
table[2].ljust(15) + desc)
status = True
else:
print(''.ljust(15) + ''.ljust(15) + ''.ljust(15) + desc)
def run_tests(directory="."):
_path = "./pjdfstest/tests/" + directory
print("Test Name".ljust(15) + "Pass/Total".ljust(15) +
"Skipped".ljust(15) + "Failed Tests")
for filename in sorted(os.listdir(_path)):
if filename.endswith(".t"):
fstest_proc = subprocess.Popen([FSTEST_PATH],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
time.sleep(1)
faildescs = []
try:
ret = subprocess.run(["bash", os.path.join(_path, filename)],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE, timeout=5)
except subprocess.TimeoutExpired as e:
ret = subprocess.CompletedProcess(
args=e.cmd,
stdout=e.stdout,
stderr=e.stderr,
returncode=None,
)
faildescs.append("Timed out.")
passed = str(ret.stdout).count("ok")
failed = str(ret.stderr).count("not ok")
skipped = str(ret.stderr).count("EOPNOTSUPP")
failed -= skipped
if ret.stderr:
error = ret.stderr.decode()
for i in error.split("not ok"):
if "not ok" not in i and len(i) > 0 \
and "EOPNOTSUPP" not in i:
faildescs.append(i.strip().replace('\n', ''))
tabulate([directory + '/' + filename,
f"{passed}/{passed + failed}", f"{skipped}", faildescs])
shutdown_fstest(fstest_proc)
def shutdown_fstest(proc):
try:
proc.send_signal(signal.SIGINT)
except Exception as e:
print(f"Failed to send shutdown command: {e}")
def main():
tests = sys.argv
if len(sys.argv) < 2:
print("No test specified")
exit(1)
print("Starting tests...")
for test in tests[1:]:
run_tests(test)
time.sleep(1)
if __name__ == "__main__":
main()