Skip to content

Commit 4234394

Browse files
authored
Merge pull request #733 from ldorau/Add_asserts_to_testNuma_checkModeInterleaveCustomPartSize
Fix two testNuma tests
2 parents 9f03d6b + 17d13b7 commit 4234394

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/provider_os_memory_multiple_numa_nodes.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,19 @@ TEST_F(testNuma, checkModeInterleave) {
373373

374374
// Test where each page will be allocated.
375375
// Get the first numa node for ptr; Each next page is expected to be on next nodes.
376+
int node = -1;
377+
ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &node));
378+
ASSERT_GE(node, 0);
376379
int index = -1;
377-
ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &index));
380+
for (size_t i = 0; i < numa_nodes.size(); i++) {
381+
if (numa_nodes[i] == (unsigned)node) {
382+
index = i;
383+
break;
384+
}
385+
}
386+
ASSERT_GE(index, 0);
387+
ASSERT_LT(index, numa_nodes.size());
388+
378389
for (size_t i = 1; i < (size_t)pages_num; i++) {
379390
index = (index + 1) % numa_nodes.size();
380391
EXPECT_NODE_EQ((char *)ptr + page_size * i, numa_nodes[index]);
@@ -417,8 +428,19 @@ TEST_F(testNuma, checkModeInterleaveCustomPartSize) {
417428
memset(ptr, 0xFF, size);
418429
// Test where each page will be allocated.
419430
// Get the first numa node for ptr; Each next part is expected to be on next nodes.
431+
int node = -1;
432+
ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &node));
433+
ASSERT_GE(node, 0);
420434
int index = -1;
421-
ASSERT_NO_FATAL_FAILURE(getNumaNodeByPtr(ptr, &index));
435+
for (size_t i = 0; i < numa_nodes.size(); i++) {
436+
if (numa_nodes[i] == (unsigned)node) {
437+
index = i;
438+
break;
439+
}
440+
}
441+
ASSERT_GE(index, 0);
442+
ASSERT_LT(index, numa_nodes.size());
443+
422444
for (size_t i = 0; i < (size_t)part_num; i++) {
423445
for (size_t j = 0; j < part_size; j += page_size) {
424446
ASSERT_NODE_EQ((char *)ptr + part_size * i + j, numa_nodes[index]);

0 commit comments

Comments
 (0)