Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -12,9 +12,12 @@
<Compile Include="CompressedStackTests.cs" />
<Compile Include="ExceptionTests.cs" />
<Compile Include="ThreadExceptionEventArgsTests.cs" />
<Compile Include="ThreadTests.netstandard.cs" />
<Compile Include="ThreadTests.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
</Compile>
<Compile Include="$(CommonTestPath)\System\Threading\ThreadTestHelpers.cs">
<Link>CommonTest\System\Threading\ThreadPoolHelpers.cs</Link>
</Compile>

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -141,6 +142,7 @@ namespace System.Threading.Threads.Tests
[Theory]
[MemberData(nameof(ApartmentStateTest_MemberData))]
[PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void GetSetApartmentStateTest_ChangeAfterThreadStarted_Windows(
Func<Thread, ApartmentState> getApartmentState,
Func<Thread, ApartmentState, int> setApartmentState,
@@ -163,6 +165,7 @@ namespace System.Threading.Threads.Tests
[Theory]
[MemberData(nameof(ApartmentStateTest_MemberData))]
[PlatformSpecific(TestPlatforms.Windows)] // Expected behavior differs on Unix and Windows
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void ApartmentStateTest_ChangeBeforeThreadStarted_Windows(
Func<Thread, ApartmentState> getApartmentState,
Func<Thread, ApartmentState, int> setApartmentState,
@@ -178,7 +181,17 @@ namespace System.Threading.Threads.Tests
Assert.Equal(ApartmentState.STA, getApartmentState(t));
t.Start();
Assert.True(t.Join(UnexpectedTimeoutMilliseconds));
Assert.Equal(ApartmentState.STA, apartmentStateInThread);
if (PlatformDetection.IsWindowsNanoServer)
{
// Nano server threads are always MTA. If you set the thread to STA
// it will read back as STA but when the thread starts it will read back as MTA.
Assert.Equal(ApartmentState.MTA, apartmentStateInThread);
}
else
{
Assert.Equal(ApartmentState.STA, apartmentStateInThread);
}
}
[Theory]
@@ -413,6 +426,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766, TargetFrameworkMonikers.UapAot)]
public static void ThreadStateTest()
{
var e0 = new ManualResetEvent(false);
@@ -641,6 +655,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766, TargetFrameworkMonikers.UapAot)]
public static void InterruptTest()
{
// Interrupting a thread that is not blocked does not do anything, but once the thread starts blocking, it gets
@@ -691,6 +706,7 @@ namespace System.Threading.Threads.Tests
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void InterruptInFinallyBlockTest_SkipOnDesktopFramework()
{
// A wait in a finally block can be interrupted. The desktop framework applies the same rules as thread abort, and
@@ -757,9 +773,11 @@ namespace System.Threading.Threads.Tests
Assert.Throws<ArgumentOutOfRangeException>(() => Thread.Sleep(TimeSpan.FromMilliseconds((double)int.MaxValue + 1)));
Thread.Sleep(0);
var startTime = DateTime.Now;
var stopwatch = Stopwatch.StartNew();
Thread.Sleep(500);
Assert.True((DateTime.Now - startTime).TotalMilliseconds >= 100);
stopwatch.Stop();
Assert.InRange((int)stopwatch.ElapsedMilliseconds, 100, int.MaxValue);
}
[Fact]
@@ -806,6 +824,7 @@ namespace System.Threading.Threads.Tests
}
[Fact]
[ActiveIssue(20766,TargetFrameworkMonikers.UapAot)]
public static void MiscellaneousTest()
{
Thread.BeginCriticalRegion();