mirror of
https://github.com/nasa/trick.git
synced 2025-04-27 06:20:26 +00:00
Exit code fixed
This commit is contained in:
parent
aab2ed927b
commit
d52350fedf
@ -6,22 +6,26 @@ import subprocess
|
||||
import inspect
|
||||
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda:0))), '../..')))
|
||||
from utils import is_web_server_started, params
|
||||
from utils import is_web_server_started, params, pause
|
||||
|
||||
# store history of failures per test class name and per index in parametrize (if parametrize used)
|
||||
web_server_status = {}
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
pause("start of test")
|
||||
if "webserver" in item.keywords:
|
||||
#retrieve the class name of the test
|
||||
cls_name = str(item.cls)
|
||||
status = web_server_status.get(cls_name, None)
|
||||
if status == None:
|
||||
print(f"Building and starting sim for class {cls_name}")
|
||||
pause("before build sim")
|
||||
build_sim()
|
||||
pause("here 2")
|
||||
status = is_web_server_started()
|
||||
web_server_status[cls_name] = status
|
||||
print(f"Web server status for {cls_name} = {status}")
|
||||
pause("here 1")
|
||||
|
||||
if not web_server_status[cls_name]:
|
||||
pytest.fail("web server is not started.")
|
||||
@ -48,12 +52,20 @@ trick.exec_set_enable_freeze(True)
|
||||
trick.exec_set_freeze_command(True)""")
|
||||
|
||||
if params.get_build_sim():
|
||||
#TODO: Need make file to only rebuild only when necessary, otherwise, test need to rebuild and this is time consuming.
|
||||
print("#"*10)
|
||||
print("Auto rebuilding sim. Auto rebuild will build the SIM everytime the test is run, which can take some time.")
|
||||
print("To turn auto rebuild off, in utils.py, self.__build_sim = False. Note: it's important that SIM rebuild is current.")
|
||||
print("#"*10)
|
||||
build_cmd = f"echo \"cd {params.get_path_to_sim()} && make -C {params.get_trick_home()}/trick_source/web/CivetServer && make clean && {params.get_trick_home()}/bin/trick-CP\" | /bin/bash"
|
||||
print("....................Running:", build_cmd)
|
||||
subprocess.run(build_cmd, shell=True)
|
||||
|
||||
if params.get_start_sim():
|
||||
cmd = f'echo "cd {params.get_path_to_sim()} && ./S_main_Linux_9.3_x86_64.exe {os.path.join(params.get_input_folder(), params.get_test_input_file())} &" | /bin/bash'
|
||||
pathToSim=params.get_path_to_sim()
|
||||
if not os.path.exists(os.path.join(pathToSim, "S_main_Linux_9.3_x86_64.exe")):
|
||||
raise RuntimeError(f"Sim executable does not exist in {pathToSim}. Buid this sim before running this test.")
|
||||
cmd = f'echo "cd {pathToSim} && ./S_main_Linux_9.3_x86_64.exe {os.path.join(params.get_input_folder(), params.get_test_input_file())} &" | /bin/bash'
|
||||
print("....................Running:", cmd)
|
||||
subprocess.run(cmd, shell=True)
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(["tests/civet_server"])
|
||||
args = list(sys.argv[1:]) + ["tests/civet_server"]
|
||||
print(args)
|
||||
sys.exit(pytest.main(args))
|
@ -13,7 +13,6 @@ import ssl
|
||||
sys.path.append("../..")
|
||||
from utils import params, is_web_server_started
|
||||
|
||||
|
||||
@pytest.mark.webserver
|
||||
class TestWebserverWs:
|
||||
if params.get_ssl_enable():
|
||||
|
@ -2,6 +2,11 @@ from time import sleep
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
def pause(my_str):
|
||||
print("Type exit to continue:" + my_str)
|
||||
os.system("/bin/bash")
|
||||
# input()
|
||||
|
||||
#This file contains variables for the civet_server tests
|
||||
class Params:
|
||||
#Change the following to change the default parameters
|
||||
@ -69,7 +74,7 @@ class Params:
|
||||
|
||||
params = Params()
|
||||
def is_web_server_started():
|
||||
for _ in range(20): #Wait 2 seconds i.e 20 * .1 seconds
|
||||
for _ in range(20): #Wait 2 seconds i.e 20 * .1 seconds, must wait for service to get to listening state.
|
||||
p = subprocess.run(f"echo \"netstat -tulpan | grep {params.get_port()}\" | /bin/bash", capture_output=True, shell=True)
|
||||
print(f"Checking for port output: {p.stdout}")
|
||||
sleep(.1) #We sleep to use less recourses
|
||||
|
Loading…
x
Reference in New Issue
Block a user