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

Try to fix a time-sensitive thread pool test #66765

Closed
wants to merge 5 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
<ItemGroup>
<Compile Include="$(CommonTestPath)System\Threading\ThreadTestHelpers.cs"
Link="CommonTest\System\Threading\ThreadTestHelpers.cs" />
<Compile Include="$(CommonTestPath)TestUtilities\System\DisableParallelization.cs"
Link="CommonTest\TestUtilities\System\DisableParallelization.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,14 @@ public static void ThreadPoolThreadCreationDoesNotTransferExecutionContext()
}).Dispose();
}

[ConditionalFact(nameof(IsThreadingAndRemoteExecutorSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/66852", TestPlatforms.OSX)]
public static bool IsThreadingAndRemoteExecutorSupported =>
PlatformDetection.IsThreadingSupported && RemoteExecutor.IsSupported;
}

[Collection(nameof(DisableParallelization))] // these tests may be sensitive to timing
public class ThreadPoolTests_NonParallel
{
[ConditionalFact(typeof(ThreadPoolTests), nameof(ThreadPoolTests.IsThreadingAndRemoteExecutorSupported))]
public static void CooperativeBlockingCanCreateThreadsFaster()
{
// Run in a separate process to test in a clean thread pool environment such that work items queued by the test
Expand Down Expand Up @@ -969,7 +975,7 @@ void AppContextSetData(string name, object value)
}).Dispose();
}

[ConditionalFact(nameof(IsThreadingAndRemoteExecutorSupported))]
[ConditionalFact(typeof(ThreadPoolTests), nameof(ThreadPoolTests.IsThreadingAndRemoteExecutorSupported))]
public static void CooperativeBlockingWithProcessingThreadsAndGoalThreadsAndAddWorkerRaceTest()
{
// Avoid contaminating the main process' environment
Expand Down Expand Up @@ -1019,8 +1025,5 @@ public static void CooperativeBlockingWithProcessingThreadsAndGoalThreadsAndAddW
}).Dispose();
}).Dispose();
}

public static bool IsThreadingAndRemoteExecutorSupported =>
PlatformDetection.IsThreadingSupported && RemoteExecutor.IsSupported;
}
}