diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-08-23 17:19:08 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-08-23 17:19:08 +0000 |
commit | 748310b193a9dac6bde656e43c94d12fab3ac501 (patch) | |
tree | 1c65fa1dafdc094abef9340c37a597db24774a0b | |
parent | 92f9d1b8ac6ed54d4bf856ae729cfa1ab6be5b1f (diff) | |
download | bcm5719-llvm-748310b193a9dac6bde656e43c94d12fab3ac501.tar.gz bcm5719-llvm-748310b193a9dac6bde656e43c94d12fab3ac501.zip |
lldbtest.py: Work around macOS SIP when testing ASANified builds.
llvm-svn: 340548
-rw-r--r-- | lldb/lit/Suite/lldbtest.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lldb/lit/Suite/lldbtest.py b/lldb/lit/Suite/lldbtest.py index 378cdbaf4ae..c17214c997a 100644 --- a/lldb/lit/Suite/lldbtest.py +++ b/lldb/lit/Suite/lldbtest.py @@ -9,6 +9,14 @@ import lit.TestRunner import lit.util from lit.formats.base import TestFormat +def getBuildDir(cmd): + found = False + for arg in cmd: + if found: + return arg + if arg == '--build-dir': + found = True + return None class LLDBTest(TestFormat): def __init__(self, dotest_cmd): @@ -49,6 +57,18 @@ class LLDBTest(TestFormat): # python exe as the first parameter of the command. cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile] + # The macOS system integrity protection (SIP) doesn't allow injecting + # libraries into system binaries, but this can be worked around by + # copying the binary into a different location. + if test.config.environment['DYLD_INSERT_LIBRARIES'] and \ + sys.executable.startswith('/System/'): + builddir = getBuildDir(cmd) + assert(builddir) + copied_python = os.path.join(builddir, 'copied-system-python') + import shutil + shutil.copy(sys.executable, os.path.join(builddir, copied_python)) + cmd[0] = copied_python + try: out, err, exitCode = lit.util.executeCommand( cmd, |