Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@ -39,10 +39,10 @@ namespace System.Threading.Tasks.Tests
[SecurityCritical]
protected override void QueueTask(Task task)
{
if (task == null) throw new ArgumentNullException("When reqeusting to QueueTask, the input task can not be null");
if (task == null) throw new ArgumentNullException("When requesting to QueueTask, the input task can not be null");
Task.Factory.StartNew(() =>
{
lock (_lockObj) //Locking so that if mutliple threads in threadpool does not incorrectly increment the counter.
lock (_lockObj) //Locking so that if multiple threads in threadpool does not incorrectly increment the counter.
{
//store the current value of the counter (This becomes the unique ID for this scheduler's Task)
SchedulerID.Value = _counter;
@ -75,7 +75,7 @@ namespace System.Threading.Tasks.Tests
[SecurityCritical]
protected override IEnumerable<Task> GetScheduledTasks() { return null; }
private Object _lockObj = new Object();
private int _counter = 1; //This is used ot keep track of how many scheduler tasks were created
private int _counter = 1; //This is used to keep track of how many scheduler tasks were created
public ThreadLocal<int> SchedulerID = new ThreadLocal<int>(); //This is the ID of the scheduler.
/// <summary>The maximum concurrency level for the scheduler.</summary>
@ -136,7 +136,7 @@ namespace System.Threading.Tasks.Tests
for (int i = 0; i < 50; i++)
{
//In the current design, when there are no more tasks to execute, the Task used by concurrentexclusive scheduler dies
//by sleeping we simulate some non trival work that takes time and causes the concurrentexclusive scheduler Task
//by sleeping we simulate some non trivial work that takes time and causes the concurrentexclusive scheduler Task
//to stay around for addition work.
taskList.Add(readers.StartNew(() => { var sw = new SpinWait(); while (!sw.NextSpinWillYield) sw.SpinOnce() ; }));
}
@ -182,7 +182,7 @@ namespace System.Threading.Tasks.Tests
}
/// <summary>
/// Test to verify that only upto maxItemsPerTask are executed by a single ConcurrentExclusiveScheduler Task
/// Test to verify that only up to maxItemsPerTask are executed by a single ConcurrentExclusiveScheduler Task
/// </summary>
/// <remarks>In ConcurrentExclusiveSchedulerPair, each tasks scheduled are run under an internal Task. The basic idea for the test
/// is that each time ConcurrentExclusiveScheduler is called QueueTasK a counter (which acts as scheduler's Task id) is incremented.
@ -260,7 +260,7 @@ namespace System.Threading.Tasks.Tests
}
/// <summary>
/// When user specfices a concurrency level above the level allowed by the task scheduler, the concurrency level should be set
/// When user specifies a concurrency level above the level allowed by the task scheduler, the concurrency level should be set
/// to the concurrencylevel specified in the taskscheduler. Also tests that the maxConcurrencyLevel specified was respected
/// </summary>
[Fact]

View File

@ -817,6 +817,12 @@ namespace System.Threading.Tasks.Tests
}
}
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
static void FinalizeHelper(DisposeTracker disposeTracker)
{
new DerivedCTS(disposeTracker);
}
// Several tests for deriving custom user types from CancellationTokenSource
[Fact]
public static void DerivedCancellationTokenSource()
@ -873,9 +879,7 @@ namespace System.Threading.Tasks.Tests
{
var disposeTracker = new DisposeTracker();
// Since the object is not assigned into a variable, it can be GC'd before the current method terminates.
// (This is only an issue in the Debug build)
new DerivedCTS(disposeTracker);
FinalizeHelper(disposeTracker);
// Wait until the DerivedCTS object is finalized
SpinWait.SpinUntil(() =>

View File

@ -2,7 +2,6 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard1.5;
netstandard;
</BuildConfigurations>
</PropertyGroup>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<Project Include="System.Threading.Tasks.Tests.csproj" />
<Project Include="System.Threading.Tasks.Tests.csproj">
<TargetGroup>netstandard1.5</TargetGroup>
<TestTFMs>netcoreapp1.0</TestTFMs>
</Project>
<Project Include="System.Threading.Tasks.Tests.csproj">
<TargetGroup>netstandard1.5</TargetGroup>
<OSGroup>Windows_NT</OSGroup>
<TestTFMs>net462</TestTFMs>
</Project>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
</Project>

View File

@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{B6C09633-D161-499A-8FE1-46B2D53A16E7}</ProjectGuid>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.5-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.5-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="XunitAssemblyAttributes.cs" />
<Compile Include="UnwrapTests.cs" />
@ -51,8 +49,8 @@
<Link>CommonTest\System\Threading\ThreadPoolHelpers.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<ItemGroup>
<Compile Include="Task\TaskDisposeTests.netstandard.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@ -18,7 +18,7 @@ using System.Diagnostics;
namespace System.Threading.Tasks.Tests
{
/// <summary>
/// A class that implements the APM pattern to ensure that TPL can support APM patttern
/// A class that implements the APM pattern to ensure that TPL can support APM pattern
/// </summary>
public sealed class TaskAPMTests : IDisposable
{

View File

@ -105,7 +105,7 @@ namespace System.Threading.Tasks.Tests.CancelWait
if (delta > 0)
{
Debug.WriteLine("ElapsedMilliseconds way more than requested Timeout.");
Debug.WriteLine("WaitTime= {0} ms, ElapsedTime= {1} ms, Allowed Descrepancy = {2} ms", _waitTimeout, sw.ElapsedMilliseconds, s_deltaTimeOut);
Debug.WriteLine("WaitTime= {0} ms, ElapsedTime= {1} ms, Allowed Discrepancy = {2} ms", _waitTimeout, sw.ElapsedMilliseconds, s_deltaTimeOut);
Debug.WriteLine("Delta= {0} ms", delta);
}
else
@ -237,7 +237,7 @@ namespace System.Threading.Tasks.Tests.CancelWait
break;
default:
throw new ArgumentOutOfRangeException(string.Format("unknown API_CancelWait of", _api));
throw new ArgumentOutOfRangeException(string.Format("unknown API_CancelWait of {0}", _api));
}
}
@ -259,7 +259,7 @@ namespace System.Threading.Tasks.Tests.CancelWait
{
// need to make sure the parent task at least called .Cancel() on the child
if (!ti.CancellationToken.IsCancellationRequested)
Assert.True(false, string.Format("Task which has been explictly cancel-requested either by parent must have CancellationRequested set as true"));
Assert.True(false, string.Format("Task which has been explicitly cancel-requested either by parent must have CancellationRequested set as true"));
}
else if (ti.IsRespectParentCancellation)
{
@ -459,7 +459,7 @@ namespace System.Threading.Tasks.Tests.CancelWait
int index = -1;
for (int i = 0; i < options.Length; i++)
{
string o = options[i].Trim(); // remove any white spaces.
string o = options[i].Trim(); // remove any whitespace.
options[i] = o;
if (o.Equals("RespectParentCancellation", StringComparison.OrdinalIgnoreCase))
{
@ -570,7 +570,7 @@ namespace System.Threading.Tasks.Tests.CancelWait
#region Helper Methods
/// <summary>
/// Recursively traverse the tree and compare the current node usign the predicate
/// Recursively traverse the tree and compare the current node using the predicate
/// </summary>
/// <param name="predicate">the predicate</param>
/// <param name="report"></param>

View File

@ -50,7 +50,7 @@ namespace Test
{
bool useFutureFactory = (z == 0);
// This would be a non-sensical combination
// This would be a nonsensical combination
if (useFutureFactory && !continuationIsFuture)
continue;

View File

@ -44,7 +44,7 @@ namespace System.Threading.Tasks.Tests.ContinueWithAllAny
_tcOption = parameters.ContinuationOptions;
// set up the TaskScheduler under which the contination will be scheduled
// set up the TaskScheduler under which the continuation will be scheduled
_tm = TaskScheduler.Default;
// create a new cancellation token for each test
@ -119,7 +119,7 @@ namespace System.Threading.Tasks.Tests.ContinueWithAllAny
// and map it to one of the things this is running.
//
// That is, given a task type, tm type, api, cancellation, etc. it should be
// straightforward to figure out what variant of continuewhen is called.
// straightforward to figure out what variant of ContinueWhen is called.
//
switch (_taskType)
{

View File

@ -682,7 +682,7 @@ namespace System.Threading.Tasks.Tests
Debug.WriteLine("RunUnwrapTests: Waiting on Unwrap() products... If we hang, something is wrong.");
Task.WaitAll(new Task[] { c1, c2, c3, c4, c5, c6, c7, c8 });
//Debug.WriteLine(" Testing that Unwrap() producs have consistent completion state...");
//Debug.WriteLine(" Testing that Unwrap() products have consistent completion state...");
checkCompletionState(c1, true, "Task ==> Task<T>, Unwrapped task complete");
checkCompletionState(c2, true, "Task<T> ==> Task<T>, Unwrapped task complete");
checkCompletionState(c3, true, "StartNew ==> Task<T>, Unwrapped task complete");
@ -865,7 +865,7 @@ namespace System.Threading.Tasks.Tests
{
if (ae.InnerExceptions.Count != 4)
{
Assert.True(false, string.Format("RunUnwrapTests: > FAILED. Monadic continuation w/ faulted childred had {0} inner exceptions, expected 4", ae.InnerExceptions.Count));
Assert.True(false, string.Format("RunUnwrapTests: > FAILED. Monadic continuation w/ faulted children had {0} inner exceptions, expected 4", ae.InnerExceptions.Count));
Assert.True(false, string.Format("RunUnwrapTests: > Exception = {0}", ae));
}
}
@ -1030,7 +1030,7 @@ namespace System.Threading.Tasks.Tests
bool t3Ran = false;
Task t1 = new Task(delegate { t1Ran = true; });
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
CancellationTokenSource ctsForT2 = new CancellationTokenSource();
Task t2 = t1.ContinueWith((ContinuedTask, obj) =>
{
@ -1336,7 +1336,7 @@ namespace System.Threading.Tasks.Tests
TaskContinuationOptions tco = ((i % 2) == 0) ? TaskContinuationOptions.None : TaskContinuationOptions.ExecuteSynchronously;
normalContinuations[i] = antecedent.ContinueWith(normalAction, tco);
// If you've hit completeAfter or cancelAfter, take the approriate action
// If you've hit completeAfter or cancelAfter, take the appropriate action
if ((i + 1) == completeAfter) completionTcs.TrySetResult(true); // Asynchronously completes the antecedent
if ((i + 1) == cancelAfter) cancellationTcs.TrySetResult(true); // Asynchronously initiates cancellation of "to be canceled" tasks
}
@ -1424,7 +1424,7 @@ namespace System.Threading.Tasks.Tests
TaskCompletionSource<int> result, TaskScheduler scheduler)
{
// If the cancellation token is already canceled, there is no need to create and link a target.
// Insted, directly return a canceled task
// Instead, directly return a canceled task
if (cts.IsCancellationRequested)
{
var canceledTaskSource = new TaskCompletionSource<object>();

View File

@ -202,7 +202,7 @@ namespace Test
// Pre-increment the dontCounts for pre-canceled continuations to make final check easier
// (i.e., all counts should be 1 at end).
int[] doneCount = { 0, 0, 1, 0, 1, 0 };
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
Task t1 = new Task(delegate { doneCount[0]++; });
Task c1 = t1.ContinueWith((_, obj) => { doneCount[1]++; }, stateParam);
@ -271,7 +271,7 @@ namespace Test
int x = 0;
int y = 0;
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
Task t1 = new Task(delegate { x = 1; });
Task t2 = t1.ContinueWith(delegate (Task t, Object obj) { y = 1; }, stateParam);
Task<int> t3 = t2.ContinueWith(delegate (Task t, Object obj) { return 5; }, stateParam);
@ -317,7 +317,7 @@ namespace Test
try
{
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
Task t2 = t1.ContinueWith((completedTask, obj) => { }, stateParam);
}
catch
@ -329,7 +329,7 @@ namespace Test
[Fact]
public static void RunContinueWithParamsTest_State_Cancellation()
{
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
//
// Test whether parentage/cancellation is working correctly
@ -380,7 +380,7 @@ namespace Test
public static void RunContinueWithParamsTest_State_IllegalParameters()
{
Task t1 = new Task(delegate { });
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
try
{
@ -421,7 +421,7 @@ namespace Test
{
bool ran = false;
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
if (runNegativeCases)
{
@ -455,7 +455,7 @@ namespace Test
bool ran = false;
Debug.WriteLine("* RunContinueWithTaskFuture_StateA(Object, options={0})", options);
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
if (runNegativeCases)
{
@ -489,7 +489,7 @@ namespace Test
bool ran = false;
Debug.WriteLine("* RunContinueWithFutureTask_State(Object, options={0})", options);
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
if (runNegativeCases)
{
@ -523,7 +523,7 @@ namespace Test
bool ran = false;
Debug.WriteLine("* RunContinueWithFutureFuture_StateA(Object, options={0})", options);
string stateParam = "test"; //used as a state parametr for the continuation if the useStateParam is true
string stateParam = "test"; //used as a state parameter for the continuation if the useStateParam is true
if (runNegativeCases)
{
RunContinueWithBase_ExceptionCases(options,

View File

@ -859,7 +859,7 @@ namespace System.Threading.Tasks.Tests
/// <summary>
/// Class that verifies that all the public constructors of Task, future, promise and futureT are working correctly
/// The test creates the test object (Task, Future, promise) using various ctor and ensures that they were
/// created and can be started. All the negative cases (expectional cases are also covered in this test set).
/// created and can be started. All the negative cases (exceptional cases are also covered in this test set).
/// </summary>
internal sealed class TaskCreateTest
{
@ -871,7 +871,7 @@ namespace System.Threading.Tasks.Tests
private const int ZETA_SEED = 1000000;
/// <summary>
/// Used to save the results that is returned by the Task upon completion (used to verify that task ran successsfully)
/// Used to save the results that is returned by the Task upon completion (used to verify that task ran successfully)
/// </summary>
private double _result;

View File

@ -269,7 +269,7 @@ namespace System.Threading.Tasks.Tests
#region AsyncFunc
/// <summary>
/// Extends the base class to implement that funtion form of APM
/// Extends the base class to implement that function form of APM
/// </summary>
public class AsyncFunc : AsyncWork
{

View File

@ -43,7 +43,7 @@ namespace System.Threading.Tasks.Tests
t2.Wait();
}
// Verification -- Verify that task IDs are unqiue and equal to the number of tasks created
// Verification -- Verify that task IDs are unique and equal to the number of tasks created
for (int i = 0; i < taskIDs.Length; i++)
{
var id = taskIDs[i];

View File

@ -296,7 +296,7 @@ namespace System.Threading.Tasks.Tests
{
t1.Wait();
Assert.False(cancellationExpected || exceptionExpected, "TaskRtTests.RunRunTests: Expected exception or cancellation");
Assert.True(something == 1, "TaskRtTests.RunRunTests: Task completed but apparantly did not run");
Assert.True(something == 1, "TaskRtTests.RunRunTests: Task completed but apparently did not run");
}
catch (AggregateException ae)
{

View File

@ -1 +1 @@
b78665c068f02ec5d01c14457652de3eeec71cc7
a2db51d7b4ab9b4e90c8d7b9d45a8934b54855c5

View File

@ -179,7 +179,7 @@ namespace System.Threading.Tasks.Tests
private TaskSchedulerType _taskSchedulerType;
private Task _task; // the main task to be run synchronously
private CancellationTokenSource _cts; // The CancellationTokenSource of which the Token is apssed to the Main task
private CancellationTokenSource _cts; // The CancellationTokenSource of which the Token is passed to the Main task
private int _taskThreadID;
public TaskRunSyncTest(TestParameters_RunSync parameters)
@ -386,7 +386,7 @@ namespace System.Threading.Tasks.Tests
{
// The following cases will cause an exception
// 1. Task already started / canceled / disposed / completed
// 2. Task is an contination task
// 2. Task is a continuation task
return (_preTaskStatus != PreTaskStatus.Created);
}
}
@ -401,7 +401,7 @@ namespace System.Threading.Tasks.Tests
if (_workloadType == WorkloadType.ThrowException)
ae.Flatten().Handle((e) => e is TPLTestException);
else
Assert.True(false, string.Format("Caught un-expected exception - {0]. Fail to re-progogate the test exception via Wait", ae));
Assert.True(false, string.Format("Caught un-expected exception - {0]. Fail to re-propagate the test exception via Wait", ae));
}
}

View File

@ -128,7 +128,7 @@ namespace System.Threading.Tasks.Tests.Status
CancellationTokenSource cts = new CancellationTokenSource();
scheduler.Cancellation = cts;
// Replace _task with a task that has a cutoms scheduler
// Replace _task with a task that has a custom scheduler
_task = Task.Factory.StartNew(() => { }, cts.Token, TaskCreationOptions.None, scheduler);
try { _task.GetAwaiter().GetResult(); }
@ -184,7 +184,7 @@ namespace System.Threading.Tasks.Tests.Status
//
if (_task.Status != TaskStatus.WaitingForChildrenToComplete && !_childTask.IsCompleted)
{
Assert.True(false, string.Format("Expecting currrent Task status to be WaitingForChildren but getting {0}", _task.Status.ToString()));
Assert.True(false, string.Format("Expecting current Task status to be WaitingForChildren but getting {0}", _task.Status.ToString()));
}
}
_task.Wait();

View File

@ -322,7 +322,7 @@ namespace System.Threading.Tasks.Tests.WaitAllAny
/// <summary>
/// the scenario verification
///
/// - all the tasks should be coplted in case of waitAll with -1 timeout
/// - all the tasks should be completed in case of waitAll with -1 timeout
/// - the returned index form WaitAny should correspond to a completed task
/// - in case of Cancelled and Exception tests the right exceptions should be got for WaitAll
/// </summary>
@ -368,7 +368,7 @@ namespace System.Threading.Tasks.Tests.WaitAllAny
{
//waitAny will not fail if a number of tasks were exceptional
if (expCaught)
Assert.True(false, string.Format("Unexcepted TPLTestException in Task at Index = {0} caught", i));
Assert.True(false, string.Format("Unexpected TPLTestException in Task at Index = {0} caught", i));
//need to check it eventually to prevent it from crashing the finalizer
faultyTasks.Add(i, ti.Task);
@ -387,7 +387,7 @@ namespace System.Threading.Tasks.Tests.WaitAllAny
else // must be API_WaitAllAny.WaitAny
{
if (expCaught) //waitAny will not fail if a number of tasks were cancelled
Assert.False(expCaught, "Unexcepted TaskCanceledException in Task at Index = " + i + " caught");
Assert.False(expCaught, "Unexpected TaskCanceledException in Task at Index = " + i + " caught");
}
}
else if (ti.Task.IsCompleted && !CheckResult(ti.Result))
@ -409,7 +409,7 @@ namespace System.Threading.Tasks.Tests.WaitAllAny
foreach (var tasks in faultyTasks)
{
if (!(tasks.Value.Exception.InnerException is TPLTestException))
Assert.True(false, string.Format("Unexcepted Exception in Task at Index = {0} caught", tasks.Key));
Assert.True(false, string.Format("Unexpected Exception in Task at Index = {0} caught", tasks.Key));
}
}
}

View File

@ -560,7 +560,6 @@ namespace System.Threading.Tasks.Tests
}
}
[ActiveIssue("https://github.com/dotnet/coreclr/issues/7892")] // BinaryCompatibility reverting FromAsync to .NET 4 behavior, causing invokesCallback=false to fail
[Theory]
[InlineData(false)]
[InlineData(true)]

Some files were not shown because too many files have changed in this diff Show More