Skip to content

Make netebpfext unit test resilient to fault injection. - #5547

Open
Shankar Seal (shankarseal) wants to merge 2 commits into
microsoft:mainfrom
shankarseal:shankarseal-fix-netebpfext-fault-injection
Open

Make netebpfext unit test resilient to fault injection.#5547
Shankar Seal (shankarseal) wants to merge 2 commits into
microsoft:mainfrom
shankarseal:shankarseal-fix-netebpfext-fault-injection

Conversation

@shankarseal

@shankarseal Shankar Seal (shankarseal) commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Description

Fixes #5460 .

Issues

  • Fault injection could cause the mock 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.log file was not getting uploaded
  • netebpfext unit test was not built in native flavor.

Changes

The PR includes the following changes.

  • Update usersim to support suspend/resume fault injection.
  • Suspend usersim fault injection while the netebpfext test helper initializes and tears down.
  • Add a unit test that exercises all NMR bindings with fault injection enabled.
  • Require all expected NMR bindings for existing tests while excluding helper initialization from fault injection.
  • Add a CI step that collects fault-injection logs so they are uploaded with the test results.
  • Add NativeOnlyDebug configuration to netebpfext_unit.vcxproj.

Testing

Do any existing tests cover this change? Are new tests needed?

If new tests were added:

  • Unit tests are added.
  • Driver tests are added.
  • Fuzz tests are added.

Documentation

Is there any documentation impact for this change?

Installation

Is there any installer impact for this change?

@github-actions

This comment was marked as resolved.

@shankarseal
Shankar Seal (shankarseal) marked this pull request as draft August 31, 2026 22:12
@shankarseal
Shankar Seal (shankarseal) force-pushed the shankarseal-fix-netebpfext-fault-injection branch from 0be3f74 to a8e58db Compare September 1, 2026 01:29
@github-actions

This comment was marked as resolved.

1 similar comment
@github-actions

This comment was marked as resolved.

Shankar Seal added 2 commits September 1, 2026 18:13
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
@shankarseal
Shankar Seal (shankarseal) force-pushed the shankarseal-fix-netebpfext-fault-injection branch from dba2b3f to 60bebfe Compare September 2, 2026 01:13
@github-actions

This comment was marked as resolved.

@shankarseal Shankar Seal (shankarseal) changed the title update netebpfext unit test to suspend fault injection during test init. Make netebpfext unit test resilient to fault injection. Sep 2, 2026
@shankarseal
Shankar Seal (shankarseal) marked this pull request as ready for review September 2, 2026 01:20
<PlatformToolset>$(EbpfPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='NativeOnlyDebug'" Label="Configuration">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we dont really need nativeonlydebug flavor here. we just need to configure the solution to build "debug" flavor of this project when "nativeonlydebug" is being built (similarly for nativeonlyrelease)

TEST_CASE("query program info", "[netebpfext]")
{
netebpf_ext_helper_t helper;
helper.require_initialized();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: since we are already adding this to every test case, we can probably skip suspend / resume entirely and just add a check in require_initialized that either it should be initialized or fault injection should be enabled.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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_helper and introduce require_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_unit under the NativeOnlyDebug configuration and add a CI step to copy fault-injection logs into TestLogs for 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.

Comment on lines +231 to +235
bool
is_registered() const
{
return nmr_client_handle != INVALID_HANDLE_VALUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Workflow failed - netebpfext_fault_injection_full

4 participants