1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
"""
Base class for lldb-mi test cases.
"""
from lldbtest import *
import unittest2
class MiTestCaseBase(Base):
mydir = None
myexe = "a.out"
mylog = "child.log"
@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)
|