Author: teemperor
Date: Tue Aug 13 05:12:19 2019
New Revision: 368679

URL: http://llvm.org/viewvc/llvm-project?rev=368679&view=rev
Log:
[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.

Added:
    lldb/trunk/packages/Python/lldbsuite/test/iohandler/
    lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/
    
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
    lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c

Added: 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py?rev=368679&view=auto
==============================================================================
--- 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 Tue Aug 13 05:12:19 2019
@@ -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()

Added: lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c?rev=368679&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/iohandler/completion/main.c Tue 
Aug 13 05:12:19 2019
@@ -0,0 +1,5 @@
+int main(int argc, char **argv) {
+  lldb_enable_attach();
+  int to_complete = 0;
+  return to_complete;
+}


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to