Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py @@ -583,7 +583,7 @@ 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 @@ 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 @@ 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 @@ # And the result object. self.res = lldb.SBCommandReturnObject() + self.setPlatformWorkingDir() self.enableLogChannelsForCurrentTest() #Initialize debug_info @@ -884,8 +923,6 @@ for dict in reversed(self.dicts): self.cleanup(dictionary=dict) - self.disableLogChannelsForCurrentTest() - # ========================================================= # Various callbacks to allow introspection of test progress # ========================================================= @@ -1614,30 +1651,6 @@ # 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 Index: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py =================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -78,7 +78,6 @@ TestBase.setUp(self) self.setUpBaseLogging() - self._remote_server_log_file = None self.debug_monitor_extra_args = [] self._pump_queues = socket_packet_pump.PumpQueues() @@ -114,12 +113,6 @@ def tearDown(self): self._pump_queues.verify_queues_empty() - if self._remote_server_log_file is not None: - lldb.remote_platform.Get(lldb.SBFileSpec(self._remote_server_log_file), - lldb.SBFileSpec(self.getLocalServerLogFile())) - lldb.remote_platform.Run(lldb.SBPlatformShellCommand("rm " + self._remote_server_log_file)) - self._remote_server_log_file = None - self.logger.removeHandler(self._verbose_log_handler) self._verbose_log_handler = None TestBase.tearDown(self) @@ -133,7 +126,6 @@ if lldb.remote_platform: log_file = lldbutil.join_remote_paths(lldb.remote_platform.GetWorkingDirectory(), "server.log") - self._remote_server_log_file = log_file else: log_file = self.getLocalServerLogFile()