diff options
22 files changed, 41 insertions, 36 deletions
diff --git a/compiler-rt/test/tsan/Darwin/symbolizer-atos.cc b/compiler-rt/test/tsan/Darwin/symbolizer-atos.cc index 894b79dd7c5..318ecf0783f 100644 --- a/compiler-rt/test/tsan/Darwin/symbolizer-atos.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/Darwin/symbolizer-dladdr.cc b/compiler-rt/test/tsan/Darwin/symbolizer-dladdr.cc index d5356378c47..bb7aa75359f 100644 --- a/compiler-rt/test/tsan/Darwin/symbolizer-dladdr.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/allocator_returns_null.cc b/compiler-rt/test/tsan/allocator_returns_null.cc index cde706bc8a1..66930076ac3 100644 --- a/compiler-rt/test/tsan/allocator_returns_null.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/deadlock_detector_stress_test.cc b/compiler-rt/test/tsan/deadlock_detector_stress_test.cc index efc13ae2624..8af70b2afb9 100644 --- a/compiler-rt/test/tsan/deadlock_detector_stress_test.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/fork_atexit.cc b/compiler-rt/test/tsan/fork_atexit.cc index a1bed4a6317..51a64fc264d 100644 --- a/compiler-rt/test/tsan/fork_atexit.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/fork_deadlock.cc b/compiler-rt/test/tsan/fork_deadlock.cc index bf57d16e887..22bed086f7d 100644 --- a/compiler-rt/test/tsan/fork_deadlock.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/fork_multithreaded.cc b/compiler-rt/test/tsan/fork_multithreaded.cc index 24e0987e770..b345f58ad0c 100644 --- a/compiler-rt/test/tsan/fork_multithreaded.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/free_race.c b/compiler-rt/test/tsan/free_race.c index 63cee8c4adc..d508552c980 100644 --- a/compiler-rt/test/tsan/free_race.c +++ b/compiler-rt/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/compiler-rt/test/tsan/halt_on_error.cc b/compiler-rt/test/tsan/halt_on_error.cc index e55454b57c1..5d481c3cbcd 100644 --- a/compiler-rt/test/tsan/halt_on_error.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/ignore_lib0.cc b/compiler-rt/test/tsan/ignore_lib0.cc index 122ec1f4562..c72aa496a1c 100644 --- a/compiler-rt/test/tsan/ignore_lib0.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/ignore_lib1.cc b/compiler-rt/test/tsan/ignore_lib1.cc index 1283cfdb4ef..e6a13a39439 100644 --- a/compiler-rt/test/tsan/ignore_lib1.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/ignore_lib2.cc b/compiler-rt/test/tsan/ignore_lib2.cc index ad3107cf53a..4f584b14664 100644 --- a/compiler-rt/test/tsan/ignore_lib2.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/ignore_lib3.cc b/compiler-rt/test/tsan/ignore_lib3.cc index 79e4ba18128..3f7be5cf823 100644 --- a/compiler-rt/test/tsan/ignore_lib3.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/lit.cfg b/compiler-rt/test/tsan/lit.cfg index 54112f7b8bf..2be10dae1c8 100644 --- a/compiler-rt/test/tsan/lit.cfg +++ b/compiler-rt/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/compiler-rt/test/tsan/malloc_overflow.cc b/compiler-rt/test/tsan/malloc_overflow.cc index dadc94484f0..b2f9b0f5779 100644 --- a/compiler-rt/test/tsan/malloc_overflow.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/mutex_cycle2.c b/compiler-rt/test/tsan/mutex_cycle2.c index 85d19a0d0c3..32659d4eec0 100644 --- a/compiler-rt/test/tsan/mutex_cycle2.c +++ b/compiler-rt/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/compiler-rt/test/tsan/race_top_suppression.cc b/compiler-rt/test/tsan/race_top_suppression.cc index 7d42dbf3b4b..bd5c1bd5f44 100644 --- a/compiler-rt/test/tsan/race_top_suppression.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/race_top_suppression1.cc b/compiler-rt/test/tsan/race_top_suppression1.cc index 881e661ba78..e34385a9b59 100644 --- a/compiler-rt/test/tsan/race_top_suppression1.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/setuid2.c b/compiler-rt/test/tsan/setuid2.c index 67a6fd14dbc..ad42db53f42 100644 --- a/compiler-rt/test/tsan/setuid2.c +++ b/compiler-rt/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/compiler-rt/test/tsan/suppressions_global.cc b/compiler-rt/test/tsan/suppressions_global.cc index c7b9bb99eb1..8928162cfb8 100644 --- a/compiler-rt/test/tsan/suppressions_global.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/suppressions_race.cc b/compiler-rt/test/tsan/suppressions_race.cc index 45c30481f0c..7a88434db82 100644 --- a/compiler-rt/test/tsan/suppressions_race.cc +++ b/compiler-rt/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/compiler-rt/test/tsan/suppressions_race2.cc b/compiler-rt/test/tsan/suppressions_race2.cc index 24ecd8ef119..b6566a80178 100644 --- a/compiler-rt/test/tsan/suppressions_race2.cc +++ b/compiler-rt/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; |