Add C library detection to processinfo3 test (#88260)
authorJustin Anderson <jander-msft@users.noreply.github.com>
Mon, 10 Jul 2023 20:17:10 +0000 (13:17 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2023 20:17:10 +0000 (16:17 -0400)
src/tests/tracing/eventpipe/processinfo3/processinfo3.cs

index a65760e..d288ead 100644 (file)
@@ -288,7 +288,29 @@ namespace Tracing.Tests.ProcessInfoValidation
             }
             else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
             {
-                expectedPortableRidOs = "linux";
+                // Check process modules for C library type indication to determine
+                // which linux RID OS is applicable.
+                Logger.logger.Log("Begin checking process modules to determine C library type.");
+                for (int i = 0; i < currentProcess.Modules.Count; i++)
+                {
+                    ProcessModule module = currentProcess.Modules[i];
+                    Logger.logger.Log($"- {module.ModuleName}");
+
+                    if (module.ModuleName.StartsWith("libc.", StringComparison.Ordinal) ||
+                        module.ModuleName.StartsWith("libc-", StringComparison.Ordinal))
+                    {
+                        Logger.logger.Log("Found gnu libc indicator.");
+                        expectedPortableRidOs = "linux";
+                        break;
+                    }
+                    else if (module.ModuleName.StartsWith("ld-musl-", StringComparison.Ordinal))
+                    {
+                        Logger.logger.Log("Found musl libc indicator.");
+                        expectedPortableRidOs = "linux-musl";
+                        break;
+                    }
+                }
+                Logger.logger.Log("Finished checking process modules.");
             }
             
             Utils.Assert(!string.IsNullOrEmpty(expectedPortableRidOs), $"Unable to calculate expected portable RID OS.");