From: Lakshan Fernando Date: Wed, 30 Sep 2020 19:24:35 +0000 (-0700) Subject: Test fixes for casing (#42879) X-Git-Tag: submit/tizen/20210909.063632~5265 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=957fdb9f966a041a394ad2a7840cbfdb9782fafe;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Test fixes for casing (#42879) Fixed #42334 --- diff --git a/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs b/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs index cdd33ce..63e305a 100644 --- a/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs +++ b/src/installer/tests/HostActivation.Tests/DependencyResolution/ResolveComponentDependencies.cs @@ -52,11 +52,14 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution [Fact] public void ComponentWithNoDependenciesCaseChangedOnAsm() { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Remove once https://github.com/dotnet/runtime/issues/42334 is resolved - return; - } + // Scenario: change the case of the first letter of component.AppDll file name + + // Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms + // Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly + // Linux: we fail + // Windows and Mac, probing succeeds but + // Windows: probing returns the original name + // Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file var component = sharedTestState.ComponentWithNoDependencies.Copy(); @@ -65,6 +68,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution string nameWOExtension = Path.GetFileNameWithoutExtension(fileName); string nameWOExtensionCaseChanged = (Char.IsUpper(nameWOExtension[0]) ? nameWOExtension[0].ToString().ToLower() : nameWOExtension[0].ToString().ToUpper()) + nameWOExtension.Substring(1); string changeFile = Path.Combine(Path.GetDirectoryName(fileName), (nameWOExtensionCaseChanged + Path.GetExtension(fileName))); + // on mac, hostpolicy returns the changed name for deps file as well + string changeDepsFile = Path.Combine(Path.GetDirectoryName(component.DepsJson), (nameWOExtensionCaseChanged + ".deps" + Path.GetExtension(component.DepsJson))); // Rename File.Move(fileName, changeFile); @@ -79,12 +84,22 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution .And.HaveStdErrContaining($"deps='{component.DepsJson}'") .And.HaveStdErrContaining($"mgd_app='{component.AppDll}'"); } + else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + sharedTestState.RunComponentResolutionTest(component) + .Should().Pass() + .And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success") + .And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]") + .And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'") + .And.HaveStdErrContaining($"deps='{changeDepsFile}'") + .And.HaveStdErrContaining($"mgd_app='{changeFile}'"); + } else { - // See https://github.com/dotnet/runtime/issues/42334 + // OSPlatform.Linux // We expect the test to fail due to the the case change of AppDll sharedTestState.RunComponentResolutionTest(component) - .Should().Pass() + .Should().Fail() .And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]"); } } @@ -92,11 +107,15 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution [Fact] public void ComponentWithNoDependenciesCaseChangedOnDepsAndAsm() { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Remove once https://github.com/dotnet/runtime/issues/42334 is resolved - return; - } + + // Scenario: change the case of the first letter of component.AppDll and component.DepsJson file names + + // Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms + // Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly + // Linux: we fail + // Windows and Mac, probing succeeds but + // Windows: probing returns the original name + // Mac: probing return the new name including 2 assembly probing with the same new name and the changed deps file var component = sharedTestState.ComponentWithNoDependencies.Copy(); @@ -122,12 +141,22 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution .And.HaveStdErrContaining($"deps='{component.DepsJson}'") .And.HaveStdErrContaining($"mgd_app='{component.AppDll}'"); } + else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + sharedTestState.RunComponentResolutionTest(component) + .Should().Pass() + .And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success") + .And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}{changeFile}{Path.PathSeparator}]") + .And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'") + .And.HaveStdErrContaining($"deps='{changeDepsFile}'") + .And.HaveStdErrContaining($"mgd_app='{changeFile}'"); + } else { - // See https://github.com/dotnet/runtime/issues/42334 + // OSPlatform.Linux // We expect the test to fail due to the the case change of AppDll sharedTestState.RunComponentResolutionTest(component) - .Should().Pass() + .Should().Fail() .And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]"); } } @@ -135,11 +164,15 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution [Fact] public void ComponentWithNoDependenciesNoDepsCaseChangedOnAsm() { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Remove once https://github.com/dotnet/runtime/issues/42334 is resolved - return; - } + + // Scenario: change the case of the first letter of component.AppDll file name and delete component.DepsJson file + + // Changing the casing of the first letter of a dependent assembly have different behavior in the 3 platforms + // Wisely the product code stays out of casing on dependent assemblies choosing the 1st assembly + // Linux: we fail + // Windows and Mac, probing succeeds but + // Windows: probing returns the original name + // Mac: probing return the new name including assembly probing with the new name and the changed deps file var component = sharedTestState.ComponentWithNoDependencies.Copy(); @@ -148,6 +181,8 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution string nameWOExtension = Path.GetFileNameWithoutExtension(fileName); string nameWOExtensionCaseChanged = (Char.IsUpper(nameWOExtension[0]) ? nameWOExtension[0].ToString().ToLower() : nameWOExtension[0].ToString().ToUpper()) + nameWOExtension.Substring(1); string changeFile = Path.Combine(Path.GetDirectoryName(fileName), (nameWOExtensionCaseChanged + Path.GetExtension(fileName))); + // on mac, hostpolicy returns the changed name for deps file as well + string changeDepsFile = Path.Combine(Path.GetDirectoryName(component.DepsJson), (nameWOExtensionCaseChanged + ".deps" + Path.GetExtension(component.DepsJson))); // Rename File.Move(fileName, changeFile); @@ -164,12 +199,22 @@ namespace Microsoft.DotNet.CoreSetup.Test.HostActivation.DependencyResolution .And.HaveStdErrContaining($"deps='{component.DepsJson}'") .And.HaveStdErrContaining($"mgd_app='{component.AppDll}'"); } + else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + sharedTestState.RunComponentResolutionTest(component) + .Should().Pass() + .And.HaveStdOutContaining("corehost_resolve_component_dependencies:Success") + .And.HaveStdOutContaining($"corehost_resolve_component_dependencies assemblies:[{changeFile}{Path.PathSeparator}]") + .And.HaveStdErrContaining($"app_root='{component.Location}{Path.DirectorySeparatorChar}'") + .And.HaveStdErrContaining($"deps='{changeDepsFile}'") + .And.HaveStdErrContaining($"mgd_app='{changeFile}'"); + } else { - // See https://github.com/dotnet/runtime/issues/42334 + // OSPlatform.Linux // We expect the test to fail due to the the case change of AppDll sharedTestState.RunComponentResolutionTest(component) - .Should().Pass() + .Should().Fail() .And.HaveStdErrContaining($"Failed to locate managed application [{component.AppDll}]"); } }