Skip to content

Add per-fixture isolation in GTEST for MsQuicLib() and some much needed de-duplications.#6149

Open
ProjectsByJackHe wants to merge 4 commits into
mainfrom
jackhe/refactor-xdp-map-test
Open

Add per-fixture isolation in GTEST for MsQuicLib() and some much needed de-duplications.#6149
ProjectsByJackHe wants to merge 4 commits into
mainfrom
jackhe/refactor-xdp-map-test

Conversation

@ProjectsByJackHe

@ProjectsByJackHe ProjectsByJackHe commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Removes the --useXdpMaps flag by adding behavior to the Gtest suite to teardown/set up a new MsQuicLib() per test fixture, and also refactor the code to remove code duplication.

Key changes:

  • Leverage the gtest SetUpTestSuite() and TearDownTestSuite() to create a new MsQuicLib() instead of re-using the old singleton for each test fixture.
  • Remove the --useXdpMap flag from the test script/binary, and instead do a probe check.
  • Introduced some base gtest class to inherit from to achieve the above

Testing

See the CI

Documentation

No documentation impact.

@ProjectsByJackHe
ProjectsByJackHe requested a review from a team as a code owner July 16, 2026 00:53
Comment thread src/test/bin/XdpMapModeHelpers.cpp Outdated
@ProjectsByJackHe ProjectsByJackHe changed the title Refactor the XDP tests to remove the --useMapMode flag Add per-fixture isolation in GTEST for MsQuicLib() and some much needed de-duplications. Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.76%. Comparing base (b3ba24c) to head (77b9208).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6149      +/-   ##
==========================================
+ Coverage   84.49%   84.76%   +0.27%     
==========================================
  Files          60       60              
  Lines       18973    18974       +1     
==========================================
+ Hits        16031    16084      +53     
+ Misses       2942     2890      -52     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfriesen mtfriesen 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.

Generally looks great to me, but please get a second set of eyeballs.

@guhetier guhetier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some initial comments at a quick review pass.
The general approach looks good.

//
// Fixture classes for plain test suites (TEST_F).
//
class ParameterValidation : public QuicTestFixture {};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need this? Is there a difference with using QuicTestFixture directly? Is it just a question of naming of the test categories?

If that is the reason why, consider moving this line close to the definition of the test that use it

// Macros that generate the standard test body boilerplate:
// logger + kernel-mode dispatch + user-mode call.
//
#define QUIC_TEST_F(Suite, Name, Func) \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I initially avoided to factor this in a macro because it can't be used in 100% of cases: some tests are UM only or need some extra parameter processing.
It makes it harder to understand why QUIC_TEST_F or TEST_F is used on a specific test since the logic is hidden far away in the file.

If we go for an extra layer of wrapping macro, let's make the name more explicit:

  • QUIC is irrelevant here, the test could be about anything
  • I'd like to see UM and KM appear in the name, to clarify it does some dispatch between the two. Maybe "TEST_UM_KM_F"? Better idea welcome...

TestLogger Logger(#Func); \
if (TestingKernelMode) { \
ASSERT_TRUE(InvokeKernelTest(FUNC(Func))); \
} else { Func(); } \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: style

::testing::ValuesIn(WithXdpMapModeArgs::Generate()));
#endif // _WIN32 && QUIC_API_ENABLE_PREVIEW_FEATURES

QUIC_TEST_F(ParameterValidation, ValidateCommonParam, QuicTestCommonParam)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Consider using the test function as a name, instead of having to parameters that are very similar most of the time.
It might be harder if the same function is reused in multiple tests, but I think I already removed all of those.

ASSERT_TRUE(InvokeKernelTest(FUNC(QuicTestRegistrationParam)));
} else {
QuicTestRegistrationParam();
static bool SuiteSkip;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the gtest doc (https://google.github.io/googletest/primer.html#same-data-multiple-tests), I don't think these should be static.
The test can access them.

SuiteFailureReason = nullptr;

if (TestingKernelMode) {
SuiteSkip = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can't you just call GTEST_SKIP from here?

}
#if defined(_WIN32) && defined(QUIC_API_ENABLE_PREVIEW_FEATURES)
struct WithXdpMapModeArgs : public QuicTestFixture,
public ::testing::WithParamInterface<XdpMapModeArgs> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are the test params used in the fixture itself?
If no, I recommend to split them. Keep the fixture class focused on setup only.
Then add parameter in a new type inheriting from that XDP-map-mode fixture and the params.

It'll make it easier to add tests with different param sets in the future.

XdpMapState.InterfaceCount = (uint32_t)IfIndices.size();
memcpy(XdpMapState.IfIndices, IfIndices.data(),
sizeof(uint32_t) * IfIndices.size());
printf("WithXdpMapModeArgs: discovered %u DuoNic interface(s)\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we avoid printf and use logging mechanism already in use?

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.

3 participants