-
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
Fix test function derive_key_exercise() #6873
Conversation
mbedtls_test_psa_setup_key_derivation_wrap() returns 1 for success, 0 for error, so the test here was wrong. This is just a hotfix in order to avoid a testing gap. Larger issues not addressed here: - I don't think we should just exit and mark the test as passed; if we're not doing the actual testing this should be marked as SKIP. - Returning 1 for success and 0 for failure is a violation of our documented coding guidelines. We're also supposed to test with == 0 or != 0. Having consistent conventions is supposed to help avoid errors like this. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
Where is this happening? It's the job of
I'm afraid I introduced this convention in test code: auxiliary functions return booleans ( I do agree that it's problematic that this is the opposite convention from library functions in terms of what 0 vs nonzero means. But I'm not convinced that changing to 0 for error and 1 for success would be less error-prone. And using library error codes wouldn't really make sense either (would they even be |
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.
Looks correct to me now, with no follow-up needed (unless it causes an existing test to break).
Ah right, missed that, thanks. |
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
mbedtls_test_psa_setup_key_derivation_wrap()
returns 1 for success, 0 for error, so the test here was wrong. Other uses of this function in the same file have the correct check (either!
or== 0
). This was causing tests usingderive_key_exercises()
to be marked as PASS even in builds where other derive key tests fail which made me notice.Gatekeeper checklist