Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d2a2d7c

Browse files
Koundinya Veluristephentoub
authored andcommitted
Enable some threading overlapped tests on Unix (#19782)
* Enable some threading overlapped tests on Unix - Depends on dotnet/coreclr#11613 - Tests for https://github.com/dotnet/corefx/issues/19785 * Address feedback
1 parent 699887f commit d2a2d7c

10 files changed

+51
-3
lines changed

src/System.Threading.Overlapped/tests/Configurations.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<BuildConfigurations>
5-
netstandard-Windows_NT;
5+
netstandard;
66
uap-Windows_NT;
77
</BuildConfigurations>
88
</PropertyGroup>

src/System.Threading.Overlapped/tests/OverlappedTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public static unsafe void UnPackTest()
145145
}
146146

147147
[Fact]
148+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
148149
public static unsafe void PackPosTest()
149150
{
150151
#pragma warning disable 618
@@ -167,7 +168,9 @@ public static unsafe void PackPosTest()
167168
}
168169
#pragma warning restore 618
169170
}
171+
170172
[Fact]
173+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPool.UnsafeQueueNativeOverlapped is not supported on Unix
171174
public static unsafe void PackPosTest1()
172175
{
173176
Overlapped ov = new Overlapped();

src/System.Threading.Overlapped/tests/System.Threading.Overlapped.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<DefineConstants Condition="'$(TargetGroup)' == 'uap'">$(DefineConstants);uap</DefineConstants>
88
</PropertyGroup>
99
<!-- Default configurations to help VS understand the configurations -->
10-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Debug|AnyCPU'" />
11-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Windows_NT-Release|AnyCPU'" />
10+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
11+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
1212
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Debug|AnyCPU'" />
1313
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Windows_NT-Release|AnyCPU'" />
1414
<ItemGroup>

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_AllocateNativeOverlappedTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public partial class ThreadPoolBoundHandleTests
1111
{
1212
[Fact]
13+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
1314
public unsafe void AllocateNativeOverlapped_NullAsCallback_ThrowsArgumentNullException()
1415
{
1516
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -22,6 +23,7 @@ public unsafe void AllocateNativeOverlapped_NullAsCallback_ThrowsArgumentNullExc
2223
}
2324

2425
[Fact]
26+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
2527
public unsafe void AllocateNativeOverlapped_PreAllocated_ThrowsArgumentNullException()
2628
{
2729
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -34,6 +36,7 @@ public unsafe void AllocateNativeOverlapped_PreAllocated_ThrowsArgumentNullExcep
3436
}
3537

3638
[Fact]
39+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
3740
public unsafe void AllocateNativeOverlapped_NullAsContext_DoesNotThrow()
3841
{
3942
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -47,6 +50,7 @@ public unsafe void AllocateNativeOverlapped_NullAsContext_DoesNotThrow()
4750
}
4851

4952
[Fact]
53+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
5054
public unsafe void AllocateNativeOverlapped_NullAsPinData_DoesNotThrow()
5155
{
5256
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -60,6 +64,7 @@ public unsafe void AllocateNativeOverlapped_NullAsPinData_DoesNotThrow()
6064
}
6165

6266
[Fact]
67+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
6368
public unsafe void AllocateNativeOverlapped_EmptyArrayAsPinData_DoesNotThrow()
6469
{
6570
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -73,6 +78,7 @@ public unsafe void AllocateNativeOverlapped_EmptyArrayAsPinData_DoesNotThrow()
7378
}
7479

7580
[Fact]
81+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
7682
public unsafe void AllocateNativeOverlapped_NonBlittableTypeAsPinData_Throws()
7783
{
7884
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -82,6 +88,7 @@ public unsafe void AllocateNativeOverlapped_NonBlittableTypeAsPinData_Throws()
8288
}
8389

8490
[Fact]
91+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
8592
public unsafe void AllocateNativeOverlapped_BlittableTypeAsPinData_DoesNotThrow()
8693
{
8794
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -95,6 +102,7 @@ public unsafe void AllocateNativeOverlapped_BlittableTypeAsPinData_DoesNotThrow(
95102
}
96103

97104
[Fact]
105+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
98106
public unsafe void AllocateNativeOverlapped_ObjectArrayAsPinData_DoesNotThrow()
99107
{
100108
object[] array = new object[]
@@ -113,6 +121,7 @@ public unsafe void AllocateNativeOverlapped_ObjectArrayAsPinData_DoesNotThrow()
113121
}
114122

115123
[Fact]
124+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
116125
public unsafe void AllocateNativeOverlapped_ObjectArrayWithNonBlittableTypeAsPinData_Throws()
117126
{
118127
object[] array = new object[]
@@ -127,6 +136,7 @@ public unsafe void AllocateNativeOverlapped_ObjectArrayWithNonBlittableTypeAsPin
127136
}
128137

129138
[Fact]
139+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
130140
public unsafe void AllocateNativeOverlapped_ReturnedNativeOverlapped_AllFieldsZero()
131141
{
132142
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -144,6 +154,7 @@ public unsafe void AllocateNativeOverlapped_ReturnedNativeOverlapped_AllFieldsZe
144154
}
145155

146156
[Fact]
157+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
147158
public unsafe void AllocateNativeOverlapped_PreAllocated_ReturnedNativeOverlapped_AllFieldsZero()
148159
{
149160
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -164,6 +175,7 @@ public unsafe void AllocateNativeOverlapped_PreAllocated_ReturnedNativeOverlappe
164175
}
165176

166177
[Fact]
178+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
167179
public unsafe void AllocateNativeOverlapped_PossibleReusedReturnedNativeOverlapped_OffsetLowAndOffsetHighSetToZero()
168180
{ // The CLR reuses NativeOverlapped underneath, check to make sure that they reset fields back to zero
169181

@@ -187,6 +199,7 @@ public unsafe void AllocateNativeOverlapped_PossibleReusedReturnedNativeOverlapp
187199
}
188200

189201
[Fact]
202+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
190203
public unsafe void AllocateNativeOverlapped_PreAllocated_ReusedReturnedNativeOverlapped_OffsetLowAndOffsetHighSetToZero()
191204
{ // The CLR reuses NativeOverlapped underneath, check to make sure that they reset fields back to zero
192205

@@ -211,6 +224,7 @@ public unsafe void AllocateNativeOverlapped_PreAllocated_ReusedReturnedNativeOve
211224
}
212225

213226
[Fact]
227+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
214228
public unsafe void AllocateNativeOverlapped_WhenDisposed_ThrowsObjectDisposedException()
215229
{
216230
ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle();
@@ -223,6 +237,7 @@ public unsafe void AllocateNativeOverlapped_WhenDisposed_ThrowsObjectDisposedExc
223237
}
224238

225239
[Fact]
240+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
226241
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenDisposed_ThrowsObjectDisposedException()
227242
{
228243
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -238,6 +253,7 @@ public unsafe void AllocateNativeOverlapped_PreAllocated_WhenDisposed_ThrowsObje
238253
}
239254

240255
[Fact]
256+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
241257
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenHandleDisposed_ThrowsObjectDisposedException()
242258
{
243259
ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle();
@@ -252,6 +268,7 @@ public unsafe void AllocateNativeOverlapped_PreAllocated_WhenHandleDisposed_Thro
252268
}
253269

254270
[Fact]
271+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
255272
public unsafe void AllocateNativeOverlapped_PreAllocated_WhenAlreadyAllocated_ThrowsArgumentException()
256273
{
257274
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_BindHandleTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public void BindHandle_MinusOneAsHandle_ThrowsArgumentException()
4343
}
4444

4545
[Fact]
46+
[PlatformSpecific(TestPlatforms.AnyUnix)]
47+
public void BindHandle_ValidHandle_ThrowsPlatformNotSupportedException()
48+
{
49+
Assert.Throws<PlatformNotSupportedException>(() => ThreadPoolBoundHandle.BindHandle(new Win32Handle(new IntPtr(1))));
50+
}
51+
52+
[Fact]
53+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
4654
public void BindHandle_SyncHandleAsHandle_ThrowsArgumentException()
4755
{ // Can't bind a handle that was not opened for overlapped I/O
4856

@@ -56,6 +64,7 @@ public void BindHandle_SyncHandleAsHandle_ThrowsArgumentException()
5664
}
5765

5866
[Fact]
67+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
5968
public void BindHandle_ClosedSyncHandleAsHandle_ThrowsArgumentException()
6069
{
6170
using(Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite())
@@ -70,6 +79,7 @@ public void BindHandle_ClosedSyncHandleAsHandle_ThrowsArgumentException()
7079
}
7180

7281
[Fact]
82+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
7383
public void BindHandle_ClosedAsyncHandleAsHandle_ThrowsArgumentException()
7484
{
7585
using(Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -84,6 +94,7 @@ public void BindHandle_ClosedAsyncHandleAsHandle_ThrowsArgumentException()
8494
}
8595

8696
[Fact]
97+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
8798
public void BindHandle_DisposedSyncHandleAsHandle_ThrowsArgumentException()
8899
{
89100
Win32Handle handle = HandleFactory.CreateSyncFileHandleFoWrite();
@@ -97,6 +108,7 @@ public void BindHandle_DisposedSyncHandleAsHandle_ThrowsArgumentException()
97108

98109

99110
[Fact]
111+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
100112
public void BindHandle_DisposedAsyncHandleAsHandle_ThrowsArgumentException()
101113
{
102114
Win32Handle handle = HandleFactory.CreateAsyncFileHandleForWrite();
@@ -109,6 +121,7 @@ public void BindHandle_DisposedAsyncHandleAsHandle_ThrowsArgumentException()
109121
}
110122

111123
[Fact]
124+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
112125
public void BindHandle_AlreadyBoundHandleAsHandle_ThrowsArgumentException()
113126
{
114127
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_DisposeTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
public partial class ThreadPoolBoundHandleTests
99
{
1010
[Fact]
11+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
1112
public void Dispose_CalledMultipleTimes_DoesNotThrow()
1213
{
1314
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -17,6 +18,7 @@ public void Dispose_CalledMultipleTimes_DoesNotThrow()
1718
}
1819

1920
[Fact]
21+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
2022
public void Dispose_DoesNotDisposeHandle()
2123
{
2224
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -29,6 +31,7 @@ public void Dispose_DoesNotDisposeHandle()
2931
}
3032

3133
[Fact]
34+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
3235
public unsafe void Dispose_WithoutFreeingNativeOverlapped_DoesNotThrow()
3336
{
3437
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_FreeNativeOverlappedTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public partial class ThreadPoolBoundHandleTests
1010
{
1111
[Fact]
12+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
1213
public unsafe void FreeNativeOverlapped_NullAsNativeOverlapped_ThrowsArgumentNullException()
1314
{
1415
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())
@@ -21,6 +22,7 @@ public unsafe void FreeNativeOverlapped_NullAsNativeOverlapped_ThrowsArgumentNul
2122
}
2223

2324
[Fact]
25+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
2426
public unsafe void FreeNativeOverlapped_WhenDisposed_DoesNotThrow()
2527
{
2628
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
@@ -30,6 +32,7 @@ public unsafe void FreeNativeOverlapped_WhenDisposed_DoesNotThrow()
3032
}
3133

3234
[Fact]
35+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
3336
public unsafe void FreeNativeOverlapped_WithWrongHandle_ThrowsArgumentException()
3437
{
3538
using(ThreadPoolBoundHandle handle = CreateThreadPoolBoundHandle())

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_GetNativeOverlappedStateTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public unsafe void GetNativeOverlappedState_NullAsNativeOverlapped_ThrowsArgumen
1919
}
2020

2121
[Fact]
22+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
2223
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsNull_ReturnsNull()
2324
{
2425
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -37,6 +38,7 @@ public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsNull_ReturnsNul
3738
}
3839

3940
[Fact]
41+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
4042
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsObject_ReturnsObject()
4143
{
4244
object context = new object();
@@ -57,6 +59,7 @@ public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsObject_ReturnsO
5759
}
5860

5961
[Fact]
62+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
6063
public unsafe void GetNativeOverlappedState_WhenUnderlyingStateIsIAsyncResult_ReturnsIAsyncResult()
6164
{ // CoreCLR/Desktop CLR version of overlapped sits on top of Overlapped class
6265
// and treats IAsyncResult specially, which is why we special case this case.

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_HandleTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public partial class ThreadPoolBoundHandleTests
1010
{
1111
[Fact]
12+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
1213
public void Handle_ReturnsHandle()
1314
{
1415
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())
@@ -21,6 +22,7 @@ public void Handle_ReturnsHandle()
2122
}
2223

2324
[Fact]
25+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
2426
public void Handle_AfterDisposed_DoesNotThrow()
2527
{
2628
using(SafeHandle handle = HandleFactory.CreateAsyncFileHandleForWrite())

src/System.Threading.Overlapped/tests/ThreadPoolBoundHandle_IntegrationTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public partial class ThreadPoolBoundHandleTests
1111
{
1212
[Fact]
13+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
1314
public unsafe void SingleOperationOverSingleHandle()
1415
{
1516
const int DATA_SIZE = 2;
@@ -47,6 +48,7 @@ public unsafe void SingleOperationOverSingleHandle()
4748
}
4849

4950
[Fact]
51+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
5052
public unsafe void MultipleOperationsOverSingleHandle()
5153
{
5254
const int DATA_SIZE = 2;
@@ -104,6 +106,7 @@ public unsafe void MultipleOperationsOverSingleHandle()
104106
}
105107

106108
[Fact]
109+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
107110
public unsafe void MultipleOperationsOverMultipleHandles()
108111
{
109112
const int DATA_SIZE = 2;
@@ -175,6 +178,7 @@ public unsafe void MultipleOperationsOverMultipleHandles()
175178
}
176179

177180
[Fact]
181+
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
178182
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Active Issue dotnet/corefx#13343")]
179183
public unsafe void FlowsAsyncLocalsToCallback()
180184
{ // Makes sure that we flow async locals to callback

0 commit comments

Comments
 (0)