From: Steve MacLean Date: Thu, 18 Apr 2019 04:48:10 +0000 (-0400) Subject: Add MockCoreClrSanity test X-Git-Tag: submit/tizen/20210909.063632~11032^2~244^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f244ab52f228156ccab7c1acae837dd6e6f4647;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add MockCoreClrSanity test Commit migrated from https://github.com/dotnet/core-setup/commit/1d3f5515e8ba9321ca091f25f442efd1897cb3e4 --- diff --git a/src/installer/test/HostActivationTests/MockCoreClrSanity.cs b/src/installer/test/HostActivationTests/MockCoreClrSanity.cs new file mode 100644 index 0000000..73aaa3b --- /dev/null +++ b/src/installer/test/HostActivationTests/MockCoreClrSanity.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.DotNet.Cli.Build; +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using Xunit; + +namespace Microsoft.DotNet.CoreSetup.Test.HostActivation +{ + public class MockCoreClrSanity : IDisposable + { + private readonly DotNetCli DotNet; + + private readonly string _dotnetDir; + + public MockCoreClrSanity() + { + _dotnetDir = Path.Combine(TestArtifact.TestArtifactsPath, "mockCoreclrSanity"); + + DotNet = new DotNetBuilder(_dotnetDir, Path.Combine(TestArtifact.TestArtifactsPath, "sharedFrameworkPublish"), "exe") + .AddMicrosoftNETCoreAppFrameworkMockCoreClr("9999.0.0") + .Build(); + } + + public void Dispose() + { + if (!TestArtifact.PreserveTestRuns()) + { + Directory.Delete(_dotnetDir, true); + } + } + + [Fact] + public void Muxer_ListRuntimes() + { + DotNet.Exec("--list-runtimes") + .CaptureStdOut() + .CaptureStdErr() + .Execute() + .Should().Pass() + .And.HaveStdOutContaining("Microsoft.NETCore.App 9999.0.0"); + } + + [Fact] + public void Muxer_ExecAppSequence() + { + var appDll = typeof(MockCoreClrSanity).Assembly.Location; + char sep = Path.DirectorySeparatorChar; + + DotNet.Exec("--roll-forward-on-no-candidate-fx", "2", appDll, "argumentOne", "arg2") + .CaptureStdOut() + .CaptureStdErr() + .Execute() + .Should().Pass() + .And.HaveStdOutContaining("mock coreclr_initialize() called") + .And.HaveStdOutContaining("mock property[TRUSTED_PLATFORM_ASSEMBLIES]") + .And.HaveStdOutContaining($"Microsoft.NETCore.App{sep}9999.0.0{sep}Microsoft.NETCore.App.deps.json") + .And.HaveStdOutContaining("mock coreclr_execute_assembly() called") + .And.HaveStdOutContaining("mock argc:2") + .And.HaveStdOutContaining($"mock managedAssemblyPath:{appDll}") + .And.HaveStdOutContaining("mock argv[0] = argumentOne") + .And.HaveStdOutContaining("mock argv[1] = arg2") + .And.HaveStdOutContaining("mock coreclr_shutdown_2() called"); + } + } +}