Skip to content

Commit 2515640

Browse files
committed
[lldb][NFC] Add basic IOHandler completion test
We have no test coverage for the IOHandler code that is doing the completion in the command line. This is adding a pexpect-based test as a preparation for the switch to using CompletionRequest in the whole completion machinery. llvm-svn: 368679
1 parent 36f2318 commit 2515640

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""
2+
Test completion in our IOHandlers.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
9+
class IOHandlerCompletionTest(TestBase):
10+
11+
mydir = TestBase.compute_mydir(__file__)
12+
NO_DEBUG_INFO_TESTCASE = True
13+
14+
def setUp(self):
15+
TestBase.setUp(self)
16+
17+
def expect_string(self, string):
18+
import pexpect
19+
"""This expects for "string", with timeout & EOF being test fails."""
20+
try:
21+
self.child.expect_exact(string)
22+
except pexpect.EOF:
23+
self.fail("Got EOF waiting for '%s'" % (string))
24+
except pexpect.TIMEOUT:
25+
self.fail("Timed out waiting for '%s'" % (string))
26+
27+
@expectedFailureAll(
28+
oslist=["windows"],
29+
bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
30+
def test_completion(self):
31+
self.setTearDownCleanup()
32+
33+
import pexpect
34+
exe = self.getBuildArtifact("a.out")
35+
prompt = "(lldb) "
36+
37+
self.child = pexpect.spawn(
38+
'%s %s %s %s' %
39+
(lldbtest_config.lldbExec, self.lldbOption, "", exe))
40+
41+
self.expect_string(prompt)
42+
self.child.send("\t\t\t")
43+
self.expect_string("register")
44+
45+
self.child.send("regi\t")
46+
self.expect_string(prompt + "register")
47+
self.child.send("\n")
48+
49+
self.child.send("\t")
50+
self.expect_string("More (Y/n/a)")
51+
self.child.send("n")
52+
self.expect_string(prompt)
53+
54+
# Shouldn't crash or anything like that.
55+
self.child.send("regoinvalid\t")
56+
self.expect_string(prompt)
57+
58+
self.deletePexpectChild()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int main(int argc, char **argv) {
2+
lldb_enable_attach();
3+
int to_complete = 0;
4+
return to_complete;
5+
}

0 commit comments

Comments
 (0)