[Lldb-commits] [lldb] [lldb] Revive TestSimulatorPlatform.py (PR #142244)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 9 19:48:05 PDT 2025
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/142244
>From ff28c4be506dd762a4f8550a4a5a44578e34535d Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 3 Jun 2025 16:03:36 -0700
Subject: [PATCH 1/2] [lldb] Revive TestSimulatorPlatform.py
This test was incorrectly disabled and bitrotted since then. This PR
fixes up the test and re-enables it.
- Build against the system libc++ (which can target the simulator)
- Bump the deployment target for iOS and tvOS on Apple Silicon
- Skip backdeploying to pre-Apple Silicon OS on Apple Silicon.
---
.../Python/lldbsuite/test/decorators.py | 55 +++++++++++++++++--
.../macosx/simulator/TestSimulatorPlatform.py | 12 ++--
2 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 868e9f7e5eca0..7e9a19028c38e 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -9,6 +9,7 @@
import sys
import tempfile
import subprocess
+import json
# Third-party modules
import unittest
@@ -451,24 +452,68 @@ def apple_simulator_test(platform):
"""
Decorate the test as a test requiring a simulator for a specific platform.
- Consider that a simulator is available if you have the corresponding SDK installed.
- The SDK identifiers for simulators are iphonesimulator, appletvsimulator, watchsimulator
+ Consider that a simulator is available if you have the corresponding SDK
+ and runtime installed.
+
+ The SDK identifiers for simulators are iphonesimulator, appletvsimulator,
+ watchsimulator
"""
def should_skip_simulator_test():
if lldbplatformutil.getHostPlatform() not in ["darwin", "macosx"]:
return "simulator tests are run only on darwin hosts."
+
+ # Make sure we recognize the platform.
+ mapping = {
+ "iphone": "ios",
+ "appletv": "tvos",
+ "watch": "watchos",
+ }
+ if platform not in mapping:
+ return "unknown simulator platform: {}".format(platform)
+
+ # Make sure we have an SDK.
try:
output = subprocess.check_output(
["xcodebuild", "-showsdks"], stderr=subprocess.DEVNULL
).decode("utf-8")
- if re.search("%ssimulator" % platform, output):
- return None
- else:
+ if not re.search("%ssimulator" % platform, output):
return "%s simulator is not supported on this system." % platform
except subprocess.CalledProcessError:
return "Simulators are unsupported on this system (xcodebuild failed)"
+ # Make sure we a simulator runtime.
+ try:
+ sim_devices_str = subprocess.check_output(
+ ["xcrun", "simctl", "list", "-j", "devices"]
+ ).decode("utf-8")
+
+ sim_devices = json.loads(sim_devices_str)["devices"]
+ for simulator in sim_devices:
+
+ if isinstance(simulator, dict):
+ runtime = simulator["name"]
+ devices = simulator["devices"]
+ else:
+ runtime = simulator
+ devices = sim_devices[simulator]
+
+ if not mapping[platform] in runtime.lower():
+ continue
+
+ for device in devices:
+ if (
+ "availability" in device
+ and device["availability"] == "(available)"
+ ):
+ return None
+ if "isAvailable" in device and device["isAvailable"]:
+ return None
+
+ return "{} simulator is not supported on this system.".format(platform)
+ except (subprocess.CalledProcessError, json.decoder.JSONDecodeError):
+ return "Simulators are unsupported on this system (simctl failed)"
+
return skipTestIfFn(should_skip_simulator_test)
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index faf2256b03a0d..74ba0ee6c83bb 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -39,15 +39,15 @@ def check_debugserver(self, log, expected_platform, expected_version):
if expected_version:
self.assertEqual(aout_info["min_version_os_sdk"], expected_version)
- @skipIf(bugnumber="rdar://76995109")
def run_with(self, arch, os, vers, env, expected_load_command):
env_list = [env] if env else []
triple = "-".join([arch, "apple", os + vers] + env_list)
sdk = lldbutil.get_xcode_sdk(os, env)
- version_min = ""
if not vers:
vers = lldbutil.get_xcode_sdk_version(sdk)
+
+ version_min = ""
if env == "simulator":
version_min = "-m{}-simulator-version-min={}".format(os, vers)
elif os == "macosx":
@@ -56,11 +56,14 @@ def run_with(self, arch, os, vers, env, expected_load_command):
sdk_root = lldbutil.get_xcode_sdk_root(sdk)
clang = lldbutil.get_xcode_clang(sdk)
+ print(triple)
+
self.build(
dictionary={
"ARCH": arch,
"ARCH_CFLAGS": "-target {} {}".format(triple, version_min),
"SDKROOT": sdk_root,
+ "USE_SYSTEM_STDLIB": 1,
},
compiler=clang,
)
@@ -146,6 +149,7 @@ def test_watchos_armv7k(self):
@skipUnlessDarwin
@skipIfDarwinEmbedded
+ @skipIf(archs=["arm64", "arm64e"])
def test_lc_version_min_macosx(self):
"""Test running a back-deploying non-simulator MacOS X binary"""
self.run_with(
@@ -198,7 +202,7 @@ def test_ios_backdeploy_apple_silicon(self):
self.run_with(
arch=self.getArchitecture(),
os="ios",
- vers="11.0",
+ vers="14.0",
env="simulator",
expected_load_command="LC_BUILD_VERSION",
)
@@ -229,7 +233,7 @@ def test_tvos_backdeploy_apple_silicon(self):
self.run_with(
arch=self.getArchitecture(),
os="tvos",
- vers="11.0",
+ vers="14.0",
env="simulator",
expected_load_command="LC_BUILD_VERSION",
)
>From 963bb920b40646e21180974cfb650ae6181f3e92 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 9 Jun 2025 19:47:51 -0700
Subject: [PATCH 2/2] Formatting
---
lldb/packages/Python/lldbsuite/test/decorators.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 7e9a19028c38e..a391319ca9b0e 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -490,7 +490,6 @@ def should_skip_simulator_test():
sim_devices = json.loads(sim_devices_str)["devices"]
for simulator in sim_devices:
-
if isinstance(simulator, dict):
runtime = simulator["name"]
devices = simulator["devices"]
More information about the lldb-commits
mailing list