Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use monotonic clock for measuring intervals in tests. #19659

Merged
merged 1 commit into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/tests/chiptest/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __startServer(self, runner, command):
def __waitFor(self, waitForString, server_process, outpipe):
logging.debug('Waiting for %s' % waitForString)

start_time = time.time()
start_time = time.monotonic()
ready, self.lastLogIndex = outpipe.CapturedLogContains(
waitForString, self.lastLogIndex)
while not ready:
Expand All @@ -128,7 +128,7 @@ def __waitFor(self, waitForString, server_process, outpipe):
(waitForString, server_process.returncode))
logging.error(died_str)
raise Exception(died_str)
if time.time() - start_time > 10:
if time.monotonic() - start_time > 10:
raise Exception('Timeout while waiting for %s' % waitForString)
time.sleep(0.1)
ready, self.lastLogIndex = outpipe.CapturedLogContains(
Expand Down
6 changes: 3 additions & 3 deletions scripts/tests/run_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, o
for i in range(iterations):
logging.info("Starting iteration %d" % (i+1))
for test in context.obj.tests:
test_start = time.time()
test_start = time.monotonic()
try:
test.Run(runner, apps_register, paths, pics_file)
test_end = time.time()
test_end = time.monotonic()
logging.info('%-20s - Completed in %0.2f seconds' %
(test.name, (test_end - test_start)))
except Exception:
test_end = time.time()
test_end = time.monotonic()
logging.exception('%s - FAILED in %0.2f seconds' %
(test.name, (test_end - test_start)))
apps_register.uninit()
Expand Down