Skip to content

Commit 2ede6af

Browse files
[TSan] Make tests work with internal shell
This patch makes all tsan tests work with the internal shell on Darwin. Tests were using various features not supported by the internal shell, mainly subshells and not using env to set environment variables. This patch also fixes one of the dynamiclib substitutions to not use a subshell. Reviewers: ndrewh, DanBlackwell, fmayer, vitalybuka Reviewed By: DanBlackwell Pull Request: #168544
1 parent 906f175 commit 2ede6af

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

compiler-rt/test/lit.common.cfg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def is_windows_lto_supported():
875875
config.substitutions.append(
876876
(
877877
"%ld_flags_rpath_so" + postfix,
878-
"-install_name @rpath/`basename %dynamiclib{}`".format(postfix),
878+
"-install_name @rpath/%base_dynamiclib{}".format(postfix),
879879
)
880880
)
881881
elif config.target_os in ("FreeBSD", "NetBSD", "OpenBSD"):
@@ -908,6 +908,9 @@ def is_windows_lto_supported():
908908
config.substitutions.append(
909909
("%dynamiclib" + postfix, "%t.dir/%xdynamiclib_filename" + postfix)
910910
)
911+
config.substitutions.append(
912+
("%base_dynamiclib" + postfix, "%xdynamiclib_filename" + postfix)
913+
)
911914
config.substitutions.append(
912915
(
913916
"%xdynamiclib_filename" + postfix,

compiler-rt/test/tsan/Darwin/dlopen.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
// RUN: %clangxx_tsan %s -o %t.so -shared -DSHARED_LIB
1010
// RUN: %clangxx_tsan -fno-sanitize=thread %s -o %t
1111

12-
// RUN: TSAN_DYLIB_PATH=`%clangxx_tsan %s -### 2>&1 \
12+
// RUN: %clangxx_tsan %s -### 2>&1 \
1313
// RUN: | grep "libclang_rt.tsan_osx_dynamic.dylib" \
14-
// RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/'`
14+
// RUN: | sed -e 's/.*"\(.*libclang_rt.tsan_osx_dynamic.dylib\)".*/\1/' \
15+
// RUN: | tr -d '\n' > %t.tsan_dylib_path
1516

1617
// Launching a non-instrumented binary that dlopen's an instrumented library should fail.
1718
// RUN: not %run %t %t.so 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL
1819
// Launching a non-instrumented binary with an explicit DYLD_INSERT_LIBRARIES should work.
19-
// RUN: DYLD_INSERT_LIBRARIES=$TSAN_DYLIB_PATH %run %t %t.so 2>&1 | FileCheck %s
20+
// RUN: env DYLD_INSERT_LIBRARIES="%{readfile:%t.tsan_dylib_path}" %run %t %t.so 2>&1 | FileCheck %s
2021

2122
#include <dlfcn.h>
2223
#include <pthread.h>

compiler-rt/test/tsan/Darwin/external-ignore-noninstrumented.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// RUN: basename %t-lib.dylib | tr -d '\n' > %t.basename
12
// RUN: %clangxx_tsan -shared %p/external-lib.cpp -fno-sanitize=thread -DUSE_TSAN_CALLBACKS \
2-
// RUN: -o %t-lib.dylib -install_name @rpath/`basename %t-lib.dylib`
3+
// RUN: -o %t-lib.dylib -install_name @rpath/%{readfile:%t.basename}
34

5+
// RUN: basename %t-module.dylib | tr -d '\n' > %t.basename
46
// RUN: %clangxx_tsan -shared %p/external-noninstrumented-module.cpp %t-lib.dylib -fno-sanitize=thread \
5-
// RUN: -o %t-module.dylib -install_name @rpath/`basename %t-module.dylib`
7+
// RUN: -o %t-module.dylib -install_name @rpath/%{readfile:%t.basename}
68

79
// RUN: %clangxx_tsan %s %t-module.dylib -o %t
810
// RUN: %run %t 2>&1 | FileCheck %s

compiler-rt/test/tsan/Darwin/external.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
// RUN: basename %t-lib-instrumented.dylib | tr -d '\n' > %t.basename
12
// RUN: %clangxx_tsan %p/external-lib.cpp -shared \
23
// RUN: -o %t-lib-instrumented.dylib \
3-
// RUN: -install_name @rpath/`basename %t-lib-instrumented.dylib`
4+
// RUN: -install_name @rpath/%{readfile:%t.basename}
45

6+
// RUN: basename %t-lib-noninstrumented.dylib | tr -d '\n' > %t.basename
57
// RUN: %clangxx_tsan %p/external-lib.cpp -shared -fno-sanitize=thread \
68
// RUN: -o %t-lib-noninstrumented.dylib \
7-
// RUN: -install_name @rpath/`basename %t-lib-noninstrumented.dylib`
9+
// RUN: -install_name @rpath/%{readfile:%t.basename}
810

11+
// RUN: basename %t-lib-noninstrumented-callbacks.dylib | tr -d '\n' > %t.basename
912
// RUN: %clangxx_tsan %p/external-lib.cpp -shared -fno-sanitize=thread -DUSE_TSAN_CALLBACKS \
1013
// RUN: -o %t-lib-noninstrumented-callbacks.dylib \
11-
// RUN: -install_name @rpath/`basename %t-lib-noninstrumented-callbacks.dylib`
14+
// RUN: -install_name @rpath/%{readfile:%t.basename}
1215

1316
// RUN: %clangxx_tsan %s %t-lib-instrumented.dylib -o %t-lib-instrumented
1417
// RUN: %clangxx_tsan %s %t-lib-noninstrumented.dylib -o %t-lib-noninstrumented

compiler-rt/test/tsan/Darwin/malloc-stack-logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// use syscalls directly) to make sure other interceptors aren't called.
55

66
// RUN: %clangxx_tsan -O1 %s -o %t
7-
// RUN: MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
7+
// RUN: env MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
88
#include <pthread.h>
99
#include <stdlib.h>
1010
#include <stdio.h>

0 commit comments

Comments
 (0)