40 lines · cpp
1// When DYLD-inserting the ASan dylib from a different location than the2// original, make sure we don't try to reexec.3 4// UNSUPPORTED: ios5 6// RUN: rm -rf %t && mkdir -p %t7// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name8// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \9// RUN: %t/libclang_rt.asan_osx_dynamic.dylib10// RUN: %clangxx_asan %s -o %t/a.out11 12// RUN: %env_asan_opts=verbosity=1 \13// RUN: DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib \14// RUN: %run %t/a.out 2>&1 \15// RUN: | FileCheck %s16 17// On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec.18// RUN: %if mac-os-10-11-or-higher %{ %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 | FileCheck --check-prefix=CHECK-NOINSERT %s %}19 20// On OS X 10.11 and higher, we don't need to DYLD-insert anymore, and the interceptors21// still installed correctly. Let's just check that things work and we don't try to re-exec.22// RUN: %if mac-os-10-10-or-lower %{ %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 | FileCheck %s %}23 24#include <stdio.h>25 26int main() {27 printf("Passed\n");28 return 0;29}30 31// CHECK-NOINSERT: exec()-ing the program with32// CHECK-NOINSERT: DYLD_INSERT_LIBRARIES33// CHECK-NOINSERT: to enable wrappers.34// CHECK-NOINSERT: Passed35 36// CHECK-NOT: exec()-ing the program with37// CHECK-NOT: DYLD_INSERT_LIBRARIES38// CHECK-NOT: to enable wrappers.39// CHECK: Passed40