summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-05-14 14:41:38 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-05-14 14:41:38 +0000
commit95b74edef69316968ec58ccba6b76a5c7a6795fc (patch)
tree6b3bb106c88a0fe26ed9eeb2e6da6ba922056309
parent56812ee8727bd45f1995a44a4cabd802c0a18159 (diff)
downloadcompiler-rt-95b74edef69316968ec58ccba6b76a5c7a6795fc.tar.gz
[ASan tests] Get rid of SharedLibs/
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208780 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc7
-rw-r--r--test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc7
-rw-r--r--test/asan/TestCases/Posix/init-order-dlopen.cc19
-rw-r--r--test/asan/TestCases/Posix/shared-lib-test.cc26
-rw-r--r--test/asan/TestCases/Posix/start-deactivated.cc12
-rw-r--r--test/asan/TestCases/SharedLibs/darwin-dummy-shared-lib-so.cc13
-rw-r--r--test/asan/TestCases/SharedLibs/dlclose-test-so.cc33
-rw-r--r--test/asan/TestCases/SharedLibs/init-order-dlopen-so.cc12
-rw-r--r--test/asan/TestCases/SharedLibs/lit.local.cfg4
-rw-r--r--test/asan/TestCases/SharedLibs/shared-lib-test-so.cc27
-rw-r--r--test/asan/TestCases/SharedLibs/start-deactivated-so.cc7
-rw-r--r--test/asan/TestCases/asan-symbolize-sanity-test.cc23
-rw-r--r--test/asan/TestCases/dlclose-test.cc30
13 files changed, 109 insertions, 111 deletions
diff --git a/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc b/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
index db6005cba..59ddd634b 100644
--- a/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
+++ b/test/asan/TestCases/Darwin/reexec-insert-libraries-env.cc
@@ -3,12 +3,14 @@
// https://code.google.com/p/address-sanitizer/issues/detail?id=159
// RUN: %clangxx_asan %s -o %t
-// RUN: %clangxx %p/../SharedLibs/darwin-dummy-shared-lib-so.cc \
+// RUN: %clangxx -DSHARED_LIB %s \
// RUN: -dynamiclib -o darwin-dummy-shared-lib-so.dylib
// FIXME: the following command line may hang in the case of a regression.
// RUN: DYLD_INSERT_LIBRARIES=darwin-dummy-shared-lib-so.dylib \
// RUN: %run %t 2>&1 | FileCheck %s || exit 1
+
+#if !defined(SHARED_LIB)
#include <stdio.h>
#include <stdlib.h>
@@ -18,3 +20,6 @@ int main() {
// CHECK: {{DYLD_INSERT_LIBRARIES=.*darwin-dummy-shared-lib-so.dylib.*}}
return 0;
}
+#else // SHARED_LIB
+void foo() {}
+#endif // SHARED_LIB
diff --git a/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc b/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
index 1f566d898..ed476b223 100644
--- a/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
+++ b/test/asan/TestCases/Darwin/unset-insert-libraries-on-exec.cc
@@ -3,7 +3,7 @@
// RUN: %clangxx_asan %s -o %t
// RUN: %clangxx %p/../Helpers/echo-env.cc -o %T/echo-env
-// RUN: %clangxx %p/../SharedLibs/darwin-dummy-shared-lib-so.cc \
+// RUN: %clangxx -DSHARED_LIB %s \
// RUN: -dynamiclib -o %t-darwin-dummy-shared-lib-so.dylib
// Make sure DYLD_INSERT_LIBRARIES doesn't contain the runtime library before
@@ -12,9 +12,14 @@
// RUN: %run %t %T/echo-env >/dev/null 2>&1
// RUN: DYLD_INSERT_LIBRARIES=%t-darwin-dummy-shared-lib-so.dylib \
// RUN: %run %t %T/echo-env 2>&1 | FileCheck %s || exit 1
+
+#if !defined(SHARED_LIB)
#include <unistd.h>
int main(int argc, char *argv[]) {
execl(argv[1], argv[1], "DYLD_INSERT_LIBRARIES", NULL);
// CHECK: {{DYLD_INSERT_LIBRARIES = .*darwin-dummy-shared-lib-so.dylib.*}}
return 0;
}
+#else // SHARED_LIB
+void foo() {}
+#endif // SHARED_LIB
diff --git a/test/asan/TestCases/Posix/init-order-dlopen.cc b/test/asan/TestCases/Posix/init-order-dlopen.cc
index 836b8615f..f7b0d6aca 100644
--- a/test/asan/TestCases/Posix/init-order-dlopen.cc
+++ b/test/asan/TestCases/Posix/init-order-dlopen.cc
@@ -3,9 +3,9 @@
// Assume we're on Darwin and try to pass -U to the linker. If this flag is
// unsupported, don't use it.
-// RUN: %clangxx_asan -O0 %p/../SharedLibs/init-order-dlopen-so.cc \
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s \
// RUN: -fPIC -shared -o %t-so.so -Wl,-U,_inc_global || \
-// RUN: %clangxx_asan -O0 %p/../SharedLibs/init-order-dlopen-so.cc \
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s \
// RUN: -fPIC -shared -o %t-so.so
// If the linker doesn't support --export-dynamic (which is ELF-specific),
// try to link without that option.
@@ -13,6 +13,7 @@
// RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t -Wl,--export-dynamic || \
// RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t
// RUN: ASAN_OPTIONS=strict_init_order=true %run %t 2>&1 | FileCheck %s
+#if !defined(SHARED_LIB)
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
@@ -55,3 +56,17 @@ int main(int argc, char *argv[]) {
// CHECK: PASSED
return 0;
}
+#else // SHARED_LIB
+#include <stdio.h>
+#include <unistd.h>
+
+extern "C" void inc_global();
+
+int slow_init() {
+ sleep(1);
+ inc_global();
+ return 42;
+}
+
+int slowly_init_glob = slow_init();
+#endif // SHARED_LIB
diff --git a/test/asan/TestCases/Posix/shared-lib-test.cc b/test/asan/TestCases/Posix/shared-lib-test.cc
index 60037344c..ccaeed6e0 100644
--- a/test/asan/TestCases/Posix/shared-lib-test.cc
+++ b/test/asan/TestCases/Posix/shared-lib-test.cc
@@ -1,12 +1,13 @@
-// RUN: %clangxx_asan -O0 %p/../SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O0 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O1 %p/../SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O1 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O2 %p/../SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O2 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %p/../SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O3 %s -ldl -o %t && not %run %t 2>&1 | FileCheck %s
+#if !defined(SHARED_LIB)
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
@@ -36,3 +37,20 @@ int main(int argc, char *argv[]) {
// CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:}}[[@LINE-4]]
return 0;
}
+#else // SHARED_LIBS
+#include <stdio.h>
+#include <string.h>
+
+int pad[10];
+int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+extern "C"
+void inc(int index) {
+ GLOB[index]++;
+}
+
+extern "C"
+void inc2(int *a, int index) {
+ a[index]++;
+}
+#endif // SHARED_LIBS
diff --git a/test/asan/TestCases/Posix/start-deactivated.cc b/test/asan/TestCases/Posix/start-deactivated.cc
index a7811aee6..ac45c16de 100644
--- a/test/asan/TestCases/Posix/start-deactivated.cc
+++ b/test/asan/TestCases/Posix/start-deactivated.cc
@@ -2,11 +2,12 @@
// Main executable is uninstrumented, but linked to ASan runtime. The shared
// library is instrumented. Memory errors before dlopen are not detected.
-// RUN: %clangxx_asan -O0 %p/../SharedLibs/start-deactivated-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx -O0 %s -c -o %t.o
// RUN: %clangxx_asan -O0 %t.o -ldl -o %t
// RUN: ASAN_OPTIONS=start_deactivated=1 not %run %t 2>&1 | FileCheck %s
+#if !defined(SHARED_LIB)
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
@@ -55,3 +56,12 @@ int main(int argc, char *argv[]) {
return 0;
}
+#else // SHARED_LIB
+#include <stdio.h>
+#include <stdlib.h>
+
+extern "C" void do_another_bad_thing() {
+ char *volatile p = (char *)malloc(100);
+ printf("%hhx\n", p[105]);
+}
+#endif // SHARED_LIB
diff --git a/test/asan/TestCases/SharedLibs/darwin-dummy-shared-lib-so.cc b/test/asan/TestCases/SharedLibs/darwin-dummy-shared-lib-so.cc
deleted file mode 100644
index 5d9399914..000000000
--- a/test/asan/TestCases/SharedLibs/darwin-dummy-shared-lib-so.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-//===----------- darwin-dummy-shared-lib-so.cc ------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of AddressSanitizer, an address sanity checker.
-//
-//===----------------------------------------------------------------------===//
-void foo() {}
diff --git a/test/asan/TestCases/SharedLibs/dlclose-test-so.cc b/test/asan/TestCases/SharedLibs/dlclose-test-so.cc
deleted file mode 100644
index 73e005073..000000000
--- a/test/asan/TestCases/SharedLibs/dlclose-test-so.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-//===----------- dlclose-test-so.cc -----------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of AddressSanitizer, an address sanity checker.
-//
-// Regression test for
-// http://code.google.com/p/address-sanitizer/issues/detail?id=19
-//===----------------------------------------------------------------------===//
-#include <stdio.h>
-
-static int pad1;
-static int static_var;
-static int pad2;
-
-extern "C"
-int *get_address_of_static_var() {
- return &static_var;
-}
-
-__attribute__((constructor))
-void at_dlopen() {
- printf("%s: I am being dlopened\n", __FILE__);
-}
-__attribute__((destructor))
-void at_dlclose() {
- printf("%s: I am being dlclosed\n", __FILE__);
-}
diff --git a/test/asan/TestCases/SharedLibs/init-order-dlopen-so.cc b/test/asan/TestCases/SharedLibs/init-order-dlopen-so.cc
deleted file mode 100644
index dc097a520..000000000
--- a/test/asan/TestCases/SharedLibs/init-order-dlopen-so.cc
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-
-extern "C" void inc_global();
-
-int slow_init() {
- sleep(1);
- inc_global();
- return 42;
-}
-
-int slowly_init_glob = slow_init();
diff --git a/test/asan/TestCases/SharedLibs/lit.local.cfg b/test/asan/TestCases/SharedLibs/lit.local.cfg
deleted file mode 100644
index b3677c17a..000000000
--- a/test/asan/TestCases/SharedLibs/lit.local.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-# Sources in this directory are compiled as shared libraries and used by
-# tests in parent directory.
-
-config.suffixes = []
diff --git a/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc b/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
deleted file mode 100644
index 8ae352f6a..000000000
--- a/test/asan/TestCases/SharedLibs/shared-lib-test-so.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------- shared-lib-test-so.cc --------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of AddressSanitizer, an address sanity checker.
-//
-//===----------------------------------------------------------------------===//
-#include <stdio.h>
-#include <string.h>
-
-int pad[10];
-int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
-extern "C"
-void inc(int index) {
- GLOB[index]++;
-}
-
-extern "C"
-void inc2(int *a, int index) {
- a[index]++;
-}
diff --git a/test/asan/TestCases/SharedLibs/start-deactivated-so.cc b/test/asan/TestCases/SharedLibs/start-deactivated-so.cc
deleted file mode 100644
index 9611fa5ba..000000000
--- a/test/asan/TestCases/SharedLibs/start-deactivated-so.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern "C" void do_another_bad_thing() {
- char *volatile p = (char *)malloc(100);
- printf("%hhx\n", p[105]);
-}
diff --git a/test/asan/TestCases/asan-symbolize-sanity-test.cc b/test/asan/TestCases/asan-symbolize-sanity-test.cc
index 8daeac9e4..077187836 100644
--- a/test/asan/TestCases/asan-symbolize-sanity-test.cc
+++ b/test/asan/TestCases/asan-symbolize-sanity-test.cc
@@ -1,9 +1,11 @@
// Check that asan_symbolize.py script works (for binaries, ASan RTL and
// shared object files.
-// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O0 %s -ldl -o %t
// RUN: ASAN_OPTIONS=symbolize=0 not %run %t 2>&1 | %asan_symbolize | FileCheck %s
+
+#if !defined(SHARED_LIB)
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
@@ -30,10 +32,27 @@ int main(int argc, char *argv[]) {
inc2(array, -1); // BOOM
// CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
// CHECK: READ of size 4 at 0x{{.*}}
- // CHECK: #0 {{.*}} in inc2 {{.*}}shared-lib-test-so.cc:26
+ // CHECK: #0 {{.*}} in inc2 {{.*}}asan-symbolize-sanity-test.cc:56
// CHECK: #1 {{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-4]]
// CHECK: allocated by thread T{{.*}} here:
// CHECK: #{{.*}} in {{(wrap_|__interceptor_)?}}malloc
// CHECK: #{{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-9]]
return 0;
}
+#else // SHARED_LIBS
+#include <stdio.h>
+#include <string.h>
+
+int pad[10];
+int GLOB[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+extern "C"
+void inc(int index) {
+ GLOB[index]++;
+}
+
+extern "C"
+void inc2(int *a, int index) {
+ a[index]++;
+}
+#endif // SHARED_LIBS
diff --git a/test/asan/TestCases/dlclose-test.cc b/test/asan/TestCases/dlclose-test.cc
index 82819c0a9..07d57b1cf 100644
--- a/test/asan/TestCases/dlclose-test.cc
+++ b/test/asan/TestCases/dlclose-test.cc
@@ -14,15 +14,16 @@
// It works on i368/x86_64 Linux, but not necessary anywhere else.
// REQUIRES: x86_64-supported-target,i386-supported-target
-// RUN: %clangxx_asan -O0 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O0 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O1 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O1 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O2 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O2 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
+// RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx_asan -O3 %s -ldl -o %t && %run %t 2>&1 | FileCheck %s
+#if !defined(SHARED_LIB)
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
@@ -75,3 +76,24 @@ int main(int argc, char *argv[]) {
// CHECK: PASS
return 0;
}
+#else // SHARED_LIB
+#include <stdio.h>
+
+static int pad1;
+static int static_var;
+static int pad2;
+
+extern "C"
+int *get_address_of_static_var() {
+ return &static_var;
+}
+
+__attribute__((constructor))
+void at_dlopen() {
+ printf("%s: I am being dlopened\n", __FILE__);
+}
+__attribute__((destructor))
+void at_dlclose() {
+ printf("%s: I am being dlclosed\n", __FILE__);
+}
+#endif // SHARED_LIB