diff --git a/decoded_output.xml b/decoded_output.xml new file mode 100644 index 000000000..e69de29bb diff --git a/src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs b/src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs index e2e94d048..41187e4d6 100644 --- a/src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs +++ b/src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs @@ -178,9 +178,14 @@ protected async Task RunSimulatorApp( _mainLog.WriteLine("Launching the app"); + // Create an application log to capture mlaunch output (including simctl launch --console output) + // This is needed for exit code detection, as the app exit code (e.g., DOTNET.APP_EXIT_CODE) + // is printed to stdout by the simulator and captured by mlaunch + var appOutputLog = _logs.Create(appInformation.BundleIdentifier + ".log", LogType.ApplicationLog.ToString(), timestamp: true); + if (waitForExit) { - var result = await _processManager.ExecuteCommandAsync(mlaunchArguments, _mainLog, timeout, cancellationToken: cancellationToken); + var result = await _processManager.ExecuteCommandAsync(mlaunchArguments, _mainLog, appOutputLog, appOutputLog, timeout, cancellationToken: cancellationToken); simulatorScanToken?.Cancel(); return result; } @@ -194,7 +199,7 @@ protected async Task RunSimulatorApp( _mainLog.WriteLine("Waiting for the app to launch.."); - var runTask = _processManager.ExecuteCommandAsync(mlaunchArguments, Log.CreateAggregatedLog(_mainLog, scanLog), timeout, cancellationToken: cancellationToken); + var runTask = _processManager.ExecuteCommandAsync(mlaunchArguments, Log.CreateAggregatedLog(_mainLog, scanLog), appOutputLog, appOutputLog, timeout, cancellationToken: cancellationToken); await Task.WhenAny(runTask, appLaunched.Task); if (!appLaunched.Task.IsCompleted) diff --git a/src/Microsoft.DotNet.XHarness.iOS.Shared/Hardware/SimulatorSelector.cs b/src/Microsoft.DotNet.XHarness.iOS.Shared/Hardware/SimulatorSelector.cs index dfe7a78d4..50a5e760f 100644 --- a/src/Microsoft.DotNet.XHarness.iOS.Shared/Hardware/SimulatorSelector.cs +++ b/src/Microsoft.DotNet.XHarness.iOS.Shared/Hardware/SimulatorSelector.cs @@ -36,9 +36,9 @@ 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" : "iPhone-11-Pro"), 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_watchOS => "com.apple.CoreSimulator.SimDeviceType." + (minVersion ? "Apple-Watch-38mm" : "Apple-Watch-Series-5-40mm"), TestTarget.Simulator_xrOS => "com.apple.CoreSimulator.SimDeviceType.Apple-Vision-Pro", _ => throw new Exception(string.Format("Invalid simulator target: {0}", target)) }; @@ -49,7 +49,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" : "iPhone-11-Pro"); } else { diff --git a/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppRunnerTests.cs b/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppRunnerTests.cs index 578be6a6f..a33a28c7a 100644 --- a/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppRunnerTests.cs +++ b/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppRunnerTests.cs @@ -69,6 +69,8 @@ public async Task RunOnSimulatorTest() x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), @@ -431,11 +433,13 @@ public async Task RunOnSimulatorNoWaitTest() x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Callback((MlaunchArguments args, ILog log, TimeSpan timeout, Dictionary env, int verbosity, CancellationToken? ct) => + .Callback((MlaunchArguments args, ILog log, ILog stdoutLog, ILog stderrLog, TimeSpan timeout, Dictionary env, int verbosity, CancellationToken? ct) => { appLog = log; appLaunchedTask.SetResult(); @@ -485,6 +489,8 @@ public async Task RunOnSimulatorNoWaitTest() x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), @@ -534,11 +540,13 @@ public async Task RunOnSimulatorNoWaitNoLaunchSignalTest() x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) - .Callback((MlaunchArguments args, ILog log, TimeSpan timeout, Dictionary env, int verbosity, CancellationToken? ct) => + .Callback((MlaunchArguments args, ILog log, ILog stdoutLog, ILog stderrLog, TimeSpan timeout, Dictionary env, int verbosity, CancellationToken? ct) => { appLaunchedTask.SetResult(); }) @@ -589,6 +597,8 @@ public async Task RunOnSimulatorNoWaitNoLaunchSignalTest() x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), It.IsAny(), + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), diff --git a/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppTesterTests.cs b/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppTesterTests.cs index 31990ae00..e3c937585 100644 --- a/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppTesterTests.cs +++ b/tests/Microsoft.DotNet.XHarness.Apple.Tests/AppOperations/AppTesterTests.cs @@ -129,6 +129,8 @@ public async Task TestOnSimulatorTest(bool useTunnel) x => x.ExecuteCommandAsync( It.Is(args => args.AsCommandLine() == expectedArgs), _mainLog.Object, + It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny(), diff --git a/tests/integration-tests/Apple/Device.iOS.Tests.proj b/tests/integration-tests/Apple/Device.iOS.Tests.proj index 268b618d7..928e2b23c 100644 --- a/tests/integration-tests/Apple/Device.iOS.Tests.proj +++ b/tests/integration-tests/Apple/Device.iOS.Tests.proj @@ -5,12 +5,12 @@ - TestTarget=ios-device;TestAppBundleName=System.Buffers.Tests.app + TestTarget=ios-device;TestArch=arm64;TestAppBundleName=System.Buffers.Tests.app - TestTarget=ios-device;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 + TestTarget=ios-device;TestArch=arm64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 diff --git a/tests/integration-tests/Apple/Device.tvOS.Tests.proj b/tests/integration-tests/Apple/Device.tvOS.Tests.proj index f122a0fd9..ac20f2d9b 100644 --- a/tests/integration-tests/Apple/Device.tvOS.Tests.proj +++ b/tests/integration-tests/Apple/Device.tvOS.Tests.proj @@ -5,12 +5,12 @@ - TestTarget=tvos-device;TestAppBundleName=System.Buffers.Tests.app + TestTarget=tvos-device;TestArch=arm64;TestAppBundleName=System.Buffers.Tests.app - TestTarget=tvos-device;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 + TestTarget=tvos-device;TestArch=arm64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 diff --git a/tests/integration-tests/Apple/Simulator.Tests.proj b/tests/integration-tests/Apple/Simulator.Tests.proj index 087d1f92d..e9dea7650 100644 --- a/tests/integration-tests/Apple/Simulator.Tests.proj +++ b/tests/integration-tests/Apple/Simulator.Tests.proj @@ -1,32 +1,45 @@ + + + $(HelixTargetQueue.Contains('arm64')) + $(HelixTargetQueue.Contains('amd64')) + arm64 + x64 + + + + + + - + - TestTarget=ios-simulator-64;TestAppBundleName=System.Numerics.Vectors.Tests.app + TestTarget=ios-simulator-64;TestArch=$(TestArch);TestAppBundleName=System.Numerics.Vectors.Tests.app - TestTarget=ios-simulator-64;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 + TestTarget=ios-simulator-64;TestArch=$(TestArch);TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 - TestTarget=maccatalyst;TestAppBundleName=System.Collections.NonGeneric.Tests.app + TestTarget=maccatalyst;TestArch=$(TestArch);TestAppBundleName=System.Collections.NonGeneric.Tests.app - TestTarget=maccatalyst;TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 + TestTarget=maccatalyst;TestArch=$(TestArch);TestAppBundleName=iOS.Simulator.PInvoke.Test.app;IncludesTestRunner=false;ExpectedExitCode=42 - TestTarget=tvos-simulator;TestAppBundleName=Microsoft.Extensions.Configuration.Ini.Tests.app + TestTarget=tvos-simulator;TestArch=$(TestArch);TestAppBundleName=Microsoft.Extensions.Configuration.Ini.Tests.app diff --git a/tests/integration-tests/Apple/TestAppBundle.proj b/tests/integration-tests/Apple/TestAppBundle.proj index c28668355..2674d64f0 100644 --- a/tests/integration-tests/Apple/TestAppBundle.proj +++ b/tests/integration-tests/Apple/TestAppBundle.proj @@ -13,9 +13,9 @@ - $(AssetsBaseUri)/ios/test-app-new/$(TestTarget) + $(AssetsBaseUri)/ios/test-app-new/$(TestTarget)/$(TestArch) $(AppStorageUrl)/$(TestAppBundleName).zip - $(ArtifactsTmpDir)test-app-new\$(TestTarget) + $(ArtifactsTmpDir)test-app-new\$(TestTarget)\$(TestArch) @@ -23,6 +23,10 @@ +