[PATCH v2 2/9] test: provide testfs via fixture
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Oct 7 02:08:28 PDT 2025
On 9/29/25 10:03 AM, Jonas Rebmann wrote:
> Move the logic of providing testfs out of the tests and into a fixture.
> Pytest-modules that prepare testing data in their own fixtures should
> build on top of this.
>
> Tests using the fixture will be skipped if the feature is unavailable;
> remove that check from existing tests.
>
> Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> conftest.py | 8 ++++++++
> test/py/test_fit.py | 5 +----
> 2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/conftest.py b/conftest.py
> index 00969e62df..116beb5d14 100644
> --- a/conftest.py
> +++ b/conftest.py
> @@ -231,3 +231,11 @@ def strategy(request, target, pytestconfig):
> strategy.force(state)
>
> return strategy
> +
> + at pytest.fixture(scope="session")
> +def testfs(strategy, env):
> + if "testfs" not in env.get_target_features():
> + pytest.skip("testfs not supported on this platform")
> +
> + path = os.path.join(os.environ["LG_BUILDDIR"], "testfs")
> + return path
> diff --git a/test/py/test_fit.py b/test/py/test_fit.py
> index 08d5feba5c..3b2b8ff871 100644
> --- a/test/py/test_fit.py
> +++ b/test/py/test_fit.py
> @@ -15,10 +15,7 @@ def generate_bootscript(barebox, image, name="test"):
> return name
>
>
> -def test_fit(barebox, env, target, barebox_config):
> - if 'testfs' not in env.get_target_features():
> - pytest.xfail("testfs feature not specified")
> -
> +def test_fit(barebox, env, target, barebox_config, testfs):
> _, _, returncode = barebox.run(f"ls {fit_name('gzipped')}")
> if returncode != 0:
> pytest.xfail("skipping test due to missing FIT image")
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list