diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py new file mode 100644 index 00000000000..944dca0af5e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py @@ -0,0 +1,54 @@ +""" +Base class for lldb-mi test cases. +""" + +from __future__ import print_function + +import use_lldb_suite + +from lldbtest import * + +class MiTestCaseBase(Base): + + mydir = None + myexe = "a.out" + mylog = "child.log" + + def getCategories(self): + return ['lldb-mi'] + + @classmethod + def classCleanup(cls): + TestBase.RemoveTempFile(cls.myexe) + TestBase.RemoveTempFile(cls.mylog) + + def setUp(self): + Base.setUp(self) + self.buildDefault() + self.child_prompt = "(gdb)" + + def tearDown(self): + if self.TraceOn(): + print("\n\nContents of %s:" % self.mylog) + try: + print(open(self.mylog, "r").read()) + except IOError: + pass + Base.tearDown(self) + + def spawnLldbMi(self, args=None): + import pexpect + self.child = pexpect.spawn("%s --interpreter %s" % ( + self.lldbMiExec, args if args else "")) + self.child.setecho(True) + self.child.logfile_read = open(self.mylog, "w") + # wait until lldb-mi has started up and is ready to go + self.expect(self.child_prompt, exactly = True) + + def runCmd(self, cmd): + self.child.sendline(cmd) + + def expect(self, pattern, exactly=False, *args, **kwargs): + if exactly: + return self.child.expect_exact(pattern, *args, **kwargs) + return self.child.expect(pattern, *args, **kwargs) |