lua proc started only if lua test items present.
This commit is contained in:
@@ -22,5 +22,6 @@ main:
|
|||||||
|
|
||||||
- sleep:
|
- sleep:
|
||||||
name: sleep item
|
name: sleep item
|
||||||
dialog: True
|
dialog: true
|
||||||
timeout: 3600
|
timeout: 3600
|
||||||
|
no_fail: true
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ global_loop_param_num: [1, 2, 3]
|
|||||||
# Plot parameters
|
# Plot parameters
|
||||||
plot_log_path: /tmp/testium_plot/$(testrun_date)/$(testrun_time)/
|
plot_log_path: /tmp/testium_plot/$(testrun_date)/$(testrun_time)/
|
||||||
|
|
||||||
python_path: $(home)/tmp/tum_venv/bin/python3
|
# python_path: $(home)/tmp/tum_venv/bin/python3
|
||||||
|
|
||||||
lua_path: /usr/bin/lua
|
# lua_path: /usr/bin/lua
|
||||||
lua_env:
|
lua_env:
|
||||||
LUA_PATH: /usr/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;/usr/lib/lua/5.4/?.lua;/usr/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua;/home/francois/.luarocks/share/lua/5.4/?.lua;/home/francois/.luarocks/share/lua/5.4/?/init.lua
|
LUA_PATH: /usr/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?.lua;/usr/local/share/lua/5.4/?/init.lua;/usr/share/lua/5.4/?/init.lua;/usr/local/lib/lua/5.4/?.lua;/usr/local/lib/lua/5.4/?/init.lua;/usr/lib/lua/5.4/?.lua;/usr/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua;/home/francois/.luarocks/share/lua/5.4/?.lua;/home/francois/.luarocks/share/lua/5.4/?/init.lua
|
||||||
LUA_CPATH: /usr/local/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;/usr/lib/lua/5.4/loadall.so;./?.so;/home/francois/.luarocks/lib/lua/5.4/?.so
|
LUA_CPATH: /usr/local/lib/lua/5.4/?.so;/usr/lib/lua/5.4/?.so;/usr/local/lib/lua/5.4/loadall.so;/usr/lib/lua/5.4/loadall.so;./?.so;/home/francois/.luarocks/lib/lua/5.4/?.so
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import traceback
|
|||||||
import libs.testium as tm
|
import libs.testium as tm
|
||||||
from interpreter.utils.params import expanse
|
from interpreter.utils.params import expanse
|
||||||
from interpreter.utils.string_queue import StringQueue
|
from interpreter.utils.string_queue import StringQueue
|
||||||
|
from interpreter.utils.tum_except import ETUMRuntimeError
|
||||||
from interpreter.utils.test_ctrl import TestSetController
|
from interpreter.utils.test_ctrl import TestSetController
|
||||||
from interpreter.utils.test_init import (
|
from interpreter.utils.test_init import (
|
||||||
env_init,
|
env_init,
|
||||||
@@ -19,6 +20,7 @@ from interpreter.utils.test_init import (
|
|||||||
backup_gd,
|
backup_gd,
|
||||||
restore_gd,
|
restore_gd,
|
||||||
)
|
)
|
||||||
|
from interpreter.utils.constants import TestItemType as cst_type
|
||||||
from interpreter.test_set import TestSet
|
from interpreter.test_set import TestSet
|
||||||
from interpreter.utils.stdout_redirect import stdio_redir
|
from interpreter.utils.stdout_redirect import stdio_redir
|
||||||
from interpreter.utils.tum_except import print_exception
|
from interpreter.utils.tum_except import print_exception
|
||||||
@@ -62,7 +64,8 @@ class TestProcess(Process):
|
|||||||
|
|
||||||
# Load the test file
|
# Load the test file
|
||||||
test_dict, cfg_files = load_test(
|
test_dict, cfg_files = load_test(
|
||||||
self.__fname, test_dir, self.__cfgf, self.__defs)
|
self.__fname, test_dir, self.__cfgf, self.__defs
|
||||||
|
)
|
||||||
|
|
||||||
# Backup the global dict in case of restart of the test
|
# Backup the global dict in case of restart of the test
|
||||||
gdict = backup_gd()
|
gdict = backup_gd()
|
||||||
@@ -76,15 +79,19 @@ class TestProcess(Process):
|
|||||||
# Thread for incoming control commands
|
# Thread for incoming control commands
|
||||||
self.init_commands(test_set)
|
self.init_commands(test_set)
|
||||||
self.cmd_th = Thread(
|
self.cmd_th = Thread(
|
||||||
target=self.process_control_commands, args=[self.__tctrl])
|
target=self.process_control_commands,
|
||||||
self.cmd_th.daemon = True
|
args=[self.__tctrl],
|
||||||
|
daemon=True,
|
||||||
|
)
|
||||||
self.cmd_th.start()
|
self.cmd_th.start()
|
||||||
|
|
||||||
test_set.report_path = locate_report_file(test_set.report_path)
|
test_set.report_path = locate_report_file(test_set.report_path)
|
||||||
|
|
||||||
# Python & lua functions call subprocess initialization
|
# Python & lua functions call subprocess initialization
|
||||||
py_fproc = py_func_call_init(tm.gd("python_path", ""), api_request)
|
py_fproc = py_func_call_init(tm.gd("python_path", ""), api_request)
|
||||||
lua_fproc = lua_func_call_init(tm.gd("lua_path", "/usr/bin/lua"), api_request)
|
lua_fproc = None
|
||||||
|
if test_set.isTestTypePresent(cst_type.TYPE_LUA_FUNCTION):
|
||||||
|
lua_fproc = lua_func_call_init(tm.gd("lua_path", ""), api_request)
|
||||||
|
|
||||||
self.__loaded = True
|
self.__loaded = True
|
||||||
|
|
||||||
@@ -101,10 +108,22 @@ class TestProcess(Process):
|
|||||||
try:
|
try:
|
||||||
test_run_init()
|
test_run_init()
|
||||||
print(test_run_header())
|
print(test_run_header())
|
||||||
|
# start the process for executing external python
|
||||||
py_fproc.start()
|
py_fproc.start()
|
||||||
lua_fproc.start()
|
if not py_fproc.wait_ready(10):
|
||||||
lua_fproc.wait_ready()
|
raise ETUMRuntimeError(
|
||||||
py_fproc.wait_ready()
|
f"""Impossible to start the external python execution process.
|
||||||
|
Is the python path correct ?
|
||||||
|
python_path = {tm.gd("python_path", "no python path defined")}"""
|
||||||
|
)
|
||||||
|
if lua_fproc is not None:
|
||||||
|
lua_fproc.start()
|
||||||
|
if not lua_fproc.wait_ready(10):
|
||||||
|
raise ETUMRuntimeError(
|
||||||
|
f"""Impossible to start the external lua execution process.
|
||||||
|
Is the lua path correct ?
|
||||||
|
lua_path = {tm.gd("lua_path", "no lua path defined")}"""
|
||||||
|
)
|
||||||
test_set.execute()
|
test_set.execute()
|
||||||
finally:
|
finally:
|
||||||
if test_set.success():
|
if test_set.success():
|
||||||
@@ -116,9 +135,10 @@ class TestProcess(Process):
|
|||||||
finally:
|
finally:
|
||||||
# Stop function execution process
|
# Stop function execution process
|
||||||
py_fproc.stop()
|
py_fproc.stop()
|
||||||
lua_fproc.stop()
|
|
||||||
lua_fproc.join()
|
|
||||||
py_fproc.join()
|
py_fproc.join()
|
||||||
|
if lua_fproc is not None:
|
||||||
|
lua_fproc.stop()
|
||||||
|
lua_fproc.join()
|
||||||
self.__exec = False
|
self.__exec = False
|
||||||
# Sends signal to the GUI
|
# Sends signal to the GUI
|
||||||
self.send_finished()
|
self.send_finished()
|
||||||
@@ -162,9 +182,7 @@ class TestProcess(Process):
|
|||||||
stdio_redir.stop()
|
stdio_redir.stop()
|
||||||
|
|
||||||
def send_finished(self):
|
def send_finished(self):
|
||||||
status = {'id': None,
|
status = {"id": None, "name": "test_process", "status": "finished"}
|
||||||
'name': "test_process",
|
|
||||||
'status': 'finished'}
|
|
||||||
self.__squeue.put(status)
|
self.__squeue.put(status)
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
|||||||
@@ -224,7 +224,9 @@ class TestSet:
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def __findItemByIdRecursively(self, item_id, parent):
|
def __findItemById(self, item_id, parent=None):
|
||||||
|
if parent is None:
|
||||||
|
parent = self._rootItem
|
||||||
res = None
|
res = None
|
||||||
i = 0
|
i = 0
|
||||||
while (res is None) and (i < parent.childCount()):
|
while (res is None) and (i < parent.childCount()):
|
||||||
@@ -239,9 +241,21 @@ class TestSet:
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def __findItemById(self, item_id):
|
def isTestTypePresent(self, test_type: cst_type, parent=None):
|
||||||
item = self.__findItemByIdRecursively(item_id, self._rootItem)
|
if parent is None:
|
||||||
return item
|
parent = self._rootItem
|
||||||
|
res = False
|
||||||
|
i = 0
|
||||||
|
while (not res) and (i < parent.childCount()):
|
||||||
|
if parent.child(i).type() == test_type.item_name:
|
||||||
|
res = True
|
||||||
|
i = i + 1
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while (not res) and (i < parent.childCount()):
|
||||||
|
res = self.isTestTypePresent(test_type, parent.child(i))
|
||||||
|
i = i + 1
|
||||||
|
return res
|
||||||
|
|
||||||
def getEnabledState(self, item_id):
|
def getEnabledState(self, item_id):
|
||||||
"""Return True if the item is enabled, False otherwise."""
|
"""Return True if the item is enabled, False otherwise."""
|
||||||
|
|||||||
@@ -44,15 +44,19 @@ def is_lua_interpreter(path: str, timeout=2) -> bool:
|
|||||||
class LuaFuncExecEngine:
|
class LuaFuncExecEngine:
|
||||||
|
|
||||||
def __init__(self, lua_path="", request_handler=None):
|
def __init__(self, lua_path="", request_handler=None):
|
||||||
if shutil.which(lua_path) is None:
|
if lua_path != "":
|
||||||
raise ETUMRuntimeError(
|
if shutil.which(lua_path) is None:
|
||||||
f"The passed lua path is not pointing to an executable: '{lua_path}'"
|
raise ETUMRuntimeError(
|
||||||
)
|
f"The passed lua path is not pointing to an executable: '{lua_path}'"
|
||||||
|
)
|
||||||
|
|
||||||
if not is_lua_interpreter(lua_path):
|
if not is_lua_interpreter(lua_path):
|
||||||
raise ETUMRuntimeError(
|
raise ETUMRuntimeError(
|
||||||
f"The passed executable is not a lua interpreter: '{lua_path}'"
|
f"The passed executable is not a lua interpreter: '{lua_path}'"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
lua_path = "/usr/bin/lua"
|
||||||
|
tm.setgd("lua_path", lua_path)
|
||||||
|
|
||||||
self._lpath = lua_path
|
self._lpath = lua_path
|
||||||
self._req_handler = request_handler
|
self._req_handler = request_handler
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class PyFuncExecEngine:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
python_path = sys.executable
|
python_path = sys.executable
|
||||||
|
tm.setgd("python_path", python_path)
|
||||||
|
|
||||||
self._ppath = python_path
|
self._ppath = python_path
|
||||||
self._req_handler = request_handler
|
self._req_handler = request_handler
|
||||||
|
|||||||
Reference in New Issue
Block a user