Skip to content

Commit

Permalink
Try to fix and enable a ThreadPool.CompletedWorkItemCount test and ad…
Browse files Browse the repository at this point in the history
…d more info about failures (#57240)

* Try to fix and enable a ThreadPool.CompletedWorkItemCount test and add more info about failures

- Not sure why it would be failing. The test seems to be calling a different sub-test method than intended. Fixed that, updated the test to use a different temp file name in case the two relevant tests run in parallel, and added more info if it happens to fail again.
- Closes dotnet/runtime#47979
- Closes dotnet/runtime#49700
  • Loading branch information
kouvel authored Aug 18, 2021
1 parent 7885e07 commit 89526a9
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading;
using System.Threading.Tests;
using Xunit;
Expand All @@ -9,11 +10,23 @@ public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
[ActiveIssue("https://github.com/dotnet/runtime/issues/49700")]
public unsafe void MultipleOperationsOverSingleHandle_CompletedWorkItemCountTest()
{
long initialCompletedWorkItemCount = ThreadPool.CompletedWorkItemCount;
MultipleOperationsOverMultipleHandles();
ThreadTestHelpers.WaitForCondition(() => ThreadPool.CompletedWorkItemCount - initialCompletedWorkItemCount >= 2);
MultipleOperationsOverSingleHandle();
long changeInCompletedWorkItemCount = 0;
try
{
ThreadTestHelpers.WaitForCondition(() =>
{
changeInCompletedWorkItemCount = ThreadPool.CompletedWorkItemCount - initialCompletedWorkItemCount;
return changeInCompletedWorkItemCount >= 2;
});
}
catch (Exception ex)
{
// Test likely timed out, include the change for more information
throw new AggregateException($"changeInCompletedWorkItemCount: {changeInCompletedWorkItemCount}", ex);
}
}
}

0 comments on commit 89526a9

Please sign in to comment.