From 9a173dfdae7909589c12a543de2e272cde014367 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 9 Apr 2026 10:31:08 +0100 Subject: [PATCH 1/2] [lldb] Handle simulator printout in TestSimulatorPlatform (#189571) 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 (cherry picked from commit 918e446ef28ac97df20d6ef2bd50c78e2fe903ac) --- .../Python/lldbsuite/test/lldbutil.py | 28 ++++++++++--------- .../macosx/simulator/TestSimulatorPlatform.py | 1 - 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py index 26d949ffbf5e4..f086124e0cf3e 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -1883,7 +1883,6 @@ def launch_exe_in_apple_simulator( device_uuid, exe_path, exe_args=[], - stderr_lines_to_read=0, stderr_patterns=[], log=None, ): @@ -1907,19 +1906,22 @@ 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 b17ee83ea04fe..865b8cd87f6ec 100644 --- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py +++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py @@ -96,7 +96,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, ) From 855225d5417eea47948ac892ba3bc3cca85ac552 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 9 Apr 2026 14:37:11 +0100 Subject: [PATCH 2/2] [lldb][test] Fix call signature in TestAppleSimulatorOSType (#191185) Commit 918e446ef28ac97df20d6ef2bd50c78e2fe903ac removed the stderr_lines_to_read argument but didn't adjust the call site in TestAppleSimulatorOSType. This patch just removes the extra arg here too. (cherry picked from commit 93845b8ef4790a853068706200d417ef3184a098) --- lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py index 4fee27823f1fa..b901feefa09ad 100644 --- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py +++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py @@ -10,8 +10,6 @@ class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase): - # Number of stderr lines to read from the simctl output. - READ_LINES = 10 def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()): # Get simulator @@ -56,7 +54,6 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()): deviceUDID, self.getBuildArtifact(exe_name), ["print-pid", "sleep:10"], - self.READ_LINES, [r"PID: (.*)"], self.trace, )