Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SimulatorLoader : ISimulatorLoader
public SimulatorLoader(IMlaunchProcessManager processManager, ISimulatorSelector? simulatorSelector = null)
{
_processManager = processManager ?? throw new ArgumentNullException(nameof(processManager));
_simulatorSelector = simulatorSelector ?? new DefaultSimulatorSelector();
_simulatorSelector = simulatorSelector ?? new DefaultSimulatorSelector(processManager);
}

public async Task LoadDevices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.XHarness.iOS.Shared.Execution;

namespace Microsoft.DotNet.XHarness.iOS.Shared.Hardware;

Expand All @@ -20,6 +21,13 @@ public interface ISimulatorSelector

public class DefaultSimulatorSelector : ISimulatorSelector
{
private readonly IMlaunchProcessManager? _processManager;

public DefaultSimulatorSelector(IMlaunchProcessManager? processManager = null)
{
_processManager = processManager;
}

public virtual string GetRuntimePrefix(TestTargetOs target)
{
return target.Platform switch
Expand All @@ -36,7 +44,7 @@ public virtual string GetDeviceType(TestTargetOs target, bool minVersion)
{
return target.Platform switch
{
TestTarget.Simulator_iOS64 => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-XS"),
TestTarget.Simulator_iOS64 => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : GetDefaultiOSDevice()),
TestTarget.Simulator_tvOS => "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p",
TestTarget.Simulator_watchOS => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "Apple-Watch-38mm" : "Apple-Watch-Series-3-38mm"),
TestTarget.Simulator_xrOS => "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro",
Expand All @@ -49,7 +57,7 @@ public virtual void GetCompanionRuntimeAndDeviceType(TestTargetOs target, bool m
if (target.Platform == TestTarget.Simulator_watchOS)
{
companionRuntime = "com.apple.CoreSimulator.SimRuntime.iOS-" + (minVersion ? SdkVersions.MinWatchOSCompanionSimulator : SdkVersions.MaxWatchOSCompanionSimulator).Replace('.', '-');
companionDeviceType = "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : "iPhone-XS");
companionDeviceType = "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "iPhone-6s" : GetDefaultiOSDevice());
}
else
{
Expand All @@ -63,4 +71,15 @@ public ISimulatorDevice SelectSimulator(IEnumerable<ISimulatorDevice> simulators
// Put Booted/Booting in front of Shutdown/Unknown
return simulators.OrderByDescending(s => s.State).First();
}

private string GetDefaultiOSDevice()
{
// iPhone 16 is available in Xcode 16+, use iPhone XS for older versions
// If XcodeVersion is not available (null process manager or version), default to iPhone-XS for backward compatibility
if (_processManager?.XcodeVersion?.Major >= 16)
{
return "iPhone-16";
}
return "iPhone-XS";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ public class DefaultSimulatorSelectorTests
{
private readonly Mock<IMlaunchProcessManager> _processManager;
private readonly Mock<ITCCDatabase> _tccDatabase;
private readonly DefaultSimulatorSelector _simulatorSelector;

public DefaultSimulatorSelectorTests()
{
_processManager = new Mock<IMlaunchProcessManager>();
_tccDatabase = new Mock<ITCCDatabase>();
_simulatorSelector = new DefaultSimulatorSelector();
}

[Fact]
public void SelectSimulatorTest()
{
var simulatorSelector = new DefaultSimulatorSelector();
var simulator1 = new SimulatorDevice(_processManager.Object, _tccDatabase.Object)
{
Name = "Simulator 1",
Expand All @@ -46,9 +45,63 @@ public void SelectSimulatorTest()
State = DeviceState.Booting,
};

var simulator = _simulatorSelector.SelectSimulator(new[] { simulator1, simulator2, simulator3 });
var simulator = simulatorSelector.SelectSimulator(new[] { simulator1, simulator2, simulator3 });

// The Booted one
Assert.Equal(simulator2, simulator);
}

[Theory]
[InlineData(TestTarget.Simulator_iOS64, false, 16, "com.apple.CoreSimulator.SimDeviceType.iPhone-16")]
[InlineData(TestTarget.Simulator_iOS64, false, 15, "com.apple.CoreSimulator.SimDeviceType.iPhone-XS")]
[InlineData(TestTarget.Simulator_iOS64, true, 16, "com.apple.CoreSimulator.SimDeviceType.iPhone-6s")]
[InlineData(TestTarget.Simulator_iOS64, true, 15, "com.apple.CoreSimulator.SimDeviceType.iPhone-6s")]
[InlineData(TestTarget.Simulator_tvOS, false, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p")]
[InlineData(TestTarget.Simulator_tvOS, true, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p")]
[InlineData(TestTarget.Simulator_watchOS, false, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm")]
[InlineData(TestTarget.Simulator_watchOS, true, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm")]
[InlineData(TestTarget.Simulator_xrOS, false, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro")]
[InlineData(TestTarget.Simulator_xrOS, true, 16, "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro")]
public void GetDeviceTypeTest(TestTarget target, bool minVersion, int xcodeMajorVersion, string expectedDeviceType)
{
_processManager.SetupGet(p => p.XcodeVersion).Returns(new System.Version(xcodeMajorVersion, 0));
var simulatorSelector = new DefaultSimulatorSelector(_processManager.Object);
var deviceType = simulatorSelector.GetDeviceType(new TestTargetOs(target, null), minVersion);
Assert.Equal(expectedDeviceType, deviceType);
}

[Fact]
public void GetDeviceTypeWithoutProcessManagerTest()
{
// When no process manager is provided, should default to iPhone-XS for backward compatibility
var simulatorSelector = new DefaultSimulatorSelector();
var deviceType = simulatorSelector.GetDeviceType(new TestTargetOs(TestTarget.Simulator_iOS64, null), false);
Assert.Equal("com.apple.CoreSimulator.SimDeviceType.iPhone-XS", deviceType);
}

[Theory]
[InlineData(TestTarget.Simulator_watchOS, false, 16, "com.apple.CoreSimulator.SimDeviceType.iPhone-16")]
[InlineData(TestTarget.Simulator_watchOS, false, 15, "com.apple.CoreSimulator.SimDeviceType.iPhone-XS")]
[InlineData(TestTarget.Simulator_watchOS, true, 16, "com.apple.CoreSimulator.SimDeviceType.iPhone-6s")]
[InlineData(TestTarget.Simulator_watchOS, true, 15, "com.apple.CoreSimulator.SimDeviceType.iPhone-6s")]
public void GetCompanionDeviceTypeTest(TestTarget target, bool minVersion, int xcodeMajorVersion, string expectedDeviceType)
{
_processManager.SetupGet(p => p.XcodeVersion).Returns(new System.Version(xcodeMajorVersion, 0));
var simulatorSelector = new DefaultSimulatorSelector(_processManager.Object);
simulatorSelector.GetCompanionRuntimeAndDeviceType(new TestTargetOs(target, null), minVersion, out var companionRuntime, out var companionDeviceType);
Assert.NotNull(companionRuntime);
Assert.Equal(expectedDeviceType, companionDeviceType);
}

[Theory]
[InlineData(TestTarget.Simulator_iOS64)]
[InlineData(TestTarget.Simulator_tvOS)]
[InlineData(TestTarget.Simulator_xrOS)]
public void GetCompanionDeviceTypeNonWatchTest(TestTarget target)
{
var simulatorSelector = new DefaultSimulatorSelector();
simulatorSelector.GetCompanionRuntimeAndDeviceType(new TestTargetOs(target, null), false, out var companionRuntime, out var companionDeviceType);
Assert.Null(companionRuntime);
Assert.Null(companionDeviceType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public SimulatorLoaderTests()
{
_executionLog = new Mock<ILog>();
_processManager = new Mock<IMlaunchProcessManager>();
// Setup default Xcode version for tests - use Xcode 15 to test backward compatibility
_processManager.SetupGet(p => p.XcodeVersion).Returns(new Version(15, 0));
_simulatorLoader = new SimulatorLoader(_processManager.Object);
}

Expand Down Expand Up @@ -113,7 +115,7 @@ public async Task LoadAsyncProcessSuccess()
MlaunchArgument outputFormatArg = passedArguments.Where(a => a is XmlOutputFormatArgument).FirstOrDefault();
Assert.NotNull(outputFormatArg);

Assert.Equal(76, _simulatorLoader.AvailableDevices.Count());
Assert.Equal(77, _simulatorLoader.AvailableDevices.Count());
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<Version>393473</Version>
</SimRuntime>
</SupportedRuntimes>
<SupportedDeviceTypes Count="50">
<SupportedDeviceTypes Count="51">
<SimDeviceType>
<Name>iPhone 4s</Name>
<Identifier>com.apple.CoreSimulator.SimDeviceType.iPhone-4s</Identifier>
Expand Down Expand Up @@ -202,6 +202,14 @@
<MaxRuntimeVersion>4294967295</MaxRuntimeVersion>
<Supports64Bits>true</Supports64Bits>
</SimDeviceType>
<SimDeviceType>
<Name>iPhone 16</Name>
<Identifier>com.apple.CoreSimulator.SimDeviceType.iPhone-16</Identifier>
<ProductFamilyId>IPhone</ProductFamilyId>
<MinRuntimeVersion>851968</MinRuntimeVersion>
<MaxRuntimeVersion>4294967295</MaxRuntimeVersion>
<Supports64Bits>true</Supports64Bits>
</SimDeviceType>
<SimDeviceType>
<Name>iPad 2</Name>
<Identifier>com.apple.CoreSimulator.SimDeviceType.iPad-2</Identifier>
Expand Down Expand Up @@ -451,7 +459,7 @@
<Supports64Bits>false</Supports64Bits>
</SimDeviceType>
</SupportedDeviceTypes>
<AvailableDevices Count="75">
<AvailableDevices Count="77">
<SimDevice UDID="B0CF5BA5-318E-4FC8-8FC1-FB82D9F2FB42" Name="iPhone 5">
<SimRuntime>com.apple.CoreSimulator.SimRuntime.iOS-10-3</SimRuntime>
<SimDeviceType>com.apple.CoreSimulator.SimDeviceType.iPhone-5</SimDeviceType>
Expand Down Expand Up @@ -716,12 +724,18 @@
<DataPath>/Users/mandel/Library/Developer/CoreSimulator/Devices/18F485DC-7F0A-440F-BEF9-5BE5954B0FB1</DataPath>
<LogPath>/Users/mandel/Library/Logs/CoreSimulator/18F485DC-7F0A-440F-BEF9-5BE5954B0FB1</LogPath>
</SimDevice>
<SimDevice UDID="336E1D83-AB00-4FAE-A70D-C516D269B90A" Name="iPhone Xs (iOS {{MAX-IOS.VERSION}}) - created by xharness">
<SimDevice UDID="336E1D83-AB00-4FAE-A70D-C516D269B90A" Name="iPhone 16 (iOS {{MAX-IOS.VERSION}}) - created by xharness">
<SimRuntime>com.apple.CoreSimulator.SimRuntime.iOS-{{MAX-IOS-VERSION}}</SimRuntime>
<SimDeviceType>com.apple.CoreSimulator.SimDeviceType.iPhone-XS</SimDeviceType>
<SimDeviceType>com.apple.CoreSimulator.SimDeviceType.iPhone-16</SimDeviceType>
<DataPath>/Users/mandel/Library/Developer/CoreSimulator/Devices/336E1D83-AB00-4FAE-A70D-C516D269B90A</DataPath>
<LogPath>/Users/mandel/Library/Logs/CoreSimulator/336E1D83-AB00-4FAE-A70D-C516D269B90A</LogPath>
</SimDevice>
<SimDevice UDID="E9914E48-7A63-493D-B7AA-D7AD90F0E999" Name="iPhone Xs (iOS {{MAX-IOS.VERSION}}) - created by xharness">
<SimRuntime>com.apple.CoreSimulator.SimRuntime.iOS-{{MAX-IOS-VERSION}}</SimRuntime>
<SimDeviceType>com.apple.CoreSimulator.SimDeviceType.iPhone-XS</SimDeviceType>
<DataPath>/Users/mandel/Library/Developer/CoreSimulator/Devices/E9914E48-7A63-493D-B7AA-D7AD90F0E999</DataPath>
<LogPath>/Users/mandel/Library/Logs/CoreSimulator/E9914E48-7A63-493D-B7AA-D7AD90F0E999</LogPath>
</SimDevice>
<SimDevice UDID="ABC2A44A-789D-4C8B-88A7-0CD7C6BF316C" Name="iPhone 11">
<SimRuntime>com.apple.CoreSimulator.SimRuntime.iOS-{{MAX-IOS-VERSION}}</SimRuntime>
<SimDeviceType>com.apple.CoreSimulator.SimDeviceType.iPhone-11</SimDeviceType>
Expand Down Expand Up @@ -909,7 +923,7 @@
<LogPath>/Users/mandel/Library/Logs/CoreSimulator/77F07B96-D2E4-4F04-B958-B68E2FBCC2ED</LogPath>
</SimDevice>
</AvailableDevices>
<AvailableDevicePairs Count="4">
<AvailableDevicePairs Count="6">
<SimDevicePair UDID="91AD462B-4179-40E3-A367-6D4A63F68432">
<Companion>62992D4C-C669-4C51-AAD4-1877891EC26B</Companion>
<Gizmo>F00FA51A-D353-4DD0-9631-FBAE0CE79D0F</Gizmo>
Expand All @@ -922,6 +936,10 @@
<Companion>336E1D83-AB00-4FAE-A70D-C516D269B90A</Companion>
<Gizmo>BB2F9CF0-A928-4909-867A-525A937D7390</Gizmo>
</SimDevicePair>
<SimDevicePair UDID="E9914E48-7A63-493D-B7AA-D7AD90F0E998">
<Companion>E9914E48-7A63-493D-B7AA-D7AD90F0E999</Companion>
<Gizmo>BB2F9CF0-A928-4909-867A-525A937D7390</Gizmo>
</SimDevicePair>
<SimDevicePair UDID="59E9A82D-89C7-4456-AE2C-FECB01899CD6">
<Companion>1840A231-2033-42A6-AEB4-B223235A2707</Companion>
<Gizmo>9B798995-5A29-45E1-BF89-6D29BB2864D3</Gizmo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<ItemGroup>
<!-- Adjust to the desired souting queue. -->
<HelixTargetQueue Include="osx.amd64.iphone.scouting.open"/>
<HelixTargetQueue Include="osx.26.arm64.open"/>
</ItemGroup>

<PropertyGroup>
<!--
Change to specify the exact Xcode version for testing.
In the CustomCommands below we can probe installed Xcode versions on Helix with `ls -al /Applications` and then choosing the write path.
-->
<XcodeVersionUnderTest>Xcode_16_beta_6</XcodeVersionUnderTest>
<iOSSimulatorVersionUnderTest>18.0</iOSSimulatorVersionUnderTest>
<XcodeVersionUnderTest>Xcode_26.0.1</XcodeVersionUnderTest>
<iOSSimulatorVersionUnderTest>26.0</iOSSimulatorVersionUnderTest>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -37,6 +37,7 @@
<LaunchTimeout>00:03:30</LaunchTimeout>
<CustomCommands>
<![CDATA[
ls -al /Applications
set -ex
xharness apple simulators install $target --verbosity=Debug --xcode /Applications/$(XcodeVersionUnderTest).app
xharness apple simulators reset-simulator --output-directory="$output_directory" --target=$target --verbosity=Debug --xcode /Applications/$(XcodeVersionUnderTest).app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk">

<ItemGroup>
<HelixTargetQueue Include="osx.amd64.scouting.open"/>
<HelixTargetQueue Include="osx.26.arm64.open"/>

<!-- apple test / ios-simulator-64 -->
<XHarnessAppleProject Include="TestAppBundle.proj">
Expand Down
1 change: 1 addition & 0 deletions tests/integration-tests/Apple/Simulator.Tests.proj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.DotNet.Helix.Sdk">

<ItemGroup>
<HelixTargetQueue Include="osx.26.arm64.open"/>
<HelixTargetQueue Include="osx.15.amd64.open"/>
<HelixTargetQueue Include="osx.14.arm64.open"/>

Expand Down
4 changes: 2 additions & 2 deletions tools/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ fi

export BUILD_REASON="dev"
export BUILD_REPOSITORY_NAME="xharness"
export BUILD_SOURCEBRANCH="master"
export BUILD_SOURCEBRANCH="main"
export SYSTEM_TEAMPROJECT="dnceng"
export SYSTEM_ACCESSTOKEN=""

highlight "> Starting tests (logging to XHarness.binlog)"
"$repo_root/build.sh" -configuration Debug -restore -test -projects "$test_project" /p:RestoreUsingNugetTargets=false /bl:./XHarness.binlog
"$repo_root/build.sh" -configuration Debug -restore -test -projects "$test_project" /p:RestoreUsingNugetTargets=false /bl:./XHarness.binlog -verbosity:diag
Loading