Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/tests/tracing/userevents/activity/activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public static int Main(string[] args)
return UserEventsTestRunner.Run(
args,
"activity",
typeof(Activity).Assembly.Location,
ActivityTracee,
s_traceValidator);
}
Expand Down
1 change: 0 additions & 1 deletion src/tests/tracing/userevents/basic/basic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static int Main(string[] args)
return UserEventsTestRunner.Run(
args,
"basic",
typeof(Basic).Assembly.Location,
BasicTracee,
s_traceValidator);
}
Expand Down
21 changes: 13 additions & 8 deletions src/tests/tracing/userevents/common/UserEventsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class UserEventsTestRunner
public static int Run(
string[] args,
string scenarioName,
string traceeAssemblyPath,
Action traceeAction,
Func<EventPipeEventSource, bool> traceValidator,
int traceeExitTimeout = DefaultTraceeExitTimeoutMs,
Expand All @@ -46,20 +45,21 @@ public static int Run(

return RunOrchestrator(
scenarioName,
traceeAssemblyPath,
traceValidator,
traceeExitTimeout,
recordTraceExitTimeout);
}

private static int RunOrchestrator(
string scenarioName,
string traceeAssemblyPath,
Func<EventPipeEventSource, bool> traceValidator,
int traceeExitTimeout,
int recordTraceExitTimeout)
{
string userEventsScenarioDir = Path.GetDirectoryName(traceeAssemblyPath);
// Use AppContext.BaseDirectory which works consistently for both CoreCLR and NativeAOT.
// For CoreCLR: .../tracing/userevents/<scenario>/<scenario>/
// For NativeAOT: .../tracing/userevents/<scenario>/<scenario>/ (even though exe is in native/ subdirectory)
string userEventsScenarioDir = AppContext.BaseDirectory;
string recordTracePath = ResolveRecordTracePath(userEventsScenarioDir);
string scriptFilePath = Path.Combine(userEventsScenarioDir, $"{scenarioName}.script");

Expand Down Expand Up @@ -115,8 +115,8 @@ private static int RunOrchestrator(
Console.WriteLine($"record-trace started with PID: {recordTraceProcess.Id}");

ProcessStartInfo traceeStartInfo = new();
traceeStartInfo.FileName = Process.GetCurrentProcess().MainModule!.FileName;
traceeStartInfo.Arguments = $"{traceeAssemblyPath} tracee";
traceeStartInfo.FileName = Environment.ProcessPath!;
traceeStartInfo.Arguments = "tracee";
traceeStartInfo.WorkingDirectory = userEventsScenarioDir;
traceeStartInfo.RedirectStandardOutput = true;
traceeStartInfo.RedirectStandardError = true;
Expand All @@ -125,6 +125,10 @@ private static int RunOrchestrator(
string diagnosticPortDir = "/tmp";
traceeStartInfo.Environment["TMPDIR"] = diagnosticPortDir;

// Note: record-trace uses perfmap/doublemapper to discover .NET process PIDs and their diagnostic ports.
// NativeAOT apps do not use doublemapping, so they will not be discovered by record-trace even with TMPDIR set.
// See https://github.com/microsoft/one-collect/issues/226 for details.

// TMPDIR is configured on Helix, but the diagnostic port is created outside of Helix's default temp datadisk path.
// The diagnostic port should be automatically cleaned up when the tracee shuts down, but zombie sockets can be left
// behind after catastrophic exits. Clean them before launching the tracee to avoid deleting sockets from a reused PID.
Expand Down Expand Up @@ -198,9 +202,10 @@ private static int RunOrchestrator(

private static string ResolveRecordTracePath(string userEventsScenarioDir)
{
// scenario dir: .../tracing/userevents/<scenario>/<scenario>
// userEventsScenarioDir is AppContext.BaseDirectory, which points to:
// .../tracing/userevents/<scenario>/<scenario>/
// Navigate up two directories to reach userevents root, then into common/userevents_common
string usereventsRoot = Path.GetFullPath(Path.Combine(userEventsScenarioDir, "..", ".."));
// common dir: .../tracing/userevents/common/userevents_common
string commonDir = Path.Combine(usereventsRoot, "common", "userevents_common");
string recordTracePath = Path.Combine(commonDir, "record-trace");
return recordTracePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public static int Main(string[] args)
return UserEventsTestRunner.Run(
args,
"custommetadata",
typeof(CustomMetadata).Assembly.Location,
CustomMetadataTracee,
s_traceValidator);
}
Expand Down
1 change: 0 additions & 1 deletion src/tests/tracing/userevents/managedevent/managedevent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static int Main(string[] args)
return UserEventsTestRunner.Run(
args,
"managedevent",
typeof(ManagedEvent).Assembly.Location,
ManagedEventTracee,
s_traceValidator);
}
Expand Down
1 change: 0 additions & 1 deletion src/tests/tracing/userevents/multithread/multithread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static int Main(string[] args)
return UserEventsTestRunner.Run(
args,
"multithread",
typeof(MultiThread).Assembly.Location,
MultiThreadTracee,
s_traceValidator);
}
Expand Down
Loading