[NFC, msan] Increase stack in small stack tests
authorVitaly Buka <vitalybuka@google.com>
Thu, 16 Apr 2020 02:36:11 +0000 (19:36 -0700)
committerVitaly Buka <vitalybuka@google.com>
Thu, 16 Apr 2020 02:41:57 +0000 (19:41 -0700)
Test fails in our setup if used with libunwind.
It needs just few bytest to pass.

compiler-rt/lib/msan/tests/msan_test.cpp

index 2d67b6f..53b9a3e 100644 (file)
@@ -3275,11 +3275,9 @@ static void *SmallStackThread_threadfn(void* data) {
 }
 
 #ifdef PTHREAD_STACK_MIN
-# define SMALLSTACKSIZE    PTHREAD_STACK_MIN
-# define SMALLPRESTACKSIZE PTHREAD_STACK_MIN
+constexpr int kThreadStackMin = PTHREAD_STACK_MIN;
 #else
-# define SMALLSTACKSIZE    64 * 1024
-# define SMALLPRESTACKSIZE 16 * 1024
+constexpr int kThreadStackMin = 0;
 #endif
 
 TEST(MemorySanitizer, SmallStackThread) {
@@ -3289,7 +3287,7 @@ TEST(MemorySanitizer, SmallStackThread) {
   int res;
   res = pthread_attr_init(&attr);
   ASSERT_EQ(0, res);
-  res = pthread_attr_setstacksize(&attr, SMALLSTACKSIZE);
+  res = pthread_attr_setstacksize(&attr, std::max(kThreadStackMin, 64 * 1024));
   ASSERT_EQ(0, res);
   res = pthread_create(&t, &attr, SmallStackThread_threadfn, NULL);
   ASSERT_EQ(0, res);
@@ -3306,7 +3304,7 @@ TEST(MemorySanitizer, SmallPreAllocatedStackThread) {
   res = pthread_attr_init(&attr);
   ASSERT_EQ(0, res);
   void *stack;
-  const size_t kStackSize = SMALLPRESTACKSIZE;
+  const size_t kStackSize = std::max(kThreadStackMin, 32 * 1024);
   res = posix_memalign(&stack, 4096, kStackSize);
   ASSERT_EQ(0, res);
   res = pthread_attr_setstack(&attr, stack, kStackSize);