blob: cb5d88d7795e30bc52e52ca7c6d04c6d945cf1ba (
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
|
#!/usr/bin/env python
import os, subprocess
teststimeout=20 # Max duration of a test
testspath = os.path.dirname(os.path.realpath(__file__))
for file in os.listdir(testspath):
testpath=os.path.join(testspath,file)
if os.path.isdir(testpath):
simulatorpath=os.path.join(testpath,"simulator.py")
outpath=os.path.join(testpath,"out")
print("- %-50s%s " % (file,"=>"),end='')
try:
out=subprocess.check_output(simulatorpath, stderr=subprocess.STDOUT,timeout=teststimeout).decode("utf-8")
outexpected=open(outpath).read()
if outexpected != out:
print("failed :(")
print("------------- Expected -------------")
print(outexpected,end="")
print("------------- Got -------------")
print(out,end="")
else:
print("passed")
except subprocess.TimeoutExpired as err:
print("failed :(")
print("------------- Test timeout (should not exceed "+str(teststimeout)+"s) -------------")
print(err.output.decode("utf-8"),end="")
exit(1)
except subprocess.CalledProcessError as err:
print("failed :(")
print("------------- Non test has a non-zero exit code -------------")
print(err.output.decode("utf-8"),end="")
exit(2)
except Exception as err:
print("failed :(")
print("Reason: "+str(err))
exit(3)
|