Fix SOS unit tests dump generation fixture (#4636)
authorMike McLaughlin <mikem@microsoft.com>
Wed, 24 Apr 2024 06:56:34 +0000 (23:56 -0700)
committerGitHub <noreply@github.com>
Wed, 24 Apr 2024 06:56:34 +0000 (23:56 -0700)
eng/Versions.props
src/SOS/SOS.UnitTests/ConfigFiles/Windows/Debugger.Tests.Config.txt
src/SOS/SOS.UnitTests/DumpGenerationFixture.cs

index bf2bab28bf1420aafe2a77aeca3fd4fa875164fb..b1c1e61a6664a38b720dbeb0a2b659bfa023407d 100644 (file)
   </PropertyGroup>
   <ItemGroup Condition="!$(InternalReleaseTesting)">
     <RuntimeTestVersions Include="Latest">
-      <!--
       <RuntimeDownload>$(VSRedistCommonNetCoreSharedFrameworkx6490Version)</RuntimeDownload>
       <Runtime>$(MicrosoftNETCoreAppRuntimewinx64Version)</Runtime>
       <AspNetDownload>$(MicrosoftAspNetCoreAppRefInternalVersion)</AspNetDownload>
       <AspNet>$(MicrosoftAspNetCoreAppRefVersion)</AspNet>
--->
-      <RuntimeDownload>9.0.0-preview.4.24218.7</RuntimeDownload>
-      <Runtime>9.0.0-preview.4.24218.7</Runtime>
-      <AspNetDownload>9.0.0-preview.4.24218.1</AspNetDownload>
-      <AspNet>9.0.0-preview.4.24218.1</AspNet>
       <TargetFramework>net9.0</TargetFramework>
     </RuntimeTestVersions>
     <RuntimeTestVersions Include="Servicing1">
index 012780602ce0c5d71d58c03a8717a90de40bf131..7a46c13e08a116ef179af54733dfcf6e7680e386 100644 (file)
@@ -21,6 +21,7 @@
   <LogDir>$(RootBinDir)\TestResults\$(TargetConfiguration)\sos.unittests_$(Timestamp)</LogDir>
   <DumpDir>$(RootBinDir)\tmp\$(TargetConfiguration)\dumps</DumpDir>
   <CDBHelperExtension>$(InstallDir)\runcommand.dll</CDBHelperExtension>
+  <MicrosoftNETCoreAppPath>$(DotNetRoot)\shared\Microsoft.NETCore.App\</MicrosoftNETCoreAppPath>
 
   <SetHostExe>true</SetHostExe>
   <SetFxVersion>true</SetFxVersion>
index 6eef51886a64b7ebf50feb9a16c6d878509424f7..f4c80e063bae09d40bae4f8cc505f2921891195b 100644 (file)
@@ -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<string> 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)
-            {
             }
         }
     }