[lldb] Make SBTarget::LaunchSimple start form the target's LaunchInfo

Currently SBTarget::LaunchSimple creates a new LaunchInfo which means it
ignores any target properties that have been set. Instead, it should
start from the target's LaunchInfo and populated the specified fields.

Differential revision: https://reviews.llvm.org/D85235
This commit is contained in:
Jonas Devlieghere
2020-08-05 09:34:18 -07:00
parent 3169d920cc
commit 882d8e60dd
3 changed files with 60 additions and 13 deletions

View File

@@ -150,6 +150,38 @@ class TargetAPITestCase(TestBase):
self.assertTrue(error.Success(), "Make sure memory read succeeded")
self.assertEqual(len(content), 1)
@add_test_categories(['pyapi'])
def test_launch_simple(self):
d = {'EXE': 'b.out'}
self.build(dictionary=d)
self.setTearDownCleanup(dictionary=d)
target = self.create_simple_target('b.out')
process = target.LaunchSimple(
['foo', 'bar'], ['baz'], self.get_process_working_directory())
self.runCmd("run")
output = process.GetSTDOUT(9999)
self.assertIn('arg: foo', output)
self.assertIn('arg: bar', output)
self.assertIn('env: baz', output)
self.runCmd("setting set target.run-args foo")
self.runCmd("setting set target.env-vars bar=baz")
process = target.LaunchSimple(None, None,
self.get_process_working_directory())
self.runCmd("run")
output = process.GetSTDOUT(9999)
self.assertIn('arg: foo', output)
self.assertIn('env: bar=baz', output)
self.runCmd("settings set target.disable-stdio true")
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.runCmd("run")
output = process.GetSTDOUT(9999)
self.assertEqual(output, "")
def create_simple_target(self, fn):
exe = self.getBuildArtifact(fn)
target = self.dbg.CreateTarget(exe)