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

Introduce the end-to-end test harness #164

Merged
merged 7 commits into from
Nov 8, 2024

Conversation

qdeslandes
Copy link
Contributor

After refactoring the unit tests harness (#161) and creating a shared testing harness in tests/harness (#163), this is the final PR to create an end-to-end testing target!

The end-to-end tests will be used to validate the bytecode generated by bpfilter by:

  • Running the bpfilter daemon locally
  • Define custom filtering rules
  • Send dummy packets to a BPF program and validate the return code

End-to-end tests rely on cmocka (like the unit tests) to run the test suite. Helper functions defined in previous PR are used to manage the daemon and define the filtering rules.

While the test harness has been moved from tests/unit/harness to
tests/harness, the unit_tests target was still linked to the harness
dependencies.

Remove the harness dependencies from tests/unit/harness to
tests/harness.
Fake functions have been moved from tests/unit/harness into
tests/harness, but they depend on src/bpfilter (e.g. bf_cgen_xxx()).
Move the fake functions back into tests/unit, and keep the fake file
functions in tests/harness.
Add autosectionlabel Sphinx extension to link to anchors in a page.

Rename docs/developers/fronts/nftables.rst to nft.rst to reflect the
actual front-end name and prevent anchor clash with
docs/usage/nftables.rst.
Add the bf_test_prog object which represents a BPF program. It will be
used in end-to-end tests to interact with a program generated by
bpfilter and execute test runs.
Creating a chain requires a bf_hook_opts object which can be cumbersome
to construct: strings must be copied and used_opts needs to be updated
for each option.

Add a new helper to easily create a bf_hook_opts object from a list of
(option, value) pairs.
Create a new e2e target to build and run end-to-end tests. End-to-end
test will configure bpfilter with a specific chain and use
BPF_PROG_TEST_RUN to ensure the BPF program behaves as expected.
@qdeslandes qdeslandes merged commit ccfe788 into facebook:main Nov 8, 2024
11 checks passed
@qdeslandes qdeslandes deleted the e2e_harness branch November 8, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants