blob: 5c1a2623fefa77c68f2aa6758001718aae64768f [file] [log] [blame]
Stephen Warren1c8b4d52016-01-15 11:15:31 -07001# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
2#
3# SPDX-License-Identifier: GPL-2.0
4
5import pytest
6import time
7
8def test_sleep(u_boot_console):
Stephen Warrene8debf32016-01-26 13:41:30 -07009 """Test the sleep command, and validate that it sleeps for approximately
10 the correct amount of time."""
Stephen Warren1c8b4d52016-01-15 11:15:31 -070011
Stephen Warren1c8b4d52016-01-15 11:15:31 -070012 # 3s isn't too long, but is enough to cross a few second boundaries.
13 sleep_time = 3
14 tstart = time.time()
15 u_boot_console.run_command('sleep %d' % sleep_time)
16 tend = time.time()
17 elapsed = tend - tstart
Stephen Warren89ab8412016-02-04 16:11:50 -070018 assert elapsed >= sleep_time
19 if not u_boot_console.config.gdbserver:
20 # 0.25s margin is hopefully enough to account for any system overhead.
21 assert elapsed < (sleep_time + 0.25)