Skip to content

Commit e40d6e1

Browse files
authored
Add C library detection to processinfo3 test (#88260)
1 parent 89d6fd5 commit e40d6e1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/tests/tracing/eventpipe/processinfo3/processinfo3.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,29 @@ public static int Main()
288288
}
289289
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
290290
{
291-
expectedPortableRidOs = "linux";
291+
// Check process modules for C library type indication to determine
292+
// which linux RID OS is applicable.
293+
Logger.logger.Log("Begin checking process modules to determine C library type.");
294+
for (int i = 0; i < currentProcess.Modules.Count; i++)
295+
{
296+
ProcessModule module = currentProcess.Modules[i];
297+
Logger.logger.Log($"- {module.ModuleName}");
298+
299+
if (module.ModuleName.StartsWith("libc.", StringComparison.Ordinal) ||
300+
module.ModuleName.StartsWith("libc-", StringComparison.Ordinal))
301+
{
302+
Logger.logger.Log("Found gnu libc indicator.");
303+
expectedPortableRidOs = "linux";
304+
break;
305+
}
306+
else if (module.ModuleName.StartsWith("ld-musl-", StringComparison.Ordinal))
307+
{
308+
Logger.logger.Log("Found musl libc indicator.");
309+
expectedPortableRidOs = "linux-musl";
310+
break;
311+
}
312+
}
313+
Logger.logger.Log("Finished checking process modules.");
292314
}
293315

294316
Utils.Assert(!string.IsNullOrEmpty(expectedPortableRidOs), $"Unable to calculate expected portable RID OS.");

0 commit comments

Comments
 (0)