Skip to content

Commit 7aeb264

Browse files
[ASan] Make most tests run under internal shell on Darwin
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: #168545
1 parent 1347b23 commit 7aeb264

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Check that when having a DYLD_ROOT_PATH set, the symbolizer still works.
22
// RUN: %clangxx_asan -O0 %s -o %t
3-
// RUN: %env_asan_opts=verbosity=2 DYLD_ROOT_PATH="/" ASAN_SYMBOLIZER_PATH=$(which atos) \
3+
// RUN: which atos | tr -d '\n' > %t.symbolizer_path
4+
// RUN: %env_asan_opts=verbosity=2 DYLD_ROOT_PATH="/" ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} \
45
// RUN: not %run %t 2>&1 | FileCheck %s
56
//
67
// Due to a bug in atos, this only works on x86_64.

compiler-rt/test/asan/TestCases/Darwin/atos-symbolizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Check that the `atos` symbolizer works.
22

33
// RUN: %clangxx_asan -O0 %s -o %t
4-
// RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s
4+
// RUN: which atos | tr -d '\n' > %t.symbolizer_path
5+
// RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=%{readfile:%t.symbolizer_path} not %run %t 2>&1 | FileCheck %s
56

67
// Path returned by `which atos` is invalid on iOS.
78
// UNSUPPORTED: ios, i386-darwin

compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
// UNSUPPORTED: ios
55

66
// RUN: rm -rf %t && mkdir -p %t
7-
// RUN: cp `%clang_asan -print-file-name=lib`/darwin/libclang_rt.asan_osx_dynamic.dylib \
7+
// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name
8+
// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \
89
// RUN: %t/libclang_rt.asan_osx_dynamic.dylib
910
// RUN: %clangxx_asan %s -o %t/a.out
1011

compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,27 @@
55
// UNSUPPORTED: ios
66

77
// RUN: rm -rf %t && mkdir -p %t
8-
// RUN: cp `%clang_asan -print-file-name=lib`/darwin/libclang_rt.asan_osx_dynamic.dylib \
8+
// RUN: %clang_asan -print-file-name=lib | tr -d '\n' > %t.lib_name
9+
// RUN: cp %{readfile:%t.lib_name}/darwin/libclang_rt.asan_osx_dynamic.dylib \
910
// RUN: %t/libclang_rt.asan_osx_dynamic.dylib
1011

1112
// RUN: %clangxx_asan %s -o %t/a.out
1213
// RUN: %clangxx -DSHARED_LIB %s \
1314
// RUN: -dynamiclib -o %t/dummy-so.dylib
1415

15-
// RUN: ( cd %t && \
16-
// RUN: DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
17-
// RUN: %run ./a.out 2>&1 ) | FileCheck %s || exit 1
16+
// RUN: cd %t
17+
// RUN: env DYLD_INSERT_LIBRARIES=@executable_path/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
18+
// RUN: %run ./a.out 2>&1 | FileCheck %s
1819

19-
// RUN: ( cd %t && \
20-
// RUN: DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
21-
// RUN: %run ./a.out 2>&1 ) | FileCheck %s || exit 1
20+
// RUN: env DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
21+
// RUN: %run ./a.out 2>&1 | FileCheck %s
2222

23-
// RUN: ( cd %t && \
24-
// RUN: %env_asan_opts=strip_env=0 \
25-
// RUN: DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
26-
// RUN: %run ./a.out 2>&1 ) | FileCheck %s --check-prefix=CHECK-KEEP || exit 1
23+
// RUN: %env_asan_opts=strip_env=0 \
24+
// RUN: DYLD_INSERT_LIBRARIES=libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
25+
// RUN: %run ./a.out 2>&1 | FileCheck %s --check-prefix=CHECK-KEEP
2726

28-
// RUN: ( cd %t && \
29-
// RUN: DYLD_INSERT_LIBRARIES=%t/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
30-
// RUN: %run ./a.out 2>&1 ) | FileCheck %s || exit 1
27+
// RUN: env DYLD_INSERT_LIBRARIES=%t/libclang_rt.asan_osx_dynamic.dylib:dummy-so.dylib \
28+
// RUN: %run ./a.out 2>&1 | FileCheck %s
3129

3230
#if !defined(SHARED_LIB)
3331
#include <stdio.h>

compiler-rt/test/asan/TestCases/Darwin/init_for_dlopen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// - By default the lit config sets this but we don't want this
66
// test to implicitly depend on this.
77
// - It avoids requiring `--crash` to be passed to `not`.
8-
// RUN: APPLE_ASAN_INIT_FOR_DLOPEN=0 %env_asan_opts=abort_on_error=0 not \
8+
// RUN: %env_asan_opts=abort_on_error=0 APPLE_ASAN_INIT_FOR_DLOPEN=0 not \
99
// RUN: %run %t %shared_libasan 2>&1 | \
1010
// RUN: FileCheck -check-prefix=CHECK-DL-OPEN-FAIL %s
1111
// RUN: env -u APPLE_ASAN_INIT_FOR_DLOPEN %env_asan_opts=abort_on_error=0 not \

compiler-rt/test/asan/TestCases/Darwin/malloc_zone-protected.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include <stdio.h>
44

55
// RUN: %clangxx_asan %s -o %t
6-
// RUN: ASAN_OPTIONS="abort_on_error=1" not --crash %run %t 2>&1 | FileCheck %s
7-
6+
// RUN: env ASAN_OPTIONS="abort_on_error=1" not --crash %run %t 2>&1 | FileCheck %s
87

98
void *pwn(malloc_zone_t *unused_zone, size_t unused_size) {
109
printf("PWNED\n");

compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
// RUN: diff %t.imports-sorted %t.exports-sorted
2525

2626
// Ensure that there is no dynamic dylib linked.
27-
// RUN: otool -L %t | (! grep -q "dynamic.dylib")
27+
// RUN: otool -L %t > %t.libs
28+
// RUN: not grep -q "dynamic.dylib" < %t.libs
2829

2930
// UNSUPPORTED: ios
3031

0 commit comments

Comments
 (0)