-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb] Revive TestSimulatorPlatform.py #142244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesThis test was incorrectly disabled. Reviving it and removing the checks for LC_VERSION_MIN_FOO as more recent Xcode's don't have the necessary simulator runtimes. Full diff: https://github.com/llvm/llvm-project/pull/142244.diff 1 Files Affected:
diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
index faf2256b03a0d..af12bd16a22a4 100644
--- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -8,21 +8,6 @@
class TestSimulatorPlatformLaunching(TestBase):
NO_DEBUG_INFO_TESTCASE = True
- def check_load_commands(self, expected_load_command):
- """sanity check the built binary for the expected number of load commands"""
- load_cmds = subprocess.check_output(
- ["otool", "-l", self.getBuildArtifact()]
- ).decode("utf-8")
- found = 0
- for line in load_cmds.split("\n"):
- if expected_load_command in line:
- found += 1
- self.assertEqual(
- found,
- 1,
- "wrong number of load commands for {}".format(expected_load_command),
- )
-
def check_debugserver(self, log, expected_platform, expected_version):
"""scan the debugserver packet log"""
process_info = lldbutil.packetlog_get_process_info(log)
@@ -39,8 +24,7 @@ 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):
+ def run_with(self, arch, os, vers, env):
env_list = [env] if env else []
triple = "-".join([arch, "apple", os + vers] + env_list)
sdk = lldbutil.get_xcode_sdk(os, env)
@@ -61,11 +45,11 @@ def run_with(self, arch, os, vers, env, expected_load_command):
"ARCH": arch,
"ARCH_CFLAGS": "-target {} {}".format(triple, version_min),
"SDKROOT": sdk_root,
+ "USE_SYSTEM_STDLIB": 1,
},
compiler=clang,
)
- self.check_load_commands(expected_load_command)
log = self.getBuildArtifact("packets.log")
self.expect("log enable gdb-remote packets -f " + log)
lldbutil.run_to_source_breakpoint(
@@ -86,7 +70,6 @@ def test_ios(self):
os="ios",
vers="",
env="simulator",
- expected_load_command="LC_BUILD_VERSION",
)
@skipIfAsan
@@ -94,29 +77,25 @@ def test_ios(self):
@skipIfDarwinEmbedded
@apple_simulator_test("appletv")
def test_tvos(self):
- """Test running an tvOS simulator binary"""
+ """Test running a tvOS simulator binary"""
self.run_with(
arch=self.getArchitecture(),
os="tvos",
vers="",
env="simulator",
- expected_load_command="LC_BUILD_VERSION",
)
@skipIfAsan
@skipUnlessDarwin
@skipIfDarwinEmbedded
- @apple_simulator_test("watch")
- @skipIfDarwin # rdar://problem/64552748
- @skipIf(archs=["arm64", "arm64e"])
- def test_watchos_i386(self):
- """Test running a 32-bit watchOS simulator binary"""
+ @apple_simulator_test("appletv")
+ def test_watchos(self):
+ """Test running a watchOS simulator binary"""
self.run_with(
- arch="i386",
+ arch=self.getArchitecture(),
os="watchos",
vers="",
env="simulator",
- expected_load_command="LC_BUILD_VERSION",
)
@skipIfAsan
@@ -124,145 +103,27 @@ def test_watchos_i386(self):
@skipIfDarwinEmbedded
@apple_simulator_test("watch")
@skipIfDarwin # rdar://problem/64552748
- @skipIf(archs=["i386", "x86_64"])
- def test_watchos_armv7k(self):
- """Test running a 32-bit watchOS simulator binary"""
- self.run_with(
- arch="armv7k",
- os="watchos",
- vers="",
- env="simulator",
- expected_load_command="LC_BUILD_VERSION",
- )
-
- #
- # Back-deployment tests.
- #
- # Older Mach-O versions used less expressive load commands, such
- # as LC_VERSION_MIN_IPHONEOS that wouldn't distinguish between ios
- # and ios-simulator. When targeting a simulator on Apple Silicon
- # macOS, however, these legacy load commands are never generated.
- #
-
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- def test_lc_version_min_macosx(self):
- """Test running a back-deploying non-simulator MacOS X binary"""
- self.run_with(
- arch=self.getArchitecture(),
- os="macosx",
- vers="10.9",
- env="",
- expected_load_command="LC_VERSION_MIN_MACOSX",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("iphone")
- @skipIf(archs=["arm64", "arm64e"])
- def test_lc_version_min_iphoneos(self):
- """Test running a back-deploying iOS simulator binary
- with a legacy iOS load command"""
- self.run_with(
- arch=self.getArchitecture(),
- os="ios",
- vers="11.0",
- env="simulator",
- expected_load_command="LC_VERSION_MIN_IPHONEOS",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("iphone")
@skipIf(archs=["arm64", "arm64e"])
- def test_ios_backdeploy_x86(self):
- """Test running a back-deploying iOS simulator binary
- with a legacy iOS load command"""
- self.run_with(
- arch=self.getArchitecture(),
- os="ios",
- vers="13.0",
- env="simulator",
- expected_load_command="LC_BUILD_VERSION",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("iphone")
- @skipIf(archs=["i386", "x86_64"])
- def test_ios_backdeploy_apple_silicon(self):
- """Test running a back-deploying iOS simulator binary"""
- self.run_with(
- arch=self.getArchitecture(),
- os="ios",
- vers="11.0",
- env="simulator",
- expected_load_command="LC_BUILD_VERSION",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("appletv")
- @skipIf(archs=["arm64", "arm64e"])
- def test_lc_version_min_tvos(self):
- """Test running a back-deploying tvOS simulator binary
- with a legacy tvOS load command"""
- self.run_with(
- arch=self.getArchitecture(),
- os="tvos",
- vers="11.0",
- env="simulator",
- expected_load_command="LC_VERSION_MIN_TVOS",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("appletv")
- @skipIf(archs=["i386", "x86_64"])
- def test_tvos_backdeploy_apple_silicon(self):
- """Test running a back-deploying tvOS simulator binary"""
- self.run_with(
- arch=self.getArchitecture(),
- os="tvos",
- vers="11.0",
- env="simulator",
- expected_load_command="LC_BUILD_VERSION",
- )
-
- @skipIfAsan
- @skipUnlessDarwin
- @skipIfDarwinEmbedded
- @apple_simulator_test("watch")
- @skipIf(archs=["arm64", "arm64e"])
- @skipIfDarwin # rdar://problem/64552748
- def test_lc_version_min_watchos(self):
- """Test running a back-deploying watchOS simulator binary
- with a legacy watchOS load command"""
+ def test_watchos_i386(self):
+ """Test running a 32-bit watchOS simulator binary"""
self.run_with(
arch="i386",
os="watchos",
- vers="4.0",
+ vers="",
env="simulator",
- expected_load_command="LC_VERSION_MIN_WATCHOS",
)
@skipIfAsan
@skipUnlessDarwin
@skipIfDarwinEmbedded
@apple_simulator_test("watch")
- @skipIf(archs=["arm64", "arm64e"])
@skipIfDarwin # rdar://problem/64552748
- def test_watchos_backdeploy_apple_silicon(self):
- """Test running a back-deploying watchOS simulator binary"""
+ @skipIf(archs=["i386", "x86_64"])
+ def test_watchos_armv7k(self):
+ """Test running a 32-bit watchOS simulator binary"""
self.run_with(
arch="armv7k",
os="watchos",
- vers="4.0",
+ vers="",
env="simulator",
- expected_load_command="LC_BUILD_VERSION",
)
|
306fde5
to
7d8d697
Compare
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(triple) | |
if self.TraceOn(): | |
print(triple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can go altogether, this was a leftover debug statement and not particularly helpful in general.
Thanks for making this change, @JDevlieghere. I appreciate it. -- FWIW, the tvOS tests fails on my macOS machine with the following error (full log):
I think this is because I don't have the "tvOS" component installed in Xcode (hence no tvOS simulator). If this is indeed the root cause, then it seems to me the test should skip by observing the unavailability of the tvOS simulator. LMK if that makes sense. |
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version 11 here is (I believe) significant. Prior to 12 there was no x86_64-apple-ios-simulator
triple, instead simulator binaries used load commands that produced a x86_64-apple-ios
triple, which was assumed to mean simulator, due to the combination of x86
and iOS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple silicon and/or macCatalyst made the dedicated -simulator
environment (and matching load commands) necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept 11.0 for the non-Apple Silicon test. On AS it's not possible to test this as the linker automatically upgrades to the first supported AS version (14.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but that's the arm64 test, so this is fine!
Yes, |
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but that's the arm64 test, so this is fine!
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.
7d8d697
to
ff28c4b
Compare
You can test this locally with the following command:darker --check --diff -r HEAD~1...HEAD lldb/packages/Python/lldbsuite/test/decorators.py lldb/test/API/macosx/simulator/TestSimulatorPlatform.py View the diff from darker here.--- packages/Python/lldbsuite/test/decorators.py 2025-06-04 21:49:00.000000 +0000
+++ packages/Python/lldbsuite/test/decorators.py 2025-06-04 21:51:21.354077 +0000
@@ -488,11 +488,10 @@
["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
|
This test was incorrectly disabled and bitrotted since then. This PR
fixes up the test and re-enables it.