diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 103 |
1 files changed, 9 insertions, 94 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 19ba0e8..dc4e322 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -29,7 +29,6 @@ $ # System modules import abc -from distutils.version import LooseVersion from functools import wraps import gc import glob @@ -58,7 +57,6 @@ from . import test_categories from lldbsuite.support import encoded_file from lldbsuite.support import funcutils from lldbsuite.support import seven -from lldbsuite.test.builders import get_builder from lldbsuite.test_event import build_exception # See also dotest.parseOptionsAndInitTestdirs(), where the environment variables @@ -516,7 +514,7 @@ def getsource_if_available(obj): def builder_module(): - return get_builder(sys.platform) + return lldbplatformutil.builder_module() class Base(unittest2.TestCase): @@ -1310,82 +1308,29 @@ class Base(unittest2.TestCase): def getArchitecture(self): """Returns the architecture in effect the test suite is running with.""" - module = builder_module() - arch = module.getArchitecture() - if arch == "amd64": - arch = "x86_64" - if arch in ["armv7l", "armv8l"]: - arch = "arm" - return arch + return lldbplatformutil.getArchitecture() def getLldbArchitecture(self): """Returns the architecture of the lldb binary.""" - if not hasattr(self, "lldbArchitecture"): - # These two target settings prevent lldb from doing setup that does - # nothing but slow down the end goal of printing the architecture. - command = [ - lldbtest_config.lldbExec, - "-x", - "-b", - "-o", - "settings set target.preload-symbols false", - "-o", - "settings set target.load-script-from-symbol-file false", - "-o", - "file " + lldbtest_config.lldbExec, - ] - - output = check_output(command) - str = output.decode() - - for line in str.splitlines(): - m = re.search(r"Current executable set to '.*' \((.*)\)\.", line) - if m: - self.lldbArchitecture = m.group(1) - break - - return self.lldbArchitecture + return lldbplatformutil.getLLDBArchitecture() def getCompiler(self): """Returns the compiler in effect the test suite is running with.""" - module = builder_module() - return module.getCompiler() + return lldbplatformutil.getCompiler() def getCompilerBinary(self): """Returns the compiler binary the test suite is running with.""" - return self.getCompiler().split()[0] + return lldbplatformutil.getCompilerBinary() def getCompilerVersion(self): """Returns a string that represents the compiler version. Supports: llvm, clang. """ - compiler = self.getCompilerBinary() - version_output = check_output([compiler, "--version"], errors="replace") - m = re.search("version ([0-9.]+)", version_output) - if m: - return m.group(1) - return "unknown" + return lldbplatformutil.getCompilerVersion() def getDwarfVersion(self): """Returns the dwarf version generated by clang or '0'.""" - if configuration.dwarf_version: - return str(configuration.dwarf_version) - if "clang" in self.getCompiler(): - try: - triple = builder_module().getTriple(self.getArchitecture()) - target = ["-target", triple] if triple else [] - driver_output = check_output( - [self.getCompiler()] + target + "-g -c -x c - -o - -###".split(), - stderr=STDOUT, - ) - driver_output = driver_output.decode("utf-8") - for line in driver_output.split(os.linesep): - m = re.search("dwarf-version=([0-9])", line) - if m: - return m.group(1) - except CalledProcessError: - pass - return "0" + return lldbplatformutil.getDwarfVersion() def platformIsDarwin(self): """Returns true if the OS triple for the selected platform is any valid apple OS""" @@ -1412,41 +1357,11 @@ class Base(unittest2.TestCase): of trunk, so any less-than or equal-to comparisons will return False, and any greater-than or not-equal-to comparisons will return True. """ - if compiler_version is None: - return True - operator = str(compiler_version[0]) - version = compiler_version[1] - - if version is None: - return True - - test_compiler_version = self.getCompilerVersion() - if test_compiler_version == "unknown": - # Assume the compiler version is at or near the top of trunk. - return operator in [">", ">=", "!", "!=", "not"] - - if operator == ">": - return LooseVersion(test_compiler_version) > LooseVersion(version) - if operator == ">=" or operator == "=>": - return LooseVersion(test_compiler_version) >= LooseVersion(version) - if operator == "<": - return LooseVersion(test_compiler_version) < LooseVersion(version) - if operator == "<=" or operator == "=<": - return LooseVersion(test_compiler_version) <= LooseVersion(version) - if operator == "!=" or operator == "!" or operator == "not": - return str(version) not in str(test_compiler_version) - return str(version) in str(test_compiler_version) + return lldbplatformutil.expectedCompilerVersion(compiler_version) def expectedCompiler(self, compilers): """Returns True iff any element of compilers is a sub-string of the current compiler.""" - if compilers is None: - return True - - for compiler in compilers: - if compiler in self.getCompiler(): - return True - - return False + return lldbplatformutil.expectedCompiler(compilers) def expectedArch(self, archs): """Returns True iff any element of archs is a sub-string of the current architecture.""" |