Skip to content

Commit

Permalink
Fix ThreadPool tests for uapaot. (dotnet#21049)
Browse files Browse the repository at this point in the history
Fix ThreadPool tests for uapaot.
  • Loading branch information
AntonLapounov authored Jun 14, 2017
1 parent d9df3ed commit 7208a27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<Compile Include="ThreadPoolTests.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>CommonTest\System\PlatformDetection.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\Threading\ThreadTestHelpers.cs">
<Link>CommonTest\System\Threading\ThreadTestHelpers.cs</Link>
</Compile>
Expand Down
13 changes: 10 additions & 3 deletions src/System.Threading.ThreadPool/tests/ThreadPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ public static class ThreadPoolTests
static ThreadPoolTests()
{
// Run the following tests before any others
ConcurrentInitializeTest();
if (!PlatformDetection.IsNetNative)
{
ConcurrentInitializeTest();
}
}

// Tests concurrent calls to ThreadPool.SetMinThreads
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "ThreadPool.SetMinThreads is not supported on UapAot.")]
public static void ConcurrentInitializeTest()
{
int processorCount = Environment.ProcessorCount;
Expand Down Expand Up @@ -52,8 +57,8 @@ public static void GetMinMaxThreadsTest()
{
int minw, minc;
ThreadPool.GetMinThreads(out minw, out minc);
Assert.True(minw > 0);
Assert.True(minc > 0);
Assert.True(minw >= 0);
Assert.True(minc >= 0);

int maxw, maxc;
ThreadPool.GetMaxThreads(out maxw, out maxc);
Expand All @@ -76,6 +81,7 @@ public static void GetAvailableThreadsTest()
}

[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "ThreadPool.SetMinThreads and SetMaxThreads are not supported on UapAot.")]
public static void SetMinMaxThreadsTest()
{
int minw, minc, maxw, maxc;
Expand Down Expand Up @@ -144,6 +150,7 @@ public static void SetMinMaxThreadsTest()
[Fact]
// Desktop framework doesn't check for this and instead, hits an assertion failure
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "ThreadPool.SetMinThreads and SetMaxThreads are not supported on UapAot.")]
public static void SetMinMaxThreadsTest_ChangedInDotNetCore()
{
int minw, minc, maxw, maxc;
Expand Down

0 comments on commit 7208a27

Please sign in to comment.