summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2015-11-19 17:28:46 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2015-11-19 17:28:46 +0000
commit71aca88f38d1e3ed41cb9e5aeb1ed0102914e487 (patch)
tree1cbc410655aae29c15f3e9bc29788457f3ea45c3 /test
parent653078b1212eb5f696fcb92d27f4ae1202a373d6 (diff)
[tsan] Implement "%env_tsan_opts" substitution to inherit default TSAN_OPTIONS
We already have %env_asan_opts for ASan, let's implement the same for TSan. Differential Revision: http://reviews.llvm.org/D14698 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/tsan/Darwin/symbolizer-atos.cc2
-rw-r--r--test/tsan/Darwin/symbolizer-dladdr.cc2
-rw-r--r--test/tsan/allocator_returns_null.cc10
-rw-r--r--test/tsan/deadlock_detector_stress_test.cc10
-rw-r--r--test/tsan/fork_atexit.cc2
-rw-r--r--test/tsan/fork_deadlock.cc2
-rw-r--r--test/tsan/fork_multithreaded.cc2
-rw-r--r--test/tsan/free_race.c2
-rw-r--r--test/tsan/halt_on_error.cc2
-rw-r--r--test/tsan/ignore_lib0.cc2
-rw-r--r--test/tsan/ignore_lib1.cc2
-rw-r--r--test/tsan/ignore_lib2.cc2
-rw-r--r--test/tsan/ignore_lib3.cc2
-rw-r--r--test/tsan/lit.cfg13
-rw-r--r--test/tsan/malloc_overflow.cc2
-rw-r--r--test/tsan/mutex_cycle2.c8
-rw-r--r--test/tsan/race_top_suppression.cc2
-rw-r--r--test/tsan/race_top_suppression1.cc2
-rw-r--r--test/tsan/setuid2.c2
-rw-r--r--test/tsan/suppressions_global.cc2
-rw-r--r--test/tsan/suppressions_race.cc2
-rw-r--r--test/tsan/suppressions_race2.cc2
22 files changed, 41 insertions, 36 deletions
diff --git a/test/tsan/Darwin/symbolizer-atos.cc b/test/tsan/Darwin/symbolizer-atos.cc
index 894b79dd7..318ecf078 100644
--- a/test/tsan/Darwin/symbolizer-atos.cc
+++ b/test/tsan/Darwin/symbolizer-atos.cc
@@ -1,5 +1,5 @@
// RUN: %clangxx_tsan %s -o %t
-// RUN: TSAN_OPTIONS=$TSAN_OPTIONS:verbosity=2:external_symbolizer_path=/usr/bin/atos %deflake %run %t | FileCheck %s
+// RUN: %env_tsan_opts=verbosity=2:external_symbolizer_path=/usr/bin/atos %deflake %run %t | FileCheck %s
#include "../test.h"
int GlobalData[10];
diff --git a/test/tsan/Darwin/symbolizer-dladdr.cc b/test/tsan/Darwin/symbolizer-dladdr.cc
index d5356378c..bb7aa7535 100644
--- a/test/tsan/Darwin/symbolizer-dladdr.cc
+++ b/test/tsan/Darwin/symbolizer-dladdr.cc
@@ -1,5 +1,5 @@
// RUN: %clangxx_tsan %s -o %t
-// RUN: TSAN_OPTIONS=$TSAN_OPTIONS:verbosity=2:external_symbolizer_path= %deflake %run %t | FileCheck %s
+// RUN: %env_tsan_opts=verbosity=2:external_symbolizer_path= %deflake %run %t | FileCheck %s
#include "../test.h"
int GlobalData[10];
diff --git a/test/tsan/allocator_returns_null.cc b/test/tsan/allocator_returns_null.cc
index cde706bc8..66930076a 100644
--- a/test/tsan/allocator_returns_null.cc
+++ b/test/tsan/allocator_returns_null.cc
@@ -4,11 +4,11 @@
//
// RUN: %clangxx_tsan -O0 %s -o %t
// RUN: not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %run %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %run %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rCRASH
-// RUN: TSAN_OPTIONS=allocator_may_return_null=0 not %run %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrCRASH
+// RUN: %env_tsan_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
+// RUN: %env_tsan_opts=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cCRASH
+// RUN: %env_tsan_opts=allocator_may_return_null=0 not %run %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coCRASH
+// RUN: %env_tsan_opts=allocator_may_return_null=0 not %run %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rCRASH
+// RUN: %env_tsan_opts=allocator_may_return_null=0 not %run %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrCRASH
#include <limits.h>
#include <stdlib.h>
diff --git a/test/tsan/deadlock_detector_stress_test.cc b/test/tsan/deadlock_detector_stress_test.cc
index efc13ae26..8af70b2af 100644
--- a/test/tsan/deadlock_detector_stress_test.cc
+++ b/test/tsan/deadlock_detector_stress_test.cc
@@ -1,12 +1,12 @@
// RUN: %clangxx_tsan %s -o %t -DLockType=PthreadMutex
-// RUN: TSAN_OPTIONS=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND
-// RUN: TSAN_OPTIONS="detect_deadlocks=1 second_deadlock_stack=1" %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SECOND
+// RUN: %env_tsan_opts=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND
+// RUN: %env_tsan_opts=detect_deadlocks=1:second_deadlock_stack=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SECOND
// RUN: %clangxx_tsan %s -o %t -DLockType=PthreadSpinLock
-// RUN: TSAN_OPTIONS=detect_deadlocks=1 %deflake %run %t | FileCheck %s
+// RUN: %env_tsan_opts=detect_deadlocks=1 %deflake %run %t | FileCheck %s
// RUN: %clangxx_tsan %s -o %t -DLockType=PthreadRWLock
-// RUN: TSAN_OPTIONS=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-RD
+// RUN: %env_tsan_opts=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-RD
// RUN: %clangxx_tsan %s -o %t -DLockType=PthreadRecursiveMutex
-// RUN: TSAN_OPTIONS=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-REC
+// RUN: %env_tsan_opts=detect_deadlocks=1 %deflake %run %t | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-REC
#include "test.h"
#undef NDEBUG
#include <assert.h>
diff --git a/test/tsan/fork_atexit.cc b/test/tsan/fork_atexit.cc
index a1bed4a63..51a64fc26 100644
--- a/test/tsan/fork_atexit.cc
+++ b/test/tsan/fork_atexit.cc
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && TSAN_OPTIONS="atexit_sleep_ms=50" %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=50 %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: darwin
#include <pthread.h>
#include <stdio.h>
diff --git a/test/tsan/fork_deadlock.cc b/test/tsan/fork_deadlock.cc
index bf57d16e8..22bed086f 100644
--- a/test/tsan/fork_deadlock.cc
+++ b/test/tsan/fork_deadlock.cc
@@ -1,4 +1,4 @@
-// RUN: %clangxx_tsan -O1 %s -o %t && TSAN_OPTIONS="atexit_sleep_ms=50" %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=50 %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: darwin
#include "test.h"
#include <errno.h>
diff --git a/test/tsan/fork_multithreaded.cc b/test/tsan/fork_multithreaded.cc
index 24e0987e7..b345f58ad 100644
--- a/test/tsan/fork_multithreaded.cc
+++ b/test/tsan/fork_multithreaded.cc
@@ -1,5 +1,5 @@
// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-DIE
-// RUN: %clangxx_tsan -O1 %s -o %t && TSAN_OPTIONS="die_after_fork=0" %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-NODIE
+// RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=die_after_fork=0 %run %t 2>&1 | FileCheck %s -check-prefix=CHECK-NODIE
// UNSUPPORTED: darwin
#include "test.h"
#include <errno.h>
diff --git a/test/tsan/free_race.c b/test/tsan/free_race.c
index 63cee8c4a..d508552c9 100644
--- a/test/tsan/free_race.c
+++ b/test/tsan/free_race.c
@@ -1,6 +1,6 @@
// RUN: %clang_tsan -O1 %s -o %t
// RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOZUPP
-// RUN: TSAN_OPTIONS="suppressions='%s.supp' print_suppressions=1" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
+// RUN: %env_tsan_opts=suppressions='%s.supp':print_suppressions=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
#include "test.h"
diff --git a/test/tsan/halt_on_error.cc b/test/tsan/halt_on_error.cc
index e55454b57..5d481c3cb 100644
--- a/test/tsan/halt_on_error.cc
+++ b/test/tsan/halt_on_error.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS halt_on_error=1" %deflake %run %t | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=halt_on_error=1 %deflake %run %t | FileCheck %s
#include "test.h"
int X;
diff --git a/test/tsan/ignore_lib0.cc b/test/tsan/ignore_lib0.cc
index 122ec1f45..c72aa496a 100644
--- a/test/tsan/ignore_lib0.cc
+++ b/test/tsan/ignore_lib0.cc
@@ -3,7 +3,7 @@
// RUN: echo running w/o suppressions:
// RUN: LD_LIBRARY_PATH=%T${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
// RUN: echo running with suppressions:
-// RUN: LD_LIBRARY_PATH=%T${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
+// RUN: LD_LIBRARY_PATH=%T${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
// Tests that interceptors coming from a library specified in called_from_lib
// suppression are ignored.
diff --git a/test/tsan/ignore_lib1.cc b/test/tsan/ignore_lib1.cc
index 1283cfdb4..e6a13a394 100644
--- a/test/tsan/ignore_lib1.cc
+++ b/test/tsan/ignore_lib1.cc
@@ -3,7 +3,7 @@
// RUN: echo running w/o suppressions:
// RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOSUPP
// RUN: echo running with suppressions:
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
+// RUN: %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-WITHSUPP
// Tests that interceptors coming from a dynamically loaded library specified
// in called_from_lib suppression are ignored.
diff --git a/test/tsan/ignore_lib2.cc b/test/tsan/ignore_lib2.cc
index ad3107cf5..4f584b146 100644
--- a/test/tsan/ignore_lib2.cc
+++ b/test/tsan/ignore_lib2.cc
@@ -1,7 +1,7 @@
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_0.so
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib2_1.so
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %deflake %run %t | FileCheck %s
+// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t | FileCheck %s
// Tests that called_from_lib suppression matched against 2 libraries
// causes program crash (this is not supported).
diff --git a/test/tsan/ignore_lib3.cc b/test/tsan/ignore_lib3.cc
index 79e4ba181..3f7be5cf8 100644
--- a/test/tsan/ignore_lib3.cc
+++ b/test/tsan/ignore_lib3.cc
@@ -1,6 +1,6 @@
// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib3.so
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %deflake %run %t | FileCheck %s
+// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t | FileCheck %s
// Tests that unloading of a library matched against called_from_lib suppression
// causes program crash (this is not supported).
diff --git a/test/tsan/lit.cfg b/test/tsan/lit.cfg
index 54112f7b8..2be10dae1 100644
--- a/test/tsan/lit.cfg
+++ b/test/tsan/lit.cfg
@@ -18,14 +18,19 @@ config.name = 'ThreadSanitizer'
config.test_source_root = os.path.dirname(__file__)
# Setup environment variables for running ThreadSanitizer.
-tsan_options = "atexit_sleep_ms=0"
+default_tsan_opts = "atexit_sleep_ms=0"
if config.host_os == 'Darwin':
# On Darwin, we default to `abort_on_error=1`, which would make tests run
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
- tsan_options += ':abort_on_error=0'
-
-config.environment['TSAN_OPTIONS'] = tsan_options
+ default_tsan_opts += ':abort_on_error=0'
+
+# Platform-specific default TSAN_OPTIONS for lit tests.
+if default_tsan_opts:
+ config.environment['TSAN_OPTIONS'] = default_tsan_opts
+ default_tsan_opts += ':'
+config.substitutions.append(('%env_tsan_opts=',
+ 'env TSAN_OPTIONS=' + default_tsan_opts))
# GCC driver doesn't add necessary compile/link flags with -fsanitize=thread.
if config.compiler_id == 'GNU':
diff --git a/test/tsan/malloc_overflow.cc b/test/tsan/malloc_overflow.cc
index dadc94484..b2f9b0f57 100644
--- a/test/tsan/malloc_overflow.cc
+++ b/test/tsan/malloc_overflow.cc
@@ -1,5 +1,5 @@
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s
+// RUN: %env_tsan_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s
#include <stdio.h>
#include <stdlib.h>
diff --git a/test/tsan/mutex_cycle2.c b/test/tsan/mutex_cycle2.c
index 85d19a0d0..32659d4ee 100644
--- a/test/tsan/mutex_cycle2.c
+++ b/test/tsan/mutex_cycle2.c
@@ -1,11 +1,11 @@
// RUN: %clangxx_tsan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
-// RUN: TSAN_OPTIONS=detect_deadlocks=1 not %run %t 2>&1 | FileCheck %s
-// RUN: TSAN_OPTIONS=detect_deadlocks=0 %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %env_tsan_opts=detect_deadlocks=1 not %run %t 2>&1 | FileCheck %s
+// RUN: %env_tsan_opts=detect_deadlocks=0 %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED
// RUN: echo "deadlock:main" > %t.supp
-// RUN: TSAN_OPTIONS="suppressions='%t.supp'" %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %env_tsan_opts=suppressions='%t.supp' %run %t 2>&1 | FileCheck %s --check-prefix=DISABLED
// RUN: echo "deadlock:zzzz" > %t.supp
-// RUN: TSAN_OPTIONS="suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s
+// RUN: %env_tsan_opts=suppressions='%t.supp' not %run %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
diff --git a/test/tsan/race_top_suppression.cc b/test/tsan/race_top_suppression.cc
index 7d42dbf3b..bd5c1bd5f 100644
--- a/test/tsan/race_top_suppression.cc
+++ b/test/tsan/race_top_suppression.cc
@@ -1,6 +1,6 @@
// RUN: echo "race_top:TopFunction" > %t.supp
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%t.supp'" %run %t 2>&1 | FileCheck %s
+// RUN: %env_tsan_opts=suppressions='%t.supp' %run %t 2>&1 | FileCheck %s
// RUN: rm %t.supp
#include "test.h"
diff --git a/test/tsan/race_top_suppression1.cc b/test/tsan/race_top_suppression1.cc
index 881e661ba..e34385a9b 100644
--- a/test/tsan/race_top_suppression1.cc
+++ b/test/tsan/race_top_suppression1.cc
@@ -1,6 +1,6 @@
// RUN: echo "race_top:TopFunction" > %t.supp
// RUN: %clangxx_tsan -O1 %s -o %t
-// RUN: TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%t.supp'" %deflake %run %t 2>&1 | FileCheck %s
+// RUN: %env_tsan_opts=suppressions='%t.supp' %deflake %run %t 2>&1 | FileCheck %s
// RUN: rm %t.supp
#include "test.h"
diff --git a/test/tsan/setuid2.c b/test/tsan/setuid2.c
index 67a6fd14d..ad42db53f 100644
--- a/test/tsan/setuid2.c
+++ b/test/tsan/setuid2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="flush_memory_ms=1 memory_limit_mb=1" %run %t 2>&1 | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=flush_memory_ms=1:memory_limit_mb=1 %run %t 2>&1 | FileCheck %s
#include "test.h"
#include <sys/types.h>
#include <unistd.h>
diff --git a/test/tsan/suppressions_global.cc b/test/tsan/suppressions_global.cc
index c7b9bb99e..8928162cf 100644
--- a/test/tsan/suppressions_global.cc
+++ b/test/tsan/suppressions_global.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
diff --git a/test/tsan/suppressions_race.cc b/test/tsan/suppressions_race.cc
index 45c30481f..7a88434db 100644
--- a/test/tsan/suppressions_race.cc
+++ b/test/tsan/suppressions_race.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s
#include "test.h"
int Global;
diff --git a/test/tsan/suppressions_race2.cc b/test/tsan/suppressions_race2.cc
index 24ecd8ef1..b6566a801 100644
--- a/test/tsan/suppressions_race2.cc
+++ b/test/tsan/suppressions_race2.cc
@@ -1,4 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && TSAN_OPTIONS="$TSAN_OPTIONS suppressions='%s.supp'" %run %t 2>&1 | FileCheck %s
+// RUN: %clang_tsan -O1 %s -o %t && %env_tsan_opts=suppressions='%s.supp' %run %t 2>&1 | FileCheck %s
#include "test.h"
int Global;