Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/baseservices')
-rw-r--r--src/tests/baseservices/exceptions/simple/ParallelCrash.cs63
-rw-r--r--src/tests/baseservices/exceptions/simple/ParallelCrash.csproj12
-rw-r--r--src/tests/baseservices/exceptions/simple/ParallelCrashMainThread.csproj10
-rw-r--r--src/tests/baseservices/exceptions/simple/ParallelCrashWorkerThreads.csproj10
4 files changed, 95 insertions, 0 deletions
diff --git a/src/tests/baseservices/exceptions/simple/ParallelCrash.cs b/src/tests/baseservices/exceptions/simple/ParallelCrash.cs
new file mode 100644
index 00000000000..0232e7690ae
--- /dev/null
+++ b/src/tests/baseservices/exceptions/simple/ParallelCrash.cs
@@ -0,0 +1,63 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+// Runtime stability in the presence of concurrent fatal errors
+
+public class ParallelCrash
+{
+ private const int ThreadCount = 10;
+
+ private volatile static int s_runningThreads;
+ private static bool s_crashMainThread;
+ private static bool s_crashWorkerThreads;
+
+ public static int Main(string[] args)
+ {
+ s_crashMainThread = true;
+ s_crashWorkerThreads = true;
+ if (args.Length > 0)
+ {
+ s_crashMainThread = (args[0] != "2");
+ s_crashWorkerThreads = (args[0] != "1");
+ }
+
+ for (int threadIndex = ThreadCount; --threadIndex >= 0;)
+ {
+ new Thread(CrashInParallel).Start();
+ }
+ if (s_crashMainThread)
+ {
+ Environment.FailFast("Parallel crash in main thread");
+ }
+ for (;;)
+ {
+ Thread.Sleep(50);
+ }
+ return 0;
+ }
+
+ private static void CrashInParallel()
+ {
+ int threadIndex = Interlocked.Increment(ref s_runningThreads);
+ string failFastMessage = string.Format("Parallel crash in thread {0}!\n", threadIndex);
+ while (s_runningThreads != ThreadCount)
+ {
+ }
+ // Now all the worker threads should be running, fire!
+ if (s_crashWorkerThreads)
+ {
+ Environment.FailFast(failFastMessage);
+ }
+ for (;;)
+ {
+ Thread.Sleep(50);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/tests/baseservices/exceptions/simple/ParallelCrash.csproj b/src/tests/baseservices/exceptions/simple/ParallelCrash.csproj
new file mode 100644
index 00000000000..e9456aa187f
--- /dev/null
+++ b/src/tests/baseservices/exceptions/simple/ParallelCrash.csproj
@@ -0,0 +1,12 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExitCode>134</CLRTestExitCode>
+ <CLRTestExitCode Condition="'$(TestWrapperTargetsWindows)' == 'true'">-2146232797</CLRTestExitCode>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="ParallelCrash.cs" />
+ </ItemGroup>
+</Project>
diff --git a/src/tests/baseservices/exceptions/simple/ParallelCrashMainThread.csproj b/src/tests/baseservices/exceptions/simple/ParallelCrashMainThread.csproj
new file mode 100644
index 00000000000..67d53cb9df7
--- /dev/null
+++ b/src/tests/baseservices/exceptions/simple/ParallelCrashMainThread.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <CLRTestKind>RunOnly</CLRTestKind>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestProjectToRun>ParallelCrash.csproj</CLRTestProjectToRun>
+ <CLRTestExecutionArguments>1</CLRTestExecutionArguments>
+ <CLRTestExitCode>134</CLRTestExitCode>
+ <CLRTestExitCode Condition="'$(TestWrapperTargetsWindows)' == 'true'">-2146232797</CLRTestExitCode>
+ </PropertyGroup>
+</Project>
diff --git a/src/tests/baseservices/exceptions/simple/ParallelCrashWorkerThreads.csproj b/src/tests/baseservices/exceptions/simple/ParallelCrashWorkerThreads.csproj
new file mode 100644
index 00000000000..03d65d6d1b2
--- /dev/null
+++ b/src/tests/baseservices/exceptions/simple/ParallelCrashWorkerThreads.csproj
@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <CLRTestKind>RunOnly</CLRTestKind>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestProjectToRun>ParallelCrash.csproj</CLRTestProjectToRun>
+ <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExitCode>134</CLRTestExitCode>
+ <CLRTestExitCode Condition="'$(TestWrapperTargetsWindows)' == 'true'">-2146232797</CLRTestExitCode>
+ </PropertyGroup>
+</Project>