From a27398a8151dc553dae85ede12f966e5b981b64b Mon Sep 17 00:00:00 2001 From: Ahsan Saghir Date: Wed, 2 Sep 2020 14:13:23 -0500 Subject: [PATCH] [PowerPC] Update MemorySanitizer test to cater for number of CPUs > 1024 MemorySanitizer test fails on systems with more than 1024 CPUs. This patch updates the test to make it work for machines that have more than 1024 CPUs. This helps to fix errors on the PowerPC sanitizer bot. Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D87053 --- compiler-rt/lib/msan/tests/msan_test.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/msan/tests/msan_test.cpp b/compiler-rt/lib/msan/tests/msan_test.cpp index 53b9a3e563e9..4c98bb4861f2 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cpp +++ b/compiler-rt/lib/msan/tests/msan_test.cpp @@ -3229,9 +3229,19 @@ TEST(MemorySanitizer, dlopenFailed) { #if !defined(__FreeBSD__) && !defined(__NetBSD__) TEST(MemorySanitizer, sched_getaffinity) { cpu_set_t mask; - int res = sched_getaffinity(getpid(), sizeof(mask), &mask); - ASSERT_EQ(0, res); - EXPECT_NOT_POISONED(mask); + if (sched_getaffinity(getpid(), sizeof(mask), &mask) == 0) + EXPECT_NOT_POISONED(mask); + else { + // The call to sched_getaffinity() may have failed because the Affinity + // mask is too small for the number of CPUs on the system (i.e. the + // system has more than 1024 CPUs). Allocate a mask large enough for + // twice as many CPUs. + cpu_set_t *DynAffinity; + DynAffinity = CPU_ALLOC(2048); + int res = sched_getaffinity(getpid(), CPU_ALLOC_SIZE(2048), DynAffinity); + ASSERT_EQ(0, res); + EXPECT_NOT_POISONED(*DynAffinity); + } } #endif