[Lldb-commits] [lldb] [lldb] Handle simulator printout in TestSimulatorPlatform (PR #189571)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 31 02:28:28 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Raphael Isemann (Teemperor)
<details>
<summary>Changes</summary>
This test invokes a binary in a simulator and then reads the first line of stderr to parse the PID of the invoked binary.
This approach fails when the simulator itself prints a warning/error on startup. In this case, we try to parse the error as the PID and fail.
This patch just removes the line limit. It doesn't seem to add any value as we anyway need to search until we find the PID line, and if there is no PID line we cannot do anything but time out eventually.
See also rdar://169799464
---
Full diff: https://github.com/llvm/llvm-project/pull/189571.diff
2 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/lldbutil.py (+15-13)
- (modified) lldb/test/API/macosx/simulator/TestSimulatorPlatform.py (-1)
``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 7f7cdde561702..e3d7506f0ff47 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1799,7 +1799,6 @@ def launch_exe_in_apple_simulator(
device_uuid,
exe_path,
exe_args=[],
- stderr_lines_to_read=0,
stderr_patterns=[],
log=None,
):
@@ -1823,18 +1822,21 @@ def launch_exe_in_apple_simulator(
total_patterns = len(stderr_patterns)
matches_found = 0
matched_strings = [None] * total_patterns
- for _ in range(0, stderr_lines_to_read):
- stderr = sim_launcher.stderr.readline().decode("utf-8")
- if not stderr:
- continue
- for i, pattern in enumerate(stderr_patterns):
- if matched_strings[i] is not None:
+ if len(stderr_patterns) != 0:
+ while True:
+ stderr = sim_launcher.stderr.readline().decode("utf-8")
+ if not stderr:
continue
- match = re.match(pattern, stderr)
- if match:
- matched_strings[i] = str(match.group(1))
- matches_found += 1
- if matches_found == total_patterns:
- break
+ if log:
+ log(f"searching stderr line: {stderr}")
+ for i, pattern in enumerate(stderr_patterns):
+ if matched_strings[i] is not None:
+ continue
+ match = re.match(pattern, stderr)
+ if match:
+ matched_strings[i] = str(match.group(1))
+ matches_found += 1
+ if matches_found == total_patterns:
+ break
return exe_path, matched_strings
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index b6f6368f6da80..216fb7c3032f3 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -97,7 +97,6 @@ def run_with(
device_udid,
self.getBuildArtifact("a.out"),
exe_args=[],
- stderr_lines_to_read=1, # in hello.cpp, the pid is printed first
stderr_patterns=[r"PID: (.*)"],
log=self.trace,
)
``````````
</details>
https://github.com/llvm/llvm-project/pull/189571
More information about the lldb-commits
mailing list