[Lldb-commits] [lldb] r357459 - Fix flakyness in TestCommandScriptImmediateOutput

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 2 02:45:40 PDT 2019


Author: labath
Date: Tue Apr  2 02:45:40 2019
New Revision: 357459

URL: http://llvm.org/viewvc/llvm-project?rev=357459&view=rev
Log:
Fix flakyness in TestCommandScriptImmediateOutput

I'm not sure why this surfaced at this particular point, but
TestCommandScriptImmediateOutput (a pexpect test) had a synchronization
issue, where the (lldb) promts it was expecting were getting out of
sync. This happened for two reasons:
- it did not expect the initial (lldb) prompt we print at startup
- launchArgs() returned None, which resulted in an extra "target create
  None" command being issued to lldb (and an extra unhandled prompt
  being printed).

Resolving these two issues seems to fix (or at least, improve) the test.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
    lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py?rev=357459&r1=357458&r2=357459&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py Tue Apr  2 02:45:40 2019
@@ -31,7 +31,9 @@ class CommandScriptImmediateOutputTestCa
     @skipIfDarwin
     def test_command_script_immediate_output_console(self):
         """Test that LLDB correctly allows scripted commands to set immediate output to the console."""
+        prompt = "\(lldb\) "
         self.launch(timeout=10)
+        self.expect(prompt)
 
         script = os.path.join(self.getSourceDir(), 'custom_command.py')
         prompt = "\(lldb\) "
@@ -44,7 +46,7 @@ class CommandScriptImmediateOutputTestCa
             'mycommand',
             patterns='this is a test string, just a test string')
         self.sendline('command script delete mycommand', patterns=[prompt])
-        self.quit(gracefully=False)
+        self.quit()
 
     @skipIfRemote  # test not remote-ready llvm.org/pr24813
     @expectedFailureAll(
@@ -54,7 +56,9 @@ class CommandScriptImmediateOutputTestCa
     @skipIfDarwin
     def test_command_script_immediate_output_file(self):
         """Test that LLDB correctly allows scripted commands to set immediate output to a file."""
+        prompt = "\(lldb\) "
         self.launch(timeout=10)
+        self.expect(prompt)
 
         test_files = {self.getBuildArtifact('read.txt'): 'r',
                       self.getBuildArtifact('write.txt'): 'w',
@@ -71,7 +75,6 @@ class CommandScriptImmediateOutputTestCa
                 init.write(starter_string)
 
         script = os.path.join(self.getSourceDir(), 'custom_command.py')
-        prompt = "\(lldb\) "
 
         self.sendline('command script import %s' % script, patterns=[prompt])
 
@@ -85,7 +88,7 @@ class CommandScriptImmediateOutputTestCa
 
         self.sendline('command script delete mywrite', patterns=[prompt])
 
-        self.quit(gracefully=False)
+        self.quit()
 
         for path, mode in test_files.items():
             with open(path, 'r') as result:
@@ -96,4 +99,3 @@ class CommandScriptImmediateOutputTestCa
                         result.readline(), write_string + mode + '\n')
 
             self.assertTrue(os.path.isfile(path))
-            os.remove(path)

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py?rev=357459&r1=357458&r2=357459&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbpexpect.py Tue Apr  2 02:45:40 2019
@@ -27,7 +27,7 @@ else:
             TestBase.setUp(self)
 
         def launchArgs(self):
-            pass
+            return ""
 
         def launch(self, timeout=None):
             if timeout is None:




More information about the lldb-commits mailing list