[Lldb-commits] [lldb] [lldb][test] Bump safety timeout in simulator tests to fix flakyness (PR #209180)
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 13 06:35:25 PDT 2026
https://github.com/Teemperor created https://github.com/llvm/llvm-project/pull/209180
On really slow machines, the current 10 second timeout can expire and cause the test to randomly fail. Bump the timeout to 10 minutes which 60 times the current value and should be unreachable even on the slowest of machines.
To avoid making the tests run for 10 minutes, we now consistently kill the test process on shutdown using the subprocess list in lldbtest which gets killed on tearDown.
>From 33d6bd5687b836e5ccb69a9457cdb9c57e41c39b Mon Sep 17 00:00:00 2001
From: Raphael Isemann <rise at apple.com>
Date: Fri, 10 Jul 2026 10:07:18 +0100
Subject: [PATCH] [lldb][test] Bump safety timeout in simulator tests to fix
flakyness
On really slow machines, the current 10 second timeout can expire and
cause the test to randomly fail. Bump the timeout to 10 minutes which
60 times the current value and should be unreachable even on the
slowest of machines.
To avoid making the tests run for 10 minutes, we now consistently
kill the test process on shutdown using the subprocess list in
lldbtest which gets killed on tearDown.
---
lldb/packages/Python/lldbsuite/test/lldbutil.py | 14 +++++++++-----
.../API/macosx/simulator/TestSimulatorPlatform.py | 1 +
lldb/test/API/macosx/simulator/hello.cpp | 4 +++-
.../apple-simulator/TestAppleSimulatorOSType.py | 3 ++-
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 91f872bce3827..aa8ce2a52e7bb 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1824,6 +1824,7 @@ def get_latest_apple_simulator(platform_name, log=None):
def launch_exe_in_apple_simulator(
+ test,
device_uuid,
exe_path,
exe_args=[],
@@ -1831,17 +1832,20 @@ def launch_exe_in_apple_simulator(
log=None,
):
exe_path = os.path.realpath(exe_path)
- cmd = [
- "xcrun",
- "simctl",
+ # Resolve the path to simctl so we can launch it directly via spawnSubprocess.
+ simctl_path = (
+ subprocess.check_output(["xcrun", "-f", "simctl"]).decode("utf-8").strip()
+ )
+ args = [
"spawn",
"-s",
device_uuid,
exe_path,
] + exe_args
if log:
- log(" ".join(cmd))
- sim_launcher = subprocess.Popen(cmd, stderr=subprocess.PIPE)
+ log(simctl_path + " " + " ".join(args))
+ # simctl itself gets terminated when the test finishes.
+ sim_launcher = test.spawnSubprocess(simctl_path, args, stderr=subprocess.PIPE)
# Read stderr to try to find matches.
# Each pattern will return the value of group[1] of the first match in the stderr.
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index 7a888cacec44c..7a87db0940e32 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -76,6 +76,7 @@ def run_with(self, arch, os, vers, env, expected_platform=None):
expected_platform, self.trace
)
_, matched_strings = lldbutil.launch_exe_in_apple_simulator(
+ self,
device_udid,
self.getBuildArtifact("a.out"),
exe_args=[],
diff --git a/lldb/test/API/macosx/simulator/hello.cpp b/lldb/test/API/macosx/simulator/hello.cpp
index e202125da0929..e39afa2f1086d 100644
--- a/lldb/test/API/macosx/simulator/hello.cpp
+++ b/lldb/test/API/macosx/simulator/hello.cpp
@@ -4,7 +4,9 @@
static void print_pid() { fprintf(stderr, "PID: %d\n", getpid()); }
-static void sleep() { std::this_thread::sleep_for(std::chrono::seconds(10)); }
+// The test kills this process after the `platform process list` check, so this
+// sleep should never expire.
+static void sleep() { std::this_thread::sleep_for(std::chrono::seconds(600)); }
int main(int argc, char **argv) {
print_pid();
diff --git a/lldb/test/API/tools/lldb-server/apple-simulator/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/apple-simulator/TestAppleSimulatorOSType.py
index 9e59ffd5db6e2..814c0c81de369 100644
--- a/lldb/test/API/tools/lldb-server/apple-simulator/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/apple-simulator/TestAppleSimulatorOSType.py
@@ -53,9 +53,10 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
# Launch the executable in the simulator
exe_path, matched_groups = lldbutil.launch_exe_in_apple_simulator(
+ self,
deviceUDID,
self.getBuildArtifact(exe_name),
- ["print-pid", "sleep:10"],
+ ["print-pid", "sleep:600"],
[r"PID: (.*)"],
self.trace,
)
More information about the lldb-commits
mailing list