Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loader][tests] Add more logging to pinpoint BinderTracingTests hang #104982

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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: 1 addition & 0 deletions src/tests/Loader/binding/tracing/BinderEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public BindOperation[] WaitAndGetEventsForAssembly(AssemblyName assemblyName)
}
}

Console.WriteLine($"Waiting for bind events for {assemblyName.Name} ({timeWaitedInMs}ms waited) Sleeping for {waitIntervalInMs}ms");
Thread.Sleep(waitIntervalInMs);
timeWaitedInMs += waitIntervalInMs;

Expand Down
4 changes: 4 additions & 0 deletions src/tests/Loader/binding/tracing/BinderTracingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private static bool RunSingleTest(MethodInfo method)
Func<BindOperation> func = (Func<BindOperation>)method.CreateDelegate(typeof(Func<BindOperation>));
using (var listener = new BinderEventListener(loadsToTrack))
{
Console.WriteLine($"[{DateTime.Now:T}] Invoking {method.Name}...");
BindOperation expected = func();
ValidateSingleBind(listener, expected.AssemblyName, expected);
}
Expand All @@ -182,6 +183,7 @@ private static bool RunSingleTest(MethodInfo method)
return false;
}

Console.WriteLine($"Test {method.Name} finished.");
return true;
}

Expand All @@ -197,6 +199,7 @@ private static bool RunTestInSeparateProcess(MethodInfo method)
Console.WriteLine($"[{DateTime.Now:T}] Launching process for {method.Name}...");
using (Process p = Process.Start(startInfo))
{
Console.WriteLine($"Started subprocess {p.Id} for {method.Name}...");
p.OutputDataReceived += (_, args) => Console.WriteLine(args.Data);
p.BeginOutputReadLine();

Expand All @@ -210,6 +213,7 @@ private static bool RunTestInSeparateProcess(MethodInfo method)

private static void ValidateSingleBind(BinderEventListener listener, AssemblyName assemblyName, BindOperation expected)
{
Console.WriteLine($"[{DateTime.Now:T}] Validating bind operation for {assemblyName}...");
BindOperation[] binds = listener.WaitAndGetEventsForAssembly(assemblyName);
Assert.True(binds.Length == 1, $"Bind event count for {assemblyName} - expected: 1, actual: {binds.Length}");
BindOperation actual = binds[0];
Expand Down
2 changes: 2 additions & 0 deletions src/tests/Loader/binding/tracing/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class Helpers
{
public static void ValidateBindOperation(BindOperation expected, BindOperation actual)
{
Console.WriteLine("ValidateBindOperation Started");
ValidateAssemblyName(expected.AssemblyName, actual.AssemblyName, nameof(BindOperation.AssemblyName));
Assert.Equal(expected.AssemblyPath ?? string.Empty, actual.AssemblyPath);
Assert.Equal(expected.AssemblyLoadContext, actual.AssemblyLoadContext);
Expand All @@ -37,6 +38,7 @@ public static void ValidateBindOperation(BindOperation expected, BindOperation a
ValidateProbedPaths(expected.ProbedPaths, actual.ProbedPaths);

ValidateNestedBinds(expected.NestedBinds, actual.NestedBinds);
Console.WriteLine("ValidateBindOperation Finished");
}

public static string GetAssemblyInAppPath(string assemblyName)
Expand Down
Loading