1673dc3d4SNico Weber // When DYLD-inserting the ASan dylib from a different location than the 2673dc3d4SNico Weber // original, make sure we don't try to reexec. 3673dc3d4SNico Weber 4673dc3d4SNico Weber // UNSUPPORTED: ios 5673dc3d4SNico Weber 6673dc3d4SNico Weber // RUN: rm -rf %t && mkdir -p %t 7673dc3d4SNico Weber // RUN: cp `%clang_asan -print-file-name=lib`/darwin/libclang_rt.asan_osx_dynamic.dylib \ 8673dc3d4SNico Weber // RUN: %t/libclang_rt.asan_osx_dynamic.dylib 9673dc3d4SNico Weber // RUN: %clangxx_asan %s -o %t/a.out 10673dc3d4SNico Weber 11673dc3d4SNico Weber // RUN: %env_asan_opts=verbosity=1 \ 12673dc3d4SNico Weber // RUN: DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib \ 13673dc3d4SNico Weber // RUN: %run %t/a.out 2>&1 \ 14673dc3d4SNico Weber // RUN: | FileCheck %s 15673dc3d4SNico Weber 16*1e90bd7fSJulian Lettner // RUN: MACOS_MAJOR=$(sw_vers -productVersion | cut -d'.' -f1) 17*1e90bd7fSJulian Lettner // RUN: MACOS_MINOR=$(sw_vers -productVersion | cut -d'.' -f2) 18*1e90bd7fSJulian Lettner 19*1e90bd7fSJulian Lettner // RUN: IS_MACOS_10_11_OR_HIGHER=$([ $MACOS_MAJOR -eq 10 ] && [ $MACOS_MINOR -lt 11 ]; echo $?) 20673dc3d4SNico Weber 21673dc3d4SNico Weber // On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec. 22*1e90bd7fSJulian Lettner // RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 0 ]; then \ 23673dc3d4SNico Weber // RUN: %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \ 24673dc3d4SNico Weber // RUN: | FileCheck --check-prefix=CHECK-NOINSERT %s; \ 25673dc3d4SNico Weber // RUN: fi 26673dc3d4SNico Weber 27673dc3d4SNico Weber // On OS X 10.11 and higher, we don't need to DYLD-insert anymore, and the interceptors 28673dc3d4SNico Weber // still installed correctly. Let's just check that things work and we don't try to re-exec. 29*1e90bd7fSJulian Lettner // RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 1 ]; then \ 30673dc3d4SNico Weber // RUN: %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \ 31673dc3d4SNico Weber // RUN: | FileCheck %s; \ 32673dc3d4SNico Weber // RUN: fi 33673dc3d4SNico Weber 34673dc3d4SNico Weber #include <stdio.h> 35673dc3d4SNico Weber main()36673dc3d4SNico Weberint main() { 37673dc3d4SNico Weber printf("Passed\n"); 38673dc3d4SNico Weber return 0; 39673dc3d4SNico Weber } 40673dc3d4SNico Weber 41673dc3d4SNico Weber // CHECK-NOINSERT: exec()-ing the program with 42673dc3d4SNico Weber // CHECK-NOINSERT: DYLD_INSERT_LIBRARIES 43673dc3d4SNico Weber // CHECK-NOINSERT: to enable wrappers. 44673dc3d4SNico Weber // CHECK-NOINSERT: Passed 45673dc3d4SNico Weber 46673dc3d4SNico Weber // CHECK-NOT: exec()-ing the program with 47673dc3d4SNico Weber // CHECK-NOT: DYLD_INSERT_LIBRARIES 48673dc3d4SNico Weber // CHECK-NOT: to enable wrappers. 49673dc3d4SNico Weber // CHECK: Passed 50