blob: b48409b4184ae46d111280af45c607f48e166de4 (
plain)
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
|
#!/bin/python
import os, sys
from io import StringIO as buf
from subprocess import PIPE, Popen
root = "/home/nolln/root/test"
def usage():
print("usage:")
print("runtest [dir | file]*")
def run(bin):
print(f">Test of {os.path.basename(bin)}")
cmd = Popen(bin, stdout=PIPE, stderr=PIPE)
out, err = cmd.communicate()
print(">>output:")
for line in buf(out.decode('utf-8')).readlines():
print(f" {line.strip()}")
if len(err) > 0:
print(">>errors:")
for line in buf(err.decode('utf-8')).readlines():
print(f" {line.strip()}")
print(f">>[OK]")
def walk(dir):
for root, _, bins in os.walk(dir):
for bin in bins:
run(f"{root}/{bin}")
def main(args):
for arg in args:
dir = f"{root}/{arg}"
if os.path.isdir(dir):
if not os.path.exists(dir):
raise ValueError(f"directory '{dir}' does not exist")
print(f"Running tests of {arg}")
print("---------------------------------------------------")
walk(dir)
else:
bin = dir
if not os.path.exists(bin):
raise ValueError(f"binary '{bin}' does not exist")
run(bin)
if __name__ == "__main__":
if len(sys.argv) == 1:
usage()
main(sys.argv[1:])
|