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):
# 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,