aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/dotest.py
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/dotest.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/dotest.py379
1 files changed, 225 insertions, 154 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index db7a345..1b2076f5 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -52,7 +52,7 @@ def is_exe(fpath):
"""Returns true if fpath is an executable."""
if fpath == None:
return False
- if sys.platform == 'win32':
+ if sys.platform == "win32":
if not fpath.endswith(".exe"):
fpath += ".exe"
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
@@ -75,7 +75,8 @@ def which(program):
def usage(parser):
parser.print_help()
if configuration.verbose > 0:
- print("""
+ print(
+ """
Examples:
This is an example of using the -f option to pinpoint to a specific test class
@@ -166,21 +167,22 @@ to create reference logs for debugging.
$ ./dotest.py --log-success
-""")
+"""
+ )
sys.exit(0)
def parseExclusion(exclusion_file):
"""Parse an exclusion file, of the following format, where
- 'skip files', 'skip methods', 'xfail files', and 'xfail methods'
- are the possible list heading values:
+ 'skip files', 'skip methods', 'xfail files', and 'xfail methods'
+ are the possible list heading values:
- skip files
- <file name>
- <file name>
+ skip files
+ <file name>
+ <file name>
- xfail methods
- <method name>
+ xfail methods
+ <method name>
"""
excl_type = None
@@ -193,11 +195,11 @@ def parseExclusion(exclusion_file):
if not line:
excl_type = None
- elif excl_type == 'skip':
+ elif excl_type == "skip":
if not configuration.skip_tests:
configuration.skip_tests = []
configuration.skip_tests.append(line)
- elif excl_type == 'xfail':
+ elif excl_type == "xfail":
if not configuration.xfail_tests:
configuration.xfail_tests = []
configuration.xfail_tests.append(line)
@@ -231,14 +233,14 @@ def parseOptionsAndInitTestdirs():
if args.set_env_vars:
for env_var in args.set_env_vars:
- parts = env_var.split('=', 1)
+ parts = env_var.split("=", 1)
if len(parts) == 1:
os.environ[parts[0]] = ""
else:
os.environ[parts[0]] = parts[1]
if args.set_inferior_env_vars:
- lldbtest_config.inferior_env = ' '.join(args.set_inferior_env_vars)
+ lldbtest_config.inferior_env = " ".join(args.set_inferior_env_vars)
if args.h:
do_help = True
@@ -249,19 +251,19 @@ def parseOptionsAndInitTestdirs():
configuration.compiler = which(args.compiler)
if not is_exe(configuration.compiler):
logging.error(
- '%s is not a valid compiler executable; aborting...',
- args.compiler)
+ "%s is not a valid compiler executable; aborting...", args.compiler
+ )
sys.exit(-1)
else:
# Use a compiler appropriate appropriate for the Apple SDK if one was
# specified
- if platform_system == 'Darwin' and args.apple_sdk:
+ if platform_system == "Darwin" and args.apple_sdk:
configuration.compiler = seven.get_command_output(
- 'xcrun -sdk "%s" -find clang 2> /dev/null' %
- (args.apple_sdk))
+ 'xcrun -sdk "%s" -find clang 2> /dev/null' % (args.apple_sdk)
+ )
else:
# 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
- candidateCompilers = ['clang-3.5', 'clang', 'gcc']
+ candidateCompilers = ["clang-3.5", "clang", "gcc"]
for candidate in candidateCompilers:
if which(candidate):
configuration.compiler = candidate
@@ -269,22 +271,27 @@ def parseOptionsAndInitTestdirs():
if args.dsymutil:
configuration.dsymutil = args.dsymutil
- elif platform_system == 'Darwin':
+ elif platform_system == "Darwin":
configuration.dsymutil = seven.get_command_output(
- 'xcrun -find -toolchain default dsymutil')
+ "xcrun -find -toolchain default dsymutil"
+ )
if args.llvm_tools_dir:
configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir)
configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir)
if not configuration.get_filecheck_path():
- logging.warning('No valid FileCheck executable; some tests may fail...')
- logging.warning('(Double-check the --llvm-tools-dir argument to dotest.py)')
+ logging.warning("No valid FileCheck executable; some tests may fail...")
+ logging.warning("(Double-check the --llvm-tools-dir argument to dotest.py)")
if args.libcxx_include_dir or args.libcxx_library_dir:
if args.lldb_platform_name:
- logging.warning('Custom libc++ is not supported for remote runs: ignoring --libcxx arguments')
+ logging.warning(
+ "Custom libc++ is not supported for remote runs: ignoring --libcxx arguments"
+ )
elif not (args.libcxx_include_dir and args.libcxx_library_dir):
- logging.error('Custom libc++ requires both --libcxx-include-dir and --libcxx-library-dir')
+ logging.error(
+ "Custom libc++ requires both --libcxx-include-dir and --libcxx-library-dir"
+ )
sys.exit(-1)
configuration.libcxx_include_dir = args.libcxx_include_dir
configuration.libcxx_include_target_dir = args.libcxx_include_target_dir
@@ -300,14 +307,12 @@ def parseOptionsAndInitTestdirs():
lldbtest_config.out_of_tree_debugserver = args.out_of_tree_debugserver
# Set SDKROOT if we are using an Apple SDK
- if platform_system == 'Darwin' and args.apple_sdk:
+ if platform_system == "Darwin" and args.apple_sdk:
configuration.sdkroot = seven.get_command_output(
- 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
- (args.apple_sdk))
+ 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)
+ )
if not configuration.sdkroot:
- logging.error(
- 'No SDK found with the name %s; aborting...',
- args.apple_sdk)
+ logging.error("No SDK found with the name %s; aborting...", args.apple_sdk)
sys.exit(-1)
if args.arch:
@@ -317,47 +322,51 @@ def parseOptionsAndInitTestdirs():
if args.categories_list:
configuration.categories_list = set(
- test_categories.validate(
- args.categories_list, False))
+ test_categories.validate(args.categories_list, False)
+ )
configuration.use_categories = True
else:
configuration.categories_list = []
if args.skip_categories:
configuration.skip_categories += test_categories.validate(
- args.skip_categories, False)
+ args.skip_categories, False
+ )
if args.xfail_categories:
configuration.xfail_categories += test_categories.validate(
- args.xfail_categories, False)
+ args.xfail_categories, False
+ )
if args.E:
- os.environ['CFLAGS_EXTRAS'] = args.E
+ os.environ["CFLAGS_EXTRAS"] = args.E
if args.dwarf_version:
configuration.dwarf_version = args.dwarf_version
# We cannot modify CFLAGS_EXTRAS because they're used in test cases
# that explicitly require no debug info.
- os.environ['CFLAGS'] = '-gdwarf-{}'.format(configuration.dwarf_version)
+ os.environ["CFLAGS"] = "-gdwarf-{}".format(configuration.dwarf_version)
if args.settings:
for setting in args.settings:
- if not len(setting) == 1 or not setting[0].count('='):
- logging.error('"%s" is not a setting in the form "key=value"',
- setting[0])
+ if not len(setting) == 1 or not setting[0].count("="):
+ logging.error(
+ '"%s" is not a setting in the form "key=value"', setting[0]
+ )
sys.exit(-1)
- setting_list = setting[0].split('=', 1)
+ setting_list = setting[0].split("=", 1)
configuration.settings.append((setting_list[0], setting_list[1]))
if args.d:
sys.stdout.write(
- "Suspending the process %d to wait for debugger to attach...\n" %
- os.getpid())
+ "Suspending the process %d to wait for debugger to attach...\n"
+ % os.getpid()
+ )
sys.stdout.flush()
os.kill(os.getpid(), signal.SIGSTOP)
if args.f:
- if any([x.startswith('-') for x in args.f]):
+ if any([x.startswith("-") for x in args.f]):
usage(parser)
configuration.filters.extend(args.f)
@@ -371,8 +380,8 @@ def parseOptionsAndInitTestdirs():
lldbtest_config.lldbExec = which(args.executable)
if not is_exe(lldbtest_config.lldbExec):
logging.error(
- '%s is not a valid executable to test; aborting...',
- args.executable)
+ "%s is not a valid executable to test; aborting...", args.executable
+ )
sys.exit(-1)
if args.excluded:
@@ -380,12 +389,12 @@ def parseOptionsAndInitTestdirs():
parseExclusion(excl_file)
if args.p:
- if args.p.startswith('-'):
+ if args.p.startswith("-"):
usage(parser)
configuration.regexp = args.p
if args.t:
- os.environ['LLDB_COMMAND_TRACE'] = 'YES'
+ os.environ["LLDB_COMMAND_TRACE"] = "YES"
if args.v:
configuration.verbose = 2
@@ -394,10 +403,9 @@ def parseOptionsAndInitTestdirs():
if args.sharp:
configuration.count = args.sharp
- if sys.platform.startswith('win32'):
- os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(
- args.disable_crash_dialog)
- os.environ['LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE'] = str(True)
+ if sys.platform.startswith("win32"):
+ os.environ["LLDB_DISABLE_CRASH_DIALOG"] = str(args.disable_crash_dialog)
+ os.environ["LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE"] = str(True)
if do_help:
usage(parser)
@@ -408,7 +416,7 @@ def parseOptionsAndInitTestdirs():
configuration.lldb_platform_url = args.lldb_platform_url
if args.lldb_platform_working_dir:
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
- if platform_system == 'Darwin' and args.apple_sdk:
+ if platform_system == "Darwin" and args.apple_sdk:
configuration.apple_sdk = args.apple_sdk
if args.test_build_dir:
configuration.test_build_dir = args.test_build_dir
@@ -416,12 +424,14 @@ def parseOptionsAndInitTestdirs():
configuration.lldb_module_cache_dir = args.lldb_module_cache_dir
else:
configuration.lldb_module_cache_dir = os.path.join(
- configuration.test_build_dir, 'module-cache-lldb')
+ configuration.test_build_dir, "module-cache-lldb"
+ )
if args.clang_module_cache_dir:
configuration.clang_module_cache_dir = args.clang_module_cache_dir
else:
configuration.clang_module_cache_dir = os.path.join(
- configuration.test_build_dir, 'module-cache-clang')
+ configuration.test_build_dir, "module-cache-clang"
+ )
if args.lldb_libs_dir:
configuration.lldb_libs_dir = args.lldb_libs_dir
@@ -431,10 +441,13 @@ def parseOptionsAndInitTestdirs():
# Gather all the dirs passed on the command line.
if len(args.args) > 0:
- configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args]
+ configuration.testdirs = [
+ os.path.realpath(os.path.abspath(x)) for x in args.args
+ ]
lldbtest_config.codesign_identity = args.codesign_identity
+
def registerFaulthandler():
try:
import faulthandler
@@ -444,9 +457,10 @@ def registerFaulthandler():
faulthandler.enable()
# faulthandler.register is not available on Windows.
- if getattr(faulthandler, 'register', None):
+ if getattr(faulthandler, "register", None):
faulthandler.register(signal.SIGTERM, chain=True)
+
def setupSysPath():
"""
Add LLDB.framework/Resources/Python to the search paths for modules.
@@ -458,7 +472,7 @@ def setupSysPath():
scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
else:
scriptPath = os.path.dirname(os.path.abspath(__file__))
- if not scriptPath.endswith('test'):
+ if not scriptPath.endswith("test"):
print("This script expects to reside in lldb's test directory.")
sys.exit(-1)
@@ -473,10 +487,10 @@ def setupSysPath():
# the LLDB source code.
os.environ["LLDB_SRC"] = lldbsuite.lldb_root
- pluginPath = os.path.join(scriptPath, 'plugins')
- toolsLLDBVSCode = os.path.join(scriptPath, 'tools', 'lldb-vscode')
- toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server')
- intelpt = os.path.join(scriptPath, 'tools', 'intelpt')
+ pluginPath = os.path.join(scriptPath, "plugins")
+ toolsLLDBVSCode = os.path.join(scriptPath, "tools", "lldb-vscode")
+ toolsLLDBServerPath = os.path.join(scriptPath, "tools", "lldb-server")
+ intelpt = os.path.join(scriptPath, "tools", "intelpt")
# Insert script dir, plugin dir and lldb-server dir to the sys.path.
sys.path.insert(0, pluginPath)
@@ -509,19 +523,21 @@ def setupSysPath():
if not lldbtest_config.lldbExec:
# Last, check the path
- lldbtest_config.lldbExec = which('lldb')
+ lldbtest_config.lldbExec = which("lldb")
if lldbtest_config.lldbExec and not is_exe(lldbtest_config.lldbExec):
print(
- "'{}' is not a path to a valid executable".format(
- lldbtest_config.lldbExec))
+ "'{}' is not a path to a valid executable".format(lldbtest_config.lldbExec)
+ )
lldbtest_config.lldbExec = None
if not lldbtest_config.lldbExec:
- print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
+ print(
+ "The 'lldb' executable cannot be located. Some of the tests may not be run as a result."
+ )
sys.exit(-1)
- os.system('%s -v' % lldbtest_config.lldbExec)
+ os.system("%s -v" % lldbtest_config.lldbExec)
lldbDir = os.path.dirname(lldbtest_config.lldbExec)
@@ -531,36 +547,47 @@ def setupSysPath():
else:
if not configuration.shouldSkipBecauseOfCategories(["lldb-vscode"]):
print(
- "The 'lldb-vscode' executable cannot be located. The lldb-vscode tests can not be run as a result.")
+ "The 'lldb-vscode' executable cannot be located. The lldb-vscode tests can not be run as a result."
+ )
configuration.skip_categories.append("lldb-vscode")
lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
# If our lldb supports the -P option, use it to find the python path:
- lldb_dash_p_result = subprocess.check_output([lldbtest_config.lldbExec, "-P"], universal_newlines=True)
+ lldb_dash_p_result = subprocess.check_output(
+ [lldbtest_config.lldbExec, "-P"], universal_newlines=True
+ )
if lldb_dash_p_result:
for line in lldb_dash_p_result.splitlines():
- if os.path.isdir(line) and os.path.exists(os.path.join(line, 'lldb', '__init__.py')):
+ if os.path.isdir(line) and os.path.exists(
+ os.path.join(line, "lldb", "__init__.py")
+ ):
lldbPythonDir = line
break
if not lldbPythonDir:
print(
- "Unable to load lldb extension module. Possible reasons for this include:")
+ "Unable to load lldb extension module. Possible reasons for this include:"
+ )
print(" 1) LLDB was built with LLDB_ENABLE_PYTHON=0")
print(
- " 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to")
+ " 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to"
+ )
print(
- " the version of Python that LLDB built and linked against, and PYTHONPATH")
+ " the version of Python that LLDB built and linked against, and PYTHONPATH"
+ )
print(
- " should contain the Lib directory for the same python distro, as well as the")
- print(" location of LLDB\'s site-packages folder.")
+ " should contain the Lib directory for the same python distro, as well as the"
+ )
+ print(" location of LLDB's site-packages folder.")
print(
- " 3) A different version of Python than that which was built against is exported in")
- print(" the system\'s PATH environment variable, causing conflicts.")
+ " 3) A different version of Python than that which was built against is exported in"
+ )
+ print(" the system's PATH environment variable, causing conflicts.")
print(
- " 4) The executable '%s' could not be found. Please check " %
- lldbtest_config.lldbExec)
+ " 4) The executable '%s' could not be found. Please check "
+ % lldbtest_config.lldbExec
+ )
print(" that it exists and is executable.")
if lldbPythonDir:
@@ -569,18 +596,18 @@ def setupSysPath():
# If the path we've constructed looks like that, then we'll strip out
# the Versions/A part.
(before, frameWithVersion, after) = lldbPythonDir.rpartition(
- "LLDB.framework/Versions/A")
+ "LLDB.framework/Versions/A"
+ )
if frameWithVersion != "":
lldbPythonDir = before + "LLDB.framework" + after
lldbPythonDir = os.path.abspath(lldbPythonDir)
if "freebsd" in sys.platform or "linux" in sys.platform:
- os.environ['LLDB_LIB_DIR'] = os.path.join(lldbPythonDir, '..', '..')
+ os.environ["LLDB_LIB_DIR"] = os.path.join(lldbPythonDir, "..", "..")
# If tests need to find LLDB_FRAMEWORK, now they can do it
- os.environ["LLDB_FRAMEWORK"] = os.path.dirname(
- os.path.dirname(lldbPythonDir))
+ os.environ["LLDB_FRAMEWORK"] = os.path.dirname(os.path.dirname(lldbPythonDir))
# This is to locate the lldb.py module. Insert it right after
# sys.path[0].
@@ -622,15 +649,15 @@ def visit_file(dir, name):
def iter_filters():
for filterspec in configuration.filters:
- parts = filterspec.split('.')
+ parts = filterspec.split(".")
if check(module, parts):
yield filterspec
elif parts[0] == base and len(parts) > 1 and check(module, parts[1:]):
- yield '.'.join(parts[1:])
+ yield ".".join(parts[1:])
else:
- for key,value in module.__dict__.items():
+ for key, value in module.__dict__.items():
if check(value, parts):
- yield key + '.' + filterspec
+ yield key + "." + filterspec
filtered = False
for filterspec in iter_filters():
@@ -648,22 +675,22 @@ def visit_file(dir, name):
# Also the fail-over case when the filterspec branch
# (base, filterspec) combo doesn't make sense.
configuration.suite.addTests(
- unittest2.defaultTestLoader.loadTestsFromName(base))
+ unittest2.defaultTestLoader.loadTestsFromName(base)
+ )
def visit(prefix, dir, names):
"""Visitor function for os.path.walk(path, visit, arg)."""
dir_components = set(dir.split(os.sep))
- excluded_components = set(['.svn', '.git'])
+ excluded_components = set([".svn", ".git"])
if dir_components.intersection(excluded_components):
return
# Gather all the Python test file names that follow the Test*.py pattern.
python_test_files = [
- name
- for name in names
- if name.endswith('.py') and name.startswith(prefix)]
+ name for name in names if name.endswith(".py") and name.startswith(prefix)
+ ]
# Visit all the python test files.
for name in python_test_files:
@@ -689,17 +716,15 @@ def visit(prefix, dir, names):
def checkDsymForUUIDIsNotOn():
cmd = ["defaults", "read", "com.apple.DebugSymbols"]
- process = subprocess.Popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
cmd_output = process.stdout.read()
output_str = cmd_output.decode("utf-8")
if "DBGFileMappedPaths = " in output_str:
- print("%s =>" % ' '.join(cmd))
+ print("%s =>" % " ".join(cmd))
print(output_str)
print(
- "Disable automatic lookup and caching of dSYMs before running the test suite!")
+ "Disable automatic lookup and caching of dSYMs before running the test suite!"
+ )
print("Exiting...")
sys.exit(0)
@@ -708,6 +733,7 @@ def exitTestSuite(exitCode=None):
# lldb.py does SBDebugger.Initialize().
# Call SBDebugger.Terminate() on exit.
import lldb
+
lldb.SBDebugger.Terminate()
if exitCode:
sys.exit(exitCode)
@@ -715,11 +741,11 @@ def exitTestSuite(exitCode=None):
def getVersionForSDK(sdk):
sdk = str.lower(sdk)
- full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
+ full_path = seven.get_command_output("xcrun -sdk %s --show-sdk-path" % sdk)
basename = os.path.basename(full_path)
basename = os.path.splitext(basename)[0]
basename = str.lower(basename)
- ver = basename.replace(sdk, '')
+ ver = basename.replace(sdk, "")
return ver
@@ -734,14 +760,16 @@ def checkCompiler():
raise Exception(c + " is not a valid compiler")
pipe = subprocess.Popen(
- ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ ["xcrun", "-find", c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ )
cmd_output = pipe.stdout.read()
if not cmd_output or "not found" in cmd_output:
raise Exception(c + " is not a valid compiler")
- configuration.compiler = cmd_output.split('\n')[0]
+ configuration.compiler = cmd_output.split("\n")[0]
print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
+
def canRunLibcxxTests():
from lldbsuite.test import lldbplatformutil
@@ -753,24 +781,35 @@ def canRunLibcxxTests():
if platform == "linux":
with tempfile.NamedTemporaryFile() as f:
cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
- p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+ p = subprocess.Popen(
+ cmd,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True,
+ )
_, stderr = p.communicate("#include <cassert>\nint main() {}")
if not p.returncode:
return True, "Compiling with -stdlib=libc++ works"
- return False, "Compiling with -stdlib=libc++ fails with the error: %s" % stderr
+ return (
+ False,
+ "Compiling with -stdlib=libc++ fails with the error: %s" % stderr,
+ )
return False, "Don't know how to build with libc++ on %s" % platform
+
def checkLibcxxSupport():
result, reason = canRunLibcxxTests()
if result:
- return # libc++ supported
+ return # libc++ supported
if "libc++" in configuration.categories_list:
- return # libc++ category explicitly requested, let it run.
+ return # libc++ category explicitly requested, let it run.
if configuration.verbose:
print("libc++ tests will not be run because: " + reason)
configuration.skip_categories.append("libc++")
+
def canRunLibstdcxxTests():
from lldbsuite.test import lldbplatformutil
@@ -781,16 +820,18 @@ def canRunLibstdcxxTests():
return True, "libstdcxx always present"
return False, "Don't know how to build with libstdcxx on %s" % platform
+
def checkLibstdcxxSupport():
result, reason = canRunLibstdcxxTests()
if result:
- return # libstdcxx supported
+ return # libstdcxx supported
if "libstdcxx" in configuration.categories_list:
- return # libstdcxx category explicitly requested, let it run.
+ return # libstdcxx category explicitly requested, let it run.
if configuration.verbose:
print("libstdcxx tests will not be run because: " + reason)
configuration.skip_categories.append("libstdcxx")
+
def canRunWatchpointTests():
from lldbsuite.test import lldbplatformutil
@@ -799,8 +840,13 @@ def canRunWatchpointTests():
if os.geteuid() == 0:
return True, "root can always write dbregs"
try:
- output = subprocess.check_output(["/sbin/sysctl", "-n",
- "security.models.extensions.user_set_dbregs"]).decode().strip()
+ output = (
+ subprocess.check_output(
+ ["/sbin/sysctl", "-n", "security.models.extensions.user_set_dbregs"]
+ )
+ .decode()
+ .strip()
+ )
if output == "1":
return True, "security.models.extensions.user_set_dbregs enabled"
except subprocess.CalledProcessError:
@@ -808,20 +854,23 @@ def canRunWatchpointTests():
return False, "security.models.extensions.user_set_dbregs disabled"
elif platform == "freebsd" and configuration.arch == "aarch64":
import lldb
+
if lldb.SBPlatform.GetHostPlatform().GetOSMajorVersion() < 13:
return False, "Watchpoint support on arm64 requires FreeBSD 13.0"
return True, "watchpoint support available"
+
def checkWatchpointSupport():
result, reason = canRunWatchpointTests()
if result:
- return # watchpoints supported
+ return # watchpoints supported
if "watchpoint" in configuration.categories_list:
- return # watchpoint category explicitly requested, let it run.
+ return # watchpoint category explicitly requested, let it run.
if configuration.verbose:
print("watchpoint tests will not be run because: " + reason)
configuration.skip_categories.append("watchpoint")
+
def checkObjcSupport():
from lldbsuite.test import lldbplatformutil
@@ -830,6 +879,7 @@ def checkObjcSupport():
print("objc tests will be skipped because of unsupported platform")
configuration.skip_categories.append("objc")
+
def checkDebugInfoSupport():
from lldbsuite.test import lldbplatformutil
@@ -837,11 +887,12 @@ def checkDebugInfoSupport():
compiler = configuration.compiler
for cat in test_categories.debug_info_categories:
if cat in configuration.categories_list:
- continue # Category explicitly requested, let it run.
+ continue # Category explicitly requested, let it run.
if test_categories.is_supported_on_platform(cat, platform, compiler):
continue
configuration.skip_categories.append(cat)
+
def checkDebugServerSupport():
from lldbsuite.test import lldbplatformutil
import lldb
@@ -853,13 +904,13 @@ def checkDebugServerSupport():
# <rdar://problem/34539270>
configuration.skip_categories.append("debugserver")
if configuration.verbose:
- print(skip_msg%"debugserver");
+ print(skip_msg % "debugserver")
else:
configuration.skip_categories.append("debugserver")
if lldb.remote_platform and lldbplatformutil.getPlatform() == "windows":
configuration.skip_categories.append("llgs")
if configuration.verbose:
- print(skip_msg%"lldb-server");
+ print(skip_msg % "lldb-server")
def checkForkVForkSupport():
@@ -888,6 +939,7 @@ def run_suite():
setupSysPath()
import lldb
+
lldb.SBDebugger.Initialize()
lldb.SBDebugger.PrintStackTraceOnError()
@@ -899,46 +951,58 @@ def run_suite():
from lldbsuite.test import lldbutil
if configuration.lldb_platform_name:
- print("Setting up remote platform '%s'" %
- (configuration.lldb_platform_name))
- lldb.remote_platform = lldb.SBPlatform(
- configuration.lldb_platform_name)
+ print("Setting up remote platform '%s'" % (configuration.lldb_platform_name))
+ lldb.remote_platform = lldb.SBPlatform(configuration.lldb_platform_name)
lldb.selected_platform = lldb.remote_platform
if not lldb.remote_platform.IsValid():
print(
- "error: unable to create the LLDB platform named '%s'." %
- (configuration.lldb_platform_name))
+ "error: unable to create the LLDB platform named '%s'."
+ % (configuration.lldb_platform_name)
+ )
exitTestSuite(1)
if configuration.lldb_platform_url:
# We must connect to a remote platform if a LLDB platform URL was
# specified
print(
- "Connecting to remote platform '%s' at '%s'..." %
- (configuration.lldb_platform_name, configuration.lldb_platform_url))
+ "Connecting to remote platform '%s' at '%s'..."
+ % (configuration.lldb_platform_name, configuration.lldb_platform_url)
+ )
platform_connect_options = lldb.SBPlatformConnectOptions(
- configuration.lldb_platform_url)
+ configuration.lldb_platform_url
+ )
err = lldb.remote_platform.ConnectRemote(platform_connect_options)
if err.Success():
print("Connected.")
else:
- print("error: failed to connect to remote platform using URL '%s': %s" % (
- configuration.lldb_platform_url, err))
+ print(
+ "error: failed to connect to remote platform using URL '%s': %s"
+ % (configuration.lldb_platform_url, err)
+ )
exitTestSuite(1)
else:
configuration.lldb_platform_url = None
if configuration.lldb_platform_working_dir:
- print("Setting remote platform working directory to '%s'..." %
- (configuration.lldb_platform_working_dir))
+ print(
+ "Setting remote platform working directory to '%s'..."
+ % (configuration.lldb_platform_working_dir)
+ )
error = lldb.remote_platform.MakeDirectory(
- configuration.lldb_platform_working_dir, 448) # 448 = 0o700
+ configuration.lldb_platform_working_dir, 448
+ ) # 448 = 0o700
if error.Fail():
- raise Exception("making remote directory '%s': %s" % (
- configuration.lldb_platform_working_dir, error))
+ raise Exception(
+ "making remote directory '%s': %s"
+ % (configuration.lldb_platform_working_dir, error)
+ )
if not lldb.remote_platform.SetWorkingDirectory(
- configuration.lldb_platform_working_dir):
- raise Exception("failed to set working directory '%s'" % configuration.lldb_platform_working_dir)
+ configuration.lldb_platform_working_dir
+ ):
+ raise Exception(
+ "failed to set working directory '%s'"
+ % configuration.lldb_platform_working_dir
+ )
lldb.selected_platform = lldb.remote_platform
else:
lldb.remote_platform = None
@@ -958,11 +1022,15 @@ def run_suite():
checkForkVForkSupport()
skipped_categories_list = ", ".join(configuration.skip_categories)
- print("Skipping the following test categories: {}".format(configuration.skip_categories))
+ print(
+ "Skipping the following test categories: {}".format(
+ configuration.skip_categories
+ )
+ )
for testdir in configuration.testdirs:
- for (dirpath, dirnames, filenames) in os.walk(testdir):
- visit('Test', dirpath, filenames)
+ for dirpath, dirnames, filenames in os.walk(testdir):
+ visit("Test", dirpath, filenames)
#
# Now that we have loaded all the test cases, run the whole test suite.
@@ -980,8 +1048,7 @@ def run_suite():
print("compiler=%s" % configuration.compiler)
# Iterating over all possible architecture and compiler combinations.
- configString = "arch=%s compiler=%s" % (configuration.arch,
- configuration.compiler)
+ configString = "arch=%s compiler=%s" % (configuration.arch, configuration.compiler)
# Output the configuration.
if configuration.verbose:
@@ -991,9 +1058,12 @@ def run_suite():
if configuration.verbose:
sys.stderr.write(configuration.separator + "\n")
sys.stderr.write(
- "Collected %d test%s\n\n" %
- (configuration.suite.countTestCases(),
- configuration.suite.countTestCases() != 1 and "s" or ""))
+ "Collected %d test%s\n\n"
+ % (
+ configuration.suite.countTestCases(),
+ configuration.suite.countTestCases() != 1 and "s" or "",
+ )
+ )
if configuration.suite.countTestCases() == 0:
logging.error("did not discover any matching tests")
@@ -1004,41 +1074,42 @@ def run_suite():
result = unittest2.TextTestRunner(
stream=sys.stderr,
verbosity=configuration.verbose,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
+ resultclass=test_result.LLDBTestResult,
+ ).run(configuration.suite)
else:
# We are invoking the same test suite more than once. In this case,
# mark __ignore_singleton__ flag as True so the signleton pattern is
# not enforced.
test_result.LLDBTestResult.__ignore_singleton__ = True
for i in range(configuration.count):
-
result = unittest2.TextTestRunner(
stream=sys.stderr,
verbosity=configuration.verbose,
- resultclass=test_result.LLDBTestResult).run(
- configuration.suite)
+ resultclass=test_result.LLDBTestResult,
+ ).run(configuration.suite)
configuration.failed = not result.wasSuccessful()
if configuration.sdir_has_content and configuration.verbose:
sys.stderr.write(
"Session logs for test failures/errors/unexpected successes"
- " can be found in the test build directory\n")
+ " can be found in the test build directory\n"
+ )
- if configuration.use_categories and len(
- configuration.failures_per_category) > 0:
+ if configuration.use_categories and len(configuration.failures_per_category) > 0:
sys.stderr.write("Failures per category:\n")
for category in configuration.failures_per_category:
sys.stderr.write(
- "%s - %d\n" %
- (category, configuration.failures_per_category[category]))
+ "%s - %d\n" % (category, configuration.failures_per_category[category])
+ )
# Exiting.
exitTestSuite(configuration.failed)
+
if __name__ == "__main__":
print(
- __file__ +
- " is for use as a module only. It should not be run as a standalone script.")
+ __file__
+ + " is for use as a module only. It should not be run as a standalone script."
+ )
sys.exit(-1)