diff options
author | Love Kumar <love.kumar@amd.com> | 2023-09-27 10:33:55 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-09 15:24:31 -0400 |
commit | 34124ad9a433eb829b7a1942e074dd500302d964 (patch) | |
tree | edcc7b0b1d4badad25f60290ee610526ab1cb8b8 | |
parent | fb730a2c5ac906730ca9e91f0178a77bdef1bb3a (diff) | |
download | u-boot-34124ad9a433eb829b7a1942e074dd500302d964.tar.gz u-boot-34124ad9a433eb829b7a1942e074dd500302d964.tar.bz2 u-boot-34124ad9a433eb829b7a1942e074dd500302d964.zip |
test/py: sleep: Add a test for the time command
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@amd.com>
-rw-r--r-- | test/py/tests/test_sleep.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py index 392af29db2..66a57434bf 100644 --- a/test/py/tests/test_sleep.py +++ b/test/py/tests/test_sleep.py @@ -41,3 +41,21 @@ 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) + +@pytest.mark.buildconfigspec("cmd_misc") +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") + + sleep_time = u_boot_console.config.env.get("env__sleep_time", 10) + sleep_margin = u_boot_console.config.env.get("env__sleep_margin", 0.25) + output = u_boot_console.run_command("time sleep %d" % sleep_time) + execute_time = float(output.split()[1]) + assert sleep_time >= (execute_time - 0.01) + if not u_boot_console.config.gdbserver: + # margin is hopefully enough to account for any system overhead. + assert sleep_time < (execute_time + sleep_margin) |