From: Mike McLaughlin Date: Wed, 24 Apr 2024 06:56:34 +0000 (-0700) Subject: Fix SOS unit tests dump generation fixture (#4636) X-Git-Tag: accepted/tizen/unified/20241231.014852~40^2~94 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=592039f9ede5cfe8e4baa42405e6a5099e6a562e;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix SOS unit tests dump generation fixture (#4636) --- diff --git a/eng/Versions.props b/eng/Versions.props index bf2bab28b..b1c1e61a6 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -119,16 +119,10 @@ - - 9.0.0-preview.4.24218.7 - 9.0.0-preview.4.24218.7 - 9.0.0-preview.4.24218.1 - 9.0.0-preview.4.24218.1 net9.0 diff --git a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt index 012780602..7a46c13e0 100644 --- a/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt +++ b/src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt @@ -21,6 +21,7 @@ $(RootBinDir)\TestResults\$(TargetConfiguration)\sos.unittests_$(Timestamp) $(RootBinDir)\tmp\$(TargetConfiguration)\dumps $(InstallDir)\runcommand.dll + $(DotNetRoot)\shared\Microsoft.NETCore.App\ true true diff --git a/src/SOS/SOS.UnitTests/DumpGenerationFixture.cs b/src/SOS/SOS.UnitTests/DumpGenerationFixture.cs index 6eef51886..f4c80e063 100644 --- a/src/SOS/SOS.UnitTests/DumpGenerationFixture.cs +++ b/src/SOS/SOS.UnitTests/DumpGenerationFixture.cs @@ -34,39 +34,56 @@ public class DumpGenerationFixture : IDisposable { } - // Create a unique list of all the runtime paths used by the tests + // Create a unique list of all the installed test runtime paths HashSet paths = new(); foreach (TestConfiguration config in TestRunConfiguration.Instance.Configurations) { - if (config.IsNETCore && config.RuntimeFrameworkVersionMajor >= 8) + // Enumerate configs until we see this property + if (config.AllSettings.TryGetValue("MicrosoftNETCoreAppPath", out string path)) { - string path = config.RuntimeSymbolsPath; if (!string.IsNullOrEmpty(path)) { - paths.Add(path); + path = TestConfiguration.MakeCanonicalPath(path); + try + { + foreach (string directory in Directory.GetDirectories(path)) + { + if (Path.GetFileName(directory).StartsWith("9")) + { + paths.Add(directory); + } + } + } + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) + { + } + break; } } } - // Now try to create the keys for the older Windows versions - try + if (paths.Count > 0) { - using RegistryKey auxiliaryKey = Registry.LocalMachine.CreateSubKey(_auxiliaryNode, writable: true); - using RegistryKey knownKey = Registry.LocalMachine.CreateSubKey(_knownNode, writable: true); + // Now try to create the keys for the older Windows versions + try + { + using RegistryKey auxiliaryKey = Registry.LocalMachine.CreateSubKey(_auxiliaryNode, writable: true); + using RegistryKey knownKey = Registry.LocalMachine.CreateSubKey(_knownNode, writable: true); - foreach (string path in paths) + foreach (string path in paths) + { + string dacPath = Path.Combine(path, "mscordaccore.dll"); + string runtimePath = Path.Combine(path, "coreclr.dll"); + knownKey.SetValue(dacPath, 0, RegistryValueKind.DWord); + auxiliaryKey.SetValue(runtimePath, dacPath, RegistryValueKind.String); + } + + // Save the paths after writing them successfully to registry + _paths = paths; + } + catch (Exception ex) when (ex is UnauthorizedAccessException) { - string dacPath = Path.Combine(path, "mscordaccore.dll"); - string runtimePath = Path.Combine(path, "coreclr.dll"); - knownKey.SetValue(dacPath, 0, RegistryValueKind.DWord); - auxiliaryKey.SetValue(runtimePath, dacPath, RegistryValueKind.String); } - - // Save the paths after writing them successfully to registry - _paths = paths; - } - catch (Exception ex) when (ex is UnauthorizedAccessException) - { } } }