-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Backport 2.1: More robust timing tests #1223
Backport 2.1: More robust timing tests #1223
Conversation
The POSIX/Unix implementation of mbedtls_set_alarm did not set the mbedtls_timing_alarmed flag when called with 0, which was inconsistent with what the documentation implied and with the Windows behavior.
mbedtls_timing_get_timer with reset=1 is called both to initialize a timer object and to reset an already-initialized object. In an initial call, the content of the data structure is indeterminate, so the code should not read from it. This could crash if signed overflows trap, for example. As a consequence, on reset, we can't return the previously elapsed time as was previously done on Windows. Return 0 as was done on Unix.
Print some not-very-nice-looking but helpful diagnosis information if the timing selftest fails. Since the failures tend to be due to heavy system load that's hard to reproduce, this information is necessary to understand what's going on.
No behavior change.
If given command line arguments, interpret them as test names and only run those tests.
E.g. "selftest -x timing" runs all the self-tests except timing.
mbedtls_timing_self_test fails annoyingly often when running on a busy machine such as can be expected of a continous integration system. Increase the tolerances in the delay test, to reduce the chance of failures that are only due to missing a deadline on a busy machine.
Increase the duration of the self test, otherwise it tends to fail on a busy machine even with the recently upped tolerance. But run the loop only once, it's enough for a simple smoke test.
We don't need to test multiple delays in a self-test. Save 5s of busy-wait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm satistifed this is a faithful backport of the main branch:
- minus the new test suite which wasn't planned for backporting
- plus a fix to an error code in selftest.c along the way (the issue wasn't present in development)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Withdrawing my approval in the light of the following CI failure: EXIT_FAILURE
not defined in selftest.c
. Please fix by making it more similar to the development branch.
Include stdlib.h for EXIT_FAILURE.
@mpg In the development branch, there's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is a partial backport of #1136 . Included:
mbedtls_timing_get_timer
on Windows (internal ref: IOTSSL-1822)mbedtls_set_alarm(0)
on Unix/POSIX.selftest
program, support running a subset of the tests with command line arguments.Not included:
Internal ref: IOTSSL-1798