mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-30 08:49:04 -04:00

This patch is the result of a discussion on lldb-dev, see http://lists.llvm.org/pipermail/lldb-dev/2018-January/013111.html for background. For each test (should be eventually: each test configuration) a separate build directory is created and we execute make VPATH=$srcdir/path/to/test -C $builddir/path/to/test -f $srcdir/path/to/test/Makefile -I $srcdir/path/to/test In order to make this work all LLDB tests need to be updated to find the executable in the test build directory, since CWD still points at the test's source directory, which is a requirement for unittest2. Although we have done extensive testing, I'm expecting that this first attempt will break a few bots. Please DO NOT HESITATE TO REVERT this patch in order to get the bots green again. We will likely have to iterate on this some more. Differential Revision: https://reviews.llvm.org/D42281 llvm-svn: 323803
61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
"""
|
|
Base class for lldb-mi test cases.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
from lldbsuite.test.lldbtest import *
|
|
|
|
|
|
class MiTestCaseBase(Base):
|
|
|
|
mydir = None
|
|
myexe = None
|
|
mylog = None
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
@classmethod
|
|
def classCleanup(cls):
|
|
if cls.myexe:
|
|
TestBase.RemoveTempFile(cls.myexe)
|
|
if cls.mylog:
|
|
TestBase.RemoveTempFile(cls.mylog)
|
|
|
|
def setUp(self):
|
|
if not self.mydir:
|
|
raise("mydir is empty")
|
|
|
|
Base.setUp(self)
|
|
self.makeBuildDir()
|
|
self.buildDefault()
|
|
self.child_prompt = "(gdb)"
|
|
self.myexe = self.getBuildArtifact("a.out")
|
|
|
|
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.mylog = self.getBuildArtifact("child.log")
|
|
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)
|