[compiler-rt] r202267 - [ASan] Split interception-in-shared-lib-test.cc into two tests with platform-specific RUN commands.
Alexander Potapenko
glider at google.com
Wed Feb 26 06:05:57 PST 2014
Author: glider
Date: Wed Feb 26 08:05:57 2014
New Revision: 202267
URL: http://llvm.org/viewvc/llvm-project?rev=202267&view=rev
Log:
[ASan] Split interception-in-shared-lib-test.cc into two tests with platform-specific RUN commands.
Get rid of a TestCases/SharedLibs/shared-lib-test-so.cc dependency in these tests.
Added:
compiler-rt/trunk/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc
- copied, changed from r202244, compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
compiler-rt/trunk/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc
- copied, changed from r202244, compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
Removed:
compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
Modified:
compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
Copied: compiler-rt/trunk/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc (from r202244, compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc?p2=compiler-rt/trunk/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc&p1=compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc&r1=202244&r2=202267&rev=202267&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interception-in-shared-lib-test.cc Wed Feb 26 08:05:57 2014
@@ -1,14 +1,22 @@
// Check that memset() call from a shared library gets intercepted.
-// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
+// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
// RUN: -fPIC
-// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T -linterception-in-shared-lib-test && \
+// 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, at executable-path -L%T -linterception-in-shared-lib-test && \
// RUN: not %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[]) {
@@ -16,6 +24,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: {{ #0 0x.* in my_memset .*shared-lib-test-so.cc:31}}
+ // CHECK: {{ #0 0x.* in my_memset .*interception-in-shared-lib-test.cc:17}}
return 0;
}
+#endif
Copied: compiler-rt/trunk/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc (from r202244, compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc?p2=compiler-rt/trunk/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc&p1=compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc&r1=202244&r2=202267&rev=202267&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interception-in-shared-lib-test.cc Wed Feb 26 08:05:57 2014
@@ -1,14 +1,22 @@
// Check that memset() call from a shared library gets intercepted.
-// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.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: not %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[]) {
@@ -16,6 +24,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: {{ #0 0x.* in my_memset .*shared-lib-test-so.cc:31}}
+ // CHECK: {{ #0 0x.* in my_memset .*interception-in-shared-lib-test.cc:17}}
return 0;
}
+#endif
Modified: compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc?rev=202267&r1=202266&r2=202267&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc Wed Feb 26 08:05:57 2014
@@ -25,8 +25,3 @@ extern "C"
void inc2(int *a, int index) {
a[index]++;
}
-
-extern "C"
-void my_memset(void *p, size_t sz) {
- memset(p, 0, sz);
-}
Removed: compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc?rev=202266&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/interception-in-shared-lib-test.cc (removed)
@@ -1,21 +0,0 @@
-// Check that memset() call from a shared library gets intercepted.
-
-// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
-// RUN: -shared -o %T/libinterception-in-shared-lib-test.so \
-// RUN: -fPIC
-// RUN: %clangxx_asan -O0 %s -o %t -Wl,-R,\$ORIGIN -L%T -linterception-in-shared-lib-test && \
-// RUN: not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <string.h>
-
-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: {{ #0 0x.* in my_memset .*shared-lib-test-so.cc:31}}
- return 0;
-}
More information about the llvm-commits
mailing list