1 # SPDX-License-Identifier: GPL-2.0
2 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
8 Note: This test doesn't rely on boardenv_* configuration values but they can
11 # Setup env__sleep_accurate to False if time is not accurate on your platform
12 env__sleep_accurate = False
16 def test_sleep(u_boot_console):
17 """Test the sleep command, and validate that it sleeps for approximately
18 the correct amount of time."""
20 sleep_skip = u_boot_console.config.env.get('env__sleep_accurate', True)
22 pytest.skip('sleep is not accurate')
24 if u_boot_console.config.buildconfig.get('config_cmd_misc', 'n') != 'y':
25 pytest.skip('sleep command not supported')
26 # 3s isn't too long, but is enough to cross a few second boundaries.
29 u_boot_console.run_command('sleep %d' % sleep_time)
31 elapsed = tend - tstart
32 assert elapsed >= (sleep_time - 0.01)
33 if not u_boot_console.config.gdbserver:
34 # 0.25s margin is hopefully enough to account for any system overhead.
35 assert elapsed < (sleep_time + 0.25)