forked from OSchip/llvm-project
[lldb/Test] Fix tests that rely on logfiles with reproducers.
Now that the log file is included in the reproducers, the path needs to be remapped for the test to find the new file in the reproducer.
This commit is contained in:
parent
d4f298c820
commit
64c87a94ca
|
@ -699,6 +699,12 @@ class Base(unittest2.TestCase):
|
|||
lldbutil.mkdir_p(self.getReproducerDir())
|
||||
return os.path.join(self.getReproducerDir(), name)
|
||||
|
||||
def getReproducerRemappedPath(self, path):
|
||||
assert configuration.replay_path
|
||||
assert os.path.isabs(path)
|
||||
path = os.path.relpath(path, '/')
|
||||
return os.path.join(configuration.replay_path, 'root', path)
|
||||
|
||||
@classmethod
|
||||
def setUpCommands(cls):
|
||||
commands = [
|
||||
|
|
|
@ -17,12 +17,15 @@ class APILogTestCase(TestBase):
|
|||
|
||||
def test_api_log(self):
|
||||
"""Test API logging"""
|
||||
logfile = os.path.join(self.getBuildDir(), "api-log.txt")
|
||||
logfile = self.getBuildArtifact("api-log.txt")
|
||||
|
||||
def cleanup():
|
||||
if os.path.exists(logfile):
|
||||
os.unlink(logfile)
|
||||
|
||||
if configuration.is_reproducer_replay():
|
||||
logfile = self.getReproducerRemappedPath(logfile)
|
||||
|
||||
self.addTearDownHook(cleanup)
|
||||
self.expect("log enable lldb api -f {}".format(logfile))
|
||||
|
||||
|
@ -30,7 +33,7 @@ class APILogTestCase(TestBase):
|
|||
self.dbg.GetScriptingLanguage(None)
|
||||
target = self.dbg.CreateTarget(None)
|
||||
|
||||
print(logfile)
|
||||
self.assertTrue(os.path.isfile(logfile))
|
||||
with open(logfile, 'r') as f:
|
||||
log = f.read()
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ class LogTestCase(TestBase):
|
|||
super(LogTestCase, self).setUp()
|
||||
self.log_file = self.getBuildArtifact("log-file.txt")
|
||||
|
||||
if configuration.is_reproducer_replay():
|
||||
self.log_file = self.getReproducerRemappedPath(self.log_file)
|
||||
|
||||
def test_file_writing(self):
|
||||
self.build()
|
||||
exe = self.getBuildArtifact("a.out")
|
||||
|
@ -44,9 +47,8 @@ class LogTestCase(TestBase):
|
|||
|
||||
self.assertTrue(os.path.isfile(self.log_file))
|
||||
|
||||
f = open(self.log_file)
|
||||
log_lines = f.readlines()
|
||||
f.close()
|
||||
with open(self.log_file, 'r') as f:
|
||||
log_lines = f.read()
|
||||
os.remove(self.log_file)
|
||||
|
||||
self.assertGreater(
|
||||
|
@ -83,7 +85,7 @@ class LogTestCase(TestBase):
|
|||
self.runCmd("log disable lldb")
|
||||
|
||||
self.assertTrue(os.path.isfile(self.log_file))
|
||||
with open(self.log_file, "r") as f:
|
||||
with open(self.log_file, 'r') as f:
|
||||
contents = f.read()
|
||||
|
||||
# check that it is still there
|
||||
|
|
|
@ -44,7 +44,9 @@ class CModulesTestCase(TestBase):
|
|||
substrs=[' resolved, hit count = 1'])
|
||||
|
||||
# Enable logging of the imported AST.
|
||||
log_file = os.path.join(self.getBuildDir(), "lldb-ast-log.txt")
|
||||
log_file = self.getBuildArtifact("lldb-ast-log.txt")
|
||||
if configuration.is_reproducer_replay():
|
||||
log_file = self.getReproducerRemappedPath(log_file)
|
||||
self.runCmd("log enable lldb ast -f '%s'" % log_file)
|
||||
|
||||
self.expect(
|
||||
|
|
|
@ -13,7 +13,11 @@ class CPPAcceleratorTableTestCase(TestBase):
|
|||
def test(self):
|
||||
"""Test that type lookups fail early (performance)"""
|
||||
self.build()
|
||||
|
||||
logfile = self.getBuildArtifact('dwarf.log')
|
||||
if configuration.is_reproducer_replay():
|
||||
logfile = self.getReproducerRemappedPath(logfile)
|
||||
|
||||
self.expect('log enable dwarf lookups -f' + logfile)
|
||||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
|
||||
self, 'break here', lldb.SBFileSpec('main.cpp'))
|
||||
|
|
|
@ -265,11 +265,15 @@ class TestMembersAndLocalsWithSameName(TestBase):
|
|||
self.assertEqual(val.GetValueAsUnsigned(), 778899)
|
||||
|
||||
def enable_expression_log(self):
|
||||
log_file = os.path.join(self.getBuildDir(), "expr.log")
|
||||
log_file = self.getBuildArtifact("expr.log")
|
||||
if configuration.is_reproducer_replay():
|
||||
log_file = self.getReproducerRemappedPath(log_file)
|
||||
self.runCmd("log enable -f '%s' lldb expr" % (log_file))
|
||||
|
||||
def disable_expression_log_and_check_for_locals(self, variables):
|
||||
log_file = os.path.join(self.getBuildDir(), "expr.log")
|
||||
log_file = self.getBuildArtifact("expr.log")
|
||||
if configuration.is_reproducer_replay():
|
||||
log_file = self.getReproducerRemappedPath(log_file)
|
||||
self.runCmd("log disable lldb expr")
|
||||
local_var_regex = re.compile(r".*__lldb_local_vars::(.*);")
|
||||
matched = []
|
||||
|
|
|
@ -32,10 +32,12 @@ class TestClangModuleHashMismatch(TestBase):
|
|||
self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
|
||||
|
||||
logfile = self.getBuildArtifact("host.log")
|
||||
if configuration.is_reproducer_replay():
|
||||
logfile = self.getReproducerRemappedPath(logfile)
|
||||
self.runCmd("log enable -v -f %s lldb host" % logfile)
|
||||
target, _, _, _ = lldbutil.run_to_source_breakpoint(
|
||||
self, "break here", lldb.SBFileSpec("main.m"))
|
||||
target.GetModuleAtIndex(0).FindTypes('my_int')
|
||||
target.GetModuleAtIndex(0).FindTypes('my_int')
|
||||
|
||||
found = False
|
||||
with open(logfile, 'r') as f:
|
||||
|
|
Loading…
Reference in New Issue