summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-08-13 12:12:19 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-08-13 12:12:19 +0000
commit2515640aee7725c29104ec3a60dae345a3dbdb07 (patch)
tree2aa63262590adb1fa1d3bc75138b7d40fe920e25 /lldb
parent36f23182bc3126b5841f7e88b8101378cf083b9d (diff)
downloadbcm5719-llvm-2515640aee7725c29104ec3a60dae345a3dbdb07.tar.gz
bcm5719-llvm-2515640aee7725c29104ec3a60dae345a3dbdb07.zip
[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
Diffstat (limited to 'lldb')
-rw-r--r--lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py58
-rw-r--r--lldb/packages/Python/lldbsuite/test/iohandler/completion/main.c5
2 files changed, 63 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py b/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
new file mode 100644
index 00000000000..16ca3a39248
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
@@ -0,0 +1,58 @@
+"""
+Test completion in our IOHandlers.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class IOHandlerCompletionTest(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ TestBase.setUp(self)
+
+ def expect_string(self, string):
+ import pexpect
+ """This expects for "string", with timeout & EOF being test fails."""
+ try:
+ self.child.expect_exact(string)
+ except pexpect.EOF:
+ self.fail("Got EOF waiting for '%s'" % (string))
+ except pexpect.TIMEOUT:
+ self.fail("Timed out waiting for '%s'" % (string))
+
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_completion(self):
+ self.setTearDownCleanup()
+
+ import pexpect
+ exe = self.getBuildArtifact("a.out")
+ prompt = "(lldb) "
+
+ self.child = pexpect.spawn(
+ '%s %s %s %s' %
+ (lldbtest_config.lldbExec, self.lldbOption, "", exe))
+
+ self.expect_string(prompt)
+ self.child.send("\t\t\t")
+ self.expect_string("register")
+
+ self.child.send("regi\t")
+ self.expect_string(prompt + "register")
+ self.child.send("\n")
+
+ self.child.send("\t")
+ self.expect_string("More (Y/n/a)")
+ self.child.send("n")
+ self.expect_string(prompt)
+
+ # Shouldn't crash or anything like that.
+ self.child.send("regoinvalid\t")
+ self.expect_string(prompt)
+
+ self.deletePexpectChild()
diff --git a/lldb/packages/Python/lldbsuite/test/iohandler/completion/main.c b/lldb/packages/Python/lldbsuite/test/iohandler/completion/main.c
new file mode 100644
index 00000000000..03350dd8299
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/iohandler/completion/main.c
@@ -0,0 +1,5 @@
+int main(int argc, char **argv) {
+ lldb_enable_attach();
+ int to_complete = 0;
+ return to_complete;
+}
OpenPOWER on IntegriCloud