Add MockCoreClrSanity test
authorSteve MacLean <Steve.MacLean@Microsoft.com>
Thu, 18 Apr 2019 04:48:10 +0000 (00:48 -0400)
committerSteve MacLean <Steve.MacLean@Microsoft.com>
Thu, 18 Apr 2019 21:52:49 +0000 (17:52 -0400)
Commit migrated from https://github.com/dotnet/core-setup/commit/1d3f5515e8ba9321ca091f25f442efd1897cb3e4

src/installer/test/HostActivationTests/MockCoreClrSanity.cs [new file with mode: 0644]

diff --git a/src/installer/test/HostActivationTests/MockCoreClrSanity.cs b/src/installer/test/HostActivationTests/MockCoreClrSanity.cs
new file mode 100644 (file)
index 0000000..73aaa3b
--- /dev/null
@@ -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");
+        }
+    }
+}