|
| 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() |
0 commit comments