@@ -373,8 +373,19 @@ TEST_F(testNuma, checkModeInterleave) {
373
373
374
374
// Test where each page will be allocated.
375
375
// 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 );
376
379
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
+
378
389
for (size_t i = 1 ; i < (size_t )pages_num; i++) {
379
390
index = (index + 1 ) % numa_nodes.size ();
380
391
EXPECT_NODE_EQ ((char *)ptr + page_size * i, numa_nodes[index]);
@@ -417,8 +428,19 @@ TEST_F(testNuma, checkModeInterleaveCustomPartSize) {
417
428
memset (ptr, 0xFF , size);
418
429
// Test where each page will be allocated.
419
430
// 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 );
420
434
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
+
422
444
for (size_t i = 0 ; i < (size_t )part_num; i++) {
423
445
for (size_t j = 0 ; j < part_size; j += page_size) {
424
446
ASSERT_NODE_EQ ((char *)ptr + part_size * i + j, numa_nodes[index]);
0 commit comments