Skip to content

Conversation

@boomanaiden154
Copy link
Contributor

This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:

TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp

@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Aiden Grossman (boomanaiden154)

Changes

This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:

TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp

Full diff: https://github.com/llvm/llvm-project/pull/168545.diff

7 Files Affected:

  • (modified) compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp (+2-1)
  • (modified) compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp (+2-1)
  • (modified) compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp (+2-1)
  • (modified) compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp (+22-17)
  • (modified) compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp (+1-1)
  • (modified) compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp (+1-1)
  • (modified) compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp (+2-1)
diff --git a/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp b/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp
index 664471b6987a8..4201d49df4d74 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp
@@ -1,6 +1,7 @@
 // Check that when having a DYLD_ROOT_PATH set, the symbolizer still works.
 // RUN: %clangxx_asan -O0 %s -o %t
-// RUN: %env_asan_opts=verbosity=2 DYLD_ROOT_PATH="/" ASAN_SYMBOLIZER_PATH=$(which atos) \
+// RUN: which atos | tr -d '\n' > %t.symbolizer_path
+// RUN: %env_asan_opts=verbosity=2 DYLD_ROOT_PATH="/" ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} \
 // RUN:   not %run %t 2>&1 | FileCheck %s
 //
 // Due to a bug in atos, this only works on x86_64.
diff --git a/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp b/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp
index bab4e4f3765c2..7487bd4cb40e6 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp
@@ -1,7 +1,8 @@
 // Check that the `atos` symbolizer works.
 
 // RUN: %clangxx_asan -O0 %s -o %t
-// RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s
+// RUN: which atos | tr -d '\n' > %t.symbolizer_path
+// RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} not %run %t 2>&1 | FileCheck %s
 
 // Path returned by `which atos` is invalid on iOS.
 // UNSUPPORTED: ios, i386-darwin
diff --git a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
index 0fec18b89411a..145e162a21c0e 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp
@@ -4,7 +4,8 @@
 // UNSUPPORTED: ios
 
 // RUN: rm -rf %t && mkdir -p %t
-// RUN: cp `%clang_asan -print-file-name=lib`/darwin/libclang_rt.asan_osx_dynamic.dylib \
+// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name
+// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \
 // RUN:   %t/libclang_rt.asan_osx_dynamic.dylib
 // RUN: %clangxx_asan %s -o %t/a.out
 
diff --git a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp
index 0672e064a1904..7e3fe584f706b 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp
@@ -5,29 +5,34 @@
 // UNSUPPORTED: ios
 
 // RUN: rm -rf %t && mkdir -p %t
-// RUN: cp `%clang_asan -print-file-name=lib`/darwin/libclang_rt.asan_osx_dynamic.dylib \
+// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name
+// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \
 // RUN:   %t/libclang_rt.asan_osx_dynamic.dylib
 
 // RUN: %clangxx_asan %s -o %t/a.out
 // RUN: %clangxx -DSHARED_LIB %s \
 // RUN:     -dynamiclib -o %t/dummy-so.dylib
 
-// RUN: ( cd %t && \
-// RUN:   DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
-// RUN:   %run ./a.out 2>&1 ) | FileCheck %s || exit 1
-
-// RUN: ( cd %t && \
-// RUN:   DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
-// RUN:   %run ./a.out 2>&1 ) | FileCheck %s || exit 1
-
-// RUN: ( cd %t && \
-// RUN:   %env_asan_opts=strip_env=0 \
-// RUN:   DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
-// RUN:   %run ./a.out 2>&1 ) | FileCheck %s --check-prefix=CHECK-KEEP || exit 1
-
-// RUN: ( cd %t && \
-// RUN:   DYLD_INSERT_LIBRARIES=%t/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
-// RUN:   %run ./a.out 2>&1 ) | FileCheck %s || exit 1
+// RUN: pushd %t
+// RUN: env DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
+// RUN: %run ./a.out 2>&1 | FileCheck %s
+// RUN: popd
+
+// RUN: pushd %t
+// RUN: env DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
+// RUN: %run ./a.out 2>&1 | FileCheck %s
+// RUN: popd
+
+// RUN: pushd %t
+// RUN: %env_asan_opts=strip_env=0 \
+// RUN: DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
+// RUN: %run ./a.out 2>&1 | FileCheck %s --check-prefix=CHECK-KEEP
+// RUN: popd
+
+// RUN: pushd %t
+// RUN: env DYLD_INSERT_LIBRARIES=%t/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
+// RUN: %run ./a.out 2>&1 | FileCheck %s
+// RUN: popd
 
 #if !defined(SHARED_LIB)
 #include <stdio.h>
diff --git a/compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp b/compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp
index 3bf8e99703a08..84d3387e0cd52 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp
@@ -5,7 +5,7 @@
 // - 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: env 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 \
diff --git a/compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp b/compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp
index 125b544724d3f..09502e3aa1512 100644
--- a/compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp
+++ b/compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp
@@ -3,7 +3,7 @@
 #include <stdio.h>
 
 // RUN: %clangxx_asan %s -o %t
-// RUN: ASAN_OPTIONS="abort_on_error=1" not --crash %run %t 2>&1 | FileCheck %s
+// RUN: env ASAN_OPTIONS="abort_on_error=1" not --crash %run %t 2>&1 | FileCheck %s
 
 
 void *pwn(malloc_zone_t *unused_zone, size_t unused_size) {
diff --git a/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
index 5da18aa971d43..66f7e06a3d1f8 100644
--- a/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -24,7 +24,8 @@
 // RUN: diff %t.imports-sorted %t.exports-sorted
 
 // Ensure that there is no dynamic dylib linked.
-// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+// RUN: otool -L %t > %t.libs 
+// not grep -q "dynamic.dylib" < %t.libs
 
 // UNSUPPORTED: ios
 

boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Nov 18, 2025
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Pull Request: llvm#168545
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Nov 18, 2025
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Pull Request: llvm#168545
Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 5820 tests passed
  • 1319 tests skipped

Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
@boomanaiden154 boomanaiden154 changed the base branch from users/boomanaiden154/main.asan-make-most-tests-run-under-internal-shell-on-darwin to main November 18, 2025 15:26
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Nov 18, 2025
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Pull Request: llvm#168545
boomanaiden154 added a commit to boomanaiden154/llvm-project that referenced this pull request Nov 18, 2025
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Pull Request: llvm#168545
Created using spr 1.3.7
Copy link
Contributor

@DanBlackwell DanBlackwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Code formatter has picked up a stray trailing space btw.

Created using spr 1.3.7
@boomanaiden154 boomanaiden154 merged commit 7aeb264 into main Nov 18, 2025
8 of 9 checks passed
@boomanaiden154 boomanaiden154 deleted the users/boomanaiden154/asan-make-most-tests-run-under-internal-shell-on-darwin branch November 18, 2025 16:22
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Nov 18, 2025
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Reviewers: thetruestblue, fhahn, vitalybuka, DanBlackwell, ndrewh

Reviewed By: DanBlackwell

Pull Request: llvm/llvm-project#168545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants