Skip to content
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

Refactor kernel interface to remove mock and global var #997

Merged
merged 4 commits into from
Oct 12, 2024

Conversation

jkilpatr
Copy link
Member

When a unit testing scheme was originally designed for the kernel interface module in 2017 it was turned into a stateful struct to accomodate a mock test environment that allowed the tests to call the real functions and specify what exact commands they expected to be run.

This structure has not been maintained, new tests are not written in that style and instead use separate testing functions. But the original tests have not been modified much since that time. Leaving Rita with a KI global variable that in production doesn't actually do anything all to support mocking during tests.

This commit removes the mock structure and turns kernel interface into just a grab bag of utility functions where tests functions are all split out internally rather than relying on mock.

While we are touching all of these files it will also be renamed to system_interface rather than kernel interface as we now interface with a lot more than just linux kernel functions from this module.

@jkilpatr jkilpatr self-assigned this Sep 22, 2024
@jkilpatr jkilpatr mentioned this pull request Sep 24, 2024
10 tasks
@jkilpatr jkilpatr force-pushed the jkilpatr/cleanup-kernel-interface branch 3 times, most recently from efa12a8 to 3864368 Compare October 7, 2024 23:50
@jkilpatr jkilpatr changed the title WIP: Refactor kernel interface to remove mock and global var Refactor kernel interface to remove mock and global var Oct 7, 2024
@jkilpatr jkilpatr force-pushed the jkilpatr/cleanup-kernel-interface branch from 3864368 to 0c4fa67 Compare October 8, 2024 00:09
@jkilpatr jkilpatr requested a review from ch-iara October 8, 2024 00:10
When a unit testing scheme was originally designed for the kernel
interface module in 2017 it was turned into a stateful struct to
accomodate a mock test environment that allowed the tests to call the
real functions and specify what exact commands they expected to be run.

This structure has not been maintained, new tests are not written in
that style and instead use separate testing functions. But the original
tests have not been modified much since that time. Leaving Rita with a
KI global variable that in production doesn't actually do anything all
to support mocking during tests.

This commit removes the mock structure and turns kernel interface into
just a grab bag of utility functions where tests functions are all split
out internally rather than relying on mock.

While we are touching all of these files it will also be renamed to
system_interface rather than kernel interface as we now interface with a
lot more than just linux kernel functions from this module.
@jkilpatr jkilpatr force-pushed the jkilpatr/cleanup-kernel-interface branch from 0c4fa67 to 0c24922 Compare October 8, 2024 15:14
Copy link
Contributor

@ch-iara ch-iara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, this will make it much less of a pain to run commands without having to do a little dance to grab KI

Fuzzer actually found a problem, so that's nice.
This commit adds a new test dependency that allows us to tag which tests
need to be run serially versus in parallel. This lets us parallelize the
rest of our test suite and run serially only those tests that must be run
serially.

This dramatically speeds up the tests because we have a number of
fuzzing and other longer run tests that take a few minutes.
@jkilpatr jkilpatr merged commit 11b7421 into master Oct 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants