Fix initialization errors in unit tests #4370
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolved issues:
Resolves #4204.
Description of changes:
In some environments, some unit tests currently error with
s2n not initialized
when linked to the shared library of s2n-tls. For example, see the the result of this GH action that builds s2n-tls with a shared library on macOS before this fix was applied.This error is due to including
utils/s2n_mem.c
in .c files:s2n-tls/tests/testlib/s2n_mem_testlib.c
Lines 20 to 21 in 7f84701
When
s2n_init()
is called,initialized
ins2m_mem.c
is set totrue
ins2n_mem_init()
:s2n-tls/utils/s2n_mem.c
Lines 249 to 253 in 7f84701
When
s2n_mem.c
is included from a .c file, this seems to causeinitialized
to be set to false when checked by functions such ass2n_free_without_wipe()
, which is causing unit tests to incorrectly fail:s2n-tls/utils/s2n_mem.c
Lines 287 to 291 in 7f84701
This PR removes the
s2n_mem.c
include from .c files, and instead uses new get/override functions to get and set the mem callbacks.Testing:
I modified the macOS GH action to additionally build and test the s2n-tls shared library, which fails without this fix.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.