From 19fc1d4e3c19caa091b2fde161f54fa3b015b028 Mon Sep 17 00:00:00 2001 From: Tamas Berghammer Date: Tue, 5 Apr 2016 14:08:18 +0000 Subject: [NFC] Cleanup the code used to run shell commands from tests Previously we had 3 different method to run shell commands on the target and 4 copy of code waiting until a given file appears on the target device (used for syncronization). This CL merges these methods to 1 run_platform_command and 1 wait_for_file_on_target functions located in some utility classes. Differential revision: http://reviews.llvm.org/D18789 llvm-svn: 265398 --- .../attach_denied/TestAttachDenied.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/process_attach') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py index d1420394332..3d1d7fdc790 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py @@ -19,12 +19,6 @@ class AttachDeniedTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def run_platform_command(self, cmd): - platform = self.dbg.GetSelectedPlatform() - shell_command = lldb.SBPlatformShellCommand(cmd) - err = platform.Run(shell_command) - return (err, shell_command.GetStatus(), shell_command.GetOutput()) - @skipIfWindows @skipIfiOSSimulator def test_attach_to_process_by_id_denied(self): @@ -41,21 +35,7 @@ class AttachDeniedTestCase(TestBase): popen = self.spawnSubprocess(exe, [pid_file_path]) self.addTearDownHook(self.cleanupSubprocesses) - max_attempts = 5 - for i in range(max_attempts): - err, retcode, msg = self.run_platform_command("ls %s" % pid_file_path) - if err.Success() and retcode == 0: - break - else: - print(msg) - if i < max_attempts: - # Exponential backoff! - time.sleep(pow(2, i) * 0.25) - else: - self.fail("Child PID file %s not found even after %d attempts." % (pid_file_path, max_attempts)) - err, retcode, pid = self.run_platform_command("cat %s" % (pid_file_path)) - self.assertTrue(err.Success() and retcode == 0, - "Failed to read file %s: %s, retcode: %d" % (pid_file_path, err.GetCString(), retcode)) + pid = lldbutil.wait_for_file_on_target(self, pid_file_path) self.expect('process attach -p ' + pid, startstr = 'error: attach failed:', -- cgit v1.2.3