From 0ed4ea8318ab20c1b964dadb0df0c78564641037 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 4 Aug 2022 23:38:57 -0700 Subject: [PATCH] Fixes for Overlapped tests - Disable test that is testing 64-bit incompatible API on 64-bit platforms - Relax ArgumentException argument name validation. The name of the argument that test was expecting did not match the actual name of the method argument since the ArgumentException originates several layers deep into the implementation. Fixes https://github.com/dotnet/runtime/issues/73421 Fixes https://github.com/dotnet/runtime/issues/73422 Fixes https://github.com/mono/mono/issues/15311 --- .../tests/OverlappedTests.cs | 4 +--- ...eadPoolBoundHandle_AllocateNativeOverlappedTests.cs | 10 ++++------ ...hreadPoolBoundHandle_PreAllocatedOverlappedTests.cs | 10 ++++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/libraries/System.Threading.Overlapped/tests/OverlappedTests.cs b/src/libraries/System.Threading.Overlapped/tests/OverlappedTests.cs index e9838b6841e379..8eb2928e1ece00 100644 --- a/src/libraries/System.Threading.Overlapped/tests/OverlappedTests.cs +++ b/src/libraries/System.Threading.Overlapped/tests/OverlappedTests.cs @@ -60,9 +60,7 @@ public static void PropertyTest2() Assert.Equal(1, obj.OffsetLow); } - [Fact] - [ActiveIssue("https://github.com/mono/mono/issues/15311", TestRuntimes.Mono)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73422", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.Is32BitProcess))] public static void PropertyTest3() { IAsyncResult asyncResult = new Task(() => Console.WriteLine("this is a dummy task")); diff --git a/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_AllocateNativeOverlappedTests.cs b/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_AllocateNativeOverlappedTests.cs index e847086001c17c..ef0a4f8a58f50e 100644 --- a/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_AllocateNativeOverlappedTests.cs +++ b/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_AllocateNativeOverlappedTests.cs @@ -80,13 +80,12 @@ public unsafe void AllocateNativeOverlapped_EmptyArrayAsPinData_DoesNotThrow() [Fact] [PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix - [ActiveIssue("https://github.com/dotnet/runtime/issues/73421", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public unsafe void AllocateNativeOverlapped_NonBlittableTypeAsPinData_Throws() { using (ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle()) { - AssertExtensions.Throws(null, () => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); - AssertExtensions.Throws(null, () => handle.UnsafeAllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); + Assert.Throws(() => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); + Assert.Throws(() => handle.UnsafeAllocateNativeOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); } } @@ -130,7 +129,6 @@ public unsafe void AllocateNativeOverlapped_ObjectArrayAsPinData_DoesNotThrow() [Fact] [PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix - [ActiveIssue("https://github.com/dotnet/runtime/issues/73421", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public unsafe void AllocateNativeOverlapped_ObjectArrayWithNonBlittableTypeAsPinData_Throws() { var array = new object[] @@ -141,8 +139,8 @@ public unsafe void AllocateNativeOverlapped_ObjectArrayWithNonBlittableTypeAsPin using (ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle()) { - AssertExtensions.Throws(null, () => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), array)); - AssertExtensions.Throws(null, () => handle.UnsafeAllocateNativeOverlapped((_, __, ___) => { }, new object(), array)); + Assert.Throws(() => handle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), array)); + Assert.Throws(() => handle.UnsafeAllocateNativeOverlapped((_, __, ___) => { }, new object(), array)); } } diff --git a/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs b/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs index 22021bec4d83f5..728732326e5bae 100644 --- a/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs +++ b/src/libraries/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_PreAllocatedOverlappedTests.cs @@ -43,11 +43,10 @@ public unsafe void PreAllocatedOverlapped_EmptyArrayAsPinData_DoesNotThrow() [Fact] [ActiveIssue("https://github.com/mono/mono/issues/15313", TestRuntimes.Mono)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73421", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public unsafe void PreAllocatedOverlapped_NonBlittableTypeAsPinData_Throws() { - AssertExtensions.Throws(null, () => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); - AssertExtensions.Throws(null, () => PreAllocatedOverlapped.UnsafeCreate((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); + Assert.Throws(() => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); + Assert.Throws(() => PreAllocatedOverlapped.UnsafeCreate((_, __, ___) => { }, new object(), new NonBlittableType() { s = "foo" })); // Make sure the PreAllocatedOverlapped finalizer does the right thing in the case where the .ctor failed. GC.Collect(); @@ -76,7 +75,6 @@ public unsafe void PreAllocatedOverlapped_ObjectArrayAsPinData_DoesNotThrow() [Fact] [ActiveIssue("https://github.com/mono/mono/issues/15313", TestRuntimes.Mono)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73421", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))] public unsafe void PreAllocatedOverlapped_ObjectArrayWithNonBlittableTypeAsPinData_Throws() { var array = new object[] @@ -85,8 +83,8 @@ public unsafe void PreAllocatedOverlapped_ObjectArrayWithNonBlittableTypeAsPinDa new byte[5], }; - AssertExtensions.Throws(null, () => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), array)); - AssertExtensions.Throws(null, () => PreAllocatedOverlapped.UnsafeCreate((_, __, ___) => { }, new object(), array)); + Assert.Throws(() => new PreAllocatedOverlapped((_, __, ___) => { }, new object(), array)); + Assert.Throws(() => PreAllocatedOverlapped.UnsafeCreate((_, __, ___) => { }, new object(), array)); // Make sure the PreAllocatedOverlapped finalizer does the right thing in the case where the .ctor failed. GC.Collect();