diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lldbtest.py | 81 |
1 files changed, 47 insertions, 34 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index a72dd6f9e1f..ee876bd1116 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -583,7 +583,7 @@ class Base(unittest2.TestCase): else: categories = "default" - if channel == "gdb-remote": + if channel == "gdb-remote" and lldb.remote_platform is None: # communicate gdb-remote categories to debugserver os.environ["LLDB_DEBUGSERVER_LOG_FLAGS"] = categories @@ -592,15 +592,17 @@ class Base(unittest2.TestCase): raise Exception('log enable failed (check LLDB_LOG_OPTION env variable)') # Communicate log path name to debugserver & lldb-server - server_log_path = "{}-server.log".format(log_basename) - open(server_log_path, 'w').close() - os.environ["LLDB_DEBUGSERVER_LOG_FILE"] = server_log_path + # For remote debugging, these variables need to be set when starting the platform + # instance. + if lldb.remote_platform is None: + server_log_path = "{}-server.log".format(log_basename) + open(server_log_path, 'w').close() + os.environ["LLDB_DEBUGSERVER_LOG_FILE"] = server_log_path - # Communicate channels to lldb-server - os.environ["LLDB_SERVER_LOG_CHANNELS"] = ":".join(lldbtest_config.channels) + # Communicate channels to lldb-server + os.environ["LLDB_SERVER_LOG_CHANNELS"] = ":".join(lldbtest_config.channels) - if len(lldbtest_config.channels) == 0: - return + self.addTearDownHook(self.disableLogChannelsForCurrentTest) def disableLogChannelsForCurrentTest(self): # close all log files that we opened @@ -611,6 +613,42 @@ class Base(unittest2.TestCase): if not self.res.Succeeded(): raise Exception('log disable failed (check LLDB_LOG_OPTION env variable)') + # Retrieve the server log (if any) from the remote system. It is assumed the server log + # is writing to the "server.log" file in the current test directory. This can be + # achieved by setting LLDB_DEBUGSERVER_LOG_FILE="server.log" when starting remote + # platform. If the remote logging is not enabled, then just let the Get() command silently + # fail. + if lldb.remote_platform: + lldb.remote_platform.Get(lldb.SBFileSpec("server.log"), + lldb.SBFileSpec(self.getLogBasenameForCurrentTest()+"-server.log")) + + def setPlatformWorkingDir(self): + if not lldb.remote_platform or not configuration.lldb_platform_working_dir: + return + + remote_test_dir = lldbutil.join_remote_paths( + configuration.lldb_platform_working_dir, + self.getArchitecture(), + str(self.test_number), + self.mydir) + error = lldb.remote_platform.MakeDirectory(remote_test_dir, 448) # 448 = 0o700 + if error.Success(): + lldb.remote_platform.SetWorkingDirectory(remote_test_dir) + + # This function removes all files from the current working directory while leaving + # the directories in place. The cleaup is required to reduce the disk space required + # by the test suit while leaving the directories untached is neccessary because + # sub-directories might belong to an other test + def clean_working_directory(): + # TODO: Make it working on Windows when we need it for remote debugging support + # TODO: Replace the heuristic to remove the files with a logic what collects the + # list of files we have to remove during test runs. + shell_cmd = lldb.SBPlatformShellCommand("rm %s/*" % remote_test_dir) + lldb.remote_platform.Run(shell_cmd) + self.addTearDownHook(clean_working_directory) + else: + print("error: making remote directory '%s': %s" % (remote_test_dir, error)) + def setUp(self): """Fixture for unittest test case setup. @@ -716,6 +754,7 @@ class Base(unittest2.TestCase): # And the result object. self.res = lldb.SBCommandReturnObject() + self.setPlatformWorkingDir() self.enableLogChannelsForCurrentTest() #Initialize debug_info @@ -884,8 +923,6 @@ class Base(unittest2.TestCase): for dict in reversed(self.dicts): self.cleanup(dictionary=dict) - self.disableLogChannelsForCurrentTest() - # ========================================================= # Various callbacks to allow introspection of test progress # ========================================================= @@ -1614,30 +1651,6 @@ class TestBase(Base): # And the result object. self.res = lldb.SBCommandReturnObject() - if lldb.remote_platform and configuration.lldb_platform_working_dir: - remote_test_dir = lldbutil.join_remote_paths( - configuration.lldb_platform_working_dir, - self.getArchitecture(), - str(self.test_number), - self.mydir) - error = lldb.remote_platform.MakeDirectory(remote_test_dir, 448) # 448 = 0o700 - if error.Success(): - lldb.remote_platform.SetWorkingDirectory(remote_test_dir) - - # This function removes all files from the current working directory while leaving - # the directories in place. The cleaup is required to reduce the disk space required - # by the test suit while leaving the directories untached is neccessary because - # sub-directories might belong to an other test - def clean_working_directory(): - # TODO: Make it working on Windows when we need it for remote debugging support - # TODO: Replace the heuristic to remove the files with a logic what collects the - # list of files we have to remove during test runs. - shell_cmd = lldb.SBPlatformShellCommand("rm %s/*" % remote_test_dir) - lldb.remote_platform.Run(shell_cmd) - self.addTearDownHook(clean_working_directory) - else: - print("error: making remote directory '%s': %s" % (remote_test_dir, error)) - def registerSharedLibrariesWithTarget(self, target, shlibs): '''If we are remotely running the test suite, register the shared libraries with the target so they get uploaded, otherwise do nothing |