Index: compiler-rt/trunk/test/tsan/Darwin/symbolizer-atos.cc =================================================================== --- compiler-rt/trunk/test/tsan/Darwin/symbolizer-atos.cc +++ compiler-rt/trunk/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]; Index: compiler-rt/trunk/test/tsan/Darwin/symbolizer-dladdr.cc =================================================================== --- compiler-rt/trunk/test/tsan/Darwin/symbolizer-dladdr.cc +++ compiler-rt/trunk/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]; Index: compiler-rt/trunk/test/tsan/allocator_returns_null.cc =================================================================== --- compiler-rt/trunk/test/tsan/allocator_returns_null.cc +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc =================================================================== --- compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc +++ compiler-rt/trunk/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 Index: compiler-rt/trunk/test/tsan/fork_atexit.cc =================================================================== --- compiler-rt/trunk/test/tsan/fork_atexit.cc +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/fork_deadlock.cc =================================================================== --- compiler-rt/trunk/test/tsan/fork_deadlock.cc +++ compiler-rt/trunk/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 Index: compiler-rt/trunk/test/tsan/fork_multithreaded.cc =================================================================== --- compiler-rt/trunk/test/tsan/fork_multithreaded.cc +++ compiler-rt/trunk/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 Index: compiler-rt/trunk/test/tsan/free_race.c =================================================================== --- compiler-rt/trunk/test/tsan/free_race.c +++ compiler-rt/trunk/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" Index: compiler-rt/trunk/test/tsan/halt_on_error.cc =================================================================== --- compiler-rt/trunk/test/tsan/halt_on_error.cc +++ compiler-rt/trunk/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; Index: compiler-rt/trunk/test/tsan/ignore_lib0.cc =================================================================== --- compiler-rt/trunk/test/tsan/ignore_lib0.cc +++ compiler-rt/trunk/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. Index: compiler-rt/trunk/test/tsan/ignore_lib1.cc =================================================================== --- compiler-rt/trunk/test/tsan/ignore_lib1.cc +++ compiler-rt/trunk/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. Index: compiler-rt/trunk/test/tsan/ignore_lib2.cc =================================================================== --- compiler-rt/trunk/test/tsan/ignore_lib2.cc +++ compiler-rt/trunk/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). Index: compiler-rt/trunk/test/tsan/ignore_lib3.cc =================================================================== --- compiler-rt/trunk/test/tsan/ignore_lib3.cc +++ compiler-rt/trunk/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). Index: compiler-rt/trunk/test/tsan/lit.cfg =================================================================== --- compiler-rt/trunk/test/tsan/lit.cfg +++ compiler-rt/trunk/test/tsan/lit.cfg @@ -18,14 +18,19 @@ 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' + default_tsan_opts += ':abort_on_error=0' -config.environment['TSAN_OPTIONS'] = tsan_options +# 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': Index: compiler-rt/trunk/test/tsan/malloc_overflow.cc =================================================================== --- compiler-rt/trunk/test/tsan/malloc_overflow.cc +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/mutex_cycle2.c =================================================================== --- compiler-rt/trunk/test/tsan/mutex_cycle2.c +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/race_top_suppression.cc =================================================================== --- compiler-rt/trunk/test/tsan/race_top_suppression.cc +++ compiler-rt/trunk/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" Index: compiler-rt/trunk/test/tsan/race_top_suppression1.cc =================================================================== --- compiler-rt/trunk/test/tsan/race_top_suppression1.cc +++ compiler-rt/trunk/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" Index: compiler-rt/trunk/test/tsan/setuid2.c =================================================================== --- compiler-rt/trunk/test/tsan/setuid2.c +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/suppressions_global.cc =================================================================== --- compiler-rt/trunk/test/tsan/suppressions_global.cc +++ compiler-rt/trunk/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 #include Index: compiler-rt/trunk/test/tsan/suppressions_race.cc =================================================================== --- compiler-rt/trunk/test/tsan/suppressions_race.cc +++ compiler-rt/trunk/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; Index: compiler-rt/trunk/test/tsan/suppressions_race2.cc =================================================================== --- compiler-rt/trunk/test/tsan/suppressions_race2.cc +++ compiler-rt/trunk/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;