From 3a6cc51cb90cba16c4485412b71964c89dcb8cd4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 8 May 2015 09:28:11 +0000 Subject: [PATCH] Make LLDB-MI tests wait for LLDB-MI to start up before sending any MI commands Summary: This set of changes addresses the issue I described in [[ http://llvm.org/pr23403 | Bug 23403 ]], in short most LLDB-MI tests fail unexpectedly due to timeout on my Ubuntu 14.10 x86_64 VirtualBox VM. I have no idea why the Ubuntu buildbots don't seem to suffer from this issue. This patch just makes **MiTestCaseBase.spawnLldbMi()** block until the spawned LLDB-MI child process outputs the **(gdb)** prompt, which ensures that MI commands aren't sent to the LLDB-MI child process until it's ready. Before these changes 52 LLDB-MI tests failed unexpectedly (all but one due to timeouts), after these changes no tests fail due to timeouts. I still get one unexpected failure in **test_lldbmi_source_option_start_script_error** in **TestMiStartupOptions.py**, but that's due to a file error, that test should be skipped on Linux just like the other two //start_script// tests until the file error is fixed. Patch from Vadim Macagon. Thanks! Test Plan: ./dotest.py -A x86_64 -C clang --executable $BUILDDIR/bin/lldb tools/lldb-mi/ Reviewers: abidh, domipheus, ki.stfu Reviewed By: ki.stfu Subscribers: brucem, lldb-commits Differential Revision: http://reviews.llvm.org/D9595 llvm-svn: 236816 --- lldb/test/tools/lldb-mi/TestMiPrompt.py | 3 --- lldb/test/tools/lldb-mi/data/TestMiData.py | 1 - lldb/test/tools/lldb-mi/lldbmi_testcase.py | 2 ++ .../startup_options/TestMiStartupOptions.py | 21 ------------------- 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/lldb/test/tools/lldb-mi/TestMiPrompt.py b/lldb/test/tools/lldb-mi/TestMiPrompt.py index af55ce2cbaaf2..15bd704d632e4 100644 --- a/lldb/test/tools/lldb-mi/TestMiPrompt.py +++ b/lldb/test/tools/lldb-mi/TestMiPrompt.py @@ -18,9 +18,6 @@ def test_lldbmi_prompt(self): self.spawnLldbMi(args = None) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that lldb-mi is ready after unknown command self.runCmd("-unknown-command") self.expect("\^error,msg=\"Driver\. Received command '-unknown-command'\. It was not handled\. Command 'unknown-command' not in Command Factory\"") diff --git a/lldb/test/tools/lldb-mi/data/TestMiData.py b/lldb/test/tools/lldb-mi/data/TestMiData.py index ac5029226a037..2c1ade534d3ea 100644 --- a/lldb/test/tools/lldb-mi/data/TestMiData.py +++ b/lldb/test/tools/lldb-mi/data/TestMiData.py @@ -85,7 +85,6 @@ def test_lldbmi_data_read_memory_bytes_local(self): """Test that -data-read-memory-bytes can access local buffers.""" self.spawnLldbMi(args = None) - self.expect(self.child_prompt, exactly = True) # Load executable self.runCmd('-file-exec-and-symbols %s' % self.myexe) diff --git a/lldb/test/tools/lldb-mi/lldbmi_testcase.py b/lldb/test/tools/lldb-mi/lldbmi_testcase.py index 61423694d70b6..d059bf2f1f500 100644 --- a/lldb/test/tools/lldb-mi/lldbmi_testcase.py +++ b/lldb/test/tools/lldb-mi/lldbmi_testcase.py @@ -36,6 +36,8 @@ def spawnLldbMi(self, args=None): self.lldbMiExec, args if args else "")) self.child.setecho(True) self.child.logfile_read = open(self.mylog, "w") + # wait until lldb-mi has started up and is ready to go + self.expect(self.child_prompt, exactly = True) def runCmd(self, cmd): self.child.sendline(cmd) diff --git a/lldb/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py b/lldb/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py index 979e67c8c4c60..abdd30940fc8c 100644 --- a/lldb/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py +++ b/lldb/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py @@ -18,9 +18,6 @@ def test_lldbmi_executable_option_file(self): self.spawnLldbMi(args = "%s" % self.myexe) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) self.expect("\^done") @@ -44,9 +41,6 @@ def test_lldbmi_executable_option_unknown_file(self): self.spawnLldbMi(args = "%s" % path) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable isn't loaded when unknown file was specified self.expect("-file-exec-and-symbols \"%s\"" % path) self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path)) @@ -66,9 +60,6 @@ def test_lldbmi_executable_option_absolute_path(self): self.spawnLldbMi(args = "%s" % path) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable is loaded when file was specified using absolute path self.expect("-file-exec-and-symbols \"%s\"" % path) self.expect("\^done") @@ -92,9 +83,6 @@ def test_lldbmi_executable_option_relative_path(self): self.spawnLldbMi(args = "%s" % path) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable is loaded when file was specified using relative path self.expect("-file-exec-and-symbols \"%s\"" % path) self.expect("\^done") @@ -118,9 +106,6 @@ def test_lldbmi_executable_option_unknown_path(self): self.spawnLldbMi(args = "%s" % path) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable isn't loaded when file was specified using unknown path self.expect("-file-exec-and-symbols \"%s\"" % path) self.expect("\^error,msg=\"Command 'file-exec-and-symbols'. Target binary '%s' is invalid. error: unable to find executable for '%s'\"" % (path, path)) @@ -241,9 +226,6 @@ def test_lldbmi_log_option(self): logDirectory = "." self.spawnLldbMi(args = "%s --log" % self.myexe) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) self.expect("\^done") @@ -279,9 +261,6 @@ def test_lldbmi_log_directory_option(self): self.spawnLldbMi(args = "%s --log --log-dir=%s" % (self.myexe,logDirectory)) - # Test that lldb-mi is ready after startup - self.expect(self.child_prompt, exactly = True) - # Test that the executable is loaded when file was specified self.expect("-file-exec-and-symbols \"%s\"" % self.myexe) self.expect("\^done")