diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools')
2 files changed, 9 insertions, 27 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 61327e6f461..1bf7fff9c3b 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -214,30 +214,21 @@ class GdbRemoteTestCaseBase(TestBase): return stub_port - def run_shell_cmd(self, cmd): - platform = self.dbg.GetSelectedPlatform() - shell_cmd = lldb.SBPlatformShellCommand(cmd) - err = platform.Run(shell_cmd) - if err.Fail() or shell_cmd.GetStatus(): - m = "remote_platform.RunShellCommand('%s') failed:\n" % cmd - m += ">>> return code: %d\n" % shell_cmd.GetStatus() - if err.Fail(): - m += ">>> %s\n" % str(err).strip() - m += ">>> %s\n" % (shell_cmd.GetOutput() or - "Command generated no output.") - raise Exception(m) - return shell_cmd.GetOutput().strip() - def init_llgs_test(self, use_named_pipe=True): if lldb.remote_platform: # Remote platforms don't support named pipe based port negotiation use_named_pipe = False # Grab the ppid from /proc/[shell pid]/stat - shell_stat = self.run_shell_cmd("cat /proc/$$/stat") + err, retcode, shell_stat = self.run_platform_command("cat /proc/$$/stat") + self.assertTrue(err.Success() and retcode == 0, + "Failed to read file /proc/$$/stat: %s, retcode: %d" % (err.GetCString(), retcode)) + # [pid] ([executable]) [state] [*ppid*] pid = re.match(r"^\d+ \(.+\) . (\d+)", shell_stat).group(1) - ls_output = self.run_shell_cmd("ls -l /proc/%s/exe" % pid) + err, retcode, ls_output = self.run_platform_command("ls -l /proc/%s/exe" % pid) + self.assertTrue(err.Success() and retcode == 0, + "Failed to read file /proc/%s/exe: %s, retcode: %d" % (pid, err.GetCString(), retcode)) exe = ls_output.split()[-1] # If the binary has been deleted, the link name has " (deleted)" appended. @@ -346,12 +337,6 @@ class GdbRemoteTestCaseBase(TestBase): commandline_args += ["--named-pipe", self.named_pipe_path] return commandline_args - def run_platform_command(self, cmd): - platform = self.dbg.GetSelectedPlatform() - shell_command = lldb.SBPlatformShellCommand(cmd) - err = platform.Run(shell_command) - return (err, shell_command.GetOutput()) - def launch_debug_monitor(self, attach_pid=None, logfile=None): # Create the command line. commandline_args = self.get_debug_monitor_command_line_args(attach_pid=attach_pid) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py index 015483519c8..5c28d288db5 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py @@ -38,11 +38,8 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase): commandline_args = ["platform", "--listen", listen_url, "--socket-file", port_file, "--", "%s/a.out" % working_dir, "foo"] self.spawnSubprocess(self.debug_monitor_exe, commandline_args, install_remote=False) self.addTearDownHook(self.cleanupSubprocesses) - - # Wait until the port_file have been created. Doing it with 1 shell command will fail because - # of a bug in LLDB shell escaping code - _, _ = self.run_platform_command("while [ ! -f %s ]; do sleep 0.25; done" % port_file) - _, socket_id = self.run_platform_command("cat %s" % port_file) + + socket_id = lldbutil.wait_for_file_on_target(self, port_file) new_debugger = lldb.SBDebugger.Create() new_debugger.SetAsync(False) |