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

tests(test/drivers): extend modern bpf test framework to all drivers (part 1) #799

Merged
merged 7 commits into from
Dec 21, 2022

Conversation

Andreagit97
Copy link
Member

What type of PR is this?

/kind feature

Any specific area of the project related to this PR?

/area build

/area CI

/area tests

Does this PR require a change in the driver versions?

No

What this PR does / why we need it:

This PR is the first part of the driver's test porting phase, here you can find the full PR #783.
More in detail, this PR adds:

  • extend the testing framework to all drivers (Cmake side). Note that we are able to run tests for all the drivers but drivers are not fixed so we have many failures with bpf and kmod.
  • rename the directory in test/drivers
  • test executable rewrite start_tests.cpp
  • fix a broken bpf_x.cpp test. This failure is due to the fact that now we use the scap engine instead of libpman so we have many more bpf syscalls called by the engine.
  • rename the LOCAL_TEST_SUITE to ACTION_SUITE. Here we could test generic actions like reading from the buffers.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

tests(test/drivers): extend modern bpf test framework to all drivers (part 1)

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
@Andreagit97
Copy link
Member Author

I added the new README :)

@Andreagit97 Andreagit97 added this to the 0.11.0 milestone Dec 19, 2022
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

Left some comments; this is incredible work @Andreagit97!
Thank you very much for taking care of this!
All in all, this LGTM!

cmake -DUSE_BUNDLED_DEPS=On -DENABLE_DRIVERS_TESTS=On -DBUILD_LIBSCAP_GVISOR=Off -DCREATE_TEST_TARGETS=On ..
```

In this case, only the `kmod` engine will be built and you can assert only the behavior of the kernel module. If you want to assert also the bpf probe you have to add `-DBUILD_BPF=True`, while if you want to add the modern bpf probe engine you have to use `-DBUILD_LIBSCAP_MODERN_BPF=On`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I dream a future where:

  • no driver is built by default
  • we use same naming for the cmake options to enable drivers, like DBUILD_LIBSCAP_MODERN_BPF, DBUILD_LIBSCAP_BPF and DBUILD_LIBSCAP_KMOD

Copy link
Member Author

Choose a reason for hiding this comment

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

you are a dreamer my friend!

test/drivers/README.md Outdated Show resolved Hide resolved
test/drivers/README.md Show resolved Hide resolved
test/drivers/event_class/event_class.cpp Outdated Show resolved Hide resolved
test/drivers/event_class/event_class.cpp Outdated Show resolved Hide resolved
test/drivers/event_class/event_class.h Outdated Show resolved Hide resolved
@@ -85,6 +84,13 @@ void assert_syscall_state(int syscall_state, const char* syscall_name, long sysc
class event_test
{
public:
static scap_t* scap_handle;
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmmh why static?
Btw can we call it s_scap_handle ?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is static because is shared between all class objects. Every event_test object uses the same scap handle.

test/drivers/start_tests.cpp Outdated Show resolved Hide resolved
}

/* We need to start the capture to calibrate socket with bpf engine */
if(scap_start_capture(event_test::scap_handle) != SCAP_SUCCESS)
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we need this, but it makes me laugh everytime 😆

gnosek
gnosek previously approved these changes Dec 20, 2022
@poiana
Copy link
Contributor

poiana commented Dec 20, 2022

LGTM label has been added.

Git tree hash: 3988ebd761248402f58ad1d31fa7883343479a77

Signed-off-by: Andrea Terzolo <andrea.terzolo@polito.it>
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

Superb job <3

@poiana
Copy link
Contributor

poiana commented Dec 21, 2022

LGTM label has been added.

Git tree hash: 52aa1f36d16cc1a990b3d83653feefc27223918f

@poiana
Copy link
Contributor

poiana commented Dec 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, leogr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Andreagit97,FedeDP,leogr]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit b3284b0 into master Dec 21, 2022
@poiana poiana deleted the support_test_1 branch December 21, 2022 10:47
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.

5 participants