twister/pytest: Add unlaunched_dut fixture
Add a new fixture, `unlaunched_dut`, which is basically the `dut` one, but without launching the device - thus also not building the application. It is useful for tests who need a finer control of the building of the application, before the dut can be launched to run it. It will be used on a future patch, which will use it to enable LLEXT EDK tests. Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
This commit is contained in:
parent
e4cc0f2780
commit
55613d035b
2 changed files with 25 additions and 0 deletions
|
@ -166,6 +166,22 @@ a fixture ``mcumgr``
|
||||||
mcumgr.reset_device()
|
mcumgr.reset_device()
|
||||||
# continue test scenario, check version etc.
|
# continue test scenario, check version etc.
|
||||||
|
|
||||||
|
|
||||||
|
unlauched_dut
|
||||||
|
=============
|
||||||
|
|
||||||
|
Similar to the ``dut`` fixture, but it does not initialize the device. It can be used when a finer
|
||||||
|
control over the build process is needed. It becomes responsibility of the test to initialize the
|
||||||
|
device.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from twister_harness import DeviceAdapter
|
||||||
|
|
||||||
|
def test_sample(unlauched_dut: DeviceAdapter):
|
||||||
|
unlaunched_dut.launch()
|
||||||
|
unlaunched_dut.readlines_until('Hello world')
|
||||||
|
|
||||||
Classes
|
Classes
|
||||||
*******
|
*******
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,15 @@ def determine_scope(fixture_name, config):
|
||||||
return 'function'
|
return 'function'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope=determine_scope)
|
||||||
|
def unlaunched_dut(request: pytest.FixtureRequest, device_object: DeviceAdapter) -> Generator[DeviceAdapter, None, None]:
|
||||||
|
"""Return device object - with logs connected, but not run"""
|
||||||
|
device_object.initialize_log_files(request.node.name)
|
||||||
|
try:
|
||||||
|
yield device_object
|
||||||
|
finally: # to make sure we close all running processes execution
|
||||||
|
device_object.close()
|
||||||
|
|
||||||
@pytest.fixture(scope=determine_scope)
|
@pytest.fixture(scope=determine_scope)
|
||||||
def dut(request: pytest.FixtureRequest, device_object: DeviceAdapter) -> Generator[DeviceAdapter, None, None]:
|
def dut(request: pytest.FixtureRequest, device_object: DeviceAdapter) -> Generator[DeviceAdapter, None, None]:
|
||||||
"""Return launched device - with run application."""
|
"""Return launched device - with run application."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue