Make netebpfext unit test resilient to fault injection. - #5547
Make netebpfext unit test resilient to fault injection.#5547Shankar Seal (shankarseal) wants to merge 3 commits into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
0be3f74 to
a8e58db
Compare
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea587460-e416-414f-9687-d52ae0a34d8f
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ea587460-e416-414f-9687-d52ae0a34d8f
dba2b3f to
60bebfe
Compare
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
🟡 Changes recommended
The new nmr_client_handle registration wrapper treats NULL handles as “registered” and may call NmrDeregisterClient(NULL) on registration failure, which can reintroduce crashes under fault injection.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens the netebpfext unit tests against usersim fault injection during NMR/WFP initialization, preventing null-provider crashes and improving CI diagnostics by ensuring fault-injection logs are collected.
Changes:
- Add a fault-injection policy to the
netebpf_ext_helperand introducerequire_initialized()so tests fail fast if required NMR providers didn’t bind. - Add a new unit test that validates all expected NMR bindings while fault injection is enabled.
- Enable building
netebpfext_unitunder theNativeOnlyDebugconfiguration and add a CI step to copy fault-injection logs intoTestLogsfor upload.
File summaries
| File | Description |
|---|---|
| tests/netebpfext_unit/netebpfext_unit.vcxproj | Adds NativeOnlyDebug configuration so the unit test participates in native-only builds. |
| tests/netebpfext_unit/netebpfext_unit.cpp | Adds an NMR-binding validation test and enforces initialization checks across existing tests. |
| tests/netebpfext_unit/netebpf_ext_helper.h | Adds fault-injection policy controls and helper state to validate initialization/bindings. |
| tests/netebpfext_unit/netebpf_ext_helper.cpp | Suspends/resumes fault injection around helper init/teardown and tracks successful hook-provider bindings. |
| ebpf-for-windows.sln | Wires the netebpfext_unit project into NativeOnlyDebug solution configuration. |
| .github/workflows/reusable-test.yml | Copies fault-injection logs into TestLogs so they get uploaded with test artifacts. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dbf0bbe to
d6d93af
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues remain in Azure fault-log collection and helper initialization and fault-injection lifecycle handling.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
tests/netebpfext_unit/netebpf_ext_helper.cpp:100
- This guard is created before
ebpf_platform_initiate()runs at line 111. On the first helper in a fault-injection process, usersim's suspend call is a no-op because the fault-injection singleton is created by platform initialization, so the subsequent NMR/provider setup is still fault-injectable despite the defaultsuspendpolicy. The matching destructor can also call resume against an unsuspended singleton. Arrange suspension after platform initialization, or explicitly handle this two-phase initialization and keep suspend/resume balanced.
_usersim_fault_injection_suspension fault_injection_suspension(
fault_injection_policy == fault_injection_policy_t::suspend);
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
d6d93af to
c65040f
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Several helper-based tests still lack initialization guards, and fault-injection coverage still assumes every NMR binding succeeds.
Review details
Suppressed comments (2)
tests/netebpfext_unit/netebpf_ext_helper.cpp:188
- Please apply this guard to the remaining helper-based tests as well:
sock_addr_bind_invoke, both bind-context tests,sock_addr_bind_callout_disambiguation,sock_addr_bind_get_network_context, andsock_addr_bind_set_redirect_context_rejectedstill construct a helper without callingrequire_initialized(). The constructor can return after a partial initialization, and the callbacks in the network-context and redirect-context tests immediately dereferenceget_program_info_provider_data(...); those tests can therefore still hit the null-provider crash this change is intended to prevent.
void
_netebpf_ext_helper::require_initialized() const
{
REQUIRE(nmr_program_info_client_handle != nullptr);
REQUIRE(nmr_program_info_client_handle->is_registered());
tests/netebpfext_unit/netebpfext_unit.cpp:67
- With
allow_fault_injection, this helper keeps fault injection active while platform/WFP setup, provider registration, and both NMR registrations run. An injectedFwpmFilterAdd0failure makes the corresponding hook attach fail, so the binding count is intentionally below all 12 expected providers andrequire_initialized()fails on the fault-injection iteration this test is meant to exercise. Please make the test validate graceful partial initialization (or otherwise avoid requiring every binding when an injected failure occurred) instead of unconditionally requiring full initialization.
initialize_platform,
allow_fault_injection);
helper.require_initialized();
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com
Description
Fixes #5460 .
Issues
FwpmFilterAdd0()in usersim.dll to fail during the netebpfext test case initialization, prior to NMR hook provider could bind, leaving the corresponding provider unavailable. Subsequent tests assumed initialization had succeeded, accessed the missing provider data, and crashed on a null pointer.fault.logfile was not getting uploadedChanges
The PR includes the following changes.
netebpfexttest helper initializes and tears down.Debug/Releaseconfigurations ofnetebpfext_unit.as part ofNativeOnly*builds.Testing
Do any existing tests cover this change? Are new tests needed?
If new tests were added:
Documentation
Is there any documentation impact for this change?
Installation
Is there any installer impact for this change?