2022-09-01 10:24:55 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os, subprocess
|
|
|
|
|
2022-09-01 11:02:55 +02:00
|
|
|
##### Setup Variables
|
|
|
|
tests_timeout=20 # Max duration of a test
|
|
|
|
tests_path = os.path.dirname(os.path.realpath(__file__))
|
2022-09-01 10:24:55 +02:00
|
|
|
|
2022-09-01 11:02:55 +02:00
|
|
|
##### Run All Tests
|
|
|
|
for file in os.listdir(tests_path):
|
|
|
|
current_test_path=os.path.join(tests_path,file)
|
|
|
|
if os.path.isdir(current_test_path):
|
|
|
|
simulator_path=os.path.join(current_test_path,"simulator.py")
|
|
|
|
out_path=os.path.join(current_test_path,"out")
|
2022-09-01 10:24:55 +02:00
|
|
|
print("- %-50s%s " % (file,"=>"),end='')
|
|
|
|
try:
|
2022-09-01 11:02:55 +02:00
|
|
|
out=subprocess.check_output(simulator_path, stderr=subprocess.STDOUT,timeout=tests_timeout).decode("utf-8")
|
|
|
|
out_expected=open(out_path).read()
|
|
|
|
if out_expected != out:
|
2022-09-01 10:24:55 +02:00
|
|
|
print("failed :(")
|
|
|
|
print("------------- Expected -------------")
|
2022-09-01 11:02:55 +02:00
|
|
|
print(out_expected,end="")
|
2022-09-01 10:24:55 +02:00
|
|
|
print("------------- Got -------------")
|
|
|
|
print(out,end="")
|
|
|
|
else:
|
|
|
|
print("passed")
|
|
|
|
except subprocess.TimeoutExpired as err:
|
|
|
|
print("failed :(")
|
2022-09-01 11:02:55 +02:00
|
|
|
print("------------- Test timeout (should not exceed "+str(tests_timeout)+"s) -------------")
|
2022-09-01 10:24:55 +02:00
|
|
|
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)
|