We can inject new environment files via FW_CFG with pytest --env. Add support for an env: key that allows manipulating the barebox environment with only the YAML.
Co-developed-by: Claude <[email protected]> Signed-off-by: Ahmad Fatoum <[email protected]> --- conftest.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/conftest.py b/conftest.py index ef6ca221a5db..4241ebce7702 100644 --- a/conftest.py +++ b/conftest.py @@ -143,6 +143,12 @@ def strategy(request, target, pytestconfig): # noqa: max-complexity=30 except KeyError: features = [] + try: + main = target.env.config.data["targets"]["main"] + yaml_env = main["env"] + except KeyError: + yaml_env = {} + try: main = target.env.config.data["targets"]["main"] qemu_bin = main["drivers"]["QEMUDriver"]["qemu_bin"] @@ -218,6 +224,19 @@ def strategy(request, target, pytestconfig): # noqa: max-complexity=30 else: pytest.exit("--env unsupported for target\n", 1) + for envpath, value in yaml_env.items(): + if virtio: + if value.startswith('@'): + source = f"file='{value[1:]}'" + else: + source = f"string='{value}'" + + strategy.append_qemu_args( + '-fw_cfg', f'name=opt/org.barebox.env/{envpath},{source}' + ) + else: + pytest.exit("env unsupported for target\n", 1) + if len(pytestconfig.option.bootarg) > 0: strategy.append_qemu_bootargs(pytestconfig.option.bootarg) -- 2.47.3
