From: Mike McLaughlin Date: Thu, 8 Apr 2021 23:37:38 +0000 (-0700) Subject: Add single-file app SOS testing Part I (#2153) X-Git-Tag: submit/tizen/20210909.063632~17^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8e50b3a2d647b841380dc0b12805e8912e7f8ec;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Add single-file app SOS testing Part I (#2153) This PR gets ready for single-file app testing, but doesn't add the app yet because the current SDK can't build them and the new SDKs break building the cli built debuggees. Also works around that the DAC GetPEFileName()/GetAssemblyName() APIs don't return the module or assembly name. --- diff --git a/src/Microsoft.Diagnostics.TestHelpers/BaseDebuggeeCompiler.cs b/src/Microsoft.Diagnostics.TestHelpers/BaseDebuggeeCompiler.cs index 64ec40158..8545164c6 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/BaseDebuggeeCompiler.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/BaseDebuggeeCompiler.cs @@ -151,7 +151,7 @@ namespace Microsoft.Diagnostics.TestHelpers protected virtual string GetDebuggeeBinaryDirPath(string debuggeeProjectDirPath, string framework, string runtime) { - string debuggeeBinaryDirPath = null; + string debuggeeBinaryDirPath; if (runtime != null) { debuggeeBinaryDirPath = Path.Combine(debuggeeProjectDirPath, "bin", "Debug", framework, runtime); @@ -163,14 +163,14 @@ namespace Microsoft.Diagnostics.TestHelpers return debuggeeBinaryDirPath; } - protected static string GetDebuggeeBinaryDllPath(string debuggeeBinaryDirPath, string debuggeeName) + protected static string GetDebuggeeBinaryDllPath(TestConfiguration config, string debuggeeBinaryDirPath, string debuggeeName) { - return Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".dll"); + return config.IsNETCore ? Path.Combine(debuggeeBinaryDirPath, debuggeeName + (config.PublishSingleFile ? "" : ".dll")) : null; } - protected static string GetDebuggeeBinaryExePath(string debuggeeBinaryDirPath, string debuggeeName) + protected static string GetDebuggeeBinaryExePath(TestConfiguration config, string debuggeeBinaryDirPath, string debuggeeName) { - return Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".exe"); + return config.IsDesktop ? Path.Combine(debuggeeBinaryDirPath, debuggeeName + ".exe") : null; } protected static string GetLogPath(TestConfiguration config, string framework, string runtime, string debuggeeName) diff --git a/src/Microsoft.Diagnostics.TestHelpers/CliDebuggeeCompiler.cs b/src/Microsoft.Diagnostics.TestHelpers/CliDebuggeeCompiler.cs index 62ca520a7..e51c3be9d 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/CliDebuggeeCompiler.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/CliDebuggeeCompiler.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; +using System.Diagnostics; using System.IO; namespace Microsoft.Diagnostics.TestHelpers @@ -33,6 +34,11 @@ namespace Microsoft.Diagnostics.TestHelpers { buildProperties.Add("RuntimeIdentifier", runtimeIdentifier); } + if (config.PublishSingleFile) + { + Debug.Assert(runtimeIdentifier != null); + buildProperties.Add("PublishSingleFile", "true"); + } string debugType = config.DebugType; if (debugType == null) { @@ -64,8 +70,8 @@ namespace Microsoft.Diagnostics.TestHelpers string debuggeeSolutionDirPath = GetDebuggeeSolutionDirPath(dotNetRootBuildDirPath, debuggeeName); string debuggeeProjectDirPath = GetDebuggeeProjectDirPath(debuggeeSolutionDirPath, initialSourceDirPath, debuggeeName); string debuggeeBinaryDirPath = GetDebuggeeBinaryDirPath(debuggeeProjectDirPath, framework, runtimeIdentifier); - string debuggeeBinaryDllPath = config.IsNETCore ? GetDebuggeeBinaryDllPath(debuggeeBinaryDirPath, debuggeeName) : null; - string debuggeeBinaryExePath = config.IsDesktop ? GetDebuggeeBinaryExePath(debuggeeBinaryDirPath, debuggeeName) : null; + string debuggeeBinaryDllPath = GetDebuggeeBinaryDllPath(config, debuggeeBinaryDirPath, debuggeeName); + string debuggeeBinaryExePath = GetDebuggeeBinaryExePath(config, debuggeeBinaryDirPath, debuggeeName); string logPath = GetLogPath(config, framework, runtimeIdentifier, debuggeeName); return new CsprojBuildDebuggeeTestStep(dotNetPath, initialSourceDirPath, diff --git a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs index f78930fe0..c5bb7ee9a 100644 --- a/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs +++ b/src/Microsoft.Diagnostics.TestHelpers/TestConfiguration.cs @@ -629,6 +629,14 @@ namespace Microsoft.Diagnostics.TestHelpers get { return GetValue("BuildProjectRuntime"); } } + /// + /// Returns "true" if build/run this cli debuggee as a single-file app + /// + public bool PublishSingleFile + { + get { return string.Equals(GetValue("PublishSingleFile"), "true", StringComparison.InvariantCultureIgnoreCase); } + } + /// /// The version of the Microsoft.NETCore.App package to reference when running the debuggee (i.e. /// using the dotnet cli --fx-version option). @@ -711,7 +719,7 @@ namespace Microsoft.Diagnostics.TestHelpers /// public bool LogToConsole { - get { return bool.TryParse(GetValue("LogToConsole"), out bool b) && b; } + get { return string.Equals(GetValue("LogToConsole"), "true", StringComparison.InvariantCultureIgnoreCase); } } /// diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt index c1bd8d982..60c10ec77 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Unix/Debugger.Tests.Config.txt @@ -34,7 +34,7 @@ false - net5.0 + net6.0 net5.0 netcoreapp3.1 netcoreapp2.1 @@ -45,8 +45,9 @@ $(DotNetRoot)/dotnet - myget.org dotnet-core=https://dotnet.myget.org/F/dotnet-core/api/v3/index.json; - nuget.org=https://www.nuget.org/api/v2/ + dotnet6=https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet6/nuget/v3/index.json; + dotnet-core=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; + dotnet-public=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json @@ -73,7 +74,7 @@ $(DotNetRoot)/shared/Microsoft.NETCore.App/$(RuntimeFrameworkVersion)