-
Notifications
You must be signed in to change notification settings - Fork 179
testing: Add test scenarios for OBJ plugin gtest #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,67 @@ TEST_P(setupObjTestFixture, queryMemTest) { | |
| EXPECT_EQ(resp[2].has_value(), false); | ||
| } | ||
|
|
||
| TEST_P(setupObjTestFixture, writeWithOffsetsTest) { | ||
| transferMemConfig mem_cfg{.numEntries_ = 2}; | ||
| transferHandler<DRAM_SEG, OBJ_SEG> transfer( | ||
| localBackendEngine_, localBackendEngine_, local_agent_name, local_agent_name, mem_cfg); | ||
| transfer.setupMems(); | ||
|
|
||
| nixl_xfer_op_t op = NIXL_WRITE; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why a stack variable assist here. |
||
| ASSERT_EQ(transfer.prepareTransfer(op), NIXL_SUCCESS); | ||
| ASSERT_EQ(transfer.postTransfer(op), NIXL_SUCCESS); | ||
| ASSERT_EQ(transfer.waitForTransfer(), NIXL_ERR_BACKEND); | ||
| } | ||
|
|
||
| TEST_P(setupObjTestFixture, readWithOffsetsTest) { | ||
| uint8_t src_byte = getRandomInt(0, 255); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To have less hard coded numbers, I would suggest: |
||
|
|
||
| // First, write entire buffer to OBJ in a single chunk (no offsets) | ||
| transferMemConfig mem_cfg_write{.numEntries_ = 1, .entrySize_ = 128, .srcBufByte_ = src_byte}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same note regarding |
||
| transferHandler<DRAM_SEG, OBJ_SEG> transferWrite(localBackendEngine_, | ||
| localBackendEngine_, | ||
| local_agent_name, | ||
| local_agent_name, | ||
| mem_cfg_write); | ||
| transferWrite.setupMems(); | ||
| transferWrite.setSrcMem(); | ||
| transferWrite.testTransfer(NIXL_WRITE); | ||
|
|
||
| // Then, read buffer from OBJ in smaller offset-based chunks | ||
| transferMemConfig mem_cfg_read{.numEntries_ = 2, .entrySize_ = 64, .srcBufByte_ = src_byte}; | ||
| transferHandler<DRAM_SEG, OBJ_SEG> transferRead( | ||
| localBackendEngine_, localBackendEngine_, local_agent_name, local_agent_name, mem_cfg_read); | ||
| transferRead.setupMems(); | ||
| transferRead.resetSrcMem(); | ||
| transferRead.testTransfer(NIXL_READ); | ||
| transferRead.checkSrcMem(); | ||
| } | ||
|
|
||
| TEST_P(setupObjTestFixture, xferUnregisteredMemTest) { | ||
| transferHandler<DRAM_SEG, OBJ_SEG> transfer( | ||
| localBackendEngine_, localBackendEngine_, local_agent_name, local_agent_name); | ||
|
|
||
| nixlMetaDesc meta_desc; | ||
| meta_desc.devId = 1; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 1 a must? if so please use named constant, otherwise a random value |
||
| transfer.addSrcDesc(meta_desc); | ||
| transfer.addDstDesc(meta_desc); | ||
|
|
||
| nixl_xfer_op_t op = NIXL_WRITE; | ||
| ASSERT_EQ(transfer.prepareTransfer(op), NIXL_SUCCESS); | ||
| ASSERT_EQ(transfer.postTransfer(op), NIXL_ERR_BACKEND); | ||
| } | ||
|
|
||
| TEST_P(setupObjTestFixture, objAsSrcMemTest) { | ||
| transferHandler<OBJ_SEG, OBJ_SEG> transfer( | ||
| localBackendEngine_, localBackendEngine_, local_agent_name, local_agent_name); | ||
| ASSERT_EQ(transfer.prepareTransfer(NIXL_WRITE), NIXL_ERR_INVALID_PARAM); | ||
| } | ||
|
|
||
| TEST_P(setupObjTestFixture, dramAsDstMemTest) { | ||
| transferHandler<DRAM_SEG, DRAM_SEG> transfer( | ||
| localBackendEngine_, localBackendEngine_, local_agent_name, local_agent_name); | ||
| ASSERT_EQ(transfer.prepareTransfer(NIXL_WRITE), NIXL_ERR_INVALID_PARAM); | ||
| } | ||
|
Comment on lines
+147
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (All around) When you have a single place to use a class you can do that creating a temporary instance with shorter life span (gone after function call), i.e.: |
||
|
|
||
| INSTANTIATE_TEST_SUITE_P(ObjTests, setupObjTestFixture, testing::Values(obj_test_params)); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
2a must? if so, please use a named constant, otherwise a random value.