[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.
This commit is contained in:
committed by
GitHub
parent
94877ce1b4
commit
a7f495f170
@@ -9,6 +9,7 @@ import re
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -39,15 +39,15 @@ class TestSimulatorPlatformLaunching(TestBase):
|
||||
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 @@ class TestSimulatorPlatformLaunching(TestBase):
|
||||
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 @@ class TestSimulatorPlatformLaunching(TestBase):
|
||||
|
||||
@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 @@ class TestSimulatorPlatformLaunching(TestBase):
|
||||
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 @@ class TestSimulatorPlatformLaunching(TestBase):
|
||||
self.run_with(
|
||||
arch=self.getArchitecture(),
|
||||
os="tvos",
|
||||
vers="11.0",
|
||||
vers="14.0",
|
||||
env="simulator",
|
||||
expected_load_command="LC_BUILD_VERSION",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user