All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Some issues with the python tests
@ 2016-10-18 22:30 Stefan Bruens
  2016-10-19 16:26 ` Stephen Warren
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Bruens @ 2016-10-18 22:30 UTC (permalink / raw)
  To: u-boot

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?

Kind regards,

Stefan

-- 
Stefan Br?ns  /  Bergstra?e 21  /  52062 Aachen
home: +49 241 53809034     mobile: +49 151 50412019
work: +49 2405 49936-424

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] Some issues with the python tests
  2016-10-18 22:30 [U-Boot] Some issues with the python tests Stefan Bruens
@ 2016-10-19 16:26 ` Stephen Warren
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Warren @ 2016-10-19 16:26 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-19 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 22:30 [U-Boot] Some issues with the python tests Stefan Bruens
2016-10-19 16:26 ` Stephen Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.