[U-Boot] [PATCH v4 2/2] test/py: add test for whitelist of variables while importing environment

Stephen Warren swarren at wwwdotorg.org
Thu Jun 7 23:21:19 UTC 2018


On 06/04/2018 03:47 AM, Quentin Schulz wrote:
> This tests that the importing of an environment with a specified
> whitelist works as intended.
> 
> If there are variables passed as parameter to the env import command,
>     those only should be imported in the current environment.
> 
> For each variable passed as parameter, if
>   - foo is bar in current env and bar2 in exported env, after importing
>   exported env, foo shall be bar2,
>   - foo does not exist in current env and foo is bar2 in exported env,
>   after importing exported env, foo shall be bar2,
>   - foo is bar in current env and does not exist in exported env (but is
>   passed as parameter), after importing exported env, foo shall be empty,
> 
> Any variable not passed as parameter should be left untouched.
> 
> Two other tests are made to test that size cannot be '-' if the checksum
> protection is enabled.

Reviewed-by: Stephen Warren <swarren at nvidia.com>

> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py

> +def test_env_import_checksum_no_size(state_test_env):
> +    """Test that omitted ('-') size parameter with checksum validation fails the
> +       env import function.
> +    """
> +    c = state_test_env.u_boot_console
> +    ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console)
> +    addr = '%08x' % ram_base
> +
> +    with c.disable_check('error_notification'):
> +        response = c.run_command('env import -c %s -' % addr)
> +    assert(response == '## Error: external checksum format must pass size')

I could imagine all kinds of other useful tests here, e.g. completely 
missing the size parameter rather than passing it explicitly as - for 
example. But we can add that later if need be.


More information about the U-Boot mailing list