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 = [
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))
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()
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")
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(
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
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(
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'))
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 = []
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: