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.
This pull requests creates the foundation to be able to test this library end to end. Right now, it uses the mock interface and dummy users to verify behavior, which completely circumvents calls to
libc
and therefore to NSS.This adds new tests, which runs must be separate from the general tests, and require the use of
libnss_wrapper
inLD_PRELOAD
to add fixture users that are actually going to be returned bylibc
.Note that the existing tests cannot be run with this, because the "current user" that it uses is not present in the fixtured data.
All mocked tests are defined under a feature called
test-integration
and will only be executed when the feature is set. Also, and I am not entirely satisfied by this, in order to only run the new tests when wrapping NSS, they are all prefixed withmocked_
right now (I neither like the naming nor the concept). We then only execute tests with that prefix for that phase.Ultimately, the three rounds of tests that are performed are:
cargo test
: same as before, nothing changesLD_PRELOAD=... cargo test --features test-integration mocked_
: run new unit testscargo test --features test-integration --test '*'
: run new integration testsThat way, current users can still run the usual test suite without any impact, and CI (or users willing to install
libnss_wrapper
) can run the whole suite.I have taken the liberty to rewrite some of the unit test in
base.rs
to take advantage of the fixtures (in a separate test module for clarity) to show how it could be done.Please add remarks, this came out of a prototype, and there are some things I am still not a fan of.
Related to #14.
Note: the
serial_test
crate was added to prevent unit tests that actually interact withlibc
from running in parallel, to prevent known thread-safety issues.