diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/dotest.py')
-rw-r--r-- | packages/Python/lldbsuite/test/dotest.py | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py index d28c5ef069b7..644f63576c06 100644 --- a/packages/Python/lldbsuite/test/dotest.py +++ b/packages/Python/lldbsuite/test/dotest.py @@ -307,6 +307,24 @@ def parseOptionsAndInitTestdirs(): os.environ['DSYMUTIL'] = seven.get_command_output( 'xcrun -find -toolchain default dsymutil') + if args.filecheck: + # The lldb-dotest script produced by the CMake build passes in a path + # to a working FileCheck binary. So does one specific Xcode project + # target. However, when invoking dotest.py directly, a valid --filecheck + # option needs to be given. + configuration.filecheck = os.path.abspath(args.filecheck) + else: + outputPaths = get_llvm_bin_dirs() + for outputPath in outputPaths: + candidatePath = os.path.join(outputPath, 'FileCheck') + if is_exe(candidatePath): + configuration.filecheck = candidatePath + break + + if not configuration.get_filecheck_path(): + logging.warning('No valid FileCheck executable; some tests may fail...') + logging.warning('(Double-check the --filecheck argument to dotest.py)') + if args.channels: lldbtest_config.channels = args.channels @@ -439,7 +457,7 @@ def parseOptionsAndInitTestdirs(): configuration.num_threads = args.num_threads if args.test_subdir: - configuration.multiprocess_test_subdir = args.test_subdir + configuration.exclusive_test_subdir = args.test_subdir if args.test_runner_name: configuration.test_runner_name = args.test_runner_name @@ -616,6 +634,31 @@ def getOutputPaths(lldbRootDirectory): return result +def get_llvm_bin_dirs(): + """ + Returns an array of paths that may have the llvm/clang/etc binaries + in them, relative to this current file. + Returns an empty array if none are found. + """ + result = [] + + lldb_root_path = os.path.join( + os.path.dirname(__file__), "..", "..", "..", "..") + paths_to_try = [ + "llvm-build/Release+Asserts/x86_64/bin", + "llvm-build/Debug+Asserts/x86_64/bin", + "llvm-build/Release/x86_64/bin", + "llvm-build/Debug/x86_64/bin", + "llvm-build/Ninja-DebugAssert/llvm-macosx-x86_64/bin", + "llvm-build/Ninja-ReleaseAssert/llvm-macosx-x86_64/bin", + "llvm-build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/bin", + ] + for p in paths_to_try: + path = os.path.join(lldb_root_path, p) + if os.path.exists(path): + result.append(path) + + return result def setupSysPath(): """ @@ -646,6 +689,7 @@ def setupSysPath(): pluginPath = os.path.join(scriptPath, 'plugins') toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi') + toolsLLDBVSCode = os.path.join(scriptPath, 'tools', 'lldb-vscode') toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server') # Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the @@ -654,6 +698,9 @@ def setupSysPath(): # Adding test/tools/lldb-mi to the path makes it easy sys.path.insert(0, toolsLLDBMIPath) # to "import lldbmi_testcase" from the MI tests + # Adding test/tools/lldb-vscode to the path makes it easy to + # "import lldb_vscode_testcase" from the VSCode tests + sys.path.insert(0, toolsLLDBVSCode) # Adding test/tools/lldb-server to the path makes it easy sys.path.insert(0, toolsLLDBServerPath) # to "import lldbgdbserverutils" from the lldb-server tests @@ -723,6 +770,15 @@ def setupSysPath(): "The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.") configuration.skipCategories.append("lldb-mi") + lldbVSCodeExec = os.path.join(lldbDir, "lldb-vscode") + if is_exe(lldbVSCodeExec): + os.environ["LLDBVSCODE_EXEC"] = lldbVSCodeExec + 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.") + configuration.skipCategories.append("lldb-vscode") + lldbPythonDir = None # The directory that contains 'lldb/__init__.py' if not configuration.lldbFrameworkPath and os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")): configuration.lldbFrameworkPath = os.path.join(lldbLibDir, "LLDB.framework") @@ -882,6 +938,7 @@ def visit_file(dir, name): unittest2.defaultTestLoader.loadTestsFromName(base)) +# TODO: This should be replaced with a call to find_test_files_in_dir_tree. def visit(prefix, dir, names): """Visitor function for os.path.walk(path, visit, arg).""" @@ -1004,14 +1061,15 @@ def getMyCommandLine(): def checkDsymForUUIDIsNotOn(): cmd = ["defaults", "read", "com.apple.DebugSymbols"] - pipe = subprocess.Popen( + process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - cmd_output = pipe.stdout.read() - if cmd_output and "DBGFileMappedPaths = " in cmd_output: + cmd_output = process.stdout.read() + output_str = cmd_output.decode("utf-8") + if "DBGFileMappedPaths = " in output_str: print("%s =>" % ' '.join(cmd)) - print(cmd_output) + print(output_str) print( "Disable automatic lookup and caching of dSYMs before running the test suite!") print("Exiting...") @@ -1159,7 +1217,6 @@ def run_suite(): from . import dosep dosep.main( configuration.num_threads, - configuration.multiprocess_test_subdir, configuration.test_runner_name, configuration.results_formatter_object) raise Exception("should never get here") @@ -1254,10 +1311,15 @@ def run_suite(): # Don't do lldb-server (llgs) tests on anything except Linux. configuration.dont_do_llgs_test = not ("linux" in target_platform) - # - # Walk through the testdirs while collecting tests. - # - for testdir in configuration.testdirs: + # Collect tests from the specified testing directories. If a test + # subdirectory filter is explicitly specified, limit the search to that + # subdirectory. + exclusive_test_subdir = configuration.get_absolute_path_to_exclusive_test_subdir() + if exclusive_test_subdir: + dirs_to_search = [exclusive_test_subdir] + else: + dirs_to_search = configuration.testdirs + for testdir in dirs_to_search: for (dirpath, dirnames, filenames) in os.walk(testdir): visit('Test', dirpath, filenames) |