Skip to content

test/mooncake: fix -Werror build failures in mooncake_backend_test#1836

Open
x41lakazam wants to merge 2 commits into
ai-dynamo:mainfrom
x41lakazam:fix-mooncake-test-werror
Open

test/mooncake: fix -Werror build failures in mooncake_backend_test#1836
x41lakazam wants to merge 2 commits into
ai-dynamo:mainfrom
x41lakazam:fix-mooncake-test-werror

Conversation

@x41lakazam

@x41lakazam x41lakazam commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Problem

mooncake_backend_test.cpp no longer compiles under the release CI flags (-O3 -DNDEBUG -Werror), which breaks nixl-ci-gpu, nixl-ci-non-gpu and nixl-ci-dl-gpu on every PR (the non-gpu/dl-gpu failures surface via the editable pip install that recompiles the C++ tree).

-DNDEBUG strips assert(), so:

  • status locals that are only read by assert() become unused (-Werror=unused-variable / -Werror=unused-but-set-variable);
  • the two switch statements whose default ends in assert(0) fall off the end of a non-void function (-Werror=return-type);
  • allocateWrongGPUTest() passes an uninitialized desc.len to allocateBuffer() (-Werror=uninitialized).

The test file is unchanged since Aug 2025 — a recent CI base-image/compiler bump turned these long-standing warnings into hard errors.

mooncake_backend_test.cpp:301: error: unused variable 'ret' [-Werror=unused-variable]
mooncake_backend_test.cpp:154: error: control reaches end of non-void function [-Werror=return-type]
mooncake_backend_test.cpp:296: error: 'desc...len' is used uninitialized [-Werror=uninitialized]
... (and similar at 323, 357, 496, 579, 619, 268)

Fix

  • Mark assert-only locals [[maybe_unused]] (ret, ret1, ret3_gen).
  • Return a fallback after assert(0) in memType2Str() and getValidationPtr() so the non-void paths are covered under NDEBUG.
  • Initialize desc.len before allocateBuffer() in allocateWrongGPUTest().

No behavioral change in debug builds; release builds now compile clean.

🤖 Generated with the help of Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Resolved compiler warnings in Mooncake backend unit tests by cleaning up unused status variables.
    • Added clear fallback returns for unsupported cases, improving test code stability and compiler compatibility.

mooncake_backend_test.cpp fails to compile under the release CI flags
(-O3 -DNDEBUG -Werror). NDEBUG strips assert(), so the status variables
that are only consulted by asserts become unused, and the two switch
statements whose default case ends in assert(0) now fall off the end of
non-void functions. A recent CI base-image/compiler bump turned these
long-standing warnings into hard errors, breaking the nixl-ci-gpu,
nixl-ci-non-gpu and nixl-ci-dl-gpu pipelines on every PR.

- Mark assert-only locals [[maybe_unused]] (ret/ret1/ret3_gen).
- Return a fallback value after assert(0) in memType2Str() and
  getValidationPtr() so the non-void paths are covered under NDEBUG.
- Initialize desc.len before allocateBuffer() in allocateWrongGPUTest()
  (it was passed uninitialized as the allocation size).

No behavioral change in debug builds; release builds now compile clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@x41lakazam x41lakazam requested a review from a team as a code owner June 25, 2026 07:50
@copy-pr-bot

copy-pr-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

👋 Hi x41lakazam! Thank you for contributing to ai-dynamo/nixl.

Your PR reviewers will review your contribution then trigger the CI to test your changes.

🚀

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Mooncake backend unit test adds explicit fallback returns in two helper functions and marks several local status variables as [[maybe_unused]] to suppress warnings.

Changes

Mooncake backend test updates

Layer / File(s) Summary
Helper fallback returns
test/unit/plugins/mooncake/mooncake_backend_test.cpp
memType2Str returns "UNKNOWN" and getValidationPtr returns nullptr after their unsupported-type branches.
Unused status variables
test/unit/plugins/mooncake/mooncake_backend_test.cpp
Several test-local return/status variables are marked [[maybe_unused]] across the Mooncake backend transfer and allocation tests.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A bunny hops through warning haze,
With maybe_unused in tidy ways.
Unknown types now have a trail,
nullptr and "UNKNOWN" set the sail,
And quiet tests go pitter-pat hooray 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing Mooncake test build failures caused by -Werror in mooncake_backend_test.cpp.
Description check ✅ Passed The description covers the problem, rationale, and fix clearly, with enough detail despite not using the exact template headings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/unit/plugins/mooncake/mooncake_backend_test.cpp`:
- Around line 304-307: The tests in mooncake_backend_test.cpp are using assert
for runtime status checks, so failures disappear in release builds and can hide
bad registerMem, loadRemoteMD, or getNotifs results. Replace the affected
assert(ret == ...) checks in the relevant test cases (including the ones around
registerMem, loadRemoteMD, getNotifs, and the notification loop) with non-elided
test assertions like ASSERT_EQ or explicit failure handling so the test still
fails when these calls return an unexpected status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 664486e9-0783-4b7b-b653-619d26778643

📥 Commits

Reviewing files that changed from the base of the PR and between 49ef3ce and 5439369.

📒 Files selected for processing (1)
  • test/unit/plugins/mooncake/mooncake_backend_test.cpp

Comment on lines +304 to 307
[[maybe_unused]] int ret = mooncake->registerMem(desc, VRAM_SEG, md);

assert(ret == NIXL_ERR_NOT_SUPPORTED);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Don’t rely on assert for runtime status checks in release builds.

With -DNDEBUG, these assert(ret == ...) checks are removed, so failed registerMem/loadRemoteMD/getNotifs calls are ignored. That can leave invalid metadata in use or spin forever in the notification loop. Please enforce these checks with non-elided test assertions (e.g., ASSERT_EQ) or explicit failure handling.

Also applies to: 326-329, 360-362, 622-625

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit/plugins/mooncake/mooncake_backend_test.cpp` around lines 304 - 307,
The tests in mooncake_backend_test.cpp are using assert for runtime status
checks, so failures disappear in release builds and can hide bad registerMem,
loadRemoteMD, or getNotifs results. Replace the affected assert(ret == ...)
checks in the relevant test cases (including the ones around registerMem,
loadRemoteMD, getNotifs, and the notification loop) with non-elided test
assertions like ASSERT_EQ or explicit failure handling so the test still fails
when these calls return an unexpected status.

@ofer

ofer commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

/build

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.

2 participants