@@ -42,7 +42,14 @@ std::vector<int> get_available_cpus() {
4242 CPU_ZERO (mask);
4343
4444 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+
4653 // Get all available cpus.
4754 printf (" All CPUs: " );
4855 for (size_t i = 0 ; i < CPU_SETSIZE; ++i) {
@@ -88,13 +95,16 @@ struct testNuma : testing::Test {
8895 ASSERT_NE (os_memory_provider, nullptr );
8996 }
9097
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 ,
95105 nodemask->size , addr, MPOL_F_ADDR);
96- UT_ASSERTeq (ret, 0 );
97- return retrieved_nodemask ;
106+
107+ ASSERT_EQ (ret, 0 ) ;
98108 }
99109
100110 void TearDown () override {
@@ -241,7 +251,17 @@ TEST_P(testNumaOnEachNode, checkModeInterleaveSingleNode) {
241251 EXPECT_NODE_EQ (ptr, numa_node_number);
242252}
243253
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+ };
245265
246266INSTANTIATE_TEST_SUITE_P (testNumaNodesAllocationsAllCpus, testNumaOnEachCpu,
247267 ::testing::ValuesIn (get_available_cpus()));
@@ -260,7 +280,7 @@ TEST_P(testNumaOnEachCpu, checkModePreferredEmptyNodeset) {
260280 int ret = sched_setaffinity (0 , sizeof (cpu_set_t ), mask);
261281 CPU_FREE (mask);
262282
263- UT_ASSERTeq (ret, 0 );
283+ ASSERT_EQ (ret, 0 );
264284
265285 umf_os_memory_provider_params_t os_memory_provider_params =
266286 UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
@@ -275,7 +295,7 @@ TEST_P(testNumaOnEachCpu, checkModePreferredEmptyNodeset) {
275295
276296 // Verify we're on the expected CPU
277297 int cpu_check = sched_getcpu ();
278- UT_ASSERTeq (cpu, cpu_check);
298+ ASSERT_EQ (cpu, cpu_check);
279299
280300 int numa_node_number = numa_node_of_cpu (cpu);
281301 printf (" Got CPU: %d, got numa node: %d\n " , cpu, numa_node_number);
@@ -297,7 +317,7 @@ TEST_P(testNumaOnEachCpu, checkModeLocal) {
297317 int ret = sched_setaffinity (0 , sizeof (cpu_set_t ), mask);
298318 CPU_FREE (mask);
299319
300- UT_ASSERTeq (ret, 0 );
320+ ASSERT_EQ (ret, 0 );
301321
302322 umf_os_memory_provider_params_t os_memory_provider_params =
303323 UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
@@ -312,7 +332,7 @@ TEST_P(testNumaOnEachCpu, checkModeLocal) {
312332
313333 // Verify we're on the expected CPU
314334 int cpu_check = sched_getcpu ();
315- UT_ASSERTeq (cpu, cpu_check);
335+ ASSERT_EQ (cpu, cpu_check);
316336
317337 int numa_node_number = numa_node_of_cpu (cpu);
318338 printf (" Got CPU: %d, got numa node: %d\n " , cpu, numa_node_number);
@@ -391,7 +411,13 @@ TEST_F(testNuma, checkModeInterleave) {
391411 EXPECT_NODE_EQ ((char *)ptr + page_size * i, numa_nodes[index]);
392412 }
393413
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+
395421 int ret = numa_bitmask_equal (retrieved_nodemask, nodemask);
396422 numa_bitmask_free (retrieved_nodemask);
397423
0 commit comments