Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,12 @@
// RUN: %run %t/a.out 2>&1 \
// RUN: | FileCheck %s

// RUN: MACOS_MAJOR=$(sw_vers -productVersion | cut -d'.' -f1)
// RUN: MACOS_MINOR=$(sw_vers -productVersion | cut -d'.' -f2)

// RUN: IS_MACOS_10_11_OR_HIGHER=$([ $MACOS_MAJOR -eq 10 ] && [ $MACOS_MINOR -lt 11 ]; echo $?)

// On OS X 10.10 and lower, if the dylib is not DYLD-inserted, ASan will re-exec.
// RUN: if [ $IS_MACOS_10_11_OR_HIGHER == 0 ]; then \
// RUN: %env_asan_opts=verbosity=1 %run %t/a.out 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOINSERT %s; \
// RUN: fi
// 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 %}

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

#include <stdio.h>

Expand Down
26 changes: 26 additions & 0 deletions compiler-rt/test/asan/TestCases/Darwin/lit.local.cfg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import subprocess


def getRoot(config):
if not config.parent:
return config
Expand All @@ -8,3 +11,26 @@ def getRoot(config):

if root.target_os not in ["Darwin"]:
config.unsupported = True


def get_product_version():
try:
version_process = subprocess.run(
["sw_vers", "-productVersion"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
version_string = version_process.stdout.decode("utf-8").split("\n")[0]
version_split = version_string.split(".")
return (int(version_split[0]), int(version_split[1]))
except:
return (0, 0)


macos_version_major, macos_version_minor = get_product_version()
if config.apple_platform == "osx":
if macos_version_major > 10 and macos_version_minor > 11:
config.available_features.add("mac-os-10-11-or-higher")
else:
config.available_features.add("mac-os-10-10-or-lower")