Remove the hooks module entirely #51
Draft
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.
These were originally added (in the perf_event crate) as a way to mock out the perf_event_open syscall and related ioctls for testing purposes. The problem ends up being that perf_event_open is a really complicated syscall. Writing a mock for most behaviour ends up being extremely hard to do.
I haven't managed to find a use case for this module and, according to sourcegraph, neither has anybody else. As such, I think removing it is the right thing to do. This is a breaking change.
Some notes on what makes mocking the system API not so useful
The hooks API allows a test to mock
However, actually using the API mostly involves:
The main features of this crate are:
Of the 3 features, the only one that can really be usefully tested with the mocked hooks module is the second. The 1st can only be usefully tested against the kernel itself and the 3rd is too complicated to actually make a mock for. However, it is really quite easy to write some for the 2nd feature that work on any machine, which kinda gets rid of the whole point of mocking them in the first place.
The one exception is that github actions completely blocks the perf_event_open API for some reason and mocking it could allow a few tests to run in CI. While this is true, it's not incredibly useful since the tests that could actually run are rather limited. It is more useful to have contributors run the unit tests on their own machines before making the PR instead.