Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions test/unit/plugins/mooncake/mooncake_backend_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ memType2Str(nixl_mem_t mem_type) {
default:
std::cout << "Unsupported memory type!" << std::endl;
assert(0);
return std::string("UNKNOWN");
}
}

Expand Down Expand Up @@ -267,6 +268,7 @@ getValidationPtr(nixl_mem_t mem_type, void *addr, size_t len) {
default:
std::cout << "Unsupported memory type!" << std::endl;
assert(0);
return nullptr;
}
}

Expand All @@ -293,12 +295,13 @@ allocateWrongGPUTest(nixlBackendEngine *mooncake, int dev_id) {
nixlBackendMD *md;
void *buf;

desc.len = 1 * 1024 * 1024;
allocateBuffer(VRAM_SEG, dev_id, desc.len, buf);

desc.devId = dev_id;
desc.addr = (uint64_t)buf;

int ret = mooncake->registerMem(desc, VRAM_SEG, md);
[[maybe_unused]] int ret = mooncake->registerMem(desc, VRAM_SEG, md);

assert(ret == NIXL_ERR_NOT_SUPPORTED);

Comment on lines +304 to 307

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.

Expand All @@ -320,7 +323,7 @@ allocateAndRegister(nixlBackendEngine *mooncake,
desc.len = len;
desc.devId = dev_id;

int ret = mooncake->registerMem(desc, mem_type, md);
[[maybe_unused]] int ret = mooncake->registerMem(desc, mem_type, md);

assert(ret == NIXL_SUCCESS);
}
Expand Down Expand Up @@ -354,7 +357,7 @@ loadRemote(nixlBackendEngine *mooncake,
// assert(info.metaInfo.size() > 0);

// We get the data from the cetnral location and populate the backend, and receive remote_meta
int ret = mooncake->loadRemoteMD(info, mem_type, agent, rmd);
[[maybe_unused]] int ret = mooncake->loadRemoteMD(info, mem_type, agent, rmd);
assert(NIXL_SUCCESS == ret);
}

Expand Down Expand Up @@ -493,7 +496,7 @@ test_intra_agent_transfer(bool p_thread, nixlBackendEngine *mooncake, nixl_mem_t
std::cout << std::endl << std::endl;

std::string agent1("Agent1");
nixl_status_t ret1;
[[maybe_unused]] nixl_status_t ret1;

int iter = 10;

Expand Down Expand Up @@ -576,7 +579,7 @@ test_inter_agent_transfer(bool p_thread,
nixlBackendEngine *mooncake2,
nixl_mem_t dst_mem_type,
int dst_dev_id) {
int ret;
[[maybe_unused]] int ret;
int iter = 10;

std::cout << std::endl << std::endl;
Expand Down Expand Up @@ -616,7 +619,7 @@ test_inter_agent_transfer(bool p_thread,
int ret_gen = 0;
notif_list_t target_notif_gen;
while (ret_gen == 0) {
int ret3_gen = mooncake2->getNotifs(target_notif_gen);
[[maybe_unused]] int ret3_gen = mooncake2->getNotifs(target_notif_gen);
ret_gen = target_notif_gen.size();
assert(ret3_gen == NIXL_SUCCESS);
}
Expand Down
Loading