Skip to content

Commit c41f642

Browse files
[ASan] Make dyld_insert_libraries_reexec work with internal shell
This test was doing some feature checks within the test itself. This patch rewrites the feature checks to be done in a fashion more idiomatic to lit, as the internal shell does not support the features needed for the previous feature checks. Reviewers: ndrewh, DanBlackwell, fmayer Reviewed By: ndrewh Pull Request: #168655
1 parent eb65517 commit c41f642

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,12 @@
1414
// RUN: %run %t/a.out 2>&1 \
1515
// RUN: | FileCheck %s
1616

17-
// RUN: MACOS_MAJOR=$(sw_vers -productVersion | cut -d'.' -f1)
18-
// RUN: MACOS_MINOR=$(sw_vers -productVersion | cut -d'.' -f2)
19-
20-
// RUN: IS_MACOS_10_11_OR_HIGHER=$([ $MACOS_MAJOR -eq 10 ] && [ $MACOS_MINOR -lt 11 ]; echo $?)
21-
2217
// On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec.
23-
// RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 0 ]; then \
24-
// RUN: %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \
25-
// RUN: | FileCheck --check-prefix=CHECK-NOINSERT %s; \
26-
// RUN: fi
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 %}
2719

2820
// On OS X 10.11 and higher, we don't need to DYLD-insert anymore, and the interceptors
2921
// still installed correctly. Let's just check that things work and we don't try to re-exec.
30-
// RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 1 ]; then \
31-
// RUN: %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \
32-
// RUN: | FileCheck %s; \
33-
// RUN: fi
22+
// RUN: %if mac-os-10-10-or-lower %{ %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 | FileCheck %s %}
3423

3524
#include <stdio.h>
3625

compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import subprocess
2+
3+
14
def getRoot(config):
25
if not config.parent:
36
return config
@@ -8,3 +11,26 @@ def getRoot(config):
811

912
if root.target_os not in ["Darwin"]:
1013
config.unsupported = True
14+
15+
16+
def get_product_version():
17+
try:
18+
version_process = subprocess.run(
19+
["sw_vers", "-productVersion"],
20+
check=True,
21+
stdout=subprocess.PIPE,
22+
stderr=subprocess.PIPE,
23+
)
24+
version_string = version_process.stdout.decode("utf-8").split("\n")[0]
25+
version_split = version_string.split(".")
26+
return (int(version_split[0]), int(version_split[1]))
27+
except:
28+
return (0, 0)
29+
30+
31+
macos_version_major, macos_version_minor = get_product_version()
32+
if config.apple_platform == "osx":
33+
if macos_version_major > 10 and macos_version_minor > 11:
34+
config.available_features.add("mac-os-10-11-or-higher")
35+
else:
36+
config.available_features.add("mac-os-10-10-or-lower")

0 commit comments

Comments
 (0)