Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -12,9 +12,9 @@ internal static partial class HandleFactory
return new Win32Handle(handle);
}
public static Win32Handle CreateSyncFileHandleFoWrite()
public static Win32Handle CreateSyncFileHandleForWrite(string fileName = null)
{
return CreateHandle(async: false);
return CreateHandle(async:false, fileName:fileName);
}
public static Win32Handle CreateAsyncFileHandleForWrite(string fileName = null)

View File

@@ -146,7 +146,6 @@ public static partial class OverlappedTests
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
[ActiveIssue("https://github.com/dotnet/corefx/issues/20365", TargetFrameworkMonikers.UapAot)]
public static unsafe void PackPosTest()
{
#pragma warning disable 618
@@ -172,7 +171,6 @@ public static partial class OverlappedTests
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
[ActiveIssue("https://github.com/dotnet/corefx/issues/20365", TargetFrameworkMonikers.UapAot)]
public static unsafe void PackPosTest1()
{
Overlapped ov = new Overlapped();

View File

@@ -26,9 +26,6 @@
<Compile Include="ThreadPoolBoundHandle_DisposeTests.cs" />
<Compile Include="ThreadPoolBoundHandle_BindHandleTests.cs" />
<Compile Include="OverlappedTests.cs" />
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
<Link>Common\System\AssertExtensions.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -83,7 +83,7 @@ public partial class ThreadPoolBoundHandleTests
{
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentException>(() => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" }));
AssertExtensions.Throws<ArgumentException>(null, () => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" }));
}
}
@@ -131,7 +131,7 @@ public partial class ThreadPoolBoundHandleTests
};
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentException>(() => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), array));
AssertExtensions.Throws<ArgumentException>(null, () => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), array));
}
}
@@ -200,6 +200,7 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
[ActiveIssue("https://github.com/dotnet/corefx/issues/18058", TargetFrameworkMonikers.Uap)]
public unsafe void AllocateNativeOverlapped_PreAllocated_ReusedReturnedNativeOverlapped_OffsetLowAndOffsetHighSetToZero()
{ // The CLR reuses NativeOverlapped underneath, check to make sure that they reset fields back to zero
@@ -277,7 +278,7 @@ public partial class ThreadPoolBoundHandleTests
{
NativeOverlapped* overlapped = handle.AllocateNativeOverlapped(preAlloc);
Assert.Throws<ArgumentException>(() =>
AssertExtensions.Throws<ArgumentException>("preAllocated", () =>
{
handle.AllocateNativeOverlapped(preAlloc);
});

View File

@@ -53,8 +53,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_SyncHandleAsHandle_ThrowsArgumentException()
{ // Can't bind a handle that was not opened for overlapped I/O
using(SafeHandle handle = HandleFactory.CreateSyncFileHandleFoWrite())
using(SafeHandle handle = HandleFactory.CreateSyncFileHandleForWrite(GetTestFilePath()))
{
AssertExtensions.Throws<ArgumentException>("handle", () =>
{
@@ -64,10 +63,11 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[ActiveIssue(21066, TargetFrameworkMonikers.Uap)]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_ClosedSyncHandleAsHandle_ThrowsArgumentException()
{
using(Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite())
using(Win32Handle handle = HandleFactory.CreateSyncFileHandleForWrite(GetTestFilePath()))
{
handle.CloseWithoutDisposing();
@@ -79,10 +79,11 @@ public partial class ThreadPoolBoundHandleTests
}
[Fact]
[ActiveIssue(21066, TargetFrameworkMonikers.Uap)]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_ClosedAsyncHandleAsHandle_ThrowsArgumentException()
{
using(Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
handle.CloseWithoutDisposing();
@@ -97,7 +98,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_DisposedSyncHandleAsHandle_ThrowsArgumentException()
{
Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite();
Win32Handle handle = HandleFactory.CreateSyncFileHandleForWrite();
handle.Dispose();
AssertExtensions.Throws<ArgumentException>("handle", () =>
@@ -111,7 +112,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_DisposedAsyncHandleAsHandle_ThrowsArgumentException()
{
Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite();
Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath());
handle.Dispose();
AssertExtensions.Throws<ArgumentException>("handle", () =>
@@ -124,7 +125,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void BindHandle_AlreadyBoundHandleAsHandle_ThrowsArgumentException()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
// Once
ThreadPoolBoundHandle.BindHandle(handle);

View File

@@ -41,7 +41,7 @@ public partial class ThreadPoolBoundHandleTests
using (ThreadPoolBoundHandle handle2 = CreateThreadPoolBoundHandle())
{
Assert.Throws<ArgumentException>(() =>
AssertExtensions.Throws<ArgumentException>("overlapped", () =>
{
handle2.FreeNativeOverlapped(overlapped);
});

View File

@@ -22,7 +22,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsNull_ReturnsNull()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
using(ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle))
{
@@ -43,7 +43,7 @@ public partial class ThreadPoolBoundHandleTests
{
object context = new object();
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
using(ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle))
{
@@ -66,7 +66,7 @@ public partial class ThreadPoolBoundHandleTests
AsyncResult context = new AsyncResult();
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
using(ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle))
{

View File

@@ -12,7 +12,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Handle_ReturnsHandle()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
using(ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle(handle))
{
@@ -25,7 +25,7 @@ public partial class ThreadPoolBoundHandleTests
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Handle_AfterDisposed_DoesNotThrow()
{
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath()))
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle(handle);
boundHandle.Dispose();

View File

@@ -3,11 +3,13 @@
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using Xunit;
public partial class ThreadPoolBoundHandleTests
public partial class ThreadPoolBoundHandleTests : FileCleanupTestBase
{
struct BlittableType
{
@@ -19,15 +21,23 @@ public partial class ThreadPoolBoundHandleTests
public string s;
}
private static ThreadPoolBoundHandle CreateThreadPoolBoundHandle()
private ThreadPoolBoundHandle CreateThreadPoolBoundHandle([CallerMemberName] string memberName = null, [CallerLineNumber] int lineNumber = 0)
{
return CreateThreadPoolBoundHandle((SafeHandle)null);
return CreateThreadPoolBoundHandle((SafeHandle)null, memberName, lineNumber);
}
private static ThreadPoolBoundHandle CreateThreadPoolBoundHandle(SafeHandle handle)
private ThreadPoolBoundHandle CreateThreadPoolBoundHandle(SafeHandle handle, [CallerMemberName] string memberName = null, [CallerLineNumber] int lineNumber = 0)
{
handle = handle ?? HandleFactory.CreateAsyncFileHandleForWrite();
handle = handle ?? HandleFactory.CreateAsyncFileHandleForWrite(GetTestFilePath(null, memberName, lineNumber));
return ThreadPoolBoundHandle.BindHandle(handle);
try
{
return ThreadPoolBoundHandle.BindHandle(handle);
}
catch (ArgumentException ex) when (ex.GetType() == typeof(ArgumentException))
{
// TODO: Remove this try/catch, which is intended to help with debugging https://github.com/dotnet/corefx/issues/18058
throw new ArgumentException("Handle value: " + handle.DangerousGetHandle(), ex.ParamName, ex);
}
}
}

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using Xunit;
@@ -15,7 +16,7 @@ public partial class ThreadPoolBoundHandleTests
{
const int DATA_SIZE = 2;
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(@"SingleOverlappedOverSingleHandle.tmp");
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(Path.Combine(TestDirectory, @"SingleOverlappedOverSingleHandle.tmp"));
ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle);
OverlappedContext result = new OverlappedContext();
@@ -53,7 +54,7 @@ public partial class ThreadPoolBoundHandleTests
{
const int DATA_SIZE = 2;
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(@"MultipleOperationsOverSingleHandle.tmp");
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(Path.Combine(TestDirectory, @"MultipleOperationsOverSingleHandle.tmp"));
ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle);
OverlappedContext result1 = new OverlappedContext();
@@ -111,8 +112,8 @@ public partial class ThreadPoolBoundHandleTests
{
const int DATA_SIZE = 2;
SafeHandle handle1 = HandleFactory.CreateAsyncFileHandleForWrite(@"MultipleOperationsOverMultipleHandle1.tmp");
SafeHandle handle2 = HandleFactory.CreateAsyncFileHandleForWrite(@"MultipleOperationsOverMultipleHandle2.tmp");
SafeHandle handle1 = HandleFactory.CreateAsyncFileHandleForWrite(Path.Combine(TestDirectory, @"MultipleOperationsOverMultipleHandle1.tmp"));
SafeHandle handle2 = HandleFactory.CreateAsyncFileHandleForWrite(Path.Combine(TestDirectory, @"MultipleOperationsOverMultipleHandle2.tmp"));
ThreadPoolBoundHandle boundHandle1 = ThreadPoolBoundHandle.BindHandle(handle1);
ThreadPoolBoundHandle boundHandle2 = ThreadPoolBoundHandle.BindHandle(handle2);
@@ -185,7 +186,7 @@ public partial class ThreadPoolBoundHandleTests
const int DATA_SIZE = 2;
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(@"AsyncLocal.tmp");
SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite(Path.Combine(TestDirectory, @"AsyncLocal.tmp"));
ThreadPoolBoundHandle boundHandle = ThreadPoolBoundHandle.BindHandle(handle);
OverlappedContext context = new OverlappedContext();

View File

@@ -43,7 +43,7 @@ public partial class ThreadPoolBoundHandleTests
[Fact]
public unsafe void PreAllocatedOverlapped_NonBlittableTypeAsPinData_Throws()
{
Assert.Throws<ArgumentException>(() => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" }));
AssertExtensions.Throws<ArgumentException>(null, () => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" }));
// Make sure the PreAllocatedOverlapped finalizer does the right thing in the case where the .ctor failed.
GC.Collect();
@@ -75,7 +75,7 @@ public partial class ThreadPoolBoundHandleTests
new NonBlittableType() { s = "foo" },
new byte[5],
};
Assert.Throws<ArgumentException>(() => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), array));
AssertExtensions.Throws<ArgumentException>(null, () => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), array));
// Make sure the PreAllocatedOverlapped finalizer does the right thing in the case where the .ctor failed.
GC.Collect();