summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbplatformutil.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbplatformutil.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index a6d9b8faf72..efc806c5a0e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -102,3 +102,36 @@ def getHostPlatform():
return 'netbsd'
else:
return sys.platform
+
+
+def getDarwinOSTriples():
+ return ['darwin', 'macosx', 'ios']
+
+def getPlatform():
+ """Returns the target platform which the tests are running on."""
+ platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+ if platform.startswith('freebsd'):
+ platform = 'freebsd'
+ elif platform.startswith('netbsd'):
+ platform = 'netbsd'
+ return platform
+
+def platformIsDarwin():
+ """Returns true if the OS triple for the selected platform is any valid apple OS"""
+ return getPlatform() in getDarwinOSTriples()
+
+class _PlatformContext(object):
+ """Value object class which contains platform-specific options."""
+
+ def __init__(self, shlib_environment_var, shlib_prefix, shlib_extension):
+ self.shlib_environment_var = shlib_environment_var
+ self.shlib_prefix = shlib_prefix
+ self.shlib_extension = shlib_extension
+
+def createPlatformContext():
+ if platformIsDarwin():
+ return _PlatformContext('DYLD_LIBRARY_PATH', 'lib', 'dylib')
+ elif getPlatform() in ("freebsd", "linux", "netbsd"):
+ return _PlatformContext('LD_LIBRARY_PATH', 'lib', 'so')
+ else:
+ return None
OpenPOWER on IntegriCloud