[asan] Change stack uar test to not use ulimit.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 14 Feb 2014 14:36:42 +0000 (14:36 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Fri, 14 Feb 2014 14:36:42 +0000 (14:36 +0000)
Because of how Android test runner is implemented, ulimit in RUN: line
gets executed on the host machine and does not affect the test.

llvm-svn: 201415

compiler-rt/test/asan/TestCases/stack-use-after-return.cc

index 75313d4..dc38be9 100644 (file)
@@ -9,8 +9,8 @@
 // RUN:   not %t 2>&1 | FileCheck %s
 // RUN: ASAN_OPTIONS=detect_stack_use_after_return=0 %t
 // Regression test for a CHECK failure with small stack size and large frame.
-// RUN: %clangxx_asan  -O3 %s -o %t -DkSize=10000 && \
-// RUN: (ulimit -s 65;  not %t) 2>&1 | FileCheck %s
+// RUN: %clangxx_asan  -O3 %s -o %t -DkSize=10000 -DUseThread -DkStackSize=65536 && \
+// RUN:   not %t 2>&1 | FileCheck --check-prefix=THREAD %s
 //
 // Test that we can find UAR in a thread other than main:
 // RUN: %clangxx_asan  -DUseThread -O2 %s -o %t && \
 # define UseThread 0
 #endif
 
+#ifndef kStackSize
+# define kStackSize 0
+#endif
+
 __attribute__((noinline))
 char *Ident(char *x) {
   fprintf(stderr, "1: %p\n", x);
@@ -67,8 +71,13 @@ void *Thread(void *unused)  {
 
 int main(int argc, char **argv) {
 #if UseThread
+  pthread_attr_t attr;
+  pthread_attr_init(&attr);
+  if (kStackSize > 0)
+    pthread_attr_setstacksize(&attr, kStackSize);
   pthread_t t;
-  pthread_create(&t, 0, Thread, 0);
+  pthread_create(&t, &attr, Thread, 0);
+  pthread_attr_destroy(&attr);
   pthread_join(t, 0);
 #else
   Func2(Func1());