Skip to content

Conversation

@nmlud21
Copy link
Contributor

@nmlud21 nmlud21 commented Sep 23, 2025

Description

Resolves #4261

Some tests in libbpf_test.cpp and netsh_test.cpp only ran for JIT/Interpreted programs. Some of these tests should also run for native programs so for each applicable test, functionality was expanded so that the test would also run for native eBPF programs.

Testing

No new tests needed.

Documentation

No.

Installation

No.

@nmlud21 nmlud21 force-pushed the clean-issue4261 branch 2 times, most recently from ce77c22 to 14c75e9 Compare September 30, 2025 20:37
Formatting changes

Rewrote more tests to run for all eBPF programs.

Modified certain tests to run for all types of eBPF programs.

Modified specific netsh_test to include all eBPF program types.

Added a scope exit to ensure cleanup during fault injection.

Reordered cleanup in test helper destructor.
Copy link
Collaborator

@dthaler dthaler left a comment

Choose a reason for hiding this comment

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

Approving since my remaining comment is not a big deal either way.
If you need to rev this again for some other reason, would be good to address.
But ok with me to merge if someone else approves it as is.

Comment on lines +133 to +147
#if !defined(CONFIG_BPF_JIT_DISABLED)
void
test_invalid_bpf_action(char log_buffer[])
{
REQUIRE(errno == EACCES);
REQUIRE(strcmp(log_buffer, "0: Invalid type (r0.type == number)\n\n") == 0);
}
#else
void
test_invalid_bpf_action(char log_buffer[])
{
UNREFERENCED_PARAMETER(log_buffer);
REQUIRE(errno == ENOTSUP);
}
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is ok, but since lines 135, 136, and 139 are the same as 142, 143, and 146, it would seem better to me to put the ifdefs inside the function, only wrapping the two different lines.

@Alan-Jowett Alan-Jowett added this pull request to the merge queue Oct 2, 2025
Merged via the queue into microsoft:main with commit 875797f Oct 2, 2025
106 checks passed
@nmlud21 nmlud21 deleted the clean-issue4261 branch October 2, 2025 20:46
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.

libbpf tests must run for native programs

3 participants