[PATCH] test/py: sleep: Add a test for the time command

Tom Rini trini at konsulko.com
Tue Sep 26 17:53:31 CEST 2023


On Tue, Sep 26, 2023 at 05:08:35PM +0530, Love Kumar wrote:
> Execute "time <sleep cmd>", and validate that it gives the approximately
> the correct amount of command execution time.
> 
> Signed-off-by: Love Kumar <love.kumar at amd.com>
> ---
>  test/py/tests/test_sleep.py | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py
> index 392af29db224..388f544d07df 100644
> --- a/test/py/tests/test_sleep.py
> +++ b/test/py/tests/test_sleep.py
> @@ -41,3 +41,23 @@ def test_sleep(u_boot_console):
>      if not u_boot_console.config.gdbserver:
>          # margin is hopefully enough to account for any system overhead.
>          assert elapsed < (sleep_time + sleep_margin)
> +
> +def test_time(u_boot_console):
> +    """Test the time command, and validate that it gives approximately the
> +    correct amount of command execution time."""
> +
> +    sleep_skip = u_boot_console.config.env.get("env__sleep_accurate", True)
> +    if not sleep_skip:
> +        pytest.skip("sleep is not accurate")
> +
> +    if u_boot_console.config.buildconfig.get("config_cmd_misc", "n") != "y":

We should use @pytest.mark.buildconfigspec('cmd_misc') on the function
def itself.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230926/af85a67d/attachment.sig>


More information about the U-Boot mailing list