Skip to content

Commit

Permalink
[browser][MT] Log ManagedThreadId and NativeThreadId for known test f…
Browse files Browse the repository at this point in the history
…ailures (#98291)

Log ManagedThreadId and NativeThreadId for known test failures
  • Loading branch information
mkhamoyan authored Feb 22, 2024
1 parent d908f00 commit 8dcb639
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,23 @@ await HttpClient_ActionInDifferentThread(url, executor1, executor2, async (HttpR
await Assert.ThrowsAsync<TaskCanceledException>(async () =>
{
CancellationTokenSource cts = new CancellationTokenSource();
var promise = response.Content.ReadAsStringAsync(cts.Token);
cts.Cancel();
await promise;
try
{
var promise = response.Content.ReadAsStringAsync(cts.Token);
Console.WriteLine("HttpClient_CancelInDifferentThread: ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
cts.Cancel();
await promise;
}
catch (TaskCanceledException ex)
{
Console.WriteLine("HttpClient_CancelInDifferentThread: TaskCanceledException is thrown with message: " + ex.ToString());
throw;
}
catch (OperationCanceledException ex)
{
Console.WriteLine("HttpClient_CancelInDifferentThread: OperationCanceledException is thrown with message: " + ex.ToString());
throw;
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,20 @@ public async Task ThreadingTimer(Executor executor)
await executor.Execute(async () =>
{
TaskCompletionSource tcs = new TaskCompletionSource();
Console.WriteLine("ThreadingTimer: Start Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
using var timer = new Timer(_ =>
{
Assert.NotEqual(1, Environment.CurrentManagedThreadId);
Assert.True(Thread.CurrentThread.IsThreadPoolThread);
tcs.SetResult();
hit = true;
tcs.SetResult();
}, null, 100, Timeout.Infinite);
await tcs.Task;
}, cts.Token);

Console.WriteLine("ThreadingTimer: End Time: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
Assert.True(hit);
}

Expand Down Expand Up @@ -451,7 +453,7 @@ await executor.Execute(Task () =>
{
exception = ex;
}
Console.WriteLine("WaitAssertsOnJSInteropThreads: ExecuterType: " + executor.Type + " ManagedThreadId: " + Environment.CurrentManagedThreadId + " NativeThreadId: " + WebWorkerTestHelper.NativeThreadId);
executor.AssertBlockingWait(exception);
return Task.CompletedTask;
Expand Down

0 comments on commit 8dcb639

Please sign in to comment.