@@ -42,7 +42,14 @@ std::vector<int> get_available_cpus() {
42
42
CPU_ZERO (mask);
43
43
44
44
int ret = sched_getaffinity (0 , sizeof (cpu_set_t ), mask);
45
- UT_ASSERTeq (ret, 0 );
45
+
46
+ if (ret != 0 ) {
47
+ available_cpus.emplace_back (-1 );
48
+ CPU_FREE (mask);
49
+
50
+ return available_cpus;
51
+ }
52
+
46
53
// Get all available cpus.
47
54
printf (" All CPUs: " );
48
55
for (size_t i = 0 ; i < CPU_SETSIZE; ++i) {
@@ -88,13 +95,16 @@ struct testNuma : testing::Test {
88
95
ASSERT_NE (os_memory_provider, nullptr );
89
96
}
90
97
91
- struct bitmask *retrieve_nodemask (void *addr) {
92
- struct bitmask *retrieved_nodemask = numa_allocate_nodemask ();
93
- UT_ASSERTne (nodemask, nullptr );
94
- int ret = get_mempolicy (nullptr , retrieved_nodemask->maskp ,
98
+ void retrieve_nodemask (void *addr, bitmask **retrieved_nodemask) {
99
+ *retrieved_nodemask = numa_allocate_nodemask ();
100
+
101
+ ASSERT_NE (nodemask, nullptr );
102
+ ASSERT_NE (*retrieved_nodemask, nullptr );
103
+
104
+ int ret = get_mempolicy (nullptr , (*retrieved_nodemask)->maskp ,
95
105
nodemask->size , addr, MPOL_F_ADDR);
96
- UT_ASSERTeq (ret, 0 );
97
- return retrieved_nodemask ;
106
+
107
+ ASSERT_EQ (ret, 0 ) ;
98
108
}
99
109
100
110
void TearDown () override {
@@ -241,7 +251,17 @@ TEST_P(testNumaOnEachNode, checkModeInterleaveSingleNode) {
241
251
EXPECT_NODE_EQ (ptr, numa_node_number);
242
252
}
243
253
244
- struct testNumaOnEachCpu : testNuma, testing::WithParamInterface<int > {};
254
+ struct testNumaOnEachCpu : testNuma, testing::WithParamInterface<int > {
255
+ void SetUp () override {
256
+ ::testNuma::SetUp ();
257
+
258
+ int cpuNumber = this ->GetParam ();
259
+
260
+ if (cpuNumber < 0 ) {
261
+ GTEST_FAIL () << " get_available_cpus() error" ;
262
+ }
263
+ }
264
+ };
245
265
246
266
INSTANTIATE_TEST_SUITE_P (testNumaNodesAllocationsAllCpus, testNumaOnEachCpu,
247
267
::testing::ValuesIn (get_available_cpus()));
@@ -260,7 +280,7 @@ TEST_P(testNumaOnEachCpu, checkModePreferredEmptyNodeset) {
260
280
int ret = sched_setaffinity (0 , sizeof (cpu_set_t ), mask);
261
281
CPU_FREE (mask);
262
282
263
- UT_ASSERTeq (ret, 0 );
283
+ ASSERT_EQ (ret, 0 );
264
284
265
285
umf_os_memory_provider_params_t os_memory_provider_params =
266
286
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
@@ -275,7 +295,7 @@ TEST_P(testNumaOnEachCpu, checkModePreferredEmptyNodeset) {
275
295
276
296
// Verify we're on the expected CPU
277
297
int cpu_check = sched_getcpu ();
278
- UT_ASSERTeq (cpu, cpu_check);
298
+ ASSERT_EQ (cpu, cpu_check);
279
299
280
300
int numa_node_number = numa_node_of_cpu (cpu);
281
301
printf (" Got CPU: %d, got numa node: %d\n " , cpu, numa_node_number);
@@ -297,7 +317,7 @@ TEST_P(testNumaOnEachCpu, checkModeLocal) {
297
317
int ret = sched_setaffinity (0 , sizeof (cpu_set_t ), mask);
298
318
CPU_FREE (mask);
299
319
300
- UT_ASSERTeq (ret, 0 );
320
+ ASSERT_EQ (ret, 0 );
301
321
302
322
umf_os_memory_provider_params_t os_memory_provider_params =
303
323
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
@@ -312,7 +332,7 @@ TEST_P(testNumaOnEachCpu, checkModeLocal) {
312
332
313
333
// Verify we're on the expected CPU
314
334
int cpu_check = sched_getcpu ();
315
- UT_ASSERTeq (cpu, cpu_check);
335
+ ASSERT_EQ (cpu, cpu_check);
316
336
317
337
int numa_node_number = numa_node_of_cpu (cpu);
318
338
printf (" Got CPU: %d, got numa node: %d\n " , cpu, numa_node_number);
@@ -391,7 +411,13 @@ TEST_F(testNuma, checkModeInterleave) {
391
411
EXPECT_NODE_EQ ((char *)ptr + page_size * i, numa_nodes[index ]);
392
412
}
393
413
394
- bitmask *retrieved_nodemask = retrieve_nodemask (ptr);
414
+ bitmask *retrieved_nodemask = nullptr ;
415
+ retrieve_nodemask (ptr, &retrieved_nodemask);
416
+
417
+ if (IS_SKIPPED_OR_FAILED ()) {
418
+ return ;
419
+ }
420
+
395
421
int ret = numa_bitmask_equal (retrieved_nodemask, nodemask);
396
422
numa_bitmask_free (retrieved_nodemask);
397
423
0 commit comments