summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc32
-rw-r--r--compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc (renamed from compiler-rt/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc)11
-rw-r--r--compiler-rt/test/asan/TestCases/suppressions-library.cc6
-rw-r--r--compiler-rt/test/asan/lit.cfg11
4 files changed, 17 insertions, 43 deletions
diff --git a/compiler-rt/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc b/compiler-rt/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc
deleted file mode 100644
index 028683d2fc4..00000000000
--- a/compiler-rt/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Check that memset() call from a shared library gets intercepted.
-// Please always keep this file in sync with
-// ../Linux/interception-in-shared-lib-test.cc.
-
-// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
-// RUN: -shared -o %t-so.so \
-// RUN: -fPIC -install_name @rpath/interception-in-shared-lib-test.cc.tmp-so.so
-// TODO(glider): figure out how to set rpath in a more portable way and unite
-// this test with ../Linux/interception-in-shared-lib-test.cc.
-// RUN: %clangxx_asan -O0 %s -o %t -Wl,-rpath,@executable_path %t-so.so && \
-// RUN: not %run %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <string.h>
-
-#if defined(SHARED_LIB)
-extern "C"
-void my_memset(void *p, size_t sz) {
- memset(p, 0, sz);
-}
-#else
-extern "C" void my_memset(void *p, size_t sz);
-
-int main(int argc, char *argv[]) {
- char buf[10];
- my_memset(buf, 11);
- // CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
- // CHECK: {{WRITE of size 11 at 0x.* thread T0}}
- // CHECK: {{0x.* in my_memset .*interception-in-shared-lib-test.cc:19}}
- return 0;
-}
-#endif
diff --git a/compiler-rt/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc b/compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc
index b828d5524ee..a7d2bfb9b43 100644
--- a/compiler-rt/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc
+++ b/compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc
@@ -1,13 +1,8 @@
// Check that memset() call from a shared library gets intercepted.
-// Please always keep this file in sync with
-// ../Darwin/interception-in-shared-lib-test.cc.
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
-// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
-// RUN: -fPIC
-// TODO(glider): figure out how to set rpath in a more portable way and unite
-// this test with ../Darwin/interception-in-shared-lib-test.cc.
-// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T -linterception-in-shared-lib-test && \
+// RUN: -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
+// RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe && \
// RUN: not %run %t 2>&1 | FileCheck %s
#include <stdio.h>
@@ -26,7 +21,7 @@ int main(int argc, char *argv[]) {
my_memset(buf, 11);
// CHECK: {{.*ERROR: AddressSanitizer: stack-buffer-overflow}}
// CHECK: {{WRITE of size 11 at 0x.* thread T0}}
- // CHECK: {{0x.* in my_memset .*interception-in-shared-lib-test.cc:19}}
+ // CHECK: {{0x.* in my_memset .*interception-in-shared-lib-test.cc:}}[[@LINE-10]]
return 0;
}
#endif
diff --git a/compiler-rt/test/asan/TestCases/suppressions-library.cc b/compiler-rt/test/asan/TestCases/suppressions-library.cc
index 28f19f54efc..b7fee239b0a 100644
--- a/compiler-rt/test/asan/TestCases/suppressions-library.cc
+++ b/compiler-rt/test/asan/TestCases/suppressions-library.cc
@@ -1,10 +1,10 @@
-// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so -install_name @rpath/suppressions-library.cc.tmp-so.so
-// RUN: %clangxx_asan -O0 %s %t-so.so -o %t -rpath @executable_path
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so
+// RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe
// Check that without suppressions, we catch the issue.
// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
-// RUN: echo "interceptor_via_lib:suppressions-library.cc.tmp-so.so" > %t.supp
+// RUN: echo "interceptor_via_lib:"`basename %dynamiclib` > %t.supp
// RUN: ASAN_OPTIONS="suppressions='%t.supp'" %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
// XFAIL: android
diff --git a/compiler-rt/test/asan/lit.cfg b/compiler-rt/test/asan/lit.cfg
index a6f443cfb6a..b303cee953a 100644
--- a/compiler-rt/test/asan/lit.cfg
+++ b/compiler-rt/test/asan/lit.cfg
@@ -135,6 +135,17 @@ config.substitutions.append( ("%libdl", libdl_flag) )
config.available_features.add("asan-" + config.bits + "-bits")
+if config.host_os == 'Darwin':
+ config.substitutions.append( ("%ld_flags_rpath_exe", '-Wl,-rpath,@executable_path/ %dynamiclib') )
+ config.substitutions.append( ("%ld_flags_rpath_so", '-install_name @rpath/`basename %dynamiclib`') )
+elif config.host_os == 'Linux':
+ config.substitutions.append( ("%ld_flags_rpath_exe", "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec") )
+ config.substitutions.append( ("%ld_flags_rpath_so", '') )
+
+# Must be defined after the substitutions that use %dynamiclib.
+config.substitutions.append( ("%dynamiclib", '%T/lib%xdynamiclib_namespec.so') )
+config.substitutions.append( ("%xdynamiclib_namespec", '$(basename %t).dynamic') )
+
# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
# because the test hangs.
if config.target_arch != 'arm':
OpenPOWER on IntegriCloud