test/mooncake: fix -Werror build failures in mooncake_backend_test#1836
test/mooncake: fix -Werror build failures in mooncake_backend_test#1836x41lakazam wants to merge 2 commits into
Conversation
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>
|
👋 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>
📝 WalkthroughWalkthroughThe Mooncake backend unit test adds explicit fallback returns in two helper functions and marks several local status variables as ChangesMooncake backend test updates
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
test/unit/plugins/mooncake/mooncake_backend_test.cpp
| [[maybe_unused]] int ret = mooncake->registerMem(desc, VRAM_SEG, md); | ||
|
|
||
| assert(ret == NIXL_ERR_NOT_SUPPORTED); | ||
|
|
There was a problem hiding this comment.
🩺 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.
|
/build |
Problem
mooncake_backend_test.cppno longer compiles under the release CI flags (-O3 -DNDEBUG -Werror), which breaksnixl-ci-gpu,nixl-ci-non-gpuandnixl-ci-dl-gpuon every PR (thenon-gpu/dl-gpufailures surface via the editablepip installthat recompiles the C++ tree).-DNDEBUGstripsassert(), so:assert()become unused (-Werror=unused-variable/-Werror=unused-but-set-variable);switchstatements whosedefaultends inassert(0)fall off the end of a non-void function (-Werror=return-type);allocateWrongGPUTest()passes an uninitializeddesc.lentoallocateBuffer()(-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.
Fix
[[maybe_unused]](ret,ret1,ret3_gen).assert(0)inmemType2Str()andgetValidationPtr()so the non-void paths are covered underNDEBUG.desc.lenbeforeallocateBuffer()inallocateWrongGPUTest().No behavioral change in debug builds; release builds now compile clean.
🤖 Generated with the help of Claude Code
Summary by CodeRabbit