Skip to content

Commit dfa3252

Browse files
committed
[lldb] Fix API test for file redirection to existing files
1 parent 8a0cb9a commit dfa3252

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

lldb/test/API/python_api/process/io/TestProcessIO.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,45 @@ def test_stdout_stderr_redirection(self):
9999
@expectedFlakeyLinux(bugnumber="llvm.org/pr26437")
100100
@skipIfDarwinEmbedded # debugserver can't create/write files on the device
101101
def test_stdout_stderr_redirection_to_existing_files(self):
102-
"""Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN to output files already exist."""
102+
"""Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR redirect to output files already exist."""
103103
self.setup_test()
104104
self.build()
105105
self.create_target()
106-
self.write_file_with_placeholder(self.output_file)
107-
self.write_file_with_placeholder(self.error_file)
108-
self.redirect_stdout()
109-
self.redirect_stderr()
110-
self.run_process(True)
111-
output = self.read_output_file_and_delete()
112-
error = self.read_error_file_and_delete()
113-
self.check_process_output(output, error)
114106

115-
def write_file_with_placeholder(self, target_file):
107+
# Create the output and error files with placeholder
116108
placeholder = "This content should be overwritten."
117109
if lldb.remote_platform:
110+
f = open(self.local_output_file, "w")
111+
f.write(placeholder)
112+
f.close()
113+
114+
f = open(self.local_error_file, "w")
115+
f.write(placeholder)
116+
f.close()
117+
self.runCmd(
118+
'platform put-file "{local}" "{remote}"'.format(
119+
local=self.local_output_file, remote=self.output_file
120+
)
121+
)
118122
self.runCmd(
119-
'platform file write "{target}" -d "{data}"'.format(
120-
target=target_file, data=placeholder
123+
'platform put-file "{local}" "{remote}"'.format(
124+
local=self.local_error_file, remote=self.error_file
121125
)
122126
)
123127
else:
124-
f = open(target_file, "w")
128+
f = open(self.output_file, "w")
129+
f.write(placeholder)
130+
f.close()
131+
f = open(self.error_file, "w")
125132
f.write(placeholder)
126133
f.close()
134+
135+
self.redirect_stdout()
136+
self.redirect_stderr()
137+
self.run_process(True)
138+
output = self.read_output_file_and_delete()
139+
error = self.read_error_file_and_delete()
140+
self.check_process_output(output, error)
127141

128142
# target_file - path on local file system or remote file system if running remote
129143
# local_file - path on local system

0 commit comments

Comments
 (0)