[Lldb-commits] [lldb] a7f495f - [lldb] Revive TestSimulatorPlatform.py (#142244)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 10 13:30:36 PDT 2025
Author: Jonas Devlieghere
Date: 2025-06-10T13:30:31-07:00
New Revision: a7f495f170864e6bddc4bb29ae7fae293a7136aa
URL: https://github.com/llvm/llvm-project/commit/a7f495f170864e6bddc4bb29ae7fae293a7136aa
DIFF: https://github.com/llvm/llvm-project/commit/a7f495f170864e6bddc4bb29ae7fae293a7136aa.diff
LOG: [lldb] Revive TestSimulatorPlatform.py (#142244)
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.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 868e9f7e5eca0..a391319ca9b0e 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,67 @@ 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",
)
More information about the lldb-commits
mailing list