[U-Boot] Some issues with the python tests

Stephen Warren swarren at wwwdotorg.org
Wed Oct 19 18:26:45 CEST 2016


On 10/18/2016 04:30 PM, Stefan Bruens wrote:
> Hi,
>
> I have started diving into the u-boot python tests. Now I have come accross
> two problems:
>
> 1. I would like to access the config, specifically the paths to e.g.
> build_dir, result_dir, ...
> 2. I would like to run and log system commands
>
> Now while I can do this via the u_boot_console fixture, I would like to issue
> some of my fixture setup on the session/module level. Unfortunately, the
> u_boot_console fixture has "function" scope, and thus my fixtures are limited
> to function scope as well.
>
> Although for the u_boot_console (i.e. the sandbox instance or the SoC
> terminal) function scope is likely correct, the runner/logger and the config
> should be accessible independent of u_boot_console.
>
> Any ideas how to solve this issue?

I think the simplest would be to create new fixture functions for the 
log and config objects. I think try adding the following to conftest.py 
right before/after function u_boot_console():

@pytest.fixture()
def log(request):
     """Generate the value of a test's log fixture.

     Args:
         request: The pytest request.

     Returns:
         The fixture value.
     """

     return console.log

@pytest.fixture()
def u_boot_config(request):
     """Generate the value of a test's u_boot_config fixture.

     Args:
         request: The pytest request.

     Returns:
         The fixture value.
     """

     return console.config

Note that the console object itself actually has global scope, and is 
initialized before any tests are run. So, accessing it from global 
fixtures is fine. The function-scoped fixture implementation actually 
returns this same console object every time; it's only function-scoped 
so that it can guarantee to call console.ensure_spawned() prior to each 
test, so make sure that U-Boot is restarted if it failed before, to give 
each test a clean slate.


More information about the U-Boot mailing list