You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@@ -7,6 +7,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Threading.Thread.Tes
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C} = {06197EED-FF48-43F3-976D-463839D43E8C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTAMain", "tests\MTAMain\MTAMain.csproj", "{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C} = {06197EED-FF48-43F3-976D-463839D43E8C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STAMain", "tests\STAMain\STAMain.csproj", "{8045E634-C181-4C6C-AE48-71AC18D1C637}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C} = {06197EED-FF48-43F3-976D-463839D43E8C}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Threading.Thread", "src\System.Threading.Thread.csproj", "{06197EED-FF48-43F3-976D-463839D43E8C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{82D06A2D-008D-4A4A-A83D-FB7F04721C87} = {82D06A2D-008D-4A4A-A83D-FB7F04721C87}
|
||||
@@ -26,10 +36,18 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Debug|Any CPU.ActiveCfg = netcoreapp-Debug|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Debug|Any CPU.Build.0 = netcoreapp-Debug|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Release|Any CPU.ActiveCfg = netcoreapp-Release|Any CPU
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE}.Release|Any CPU.Build.0 = netcoreapp-Release|Any CPU
|
||||
{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
|
||||
{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
|
||||
{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
|
||||
{06B19C7D-9EBE-420F-BD33-137DB18A1FEB}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
|
||||
{8045E634-C181-4C6C-AE48-71AC18D1C637}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
|
||||
{8045E634-C181-4C6C-AE48-71AC18D1C637}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
|
||||
{8045E634-C181-4C6C-AE48-71AC18D1C637}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
|
||||
{8045E634-C181-4C6C-AE48-71AC18D1C637}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C}.Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C}.Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C}.Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
|
||||
@@ -44,6 +62,8 @@ Global
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{33F5A50E-B823-4FDD-8571-365C909ACEAE} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
|
||||
{06B19C7D-9EBE-420F-BD33-137DB18A1FEB} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
|
||||
{8045E634-C181-4C6C-AE48-71AC18D1C637} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
|
||||
{06197EED-FF48-43F3-976D-463839D43E8C} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
|
||||
{82D06A2D-008D-4A4A-A83D-FB7F04721C87} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
|
||||
EndGlobalSection
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace System.Threading
|
||||
public System.Threading.ApartmentState GetApartmentState() { throw null; }
|
||||
[System.ObsoleteAttribute("Thread.GetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
|
||||
public System.Threading.CompressedStack GetCompressedStack() { throw null; }
|
||||
public static int GetCurrentProcessorId() { throw null; }
|
||||
public static object GetData(System.LocalDataStoreSlot slot) { throw null; }
|
||||
public static System.AppDomain GetDomain() { throw null; }
|
||||
public static int GetDomainID() { throw null; }
|
||||
|
||||
@@ -272,6 +272,7 @@ namespace System.Threading
|
||||
throw new InvalidOperationException(SR.Thread_GetSetCompressedStack_NotSupported);
|
||||
}
|
||||
|
||||
public static int GetCurrentProcessorId() => RuntimeThread.GetCurrentProcessorId();
|
||||
public static AppDomain GetDomain() => AppDomain.CurrentDomain;
|
||||
public static int GetDomainID() => GetDomain().Id;
|
||||
public override int GetHashCode() => ManagedThreadId;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
netstandard;
|
||||
netcoreapp;
|
||||
uap;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -7,12 +7,19 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="CompressedStackTests.cs" />
|
||||
<Compile Include="ExceptionTests.cs" />
|
||||
<Compile Include="ThreadExceptionEventArgsTests.cs" />
|
||||
<Compile Include="ThreadTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
|
||||
<Compile Include="ThreadTests.netcoreapp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(CommonTestPath)\System\Threading\ThreadTestHelpers.cs">
|
||||
<Link>CommonTest\System\Threading\ThreadPoolHelpers.cs</Link>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace System.Threading.Threads.Tests
|
||||
public static string HostRunnerTest = HostRunner;
|
||||
}
|
||||
|
||||
public static class ThreadTests
|
||||
public static partial class ThreadTests
|
||||
{
|
||||
private const int UnexpectedTimeoutMilliseconds = ThreadTestHelpers.UnexpectedTimeoutMilliseconds;
|
||||
private const int ExpectedTimeoutMilliseconds = ThreadTestHelpers.ExpectedTimeoutMilliseconds;
|
||||
@@ -26,6 +26,11 @@ namespace System.Threading.Threads.Tests
|
||||
[Fact]
|
||||
public static void ConstructorTest()
|
||||
{
|
||||
const int SmallStackSize = 64 << 10; // 64 KB, currently accepted in all supported platforms, and is the PAL minimum
|
||||
const int LargeStackSize = 2 << 20; // 2 MB, see https://github.com/dotnet/coreclr/issues/17170
|
||||
|
||||
int pageSizeBytes = Environment.SystemPageSize;
|
||||
|
||||
Action<Thread> startThreadAndJoin =
|
||||
t =>
|
||||
{
|
||||
@@ -38,22 +43,25 @@ namespace System.Threading.Threads.Tests
|
||||
{
|
||||
// Try to stack-allocate an array to verify that close to the expected amount of stack space is actually
|
||||
// available
|
||||
int bufferSizeBytes = Math.Max(16 << 10, stackSizeBytes - (64 << 10));
|
||||
int bufferSizeBytes = Math.Max(16 << 10, stackSizeBytes - SmallStackSize);
|
||||
unsafe
|
||||
{
|
||||
byte* buffer = stackalloc byte[bufferSizeBytes];
|
||||
Volatile.Write(ref buffer[0], 0xff);
|
||||
for (int i = 0; i < bufferSizeBytes; i += pageSizeBytes)
|
||||
{
|
||||
Volatile.Write(ref buffer[i], 0xff);
|
||||
}
|
||||
Volatile.Write(ref buffer[bufferSizeBytes - 1], 0xff);
|
||||
}
|
||||
};
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(0)));
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(0), 0));
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(64 << 10), 64 << 10)); // 64 KB
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(16 << 20), 16 << 20)); // 16 MB
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(SmallStackSize), SmallStackSize));
|
||||
startThreadAndJoin(new Thread(() => verifyStackSize(LargeStackSize), LargeStackSize));
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(0)));
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(0), 0));
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(64 << 10), 64 << 10)); // 64 KB
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(16 << 20), 16 << 20)); // 16 MB
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(SmallStackSize), SmallStackSize));
|
||||
startThreadAndJoin(new Thread(state => verifyStackSize(LargeStackSize), LargeStackSize));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => new Thread((ThreadStart)null));
|
||||
Assert.Throws<ArgumentNullException>(() => new Thread((ThreadStart)null, 0));
|
||||
@@ -506,12 +514,43 @@ namespace System.Threading.Threads.Tests
|
||||
[Fact]
|
||||
public static void NameTest()
|
||||
{
|
||||
var t = new Thread(() => { });
|
||||
string name = Guid.NewGuid().ToString("N");
|
||||
Action waitForThread;
|
||||
var t =
|
||||
ThreadTestHelpers.CreateGuardedThread(out waitForThread, () =>
|
||||
{
|
||||
var ct = Thread.CurrentThread;
|
||||
Assert.Equal(name, ct.Name);
|
||||
Assert.Throws<InvalidOperationException>(() => ct.Name = null);
|
||||
Assert.Throws<InvalidOperationException>(() => ct.Name = name + "b");
|
||||
Assert.Equal(name, ct.Name);
|
||||
});
|
||||
t.IsBackground = true;
|
||||
Assert.Null(t.Name);
|
||||
t.Name = "a";
|
||||
Assert.Equal("a", t.Name);
|
||||
Assert.Throws<InvalidOperationException>(() => t.Name = "b");
|
||||
Assert.Equal("a", t.Name);
|
||||
t.Name = null;
|
||||
t.Name = null;
|
||||
Assert.Null(t.Name);
|
||||
t.Name = name;
|
||||
Assert.Equal(name, t.Name);
|
||||
Assert.Throws<InvalidOperationException>(() => t.Name = null);
|
||||
Assert.Throws<InvalidOperationException>(() => t.Name = name + "b");
|
||||
Assert.Equal(name, t.Name);
|
||||
t.Start();
|
||||
waitForThread();
|
||||
|
||||
ThreadTestHelpers.RunTestInBackgroundThread(() =>
|
||||
{
|
||||
var ct = Thread.CurrentThread;
|
||||
Assert.Null(ct.Name);
|
||||
ct.Name = null;
|
||||
ct.Name = null;
|
||||
Assert.Null(ct.Name);
|
||||
ct.Name = name;
|
||||
Assert.Equal(name, ct.Name);
|
||||
Assert.Throws<InvalidOperationException>(() => ct.Name = null);
|
||||
Assert.Throws<InvalidOperationException>(() => ct.Name = name + "b");
|
||||
Assert.Equal(name, ct.Name);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -893,7 +932,12 @@ namespace System.Threading.Threads.Tests
|
||||
{
|
||||
var e = new AutoResetEvent(false);
|
||||
Action waitForThread;
|
||||
var t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, e.CheckedWait);
|
||||
Thread t = null;
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, () =>
|
||||
{
|
||||
e.CheckedWait();
|
||||
Assert.Same(t, Thread.CurrentThread);
|
||||
});
|
||||
t.IsBackground = true;
|
||||
Assert.Throws<InvalidOperationException>(() => t.Start(null));
|
||||
Assert.Throws<InvalidOperationException>(() => t.Start(t));
|
||||
@@ -915,17 +959,29 @@ namespace System.Threading.Threads.Tests
|
||||
Assert.Throws<ThreadStateException>(() => t.Start(null));
|
||||
Assert.Throws<ThreadStateException>(() => t.Start(t));
|
||||
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter => Assert.Null(parameter));
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter =>
|
||||
{
|
||||
Assert.Null(parameter);
|
||||
Assert.Same(t, Thread.CurrentThread);
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start();
|
||||
waitForThread();
|
||||
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter => Assert.Null(parameter));
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter =>
|
||||
{
|
||||
Assert.Null(parameter);
|
||||
Assert.Same(t, Thread.CurrentThread);
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start(null);
|
||||
waitForThread();
|
||||
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter => Assert.Equal(t, parameter));
|
||||
t = ThreadTestHelpers.CreateGuardedThread(out waitForThread, parameter =>
|
||||
{
|
||||
Assert.Same(t, parameter);
|
||||
Assert.Same(t, Thread.CurrentThread);
|
||||
});
|
||||
t.IsBackground = true;
|
||||
t.Start(t);
|
||||
waitForThread();
|
||||
|
||||
16
external/corefx/src/System.Threading.Thread/tests/ThreadTests.netcoreapp.cs
vendored
Normal file
16
external/corefx/src/System.Threading.Thread/tests/ThreadTests.netcoreapp.cs
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace System.Threading.Threads.Tests
|
||||
{
|
||||
public static partial class ThreadTests
|
||||
{
|
||||
public static void GetCurrentProcessorId()
|
||||
{
|
||||
Assert.True(Thread.GetCurrentProcessorId() >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user