added debug features to the lua and python jrpc servers.

Added doc of lua func item
This commit is contained in:
2025-12-31 13:38:19 +01:00
parent f54e09098a
commit 2e9c5e6c52
17 changed files with 129 additions and 54 deletions

View File

@@ -166,7 +166,7 @@ The test items returning a value are:
* :ref:`dialog_value test items<sec_dialog_value_test_item>`
* :ref:`py_func test item<sec_func_item>`
* :ref:`py_func test item<sec_py_func_item>`
* :ref:`dialog_choices test item<sec_dialog_choices_test_item>`

View File

@@ -0,0 +1,65 @@
.. _sec_lua_func_item:
**lua_func** test item
============================================================
The ``lua_func`` test item is used to execute custom lua 5.4 scripts with the given
input parameters.
The ``lua_func`` test item is of the form:
.. code-block:: lua
:caption: ``lua_func`` python function example
:name: script_file.lua
local module = {}
function module.dummy_func(param1, param2, param4, param4):
...
return 10
return module
.. code-block:: yaml
:caption: corresponding ``lua_func`` tum extract
- lua_func:
name: lua function test item
file: script_file.lua
func_name: dummy_func
param:
- 123
- 0.123
- True
- $(global_dict_key)
expected_result: 10
**Attributes**
Beside common test items attributes, lua_func item has specific attribute, some of which being mandatory.
* ``file``: the script file name that contains the function to be executed.
Only python script format is supported.
* ``func_name``: The function name to be executed.
* ``param``: This is a list of parameters that are passed to the function
in the order they are presented in the script. These parameters are not
mandatory and are highly dependent of the function prototype.
.. code-block:: yaml
:caption: ``lua_func`` test item example of usage
- lua_func:
name: activity
file: script_name.lua
func_name: methodName
param:
- $(my_param)
The result of the function (after eventual post treatment) is stored in the global
variable named ``pfn_<func_name>``
(See :ref:`global variables<sec_global_variables>` for more detail
on how to access to global variables from test items and scripts).
In the example above, the global variable ``$(lfn_activity)``
would be created at the end of the item execution. It would contain the resulting
value of the funcToBeExecuted python function.

View File

@@ -1,4 +1,4 @@
.. _sec_func_item:
.. _sec_py_func_item:
**py_func** test item
============================================================
@@ -99,10 +99,10 @@ Beside common test items attributes, py_func item has specific attribute, some o
- $(my_param)
The result of the function (after eventual post treatment) is stored in the global
variable named ``fn_<func_name>``
variable named ``pfn_<func_name>``
(See :ref:`global variables<sec_global_variables>` for more detail
on how to access to global variables from test items and scripts).
In the example above, the global variable ``$(fn_function test item)``
In the example above, the global variable ``$(pfn_function test item)``
would be created at the end of the item execution. It would contain the resulting
value of the funcToBeExecuted python function.

View File

@@ -142,7 +142,8 @@ library API (see :ref:`helper library<sec_python_helper_library>`)
* ``ts_end_<item_name>``: timestamp at the end of test item execution (see :ref:`sec_item_common`),
* ``ts_duration_<item_name>``: duration of test item execution in seconds (see :ref:`sec_item_common`),
* ``cn_<test_name>``: console test item result (see section :ref:`sec_console_test_item`),
* ``fn_<func_name>``: py_func test item result (see section :ref:`sec_func_item`),
* ``pfn_<func_name>``: py_func test item result (see section :ref:`sec_py_func_item`),
* ``lfn_<func_name>``: lua_func test item result (see section :ref:`sec_lua_func_item`),
* ``cs_<test_name>``: dialog_choices test item result (see section :ref:`sec_dialog_choices_test_item`),
* ``loop_param``: loop iterator (available from within a loop item,
see :ref:`sec_loop_item`),
@@ -237,6 +238,7 @@ step list attributes.
test_items/json-rpc_test_item.rst
test_items/let_test_item.rst
test_items/loop_test_item.rst
test_items/lua_func_test_item.rst
test_items/plot_test_item.rst
test_items/report_test_item.rst
test_items/run_test_item.rst

Binary file not shown.