Skip to content

Commit 1a25b72

Browse files
authored
[lldb] Fixed the test TestPlatformProcessLaunch running on a remote target (llvm#91923)
Transfer `stdio.log` from the remote target if necessary.
1 parent 25a3ba3 commit 1a25b72

File tree

1 file changed

+46
-44
lines changed

1 file changed

+46
-44
lines changed

lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
from textwrap import dedent
6+
from lldbsuite.test import lldbutil
67
from lldbsuite.test.lldbtest import TestBase
78

89

@@ -11,28 +12,29 @@ class ProcessLaunchTestCase(TestBase):
1112

1213
def setup(self):
1314
self.build()
14-
exe = self.getBuildArtifact("a.out")
15-
self.runCmd("file " + exe)
16-
return (exe, self.getBuildArtifact("stdio.log"))
15+
self.runCmd("file " + self.getBuildArtifact("a.out"))
16+
exe = lldbutil.append_to_process_working_directory(self, "a.out")
17+
outfile = lldbutil.append_to_process_working_directory(self, "stdio.log")
18+
return (exe, outfile)
1719

1820
def test_process_launch_no_args(self):
1921
# When there are no extra arguments we just have 0, the program name.
2022
exe, outfile = self.setup()
2123
self.runCmd("platform process launch --stdout {} -s".format(outfile))
2224
self.runCmd("continue")
2325

24-
with open(outfile) as f:
25-
self.assertEqual(
26-
dedent(
27-
"""\
28-
Got 1 argument(s).
29-
[0]: {}
30-
""".format(
31-
exe
32-
)
33-
),
34-
f.read(),
35-
)
26+
stdio_log = lldbutil.read_file_on_target(self, outfile)
27+
self.assertEqual(
28+
dedent(
29+
"""\
30+
Got 1 argument(s).
31+
[0]: {}
32+
""".format(
33+
exe
34+
)
35+
),
36+
stdio_log,
37+
)
3638

3739
def test_process_launch_command_args(self):
3840
exe, outfile = self.setup()
@@ -41,21 +43,21 @@ def test_process_launch_command_args(self):
4143
self.runCmd("platform process launch --stdout {} -s -- A B C".format(outfile))
4244
self.runCmd("continue")
4345

44-
with open(outfile) as f:
45-
self.assertEqual(
46-
dedent(
47-
"""\
48-
Got 4 argument(s).
49-
[0]: {}
50-
[1]: A
51-
[2]: B
52-
[3]: C
53-
""".format(
54-
exe
55-
)
56-
),
57-
f.read(),
58-
)
46+
stdio_log = lldbutil.read_file_on_target(self, outfile)
47+
self.assertEqual(
48+
dedent(
49+
"""\
50+
Got 4 argument(s).
51+
[0]: {}
52+
[1]: A
53+
[2]: B
54+
[3]: C
55+
""".format(
56+
exe
57+
)
58+
),
59+
stdio_log,
60+
)
5961

6062
def test_process_launch_target_args(self):
6163
exe, outfile = self.setup()
@@ -64,17 +66,17 @@ def test_process_launch_target_args(self):
6466
self.runCmd("platform process launch --stdout {} -s".format(outfile))
6567
self.runCmd("continue")
6668

67-
with open(outfile) as f:
68-
self.assertEqual(
69-
dedent(
70-
"""\
71-
Got 3 argument(s).
72-
[0]: {}
73-
[1]: D
74-
[2]: E
75-
""".format(
76-
exe
77-
)
78-
),
79-
f.read(),
80-
)
69+
stdio_log = lldbutil.read_file_on_target(self, outfile)
70+
self.assertEqual(
71+
dedent(
72+
"""\
73+
Got 3 argument(s).
74+
[0]: {}
75+
[1]: D
76+
[2]: E
77+
""".format(
78+
exe
79+
)
80+
),
81+
stdio_log,
82+
)

0 commit comments

Comments
 (0)