summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-04-02 09:45:40 +0000
committerPavel Labath <pavel@labath.sk>2019-04-02 09:45:40 +0000
commitc5cefa2caf79af2f40555754cbb6ff6756053b12 (patch)
treed32f58ee7e3c49b780f9df67d8da1de9233a6983
parentf42197885813cee43234d63271ec99026b546b79 (diff)
downloadbcm5719-llvm-c5cefa2caf79af2f40555754cbb6ff6756053b12.tar.gz
bcm5719-llvm-c5cefa2caf79af2f40555754cbb6ff6756053b12.zip
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. llvm-svn: 357459
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py10
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbpexpect.py2
2 files changed, 7 insertions, 5 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
index bd7973e0dc3..9d4f8e1f0c7 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/command_script_immediate_output/TestCommandScriptImmediateOutput.py
@@ -31,7 +31,9 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
@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 CommandScriptImmediateOutputTestCase (PExpectTest):
'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 CommandScriptImmediateOutputTestCase (PExpectTest):
@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 CommandScriptImmediateOutputTestCase (PExpectTest):
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 CommandScriptImmediateOutputTestCase (PExpectTest):
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 CommandScriptImmediateOutputTestCase (PExpectTest):
result.readline(), write_string + mode + '\n')
self.assertTrue(os.path.isfile(path))
- os.remove(path)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index a19e6efa9f0..d67a2f3e998 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -27,7 +27,7 @@ else:
TestBase.setUp(self)
def launchArgs(self):
- pass
+ return ""
def launch(self, timeout=None):
if timeout is None:
OpenPOWER on IntegriCloud