diff options
Diffstat (limited to 'test/asan')
54 files changed, 304 insertions, 89 deletions
diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt index e6d1df5e039a..6c22ef3b10ef 100644 --- a/test/asan/CMakeLists.txt +++ b/test/asan/CMakeLists.txt @@ -56,7 +56,7 @@ foreach(arch ${ASAN_TEST_ARCH}) string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX) get_bits_for_arch(${arch} ASAN_TEST_BITS) get_test_cc_for_arch(${arch} ASAN_TEST_TARGET_CC ASAN_TEST_TARGET_CFLAGS) - if(ANDROID) + if(ANDROID OR APPLE) set(ASAN_TEST_DYNAMIC True) else() set(ASAN_TEST_DYNAMIC False) diff --git a/test/asan/TestCases/Darwin/init_for_dlopen.cc b/test/asan/TestCases/Darwin/init_for_dlopen.cc new file mode 100644 index 000000000000..8a0fbf943b67 --- /dev/null +++ b/test/asan/TestCases/Darwin/init_for_dlopen.cc @@ -0,0 +1,46 @@ +// RUN: %clangxx -g -O0 %s -o %t + +// Check that trying to dlopen() the ASan dylib fails. +// We explictly set `abort_on_error=0` because +// - By default the lit config sets this but we don't want this +// test to implicitly depend on this. +// - It avoids requiring `--crash` to be passed to `not`. +// RUN: APPLE_ASAN_INIT_FOR_DLOPEN=0 %env_asan_opts=abort_on_error=0 not \ +// RUN: %run %t %shared_libasan 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-DL-OPEN-FAIL %s +// RUN: env -u APPLE_ASAN_INIT_FOR_DLOPEN %env_asan_opts=abort_on_error=0 not \ +// RUN: %run %t %shared_libasan 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-DL-OPEN-FAIL %s + +// Check that we can successfully dlopen the ASan dylib when we set the right +// environment variable. +// RUN: env APPLE_ASAN_INIT_FOR_DLOPEN=1 %run %t %shared_libasan 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-DL-OPEN-SUCCESS %s + +#include <dlfcn.h> +#include <stdio.h> + +// CHECK-DL-OPEN-FAIL: ERROR: Interceptors are not working + +int main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "Usage: %s <dylib_path>\n", argv[0]); + return 1; + } + const char *dylib_path = argv[1]; + void *handle = dlopen(dylib_path, RTLD_LAZY); + if (!handle) { + fprintf(stderr, "Failed to dlopen: %s\n", dlerror()); + return 1; + } + // Make sure we can find a function we expect to be in the dylib. + void *fn = dlsym(handle, "__sanitizer_mz_size"); + if (!fn) { + fprintf(stderr, "Failed to get symbol: %s\n", dlerror()); + return 1; + } + // TODO(dliew): Actually call a function from the dylib that is safe to call. + // CHECK-DL-OPEN-SUCCESS: DONE + printf("DONE\n"); + return 0; +} diff --git a/test/asan/TestCases/Darwin/odr-lto.cc b/test/asan/TestCases/Darwin/odr-lto.cc index 56dd89b164c2..e1e454be077f 100644 --- a/test/asan/TestCases/Darwin/odr-lto.cc +++ b/test/asan/TestCases/Darwin/odr-lto.cc @@ -1,4 +1,4 @@ -// Check that -asan-use-private-alias and use_odr_indicator=1 silence the false +// Check that -asan-use-private-alias silence the false // positive ODR violation on Darwin with LTO. // REQUIRES: lto @@ -6,7 +6,7 @@ // RUN: %clangxx_asan -DPART=0 -c %s -o %t-1.o -flto -mllvm -asan-use-private-alias // RUN: %clangxx_asan -DPART=1 -c %s -o %t-2.o -flto -mllvm -asan-use-private-alias // RUN: %clangxx_asan %t-1.o %t-2.o -o %t -flto -// RUN: %env_asan_opts=use_odr_indicator=1 %run %t 2>&1 | FileCheck %s +// RUN: %run %t 2>&1 | FileCheck %s #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/Darwin/segv_read_write.c b/test/asan/TestCases/Darwin/segv_read_write.c index d8e2d215f832..127365d2f09c 100644 --- a/test/asan/TestCases/Darwin/segv_read_write.c +++ b/test/asan/TestCases/Darwin/segv_read_write.c @@ -9,11 +9,8 @@ static volatile int sink; __attribute__((noinline)) void Read(int *ptr) { sink = *ptr; } __attribute__((noinline)) void Write(int *ptr) { *ptr = 0; } int main(int argc, char **argv) { - // Writes to shadow are detected as reads from shadow gap (because of how the - // shadow mapping works). This is kinda hard to fix. Test a random address in - // the application part of the address space. void *volatile p = - mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, 0, 0); + mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); munmap(p, 4096); if (argc == 1) Read((int *)p); diff --git a/test/asan/TestCases/Linux/asan_rt_confict_test-2.cc b/test/asan/TestCases/Linux/asan_rt_confict_test-2.cc index 4c935e2b0f3b..6328cbb2ce81 100644 --- a/test/asan/TestCases/Linux/asan_rt_confict_test-2.cc +++ b/test/asan/TestCases/Linux/asan_rt_confict_test-2.cc @@ -1,8 +1,8 @@ // Test that mixed static/dynamic sanitization of program objects // is prohibited. // -// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -// RUN: %clangxx_asan_static %s %t.so -o %t +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib +// RUN: %clangxx_asan_static %s %ld_flags_rpath_exe -o %t // RUN: not %run %t 2>&1 | FileCheck %s // REQUIRES: asan-dynamic-runtime diff --git a/test/asan/TestCases/Linux/coverage-missing.cc b/test/asan/TestCases/Linux/coverage-missing.cc index 32aada645deb..10acef9af4b0 100644 --- a/test/asan/TestCases/Linux/coverage-missing.cc +++ b/test/asan/TestCases/Linux/coverage-missing.cc @@ -45,7 +45,15 @@ // RUN: diff bar.txt foo-missing.txt > %t.log || true // RUN: not grep "^<" %t.log -// REQUIRES: x86-target-arch +// FIXME %sancov GetInstrumentedPCs relies on objdump -d to +// obtain the number of instrumented PCs. The i386 +// %dynamiclib has .plt entries that are not recognized by +// objdump, +// "sancov.py: found 0 instrumented PCs in *.so", +// causing AddressSanitizer-i386-linux to fail. +// Change it back to x86-target-arch after %sancov switches to a more robust approach. + +// REQUIRES: x86_64-target-arch // XFAIL: android #include <stdio.h> diff --git a/test/asan/TestCases/Linux/local_alias.cc b/test/asan/TestCases/Linux/local_alias.cc index 266d3fe6bc8f..a8b3d75e375b 100644 --- a/test/asan/TestCases/Linux/local_alias.cc +++ b/test/asan/TestCases/Linux/local_alias.cc @@ -4,14 +4,11 @@ // false positive global-buffer-overflow due to sanitized library poisons // globals from non-sanitized one. // -// FIXME: https://github.com/google/sanitizers/issues/316 -// XFAIL: android -// -// RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %t-INSTRUMENTED-SO.so -// RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %t-UNINSTRUMENTED-SO.so +// RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib1 +// RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %dynamiclib2 // RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o -// RUN: %clangxx_asan %t.o %t-UNINSTRUMENTED-SO.so %t-INSTRUMENTED-SO.so -o %t-EXE -// RUN: %env_asan_opts=use_odr_indicator=true %run %t-EXE +// RUN: %clangxx_asan %t.o %ld_flags_rpath_exe2 %ld_flags_rpath_exe1 -o %t-EXE +// RUN: %run %t-EXE #if defined (BUILD_INSTRUMENTED_DSO) long h = 15; diff --git a/test/asan/TestCases/Linux/new_delete_mismatch.cc b/test/asan/TestCases/Linux/new_delete_mismatch.cc index 3a71862fb732..05f74bda7549 100644 --- a/test/asan/TestCases/Linux/new_delete_mismatch.cc +++ b/test/asan/TestCases/Linux/new_delete_mismatch.cc @@ -14,3 +14,4 @@ int main() { } // CHECK: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x +// CHECK: is located 0 bytes inside of 10-byte region diff --git a/test/asan/TestCases/Linux/new_delete_mismatch_global.cc b/test/asan/TestCases/Linux/new_delete_mismatch_global.cc new file mode 100644 index 000000000000..3f1a78715caf --- /dev/null +++ b/test/asan/TestCases/Linux/new_delete_mismatch_global.cc @@ -0,0 +1,16 @@ +// Check that we report delete on a memory that belongs to a global variable. + +// RUN: %clangxx_asan -g %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1 not %run %t 2>&1 | FileCheck %s + +#include <stdlib.h> + +static volatile char *x; +char a[10]; + +int main() { + x = &a[0]; + delete x; +} + +// CHECK: AddressSanitizer: attempting free on address which was not malloc()-ed +// CHECK: is located 0 bytes inside of global variable 'a' defined in diff --git a/test/asan/TestCases/Linux/new_delete_mismatch_stack.cc b/test/asan/TestCases/Linux/new_delete_mismatch_stack.cc new file mode 100644 index 000000000000..bbf07cc21380 --- /dev/null +++ b/test/asan/TestCases/Linux/new_delete_mismatch_stack.cc @@ -0,0 +1,17 @@ +// Check that we report delete on a memory that belongs to a stack variable. + +// RUN: %clangxx_asan -g %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1 not %run %t 2>&1 | FileCheck %s + +#include <stdlib.h> + +static volatile char *x; + +int main() { + char a[10]; + x = &a[0]; + delete x; +} + +// CHECK: AddressSanitizer: attempting free on address which was not malloc()-ed +// CHECK: is located in stack of thread T0 at offset +// CHECK: 'a'{{.*}} <== Memory access at offset {{16|32}} is inside this variable diff --git a/test/asan/TestCases/Linux/odr-violation.cc b/test/asan/TestCases/Linux/odr-violation.cc index 70437a8321b9..a1941fcc8d7a 100644 --- a/test/asan/TestCases/Linux/odr-violation.cc +++ b/test/asan/TestCases/Linux/odr-violation.cc @@ -5,15 +5,15 @@ // pointers. This setting is not on by default because it's too expensive. // // Different size: detect a bug if detect_odr_violation>=1 -// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so -// RUN: %clangxx_asan %s %t-ODR-SO.so -Wl,-R. -o %t-ODR-EXE +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib +// RUN: %clangxx_asan %s %ld_flags_rpath_exe -o %t-ODR-EXE // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 not %run %t-ODR-EXE 2>&1 | FileCheck %s // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s // // Same size: report a bug only if detect_odr_violation>=2. -// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-ODR-SO.so -DSZ=100 +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib -DSZ=100 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s // RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s @@ -23,12 +23,20 @@ // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED // RUN: rm -f %t.supp // +// Use private aliases for global variables without indicator symbol. +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib -DSZ=100 +// RUN: %clangxx_asan -mllvm -asan-use-private-alias %s %ld_flags_rpath_exe -o %t-ODR-EXE +// RUN: %env_asan_opts=fast_unwind_on_malloc=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED + // Use private aliases for global variables: use indicator symbol to detect ODR violation. -// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %t-ODR-SO.so -DSZ=100 -// RUN: %clangxx_asan -mllvm -asan-use-private-alias %s %t-ODR-SO.so -Wl,-R. -o %t-ODR-EXE -// RUN: %env_asan_opts=fast_unwind_on_malloc=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED -// RUN: %env_asan_opts=fast_unwind_on_malloc=0:use_odr_indicator=false %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED -// RUN: %env_asan_opts=fast_unwind_on_malloc=0:use_odr_indicator=true not %run %t-ODR-EXE 2>&1 | FileCheck %s +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-private-alias -mllvm -asan-use-odr-indicator %s -o %dynamiclib -DSZ=100 +// RUN: %clangxx_asan -mllvm -asan-use-private-alias -mllvm -asan-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE +// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s + +// Same as above but with clang switches. +// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared -fsanitize-address-use-odr-indicator %s -o %dynamiclib -DSZ=100 +// RUN: %clangxx_asan -fsanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE +// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s // GNU driver doesn't handle .so files properly. // REQUIRES: Clang @@ -52,6 +60,6 @@ int main(int argc, char **argv) { // CHECK: These globals were registered at these points: // CHECK: ODR-EXE -// CHECK: ODR-SO +// CHECK: odr-violation.cc.dynamic // CHECK: SUMMARY: AddressSanitizer: odr-violation: global 'foo::G' at {{.*}}odr-violation.cc // DISABLED: PASS diff --git a/test/asan/TestCases/Linux/odr-vtable.cc b/test/asan/TestCases/Linux/odr-vtable.cc new file mode 100644 index 000000000000..fdbab4bb1fd8 --- /dev/null +++ b/test/asan/TestCases/Linux/odr-vtable.cc @@ -0,0 +1,26 @@ +// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared %s -o %dynamiclib1 +// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared %s -o %dynamiclib2 +// RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t +// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s + +struct XYZ { + virtual void foo(); +}; + +#if defined(BUILD_SO1) + +void XYZ::foo() {} + +#elif defined(BUILD_SO2) + +void XYZ::foo() {} + +#else + +int main() {} + +#endif + +// CHECK: AddressSanitizer: odr-violation +// CHECK-NEXT: 'vtable for XYZ' +// CHECK-NEXT: 'vtable for XYZ' diff --git a/test/asan/TestCases/Linux/odr_c_test.c b/test/asan/TestCases/Linux/odr_c_test.c index b1d23493b570..c1423ed30b1b 100644 --- a/test/asan/TestCases/Linux/odr_c_test.c +++ b/test/asan/TestCases/Linux/odr_c_test.c @@ -1,13 +1,11 @@ // Test that we can properly report an ODR violation // between an instrumented global and a non-instrumented global. -// RUN: %clang_asan %s -fPIC -shared -o %t-1.so -DFILE1 -// RUN: %clang_asan %s -fPIC -shared -o %t-2.so -DFILE2 -// RUN: %clang_asan %s -fPIE %t-1.so %t-2.so -Wl,-R`pwd` -o %t +// RUN: %clang_asan %s -fPIC -shared -o %dynamiclib1 -DFILE1 +// RUN: %clang_asan %s -fPIC -shared -o %dynamiclib2 -DFILE2 +// RUN: %clang_asan %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t // RUN: not %run %t 2>&1 | FileCheck %s // -// REQUIRES: x86_64-target-arch -// // CHECK: The following global variable is not properly aligned. // CHECK: ERROR: AddressSanitizer: odr-violation #if defined(FILE1) diff --git a/test/asan/TestCases/Linux/odr_indicators.cc b/test/asan/TestCases/Linux/odr_indicators.cc new file mode 100644 index 000000000000..36176b552906 --- /dev/null +++ b/test/asan/TestCases/Linux/odr_indicators.cc @@ -0,0 +1,26 @@ +// RUN: %clangxx_asan -fPIC %s -o %t +// RUN: %env_asan_opts=report_globals=2 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,INDICATOR0 + +// RUN: %clangxx_asan -fsanitize-address-use-odr-indicator -fPIC %s -o %t +// RUN: %env_asan_opts=report_globals=2 %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,INDICATOR1 + +#include <stdio.h> + +int test_global_1; +// INDICATOR0-DAG: Added Global{{.*}} name=test_global_1{{.*}} odr_indicator={{0x0+$}} +// INDICATOR1-DAG: Added Global{{.*}} name=test_global_1{{.*}} odr_indicator={{0x0*[^0]+.*$}} + +static int test_global_2; +// CHECK-DAG: Added Global{{.*}} name=test_global_2{{.*}} odr_indicator={{0xf+$}} + +namespace { +static int test_global_3; +// CHECK-DAG: Added Global{{.*}} name={{.*}}::test_global_3{{.*}} odr_indicator={{0xf+$}} +} // namespace + +int main() { + const char f[] = "%d %d %d\n"; + // CHECK-DAG: Added Global{{.*}} name=__const.main.f{{.*}} odr_indicator={{0xf+$}} + printf(f, test_global_1, test_global_2, test_global_3); + return 0; +} diff --git a/test/asan/TestCases/Linux/preinit_test.cc b/test/asan/TestCases/Linux/preinit_test.cc index 10dde67d6a9b..f8c2b6bf52f1 100644 --- a/test/asan/TestCases/Linux/preinit_test.cc +++ b/test/asan/TestCases/Linux/preinit_test.cc @@ -1,8 +1,5 @@ -// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 -// XFAIL: android -// -// RUN: %clangxx -DFUNC=zzzz %s -shared -o %t.so -fPIC -// RUN: %clangxx_asan -DFUNC=main %s -o %t -Wl,-R. %t.so +// RUN: %clangxx -DFUNC=zzzz %s -shared -o %dynamiclib -fPIC +// RUN: %clangxx_asan -DFUNC=main %s -o %t %ld_flags_rpath_exe // RUN: %run %t // GNU driver doesn't handle .so files properly. diff --git a/test/asan/TestCases/Linux/preinstalled_signal.cc b/test/asan/TestCases/Linux/preinstalled_signal.cc index ac4ea93a5418..2b50944c6f2f 100644 --- a/test/asan/TestCases/Linux/preinstalled_signal.cc +++ b/test/asan/TestCases/Linux/preinstalled_signal.cc @@ -1,4 +1,3 @@ -// clang-format off // RUN: %clangxx -std=c++11 %s -o %t // RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=1 not %run %t 2>&1 | FileCheck %s // RUN: env LD_PRELOAD=%shared_libasan %env_asan_opts=handle_segv=2 not %run %t 2>&1 | FileCheck %s @@ -17,7 +16,6 @@ // This way of setting LD_PRELOAD does not work with Android test runner. // REQUIRES: !android -// clang-format on #include <assert.h> #include <signal.h> diff --git a/test/asan/TestCases/Posix/coverage-reset.cc b/test/asan/TestCases/Posix/coverage-reset.cc index 6d76a309b76f..152be2ab3a29 100644 --- a/test/asan/TestCases/Posix/coverage-reset.cc +++ b/test/asan/TestCases/Posix/coverage-reset.cc @@ -5,6 +5,8 @@ // // UNSUPPORTED: ios +// XFAIL: i386-netbsd + #include <stdio.h> #include <sanitizer/coverage_interface.h> diff --git a/test/asan/TestCases/Posix/coverage.cc b/test/asan/TestCases/Posix/coverage.cc index 12a88402eb5a..9dbd72eabd2c 100644 --- a/test/asan/TestCases/Posix/coverage.cc +++ b/test/asan/TestCases/Posix/coverage.cc @@ -18,6 +18,7 @@ // // https://code.google.com/p/address-sanitizer/issues/detail?id=263 // XFAIL: android +// XFAIL: i386-netbsd // UNSUPPORTED: ios #include <assert.h> diff --git a/test/asan/TestCases/Posix/dlclose-test.cc b/test/asan/TestCases/Posix/dlclose-test.cc index 0aafa3e79f6b..160c1c940e6f 100644 --- a/test/asan/TestCases/Posix/dlclose-test.cc +++ b/test/asan/TestCases/Posix/dlclose-test.cc @@ -23,6 +23,8 @@ // RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so // RUN: %clangxx_asan -O3 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s +// XFAIL: i386-netbsd + #if !defined(SHARED_LIB) #include <assert.h> #include <dlfcn.h> diff --git a/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc b/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc index a7d2bfb9b43c..b31b035f9e40 100644 --- a/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc +++ b/test/asan/TestCases/Posix/interception-in-shared-lib-test.cc @@ -5,6 +5,8 @@ // RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe && \ // RUN: not %run %t 2>&1 | FileCheck %s +// XFAIL: i386-netbsd + #include <stdio.h> #include <string.h> diff --git a/test/asan/TestCases/Posix/mmap_limit_mb.cc b/test/asan/TestCases/Posix/mmap_limit_mb.cc index 508c03fbcb16..cb613f53577a 100644 --- a/test/asan/TestCases/Posix/mmap_limit_mb.cc +++ b/test/asan/TestCases/Posix/mmap_limit_mb.cc @@ -9,7 +9,7 @@ // RUN: %env_asan_opts=mmap_limit_mb=300 not %run %t 500 1000000 2>&1 | FileCheck %s // // FIXME: Windows doesn't implement mmap_limit_mb. -// XFAIL: win32 +// XFAIL: windows-msvc #include <assert.h> #include <stdlib.h> diff --git a/test/asan/TestCases/Posix/no-fd.cc b/test/asan/TestCases/Posix/no-fd.cc new file mode 100644 index 000000000000..086b01412ddb --- /dev/null +++ b/test/asan/TestCases/Posix/no-fd.cc @@ -0,0 +1,43 @@ +// RUN: %clangxx_asan -std=c++11 -O0 %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s +// RUN: %env_asan_opts=debug=1,verbosity=2 %run %t 2>&1 | FileCheck %s + +// Test ASan initialization + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +extern "C" const char *__asan_default_options() { + return "test_only_emulate_no_memorymap=1"; +} + +void parent(int argc, char **argv) { + fprintf(stderr, "hello\n"); + // CHECK: hello + close(0); + close(1); + dup2(2, 3); + close(2); + char *const newargv[] = {argv[0], (char *)"x", nullptr}; + execv(argv[0], newargv); + perror("execve"); + exit(1); +} + +void child() { + assert(dup(3) == 0); + assert(dup(3) == 1); + assert(dup(3) == 2); + fprintf(stderr, "world\n"); + // CHECK: world +} + +int main(int argc, char **argv) { + if (argc == 1) { + parent(argc, argv); + } else { + child(); + } +} diff --git a/test/asan/TestCases/Posix/stack-use-after-return.cc b/test/asan/TestCases/Posix/stack-use-after-return.cc index 237c880f8e61..02588d708e22 100644 --- a/test/asan/TestCases/Posix/stack-use-after-return.cc +++ b/test/asan/TestCases/Posix/stack-use-after-return.cc @@ -17,7 +17,7 @@ // This test runs out of stack on AArch64. // UNSUPPORTED: aarch64 // stack size log lower than expected -// XFAIL: freebsd +// XFAIL: freebsd,netbsd // FIXME: Fix this test for dynamic runtime on arm linux. // UNSUPPORTED: (arm-linux || armhf-linux) && asan-dynamic-runtime @@ -78,9 +78,11 @@ int main(int argc, char **argv) { pthread_attr_init(&attr); if (kStackSize > 0) { size_t desired_stack_size = kStackSize; +#ifdef PTHREAD_STACK_MIN if (desired_stack_size < PTHREAD_STACK_MIN) { desired_stack_size = PTHREAD_STACK_MIN; } +#endif int ret = pthread_attr_setstacksize(&attr, desired_stack_size); if (ret != 0) { diff --git a/test/asan/TestCases/Posix/strndup_oob_test.cc b/test/asan/TestCases/Posix/strndup_oob_test.cc index 326ddcfd6b06..22bbf7c7ef1c 100644 --- a/test/asan/TestCases/Posix/strndup_oob_test.cc +++ b/test/asan/TestCases/Posix/strndup_oob_test.cc @@ -7,7 +7,7 @@ // RUN: %clangxx_asan -O3 -xc %s -o %t && not %run %t 2>&1 | FileCheck %s // Unwind problem on arm: "main" is missing from the allocation stack trace. -// UNSUPPORTED: win32,s390,arm && !fast-unwinder-works +// UNSUPPORTED: windows-msvc,s390,arm && !fast-unwinder-works #include <string.h> diff --git a/test/asan/TestCases/Posix/strndup_oob_test2.cc b/test/asan/TestCases/Posix/strndup_oob_test2.cc index 44df6bda9c83..8cc822d7cb3e 100644 --- a/test/asan/TestCases/Posix/strndup_oob_test2.cc +++ b/test/asan/TestCases/Posix/strndup_oob_test2.cc @@ -1,22 +1,22 @@ -// RUN: %clang_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clang_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clang_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clang_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s - -// When built as C on Linux, strndup is transformed to __strndup. -// RUN: %clang_asan -O3 -xc %s -o %t && not %run %t 2>&1 | FileCheck %s - -// Unwind problem on arm: "main" is missing from the allocation stack trace. -// UNSUPPORTED: win32,s390,arm && !fast-unwinder-works - -#include <string.h> - -char kChars[] = { 'f', 'o', 'o' }; - -int main(int argc, char **argv) { - char *copy = strndup(kChars, 3); - copy = strndup(kChars, 10); - // CHECK: AddressSanitizer: global-buffer-overflow - // CHECK: {{.*}}main {{.*}}.cc:[[@LINE-2]] - return *copy; -} +// RUN: %clang_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// When built as C on Linux, strndup is transformed to __strndup.
+// RUN: %clang_asan -O3 -xc %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// Unwind problem on arm: "main" is missing from the allocation stack trace.
+// UNSUPPORTED: windows-msvc,s390,arm && !fast-unwinder-works +
+#include <string.h>
+
+char kChars[] = { 'f', 'o', 'o' };
+
+int main(int argc, char **argv) {
+ char *copy = strndup(kChars, 3);
+ copy = strndup(kChars, 10);
+ // CHECK: AddressSanitizer: global-buffer-overflow
+ // CHECK: {{.*}}main {{.*}}.cc:[[@LINE-2]]
+ return *copy;
+}
diff --git a/test/asan/TestCases/Posix/tsd_dtor_leak.cc b/test/asan/TestCases/Posix/tsd_dtor_leak.cc index 9e71ff61cf02..26109fe1a5f4 100644 --- a/test/asan/TestCases/Posix/tsd_dtor_leak.cc +++ b/test/asan/TestCases/Posix/tsd_dtor_leak.cc @@ -2,6 +2,9 @@ // https://code.google.com/p/address-sanitizer/issues/detail?id=233 // RUN: %clangxx_asan -O1 %s -pthread -o %t // RUN: %env_asan_opts=quarantine_size_mb=0 %run %t +// XFAIL: x86_64-netbsd +// Assertion fails +// XFAIL: x86_64-freebsd #include <pthread.h> #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/asan_and_llvm_coverage_test.cc b/test/asan/TestCases/asan_and_llvm_coverage_test.cc index 1574a344399b..2ba5a42d1b7b 100644 --- a/test/asan/TestCases/asan_and_llvm_coverage_test.cc +++ b/test/asan/TestCases/asan_and_llvm_coverage_test.cc @@ -2,7 +2,8 @@ // RUN: %env_asan_opts=check_initialization_order=1 %run %t 2>&1 | FileCheck %s // We don't really support running tests using profile runtime on Windows. -// UNSUPPORTED: win32 +// UNSUPPORTED: windows-msvc + #include <stdio.h> int foo() { return 1; } int XXX = foo(); diff --git a/test/asan/TestCases/atoll_strict.c b/test/asan/TestCases/atoll_strict.c index 2b02354a92eb..0cb568969250 100644 --- a/test/asan/TestCases/atoll_strict.c +++ b/test/asan/TestCases/atoll_strict.c @@ -11,7 +11,7 @@ // RUN: %env_asan_opts=strict_string_checks=true not %run %t test3 2>&1 | FileCheck %s --check-prefix=CHECK3 // FIXME: Needs Windows interceptor. -// XFAIL: win32 +// XFAIL: windows-msvc #include <assert.h> #include <stdlib.h> diff --git a/test/asan/TestCases/heavy_uar_test.cc b/test/asan/TestCases/heavy_uar_test.cc index 94df0cefc73b..29a1d196567b 100644 --- a/test/asan/TestCases/heavy_uar_test.cc +++ b/test/asan/TestCases/heavy_uar_test.cc @@ -1,6 +1,6 @@ // RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s // RUN: %clangxx_asan -O2 %s -o %t && %env_asan_opts=detect_stack_use_after_return=1 not %run %t 2>&1 | FileCheck %s -// XFAIL: win32 +// XFAIL: windows-msvc // FIXME: Fix this test under GCC. // REQUIRES: Clang @@ -53,8 +53,8 @@ int main(int argc, char **argv) { RecursiveFunctionWithStackFrame<1024>(depth); RecursiveFunctionWithStackFrame<2000>(depth); // The stack size is tight for the main thread in multithread - // environment on FreeBSD. -#if !defined(__FreeBSD__) + // environment on FreeBSD and NetBSD. +#if !defined(__FreeBSD__) && !defined(__NetBSD__) RecursiveFunctionWithStackFrame<5000>(depth); RecursiveFunctionWithStackFrame<10000>(depth); #endif diff --git a/test/asan/TestCases/initialization-bug.cc b/test/asan/TestCases/initialization-bug.cc index 6ecc6c836c5c..20fdbfe5f59d 100644 --- a/test/asan/TestCases/initialization-bug.cc +++ b/test/asan/TestCases/initialization-bug.cc @@ -6,7 +6,7 @@ // Do not test with optimization -- the error may be optimized away. // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=186 -// XFAIL: win32 +// XFAIL: windows-msvc // The test is expected to fail on OS X Yosemite and older // UNSUPPORTED: osx-no-ld64-live_support diff --git a/test/asan/TestCases/intercept-rethrow-exception.cc b/test/asan/TestCases/intercept-rethrow-exception.cc index e81dc5398a98..019092a9e8b9 100644 --- a/test/asan/TestCases/intercept-rethrow-exception.cc +++ b/test/asan/TestCases/intercept-rethrow-exception.cc @@ -4,6 +4,10 @@ // RUN: %clangxx_asan -fexceptions -O0 %s -o %t // RUN: %run %t +// The current implementation of this functionality requires special +// combination of libraries that are not used by default on NetBSD +// XFAIL: netbsd + #include <assert.h> #include <exception> #include <sanitizer/asan_interface.h> diff --git a/test/asan/TestCases/interception_failure_test.cc b/test/asan/TestCases/interception_failure_test.cc index d85500b50486..4f6698e3a537 100644 --- a/test/asan/TestCases/interception_failure_test.cc +++ b/test/asan/TestCases/interception_failure_test.cc @@ -11,6 +11,10 @@ // it works with the dynamic runtime. // XFAIL: win32-static-asan +// On NetBSD, defining strtol in a static build results in linker errors, but +// it works with the dynamic runtime. +// XFAIL: netbsd && !asan-dynamic-runtime + #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/test/asan/TestCases/intra-object-overflow.cc b/test/asan/TestCases/intra-object-overflow.cc index 56b5bb2b729f..b71e951bb0b7 100644 --- a/test/asan/TestCases/intra-object-overflow.cc +++ b/test/asan/TestCases/intra-object-overflow.cc @@ -5,7 +5,7 @@ // FIXME: fix 32-bits. // REQUIRES: asan-64-bits, shadow-scale-3 // FIXME: Implement ASan intra-object padding in Clang's MS record layout -// UNSUPPORTED: win32 +// UNSUPPORTED: windows-msvc #include <stdio.h> #include <stdlib.h> class Foo { diff --git a/test/asan/TestCases/log-path_test.cc b/test/asan/TestCases/log-path_test.cc index 710d22017700..fd33a31d6df9 100644 --- a/test/asan/TestCases/log-path_test.cc +++ b/test/asan/TestCases/log-path_test.cc @@ -31,7 +31,7 @@ // RUN: not cat %t.log.* // FIXME: log_path is not supported on Windows yet. -// XFAIL: win32 +// XFAIL: windows-msvc #include <stdlib.h> #include <string.h> diff --git a/test/asan/TestCases/pass-object-byval.cc b/test/asan/TestCases/pass-object-byval.cc index b99360fa7850..f9191c53d708 100644 --- a/test/asan/TestCases/pass-object-byval.cc +++ b/test/asan/TestCases/pass-object-byval.cc @@ -5,7 +5,7 @@ // RUN: Assertion{{.*}}failed // ASan instrumentation can't insert red-zones around inalloca parameters. -// XFAIL: win32 && asan-32-bits +// XFAIL: windows-msvc && asan-32-bits #include <cassert> diff --git a/test/asan/TestCases/printf-2.c b/test/asan/TestCases/printf-2.c index 0544847ff5bf..7127347f883b 100644 --- a/test/asan/TestCases/printf-2.c +++ b/test/asan/TestCases/printf-2.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=replace_str=0:intercept_strlen=0:replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: win32 +// XFAIL: windows-msvc #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/printf-3.c b/test/asan/TestCases/printf-3.c index 010e6c8ef0c2..4f54ff956e3d 100644 --- a/test/asan/TestCases/printf-3.c +++ b/test/asan/TestCases/printf-3.c @@ -4,7 +4,11 @@ // RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: win32 +// XFAIL: windows-msvc + +// New Bionic rejects %n +// https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336 +// UNSUPPORTED: android #include <stdio.h> int main() { diff --git a/test/asan/TestCases/printf-4.c b/test/asan/TestCases/printf-4.c index 70f4073cc496..2af81b0efa15 100644 --- a/test/asan/TestCases/printf-4.c +++ b/test/asan/TestCases/printf-4.c @@ -4,7 +4,7 @@ // FIXME: sprintf is not intercepted on Windows yet. But this test can // pass if sprintf calls memmove, which is intercepted, so we can't XFAIL it. -// UNSUPPORTED: win32 +// UNSUPPORTED: windows-msvc #include <stdio.h> int main() { diff --git a/test/asan/TestCases/printf-5.c b/test/asan/TestCases/printf-5.c index a614462d2f4a..2257bb4e61aa 100644 --- a/test/asan/TestCases/printf-5.c +++ b/test/asan/TestCases/printf-5.c @@ -5,7 +5,7 @@ // RUN: %env_asan_opts=replace_intrin=0 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ON %s // FIXME: printf is not intercepted on Windows yet. -// XFAIL: win32 +// XFAIL: windows-msvc #include <stdio.h> #include <string.h> diff --git a/test/asan/TestCases/printf-m.c b/test/asan/TestCases/printf-m.c index 9cd5ae1c288e..3998a6956f74 100644 --- a/test/asan/TestCases/printf-m.c +++ b/test/asan/TestCases/printf-m.c @@ -1,7 +1,7 @@ // RUN: %clang_asan -O2 %s -o %t && %run %t // FIXME: printf is not intercepted on Windows yet. -// UNSUPPORTED: win32 +// UNSUPPORTED: windows-msvc #include <stdio.h> diff --git a/test/asan/TestCases/set_shadow_test.c b/test/asan/TestCases/set_shadow_test.c index daa79a66a389..95bbd829ba85 100644 --- a/test/asan/TestCases/set_shadow_test.c +++ b/test/asan/TestCases/set_shadow_test.c @@ -6,7 +6,7 @@ // RUN: not %run %t 0xf5 2>&1 | FileCheck %s -check-prefix=XF5 // RUN: not %run %t 0xf8 2>&1 | FileCheck %s -check-prefix=XF8 -// XFAIL: win32 +// XFAIL: windows-msvc #include <assert.h> #include <sanitizer/asan_interface.h> diff --git a/test/asan/TestCases/strcasestr-1.c b/test/asan/TestCases/strcasestr-1.c index dccfbcde7709..bb0863de77d2 100644 --- a/test/asan/TestCases/strcasestr-1.c +++ b/test/asan/TestCases/strcasestr-1.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false %run %t 2>&1 // There's no interceptor for strcasestr on Windows -// XFAIL: win32 +// XFAIL: windows-msvc #define _GNU_SOURCE #include <assert.h> diff --git a/test/asan/TestCases/strcasestr-2.c b/test/asan/TestCases/strcasestr-2.c index 70de2dda437d..35d05c277eae 100644 --- a/test/asan/TestCases/strcasestr-2.c +++ b/test/asan/TestCases/strcasestr-2.c @@ -6,7 +6,7 @@ // RUN: %env_asan_opts=intercept_strstr=false:replace_str=false:intercept_strlen=false %run %t 2>&1 // There's no interceptor for strcasestr on Windows -// XFAIL: win32 +// XFAIL: windows-msvc #define _GNU_SOURCE #include <assert.h> diff --git a/test/asan/TestCases/strcasestr_strict.c b/test/asan/TestCases/strcasestr_strict.c index 956bee71a390..16adae184b53 100644 --- a/test/asan/TestCases/strcasestr_strict.c +++ b/test/asan/TestCases/strcasestr_strict.c @@ -4,7 +4,7 @@ // RUN: %env_asan_opts=strict_string_checks=true not %run %t 2>&1 | FileCheck %s // There's no interceptor for strcasestr on Windows -// XFAIL: win32 +// XFAIL: windows-msvc #define _GNU_SOURCE #include <assert.h> diff --git a/test/asan/TestCases/strcat-overlap.cc b/test/asan/TestCases/strcat-overlap.cc index 89991fbd7881..5539b130f4e2 100644 --- a/test/asan/TestCases/strcat-overlap.cc +++ b/test/asan/TestCases/strcat-overlap.cc @@ -31,7 +31,7 @@ // depending on how strcat() is implemented. For now only run // on platforms where we know the test passes. // REQUIRES: x86_64h-darwin || x86_64-darwin || i386-darwin || x86_64-linux || i386-linux -// UNSUPPORTED: win32 +// UNSUPPORTED: windows-msvc // UNSUPPORTED: android #include <string.h> diff --git a/test/asan/TestCases/strncasecmp_strict.c b/test/asan/TestCases/strncasecmp_strict.c index aa658402b42b..bd937214092d 100644 --- a/test/asan/TestCases/strncasecmp_strict.c +++ b/test/asan/TestCases/strncasecmp_strict.c @@ -14,7 +14,7 @@ // RUN: %env_asan_opts=strict_string_checks=false %run %t i 2>&1 // RUN: %env_asan_opts=strict_string_checks=true not %run %t i 2>&1 | FileCheck %s -// XFAIL: win32 +// XFAIL: windows-msvc #include <assert.h> #include <stdlib.h> diff --git a/test/asan/TestCases/strtoll_strict.c b/test/asan/TestCases/strtoll_strict.c index 93cce30f8cb9..3fa800ca4136 100644 --- a/test/asan/TestCases/strtoll_strict.c +++ b/test/asan/TestCases/strtoll_strict.c @@ -24,7 +24,7 @@ // FIXME: Enable strtoll interceptor. // REQUIRES: shadow-scale-3 -// XFAIL: win32 +// XFAIL: windows-msvc #include <assert.h> #include <stdlib.h> diff --git a/test/asan/TestCases/suppressions-exec-relative-location.cc b/test/asan/TestCases/suppressions-exec-relative-location.cc index d7497566a8c3..3f6d239257d2 100644 --- a/test/asan/TestCases/suppressions-exec-relative-location.cc +++ b/test/asan/TestCases/suppressions-exec-relative-location.cc @@ -24,7 +24,7 @@ // RUN: FileCheck --check-prefix=CHECK-WRONG-FILE-NAME %s // XFAIL: android -// XFAIL: win32 +// XFAIL: windows-msvc // UNSUPPORTED: ios #include <stdio.h> diff --git a/test/asan/TestCases/suppressions-function.cc b/test/asan/TestCases/suppressions-function.cc index becefa2ee31c..510a9bc5bb56 100644 --- a/test/asan/TestCases/suppressions-function.cc +++ b/test/asan/TestCases/suppressions-function.cc @@ -7,7 +7,7 @@ // RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s // FIXME: Windows symbolizer needs work to make this pass. -// XFAIL: android,win32 +// XFAIL: android,windows-msvc // UNSUPPORTED: ios // FIXME: atos does not work for inlined functions, yet llvm-symbolizer diff --git a/test/asan/TestCases/suppressions-library.cc b/test/asan/TestCases/suppressions-library.cc index 39ede0840105..181ed75826ce 100644 --- a/test/asan/TestCases/suppressions-library.cc +++ b/test/asan/TestCases/suppressions-library.cc @@ -11,6 +11,7 @@ // RUN: %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s // XFAIL: android +// XFAIL: i386-netbsd #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/throw_catch.cc b/test/asan/TestCases/throw_catch.cc index 01083510c32f..d7f00ea9e193 100644 --- a/test/asan/TestCases/throw_catch.cc +++ b/test/asan/TestCases/throw_catch.cc @@ -21,6 +21,7 @@ void ThrowAndCatch() { } } +__attribute__((noinline)) void TestThrow() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, @@ -36,6 +37,7 @@ void TestThrow() { assert(!__asan_address_is_poisoned(x + 32)); } +__attribute__((noinline)) void TestThrowInline() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, diff --git a/test/asan/TestCases/time_interceptor.cc b/test/asan/TestCases/time_interceptor.cc index 89b2183bcde2..f78af1056af6 100644 --- a/test/asan/TestCases/time_interceptor.cc +++ b/test/asan/TestCases/time_interceptor.cc @@ -3,7 +3,7 @@ // Test the time() interceptor. // There's no interceptor for time() on Windows yet. -// XFAIL: win32 +// XFAIL: windows-msvc #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/verbose-log-path_test.cc b/test/asan/TestCases/verbose-log-path_test.cc index 8088ff924761..5407d15d6f6e 100644 --- a/test/asan/TestCases/verbose-log-path_test.cc +++ b/test/asan/TestCases/verbose-log-path_test.cc @@ -10,7 +10,7 @@ // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t-dir/asan.log.verbose-log-path_test-binary.* // FIXME: only FreeBSD, NetBSD and Linux have verbose log paths now. -// XFAIL: win32,android +// XFAIL: windows-msvc,android // UNSUPPORTED: ios #include <stdlib.h> diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg index f8994d069ad8..3deb4ccc5f91 100644 --- a/test/asan/lit.cfg +++ b/test/asan/lit.cfg @@ -101,8 +101,17 @@ config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) ) config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) ) -config.substitutions.append( ("%shared_libasan", "libclang_rt.asan%s.so" % config.target_suffix)) if config.asan_dynamic: + if config.host_os in ['Linux', 'NetBSD']: + shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix)) + elif config.host_os == 'Darwin': + shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform)) + else: + lit_config.warning('%shared_libasan substitution not set but dynamic ASan is available.') + shared_libasan_path = None + + if shared_libasan_path is not None: + config.substitutions.append( ("%shared_libasan", shared_libasan_path) ) config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) ) config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) ) |