diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2016-03-03 12:24:52 -0800 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2016-03-03 12:24:52 -0800 |
commit | 316e43433443447d345c7a48b9deb5cdd7946144 (patch) | |
tree | 7aadb71ef255f4201c9624da9d1fe7de0c8caaaa /tests/src/baseservices | |
parent | fdc40a40581f6a601ba508e33ad641640a956f91 (diff) | |
download | coreclr-316e43433443447d345c7a48b9deb5cdd7946144.tar.gz coreclr-316e43433443447d345c7a48b9deb5cdd7946144.tar.bz2 coreclr-316e43433443447d345c7a48b9deb5cdd7946144.zip |
Open source tests from baseservices/threading.
Diffstat (limited to 'tests/src/baseservices')
228 files changed, 16836 insertions, 0 deletions
diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs new file mode 100644 index 0000000000..0f96e70ec3 --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +// using System.Configuration; +using System.Runtime.InteropServices; + +namespace StackCommitTest +{ + class DefaultStackCommit + { + static int Main(string[] args) + { + int result = 1; + bool commitEnabled = false; + + if (Utility.RunTest(commitEnabled)) + { + result = 100; + } + + Console.WriteLine(result == 100 ? "Success!" : "FAILED!"); + return result; + } + } +} diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj new file mode 100644 index 0000000000..5966cfb6ce --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/DefaultStackCommit.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{c485e164-f82c-4a4f-a02e-bc711827e5be}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="DefaultStackCommit.cs" /> + <Compile Include="StackCommitCommon.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config b/tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config new file mode 100644 index 0000000000..eaa1bdc3f4 --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/DisablePreCommit.exe.config @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <runtime> + <disableCommitThreadStack enabled="1" /> + </runtime> + <appSettings> + <add key="expectStackCommit" value="false"/> + </appSettings> +</configuration> diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config b/tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config new file mode 100644 index 0000000000..cc68420ce8 --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/EnablePreCommit.exe.config @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <runtime> + <disableCommitThreadStack enabled="0" /> + </runtime> + <appSettings> + <add key="expectStackCommit" value="true"/> + </appSettings> +</configuration> diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs new file mode 100644 index 0000000000..59dd9f24b9 --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/StackCommitCommon.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Threading; +//using System.Configuration; + +namespace StackCommitTest +{ + public unsafe class WinApi + { + [DllImport("kernel32.dll")] + public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo); + + [StructLayout(LayoutKind.Sequential)] + public struct SYSTEM_INFO + { + internal PROCESSOR_INFO_UNION uProcessorInfo; + public uint dwPageSize; + public IntPtr lpMinimumApplicationAddress; + public IntPtr lpMaximumApplicationAddress; + public IntPtr dwActiveProcessorMask; + public uint dwNumberOfProcessors; + public uint dwProcessorType; + public uint dwAllocationGranularity; + public ushort dwProcessorLevel; + public ushort dwProcessorRevision; + } + + [StructLayout(LayoutKind.Explicit)] + public struct PROCESSOR_INFO_UNION + { + [FieldOffset(0)] + internal uint dwOemId; + [FieldOffset(0)] + internal ushort wProcessorArchitecture; + [FieldOffset(2)] + internal ushort wReserved; + } + + [DllImport("kernel32")] + public static extern IntPtr VirtualQuery(void* address, ref MEMORY_BASIC_INFORMATION buffer, IntPtr length); + + public struct MEMORY_BASIC_INFORMATION + { + public byte* BaseAddress; + public byte* AllocationBase; + public int AllocationProtect; + public IntPtr RegionSize; + public MemState State; + public int Protect; + public int Type; + } + + [Flags] + public enum MemState + { + MEM_COMMIT = 0x1000, + MEM_RESERVE = 0x2000, + MEM_FREE = 0x10000, + } + + + public const int PAGE_GUARD = 0x100; + + } + + unsafe public static class Utility + { + public static Int64 PageSize { get; private set; } + + static Utility() + { + WinApi.SYSTEM_INFO sysInfo = new WinApi.SYSTEM_INFO(); + + WinApi.GetSystemInfo(ref sysInfo); + + PageSize = (Int64)sysInfo.dwPageSize; + } + + public static void GetStackExtents(out byte* stackBase, out long stackSize) + { + WinApi.MEMORY_BASIC_INFORMATION info = new WinApi.MEMORY_BASIC_INFORMATION(); + WinApi.VirtualQuery(&info, ref info, new IntPtr(sizeof(WinApi.MEMORY_BASIC_INFORMATION))); + stackBase = info.AllocationBase; + stackSize = (info.BaseAddress - info.AllocationBase) + info.RegionSize.ToInt64(); + } + + public static List<WinApi.MEMORY_BASIC_INFORMATION> GetRegionsOfStack() + { + byte* stackBase; + long stackSize; + GetStackExtents(out stackBase, out stackSize); + + List<WinApi.MEMORY_BASIC_INFORMATION> result = new List<WinApi.MEMORY_BASIC_INFORMATION>(); + + byte* current = stackBase; + while (current < stackBase + stackSize) + { + WinApi.MEMORY_BASIC_INFORMATION info = new WinApi.MEMORY_BASIC_INFORMATION(); + WinApi.VirtualQuery(current, ref info, new IntPtr(sizeof(WinApi.MEMORY_BASIC_INFORMATION))); + result.Add(info); + current = info.BaseAddress + info.RegionSize.ToInt64(); + } + + result.Reverse(); + return result; + } + + + public static bool ValidateStack(string threadName, bool shouldBePreCommitted, Int32 expectedStackSize) + { + bool result = true; + + byte* stackBase; + long stackSize; + GetStackExtents(out stackBase, out stackSize); + + Console.WriteLine("{2} -- Base: {0:x}, Size: {1}kb", new IntPtr(stackBase).ToInt64(), stackSize / 1024, threadName); + + // + // Start at the highest addresses, which should be committed (because that's where we're currently running). + // The next region should be committed, but marked as a guard page. + // After that, we'll either find committed pages, or reserved pages, depending on whether the runtime + // is pre-committing stacks. + // + bool foundGuardRegion = false; + + foreach (var info in GetRegionsOfStack()) + { + string regionType = string.Empty; + + if (!foundGuardRegion) + { + if ((info.Protect & WinApi.PAGE_GUARD) != 0) + { + foundGuardRegion = true; + regionType = "guard region"; + } + else + { + regionType = "active region"; + } + } + else + { + if (shouldBePreCommitted) + { + if (!info.State.HasFlag(WinApi.MemState.MEM_COMMIT)) + { + // If we pre-commit the stack, the last 1 or 2 pages are left "reserved" (they are the "hard guard region") + // ??? How to decide whether it is 1 or 2 pages? + if ((info.BaseAddress != stackBase || info.RegionSize.ToInt64() > PageSize)) + { + result = false; + regionType = "<---- should be pre-committed"; + } + } + } + else + { + if (info.State.HasFlag(WinApi.MemState.MEM_COMMIT)) + { + result = false; + regionType = "<---- should not be pre-committed"; + } + } + } + + Console.WriteLine( + "{0:x8}-{1:x8} {2,5:g}kb {3,-11:g} {4}", + new IntPtr(info.BaseAddress).ToInt64(), + new IntPtr(info.BaseAddress + info.RegionSize.ToInt64()).ToInt64(), + info.RegionSize.ToInt64() / 1024, + info.State, + regionType); + } + + if (!foundGuardRegion) + { + result = false; + + Console.WriteLine("Did not find GuardRegion for the whole stack"); + } + + if (expectedStackSize != -1 && stackSize != expectedStackSize) + { + result = false; + + Console.WriteLine("Stack size is not as expected: actual -- {0}, expected -- {1}", stackSize, expectedStackSize); + } + + Console.WriteLine(); + return result; + } + + static private bool RunTestItem(string threadName, bool shouldBePreCommitted, Int32 expectedThreadSize, Action<Action> runOnThread) + { + bool result = false; + ManualResetEventSlim mre = new ManualResetEventSlim(); + + runOnThread(() => + { + result = Utility.ValidateStack(threadName, shouldBePreCommitted, expectedThreadSize); + mre.Set(); + }); + + mre.Wait(); + return result; + } + + static public bool RunTest(bool shouldBePreCommitted) + { + if (RunTestItem("Main", shouldBePreCommitted, -1, action => action()) & + RunTestItem("ThreadPool", shouldBePreCommitted, -1, action => ThreadPool.QueueUserWorkItem(state => action())) & + RunTestItem("new Thread()", shouldBePreCommitted, -1, action => new Thread(() => action()).Start()) & + //RunTestItem("new Thread(512kb)", true, 512 * 1024, action => new Thread(() => action(), 512 * 1024).Start()) & + RunTestItem("Finalizer", shouldBePreCommitted, -1, action => Finalizer.Run(action))) + { + return true; + } + + return false; + } + } + + public class Finalizer + { + Action m_action; + private Finalizer(Action action) { m_action = action; } + ~Finalizer() { m_action(); } + + public static void Run(Action action) + { + new Finalizer(action); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/commitstackonlyasneeded/project.json b/tests/src/baseservices/threading/commitstackonlyasneeded/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/commitstackonlyasneeded/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs new file mode 100644 index 0000000000..2d9e4b6a31 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.cs @@ -0,0 +1,147 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + AutoResetEvent are = null; + + Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + +// try { +// #pragma warning disable 618 +// are.Handle = new IntPtr(1); +// #pragma warning restore 618 +// rValue = 1; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (are.Handle(new IntPtr(1)))"); +// } +// try { +// #pragma warning disable 618 +// IntPtr iptr = are.Handle; +// #pragma warning restore 618 +// rValue = 2; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (IntPtr iptr = are.Handle)"); +// } + + // try { + // are.Close(); + // rValue = 3; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (are.Close())"); + // } + + try { + are.Equals(new ManualResetEvent(true)); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.Equals(new ManualResetEvent()))"); + } + + try { + are.GetHashCode(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.GetHasCode())"); + } + + // try { + // are.GetLifetimeService(); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (are.GetLifetimeService())"); + // } + + try { + are.GetType(); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.GetType())"); + } + + // try { + // are.InitializeLifetimeService(); + // rValue = 8; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (are.InitializeLifeTimeService())"); + // } + + try { + are.Reset(); + rValue = 9; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.Reset())"); + } + + try { + are.Set(); + rValue = 10; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.Set())"); + } + + try { + are.ToString(); + rValue = 11; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.ToString())"); + } + + try { + are.WaitOne(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.WaitOne())"); + } + + try { + are.WaitOne(1000);//,true); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.WaitOne(int,bool))"); + } + + // try { + // are.WaitOne(1000);//,false); + // rValue = 14; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (are.WaitOne(int,bool))"); + // } + + try { + are.WaitOne(new TimeSpan(1000));//,true); + rValue = 15; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (are.WaitOne(TimeSpan,bool))"); + } + + // try { + // are.WaitOne(new TimeSpan(1000));//,false); + // rValue = 16; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (are.WaitOne(TimeSpan,bool))"); + // } + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj new file mode 100644 index 0000000000..65323f983f --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_ARENullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_ARENullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs new file mode 100644 index 0000000000..443cd2a26b --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.cs @@ -0,0 +1,147 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + ManualResetEvent mre = null; + + Console.WriteLine("Test ManualResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + +// try { +// #pragma warning disable 618 +// mre.Handle = new IntPtr(1); +// #pragma warning restore 618 +// rValue = 1; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (mre.Handle(new IntPtr(1)))"); +// } +// try { +// #pragma warning disable 618 +// IntPtr iptr = mre.Handle; +// #pragma warning restore 618 +// rValue = 2; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (IntPtr iptr = mre.Handle)"); +// } + + // try { + // mre.Close(); + // rValue = 3; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mre.Close())"); + // } + + try { + mre.Equals(new ManualResetEvent(true)); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.Equals(new ManualResetEvent()))"); + } + + try { + mre.GetHashCode(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.GetHasCode())"); + } + + // try { + // mre.GetLifetimeService(); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mre.GetLifetimeService())"); + // } + + try { + mre.GetType(); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.GetType())"); + } + + // try { + // mre.InitializeLifetimeService(); + // rValue = 8; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mre.InitializeLifeTimeService())"); + // } + + try { + mre.Reset(); + rValue = 9; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.Reset())"); + } + + try { + mre.Set(); + rValue = 10; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.Set())"); + } + + try { + mre.ToString(); + rValue = 11; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.ToString())"); + } + + try { + mre.WaitOne(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.WaitOne())"); + } + + try { + mre.WaitOne(1000);//,true); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.WaitOne(int)"); + } + + // try { + // mre.WaitOne(1000);//,false); + // rValue = 14; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mre.WaitOne(int,bool))"); + // } + + try { + mre.WaitOne(new TimeSpan(1000));//,true); + rValue = 15; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mre.WaitOne(TimeSpan)"); + } + + // try { + // mre.WaitOne(new TimeSpan(1000));//,false); + // rValue = 16; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mre.WaitOne(TimeSpan,bool))"); + // } + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj new file mode 100644 index 0000000000..797ad91946 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_MRENullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_MRENullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs new file mode 100644 index 0000000000..dfa05584a1 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.cs @@ -0,0 +1,139 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + Mutex mut = null; + + Console.WriteLine("Test Mutex for expected NullRef Exceptions"); + Console.WriteLine( ); + + +// try { +// #pragma warning disable 618 +// mut.Handle = new IntPtr(1); +// #pragma warning restore 618 +// rValue = 1; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (mut.Handle(new IntPtr(1)))"); +// } +// try { +// #pragma warning disable 618 +// IntPtr iptr = mut.Handle; +// #pragma warning restore 618 +// rValue = 2; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (IntPtr iptr = mut.Handle)"); +// } + + // try { + // mut.Close(); + // rValue = 3; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mut.Close())"); + // } + + try { + mut.Equals(new ManualResetEvent(true)); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.Equals(new ManualResetEvent()))"); + } + + try { + mut.GetHashCode(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.GetHasCode())"); + } + + // try { + // mut.GetLifetimeService(); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mut.GetLifetimeService())"); + // } + + try { + mut.GetType(); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.GetType())"); + } + + // try { + // mut.InitializeLifetimeService(); + // rValue = 8; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mut.InitializeLifeTimeService())"); + // } + + try { + mut.ReleaseMutex(); + rValue = 9; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.ReleaseMutex())"); + } + + try { + mut.ToString(); + rValue = 11; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.ToString())"); + } + + try { + mut.WaitOne(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.WaitOne())"); + } + + try { + mut.WaitOne(1000);//,true); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.WaitOne(int)"); + } + + // try { + // mut.WaitOne(1000,false); + // rValue = 14; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mut.WaitOne(int,bool))"); + // } + + try { + mut.WaitOne(new TimeSpan(1000));//,true); + rValue = 15; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (mut.WaitOne(TimeSpan))"); + } + + // try { + // mut.WaitOne(new TimeSpan(1000),false); + // rValue = 16; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (mut.WaitOne(TimeSpan,bool))"); + // } + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj new file mode 100644 index 0000000000..4a9f791702 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_MutexNullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_MutexNullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs new file mode 100644 index 0000000000..5761876500 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.cs @@ -0,0 +1,73 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + RegisteredWaitHandle rwh = null; + + Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + + try { + rwh.Equals(new ManualResetEvent(true)); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (rwh.Equals(new ManualResetEvent()))"); + } + + try { + rwh.GetHashCode(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (rwh.GetHasCode())"); + } + + // try { + // rwh.GetLifetimeService(); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (rwh.GetLifetimeService())"); + // } + + try { + rwh.GetType(); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (rwh.GetType())"); + } + + // try { + // rwh.InitializeLifetimeService(); + // rValue = 8; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (rwh.InitializeLifeTimeService())"); + // } + + try { + rwh.ToString(); + rValue = 11; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (rwh.ToString())"); + } + + try { + rwh.Unregister(new AutoResetEvent(true)); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (rwh.Unregister())"); + } + + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj new file mode 100644 index 0000000000..ff722ba5e4 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_RWHNullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_RWHNullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs new file mode 100644 index 0000000000..0ec905e4b7 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.cs @@ -0,0 +1,122 @@ +using System; +using System.Threading; +// using System.Runtime.Remoting; +using System.Runtime.Serialization; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + SynchronizationLockException sle = null; + + Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + try { + sle.HelpLink = "Hello"; + rValue = 1; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.HelpLink = Hello)"); + } + + try { + String s = sle.HelpLink; + rValue = 2; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (string s = sle.HelpLink)"); + } + + try { + Exception e = sle.InnerException; + rValue = 3; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.InnerException)"); + } + + try { + String s = sle.Message; + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.Message)"); + } + + try { + String s = sle.Source; + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.Source)"); + } + + try { + String s = sle.StackTrace; + rValue = 6; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.StackTrace)"); + } + + // try { + // sle.TargetSite.ToString(); + // rValue = 7; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (sle.TargetSite))"); + // } + + try { + sle.Equals(new Exception("Hello")); + rValue = 8; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.Equals(new Exception()))"); + } + + try { + sle.GetBaseException(); + rValue = 9; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.GetBaseException())"); + } + + try { + sle.GetHashCode(); + rValue = 10; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.GetHasCode())"); + } + + // try { + // sle.GetObjectData(new SerializationInfo(1.GetType(),new FormatterConverter()),new StreamingContext(StreamingContextStates.All)); + // rValue = 11; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (sle.ObjectData(SerializationInfo,StreamingContext))"); + // } + + try { + sle.GetType(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.GetType())"); + } + + try { + sle.ToString(); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (sle.ToString())"); + } + + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj new file mode 100644 index 0000000000..96fb110699 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_SLENullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_SLENullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs new file mode 100644 index 0000000000..d8a21fa473 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.cs @@ -0,0 +1,121 @@ +using System; +using System.Threading; +using System.Runtime.Serialization; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + ThreadStateException ta = null; + + Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + try { + ta.HelpLink = "Hello"; + rValue = 1; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.HelpLink = Hello)"); + } + + try { + String s = ta.HelpLink; + rValue = 2; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (string s = ta.HelpLink)"); + } + + try { + Exception e = ta.InnerException; + rValue = 3; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.InnerException)"); + } + + try { + String s = ta.Message; + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.Message)"); + } + + try { + String s = ta.Source; + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.Source)"); + } + + try { + String s = ta.StackTrace; + rValue = 6; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.StackTrace)"); + } + + // try { + // ta.TargetSite.ToString(); + // rValue = 7; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (ta.TargetSite))"); + // } + + try { + ta.Equals(new Exception("Hello")); + rValue = 8; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.Equals(new Exception()))"); + } + + try { + ta.GetBaseException(); + rValue = 9; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.GetBaseException())"); + } + + try { + ta.GetHashCode(); + rValue = 10; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.GetHasCode())"); + } + + // try { + // ta.GetObjectData(new SerializationInfo(1.GetType(),new FormatterConverter()),new StreamingContext(StreamingContextStates.All)); + // rValue = 11; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (ta.ObjectData(SerializationInfo,StreamingContext))"); + // } + + try { + ta.GetType(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.GetType())"); + } + + try { + ta.ToString(); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (ta.ToString())"); + } + + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj new file mode 100644 index 0000000000..b4efdd67e9 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_TSNullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_TSNullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs new file mode 100644 index 0000000000..80845a1e1e --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.cs @@ -0,0 +1,111 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + + int rValue = 100; + Timer time = null; + + Console.WriteLine("Test that timer fields return correct null ref"); + + try { + time.Change(5,10); + rValue = 1; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Change(5,10)"); + } + + try { + time.Change(5,10); + rValue = 2; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Change((long)5,(long)10)"); + } + + try { + time.Change(new TimeSpan(500),new TimeSpan(100)); + rValue = 3; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Change(new TimeSpan(500),new TimeSpan(100))"); + } + + try { + time.Change(500,100); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Change((uint)500,(uint)100)"); + } + + try { + time.Dispose(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Dispose( ))"); + } + + // try { + // time.Dispose(new AutoResetEvent(true)); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (time.Dispose(new WaitHandle( )))"); + // } + + try { + time.Equals(new AutoResetEvent(true)); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.Equals(new WaitHandle( )))"); + } + + try { + time.GetHashCode(); + rValue = 8; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.GetHashCode())"); + } + + // try { + // time.GetLifetimeService(); + // rValue = 9; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (time.GetLifetimeService())"); + // } + + try { + time.GetType(); + rValue = 10; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.GetType())"); + } + + // try { + // time.InitializeLifetimeService(); + // rValue = 11; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (time.InitializeLifetimeService())"); + // } + + try { + time.ToString(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (time.ToString())"); + } + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj new file mode 100644 index 0000000000..8539d89b5b --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_TimerNullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_TimerNullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs new file mode 100644 index 0000000000..eb5c58933f --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.cs @@ -0,0 +1,131 @@ +using System; +using System.Threading; + +public class mytest { + public static int Main(String [] args) { + int rValue = 100; + WaitHandle wh = null; + + Console.WriteLine("Test AutoResetEvent for expected NullRef Exceptions"); + Console.WriteLine( ); + + +// try { +// #pragma warning disable 618 +// wh.Handle = new IntPtr(1); +// #pragma warning restore 618 +// rValue = 1; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (wh.Handle(new IntPtr(1)))"); +// } +// try { +// #pragma warning disable 618 +// IntPtr iptr = wh.Handle; +// #pragma warning restore 618 +// rValue = 2; +// } +// catch (NullReferenceException) { +// Console.WriteLine("Caught NullReferenceException (IntPtr iptr = wh.Handle)"); +// } + + // try { + // wh.Close(); + // rValue = 3; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (wh.Close())"); + // } + + try { + wh.Equals(new ManualResetEvent(true)); + rValue = 4; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.Equals(new ManualResetEvent()))"); + } + + try { + wh.GetHashCode(); + rValue = 5; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.GetHasCode())"); + } + + // try { + // wh.GetLifetimeService(); + // rValue = 6; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (wh.GetLifetimeService())"); + // } + + try { + wh.GetType(); + rValue = 7; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.GetType())"); + } + + // try { + // wh.InitializeLifetimeService(); + // rValue = 8; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (wh.InitializeLifeTimeService())"); + // } + + try { + wh.ToString(); + rValue = 11; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.ToString())"); + } + + try { + wh.WaitOne(); + rValue = 12; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.WaitOne())"); + } + + try { + wh.WaitOne(1000);//,true); + rValue = 13; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.WaitOne(int))"); + } + + // try { + // wh.WaitOne(1000,false); + // rValue = 14; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (wh.WaitOne(int,bool))"); + // } + + try { + wh.WaitOne(new TimeSpan(1000));//,true); + rValue = 15; + } + catch (NullReferenceException) { + Console.WriteLine("Caught NullReferenceException (wh.WaitOne(TimeSpan,bool))"); + } + + // try { + // wh.WaitOne(new TimeSpan(1000),false); + // rValue = 16; + // } + // catch (NullReferenceException) { + // Console.WriteLine("Caught NullReferenceException (wh.WaitOne(TimeSpan,bool))"); + // } + + Console.WriteLine("Return Code == {0}",rValue); + return rValue; + } +} diff --git a/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj new file mode 100644 index 0000000000..ea0a01aa25 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/CS_WHNullRefEx.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CS_WHNullRefEx.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/coverage/Nullref/project.json b/tests/src/baseservices/threading/coverage/Nullref/project.json new file mode 100644 index 0000000000..864cd20ce2 --- /dev/null +++ b/tests/src/baseservices/threading/coverage/Nullref/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.Timer": "4.0.0-rc3-23823", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs new file mode 100644 index 0000000000..b2b4aed1b7 --- /dev/null +++ b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.cs @@ -0,0 +1,65 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class ARETestClass +{ + + public static int Main() + { + ARETestClass testAutoReset = new ARETestClass(); + int ret = testAutoReset.Run(); + Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed"); + return ret; + } + + public int Run() + { + Stopwatch sw = new Stopwatch(); + AutoResetEvent are = new AutoResetEvent(false); + sw.Start(); + bool ret = are.WaitOne(1000);//,false); + sw.Stop(); + //We should never get signaled + if(ret) + { + Console.WriteLine("AutoResetEvent should never be signalled."); + return -1; + } + + if(sw.ElapsedMilliseconds < 900) + { + Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);."); + Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds); + return -2; + } + + are.Set(); + if(!are.WaitOne(0))//,false)) + { + Console.WriteLine("Signalled event should always return true on call to !are.WaitOne(0,false)."); + return -3; + } + + sw.Reset(); + sw.Start(); + ret = are.WaitOne(1000);//,false); + sw.Stop(); + //We should never get signaled + if(ret) + { + Console.WriteLine("AutoResetEvent should never be signalled after is is AutoReset."); + return -4; + } + + if(sw.ElapsedMilliseconds < 900) + { + Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);."); + Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds); + return -5; + } + + return 100; + + } +} diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj new file mode 100644 index 0000000000..b67abf1841 --- /dev/null +++ b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructFalse.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{1de36f31-ddef-43ff-a8e8-e09f11711c13}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ConstructFalse.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs new file mode 100644 index 0000000000..9fedcc480a --- /dev/null +++ b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.cs @@ -0,0 +1,47 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class ARETestClass +{ + + public static int Main() + { + ARETestClass testAutoReset = new ARETestClass(); + + int ret = testAutoReset.Run(); + Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed"); + return ret; + } + + public int Run() + { + AutoResetEvent are = new AutoResetEvent(true); + Stopwatch sw = new Stopwatch(); + + if(!are.WaitOne(0))//,false)) +{ + Console.WriteLine("Signalled event should always return true on call to !are.WaitOne(0,false)."); + return -3; + } + + sw.Start(); + bool ret = are.WaitOne(1000);//,false); + sw.Stop(); + //We should never get signaled + if(ret) + { + Console.WriteLine("AutoResetEvent should never be signalled."); + return -1; + } + + if(sw.ElapsedMilliseconds < 900) + { + Console.WriteLine("It should take at least 900 milliseconds to call bool ret = are.WaitOne(1000,false);."); + Console.WriteLine("sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds); + return -2; + } + return 100; + + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj new file mode 100644 index 0000000000..715b25e429 --- /dev/null +++ b/tests/src/baseservices/threading/events/AutoResetEvent/ConstructTrue.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{1de36f31-ddef-43ff-a8e8-e09f11711c13}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ConstructTrue.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/AutoResetEvent/project.json b/tests/src/baseservices/threading/events/AutoResetEvent/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/events/AutoResetEvent/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs new file mode 100644 index 0000000000..1048797e56 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.cs @@ -0,0 +1,42 @@ +using System; +using System.Threading; + +class AutoResetCtor +{ + EventWaitHandle ewh; + + public static int Main() + { + AutoResetCtor arc = new AutoResetCtor(); + return arc.Run(); + } + + private int Run() + { + // Testing the initialState = true for an AutoResetEvent + int iRet = -1; + ewh = (EventWaitHandle)new AutoResetEvent(true); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + // when doing another wait, it should not return until set. + Console.WriteLine("Main: Waiting..."); + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne didn't reset!"); + else + iRet = 100; + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + Console.WriteLine("TW: Waiting..."); + // This should return immediately + ewh.WaitOne(); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj new file mode 100644 index 0000000000..a76597bbaf --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast1.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoResetCast1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs new file mode 100644 index 0000000000..28f5ecaed8 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.cs @@ -0,0 +1,47 @@ +using System; +using System.Threading; + +class AutoResetCtor +{ + EventWaitHandle ewh; + int iRet = -1; + + public static int Main() + { + AutoResetCtor arc = new AutoResetCtor(); + return arc.Run(); + } + + private int Run() + { + // Testing the initialState = false for an AutoResetEvent + ewh = (EventWaitHandle)new AutoResetEvent(false); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + ewh.Set(); + // when doing another wait, it should return immediately + Console.WriteLine("Main: Waiting..."); + bool b = ewh.WaitOne(5000);//, false); + if(b) + iRet += 50; + else + Console.WriteLine("WaitOne() timed out"); + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + Console.WriteLine("TW: Waiting..."); + // This should NOT return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne returned successful"); + else + iRet = 50; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj new file mode 100644 index 0000000000..8655509553 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCast2.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoResetCast2.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs new file mode 100644 index 0000000000..69d2e440d3 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.cs @@ -0,0 +1,42 @@ +using System; +using System.Threading; + +class AutoResetCtor +{ + EventWaitHandle ewh; + + public static int Main() + { + AutoResetCtor arc = new AutoResetCtor(); + return arc.Run(); + } + + private int Run() + { + // Testing the initialState = true for an AutoResetEvent + int iRet = -1; + ewh = new EventWaitHandle(true, EventResetMode.AutoReset); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + // when doing another wait, it should not return until set. + Console.WriteLine("Main: Waiting..."); + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne didn't reset!"); + else + iRet = 100; + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + Console.WriteLine("TW: Waiting..."); + // This should return immediately + ewh.WaitOne(); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj new file mode 100644 index 0000000000..9b62b50e40 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor1.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoResetCtor1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs new file mode 100644 index 0000000000..c3994affcb --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.cs @@ -0,0 +1,47 @@ +using System; +using System.Threading; + +class AutoResetCtor +{ + EventWaitHandle ewh; + int iRet = -1; + + public static int Main() + { + AutoResetCtor arc = new AutoResetCtor(); + return arc.Run(); + } + + private int Run() + { + // Testing the initialState = false for an AutoResetEvent + ewh = new EventWaitHandle(false, EventResetMode.AutoReset); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + ewh.Set(); + // when doing another wait, it should return immediately + Console.WriteLine("Main: Waiting..."); + bool b = ewh.WaitOne(5000);//, false); + if(b) + iRet += 50; + else + Console.WriteLine("WaitOne() timed out"); + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + Console.WriteLine("TW: Waiting..."); + // This should NOT return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne returned successful"); + else + iRet = 50; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj new file mode 100644 index 0000000000..9499bac773 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/AutoResetCtor2.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoResetCtor2.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json new file mode 100644 index 0000000000..864cd20ce2 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/AutoReset/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.Timer": "4.0.0-rc3-23823", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs new file mode 100644 index 0000000000..2ad09bb955 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading; + +class ManualResetCtor +{ + EventWaitHandle ewh; + + public static int Main() + { + ManualResetCtor mrc = new ManualResetCtor(); + return mrc.Run(); + } + + private int Run() + { + // Testing the initialState = true for a ManualResetEvent + int iRet = -1; + ewh = (EventWaitHandle)new ManualResetEvent(true); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + // This should return immediately + ewh.WaitOne(); + ewh.Reset(); + + // when doing another wait, it should not return until set. + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("Event didn't reset!"); + else + iRet = 100; + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + // This should return immediately + ewh.WaitOne(); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj new file mode 100644 index 0000000000..73cfcb21d5 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast1.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualResetCast1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs new file mode 100644 index 0000000000..dc1af59b33 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading; + +class ManualResetCtor +{ + EventWaitHandle ewh; + int iRet = -1; + + public static int Main() + { + ManualResetCtor mrc = new ManualResetCtor(); + return mrc.Run(); + } + + private int Run() + { + // Testing the initialState = false for a ManualResetEvent + ewh = (EventWaitHandle)new ManualResetEvent(false); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + ewh.Set(); + // when doing another wait, it should return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + iRet += 50; + else + Console.WriteLine("WaitOne() timed out"); + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + // This should NOT return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne returned successful"); + else + iRet = 50; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj new file mode 100644 index 0000000000..5a26b3082a --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCast2.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualResetCast2.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs new file mode 100644 index 0000000000..6335cefe62 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading; + +class ManualResetCtor +{ + EventWaitHandle ewh; + + public static int Main() + { + ManualResetCtor mrc = new ManualResetCtor(); + return mrc.Run(); + } + + private int Run() + { + // Testing the initialState = true for a ManualResetEvent + int iRet = -1; + ewh = new EventWaitHandle(true, EventResetMode.ManualReset); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + // This should return immediately + ewh.WaitOne(); + ewh.Reset(); + + // when doing another wait, it should not return until set. + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("Event didn't reset!"); + else + iRet = 100; + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + // This should return immediately + ewh.WaitOne(); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj new file mode 100644 index 0000000000..62cb64788d --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor1.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualResetCtor1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs new file mode 100644 index 0000000000..e19f99d54a --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading; + +class ManualResetCtor +{ + EventWaitHandle ewh; + int iRet = -1; + + public static int Main() + { + ManualResetCtor mrc = new ManualResetCtor(); + return mrc.Run(); + } + + private int Run() + { + // Testing the initialState = false for a ManualResetEvent + ewh = new EventWaitHandle(false, EventResetMode.ManualReset); + + Thread t = new Thread(new ThreadStart(ThreadWorker)); + t.Start(); + t.Join(); + + ewh.Set(); + // when doing another wait, it should return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + iRet += 50; + else + Console.WriteLine("WaitOne() timed out"); + + Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed"); + return iRet; + } + + private void ThreadWorker() + { + // This should NOT return immediately + bool b = ewh.WaitOne(5000);//, false); + if(b) + Console.WriteLine("WaitOne returned successful"); + else + iRet = 50; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj new file mode 100644 index 0000000000..37f40de5e8 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/ManualResetCtor2.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualResetCtor2.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/ManualReset/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs b/tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs new file mode 100644 index 0000000000..e793b73759 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/NamedCommon.cs @@ -0,0 +1,32 @@ +using System; +using System.Threading; + +class Common +{ + public static string GenerateUnicodeString(int iNumChars) + { + Random rand = new Random(); + string semName = string.Empty; + string semNameNum = string.Empty; + for (int i = 0; i < iNumChars; i++) + { + char c = '\\'; + while (c == '\\') + { + c = (char)rand.Next(Char.MinValue, Char.MaxValue); + } + semNameNum += ((int)c).ToString() + ";"; + semName += c; + } + // write to output + Console.WriteLine("Unicode string: " + semNameNum); + return semName; + } + + public static string GetUniqueName() + { + string sName = Guid.NewGuid().ToString(); + Console.WriteLine("Name created: " + sName); + return sName; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs new file mode 100644 index 0000000000..7711111bbe --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.cs @@ -0,0 +1,32 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class AutoConstructFalse : EventWaitHandleTest +{ + public static int Main() + { + return RunTest(new Func<int>(Run)); + } + + public static int Run() + { + var sw = new Stopwatch(); + var ewh = new EventWaitHandle(false, System.Threading.EventResetMode.AutoReset); + + // Should not signal + if (ewh.TestWaitOne(1000, sw)) + return -1; + + // Should signal + ewh.Set(); + if (!ewh.TestWaitOne(0, null)) + return -2; + + // Should not signal + if (ewh.TestWaitOne(1000, sw)) + return -3; + + return TestPassed; + } +} diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj new file mode 100644 index 0000000000..a8b1706d22 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructFalse.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoConstructFalse.cs" /> + <Compile Include="EventWaitHandleTest.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs new file mode 100644 index 0000000000..b57994edd6 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.cs @@ -0,0 +1,25 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class AutoConstructTrue : EventWaitHandleTest +{ + public static int Main() + { + return RunTest(new Func<int>(Run)); + } + + public static int Run() + { + var ewh = new EventWaitHandle(true, EventResetMode.AutoReset); + var sw = new Stopwatch(); + + if (!ewh.TestWaitOne(0, null)) + return -1; + + if (ewh.TestWaitOne(1000, sw)) + return -2; + + return TestPassed; + } +} diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj new file mode 100644 index 0000000000..1be401514b --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/AutoConstructTrue.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AutoConstructTrue.cs" /> + <Compile Include="EventWaitHandleTest.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs new file mode 100644 index 0000000000..da028fefb3 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/EventWaitHandleTest.cs @@ -0,0 +1,57 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class EventWaitHandleTest +{ + public const int TestPassed = 100; // Returned by Run() on success + + public static int RunTest(Func<int> test) { + var rv = test(); + Console.WriteLine(rv == TestPassed ? "Test passed" : "Test failed"); + return rv; + } + + public static bool TryOpenExisting<Expected>(string name) where Expected : Exception + { + EventWaitHandle ewh; + return TryOpenExisting<Expected>(name, out ewh); + } + + public static bool TryOpenExisting<Expected>(string name, out EventWaitHandle ewh) where Expected : Exception + { + ewh = null; + try { + ewh = EventWaitHandle.OpenExisting(name); + } catch (Expected) { + } catch (Exception ne) { + Console.WriteLine("Caught unexpected exception: {0}", ne); + return false; + } + return true; + } + + public class NoException : Exception {} +} + +public static class EventWaitHandleExtensions +{ + const int FudgeFactor = 100; // Account for timing uncertainties + + public static bool TestWaitOne(this EventWaitHandle ewh, int timeout, Stopwatch sw) + { + if (timeout == 0) + return ewh.WaitOne(); + + if (sw == null) + sw = new Stopwatch(); + else + sw.Reset(); + + sw.Start(); + bool signaled = ewh.WaitOne(timeout); + sw.Stop(); + + return signaled || sw.ElapsedMilliseconds < timeout - FudgeFactor; + } +} diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs new file mode 100644 index 0000000000..494d660205 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class ManualConstructFalse : EventWaitHandleTest +{ + public static int Main() + { + return RunTest(new Func<int>(Run)); + } + + public static int Run() + { + var sw = new Stopwatch(); + var ewh = new EventWaitHandle(false, EventResetMode.ManualReset); + + // Should not signal + if (ewh.TestWaitOne(1000, sw)) + return -1; + + // Should signal + ewh.Set(); + if (!ewh.TestWaitOne(0, sw)) + return -2; + + // Should not signal + ewh.Reset(); + if (ewh.TestWaitOne(1000, sw)) + return -3; + + return TestPassed; + } +} diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj new file mode 100644 index 0000000000..fb35a4bcc0 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructFalse.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualConstructFalse.cs" /> + <Compile Include="EventWaitHandleTest.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs new file mode 100644 index 0000000000..a9ad7cc6aa --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.cs @@ -0,0 +1,31 @@ +using System; +using System.Threading; + +public class ManualConstructTrue : EventWaitHandleTest +{ + public static int Main() + { + return RunTest(new Func<int>(Run)); + } + + public static int Run() + { + var ewh = new EventWaitHandle(true, EventResetMode.ManualReset); + + // Should signal + if (!ewh.TestWaitOne(0, null)) + return -1; + + // Should not signal + ewh.Reset(); + if (ewh.TestWaitOne(1000, null)) + return -2; + + // Should signal + ewh.Set(); + if (!ewh.TestWaitOne(0, null)) + return -3; + + return TestPassed; + } +} diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj new file mode 100644 index 0000000000..687fb2d2a0 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/ManualConstructTrue.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7e4cd64f-c8d1-491c-bf2e-72f841ec6813}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ManualConstructTrue.cs" /> + <Compile Include="EventWaitHandleTest.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json b/tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/events/EventWaitHandle/unit/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs new file mode 100644 index 0000000000..566edef102 --- /dev/null +++ b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.cs @@ -0,0 +1,55 @@ +using System; +using System.Threading; +using System.Diagnostics; + +public class MRETestClass +{ + + public static int Main() + { + MRETestClass testManualReset = new MRETestClass(); + int ret = testManualReset.Run(); + Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed"); + return ret; + } + + public int Run() + { + Stopwatch sw = new Stopwatch(); + ManualResetEvent mre = new ManualResetEvent(false); + sw.Start(); + bool ret = mre.WaitOne(1000);//,false); + sw.Stop(); + //We should never get signaled + Console.WriteLine("Expect WaitOne to return False and time-out after 1000 milliseconds waiting for signal."); + Console.WriteLine("Actual return is: " + ret.ToString()); + Console.WriteLine("Expect Stopwatch to use entire 1000 milliseconds."); + Console.WriteLine("Actual time taken is: " + sw.ElapsedMilliseconds.ToString()); + Console.WriteLine(); + if(ret || sw.ElapsedMilliseconds < 900) + return -1; + Console.WriteLine("Manual Reset Event signalled."); + mre.Set(); + ret = mre.WaitOne(0);//,false); + Console.WriteLine("Expect WaitOne to return True and time-out after 1000 milliseconds waiting for signal."); + Console.WriteLine("Actual return is: " + ret.ToString()); + Console.WriteLine(); + if(!ret) + return -3; + mre.Reset(); + sw.Reset(); + sw.Start(); + ret = mre.WaitOne(1000);//,false); + sw.Stop(); + //We should never get signaled + Console.WriteLine("Expect WaitOne to return false and time-out after 1000 milliseconds waiting for signal."); + Console.WriteLine("Actual return is: " + ret.ToString()); + Console.WriteLine("Expect Stopwatch to use entire 1000 milliseconds."); + Console.WriteLine("Actual time taken is: " + sw.ElapsedMilliseconds.ToString()); + if(ret || sw.ElapsedMilliseconds < 900) + return -1; + + return 100; + + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj new file mode 100644 index 0000000000..6f5e35ccb9 --- /dev/null +++ b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructFalse.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{717a283b-e0af-4ef2-b072-0378decb2d96}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ConstructFalse.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs new file mode 100644 index 0000000000..26ea5b3f94 --- /dev/null +++ b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; + +public class MRETestClass +{ + + public static int Main() + { + MRETestClass testManualReset = new MRETestClass(); + + int ret = testManualReset.Run(); + Console.WriteLine(ret == 100 ? "Test Passed":"Test Failed"); + return ret; + } + + public int Run() + { + ManualResetEvent mre = new ManualResetEvent(true); + + if(!mre.WaitOne(0))//,false)) //are.WaitOne returns true if signaled + return -1; + mre.Reset(); + if(mre.WaitOne(1000))//,false)) + return -3; + mre.Set(); + if(mre.WaitOne(0))//,false)) + return 100; + + Console.WriteLine("ManualResetEvent Broken"); + return -3; + + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj new file mode 100644 index 0000000000..c83e641fb7 --- /dev/null +++ b/tests/src/baseservices/threading/events/ManualResetEvent/ConstructTrue.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{717a283b-e0af-4ef2-b072-0378decb2d96}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ConstructTrue.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/events/ManualResetEvent/project.json b/tests/src/baseservices/threading/events/ManualResetEvent/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/events/ManualResetEvent/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs new file mode 100644 index 0000000000..e175cdbda9 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.cs @@ -0,0 +1,91 @@ +using System; +using System.Threading; + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void EnterExitTest() + { + Type monitor = typeof(Gen<T>); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj new file mode 100644 index 0000000000..3665d5920f --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit01.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit01.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs new file mode 100644 index 0000000000..30829c4447 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.cs @@ -0,0 +1,164 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void EnterExitTest<U>() + { + Type monitorT = typeof(Gen<T>); + Type monitorU = typeof(Gen<U>); + + if(monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + + for(int i=0;i<Test.nThreads;i++) + { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj new file mode 100644 index 0000000000..50ce3c345c --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit02.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit02.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs new file mode 100644 index 0000000000..1e0d2f427a --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.cs @@ -0,0 +1,96 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + + +struct Gen<T> +{ + public static void EnterExitTest() + { + Type monitor = typeof(Gen<T>); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<Test.nThreads;i++) + // { + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++) + { + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj new file mode 100644 index 0000000000..5aa237621f --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit03.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit03.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs new file mode 100644 index 0000000000..2184f5cd59 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.cs @@ -0,0 +1,169 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + + +struct Gen<T> +{ + public static void EnterExitTest<U>() + { + Type monitorT = typeof(Gen<T>); + Type monitorU = typeof(Gen<U>); + + if(monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0; i<Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj new file mode 100644 index 0000000000..37d7fd61c9 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit04.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit04.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs new file mode 100644 index 0000000000..b879d2a8fd --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.cs @@ -0,0 +1,96 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void EnterExitTest() + { + Type monitor = typeof(Gen<T>).GetGenericTypeDefinition(); + TestHelper myHelper = new TestHelper(Test.nThreads); + + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<Test.nThreads;i++) + // { + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++) + { + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj new file mode 100644 index 0000000000..087c37700e --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit05.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit05.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs new file mode 100644 index 0000000000..65c4f95be4 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.cs @@ -0,0 +1,168 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void EnterExitTest<U>() + { + Type monitorT = typeof(Gen<T>).GetGenericTypeDefinition(); + Type monitorU = typeof(Gen<U>).GetGenericTypeDefinition(); + + if(!monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0;i<Test.nThreads;i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } + +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj new file mode 100644 index 0000000000..a8d45d034f --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit06.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit06.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs new file mode 100644 index 0000000000..3ced28e57e --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.cs @@ -0,0 +1,95 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + public static void EnterExitTest() + { + Type monitor = typeof(Gen<T>).GetGenericTypeDefinition(); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<Test.nThreads;i++) + // { + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++) + { + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj new file mode 100644 index 0000000000..2ee283f8e3 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit07.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit07.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs new file mode 100644 index 0000000000..5f1d3a8757 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.cs @@ -0,0 +1,168 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + + +struct Gen<T> +{ + public static void EnterExitTest<U>() + { + Type monitorT = typeof(Gen<T>).GetGenericTypeDefinition(); + Type monitorU = typeof(Gen<U>).GetGenericTypeDefinition(); + + if(!monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0;i<Test.nThreads;i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } + +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj new file mode 100644 index 0000000000..d485558cc1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit08.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit08.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs new file mode 100644 index 0000000000..d39cf8cfd1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.cs @@ -0,0 +1,94 @@ +using System; +using System.Threading; + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void EnterExitTest() + { + Gen<T> monitor = new Gen<T>(); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<Test.nThreads;i++) + // { + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++) + { + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj new file mode 100644 index 0000000000..8acf69410a --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit09.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit09.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs new file mode 100644 index 0000000000..710e929688 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.cs @@ -0,0 +1,110 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + + +class Gen<T> +{ + public static void EnterExitTest() + { + Gen<T> monitorT = new Gen<T>(); + Gen<T> monitorU = new Gen<T>(); + + if(monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0;i<Test.nThreads;i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } + +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj new file mode 100644 index 0000000000..9c21754858 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit10.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit10.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs new file mode 100644 index 0000000000..7d00e28f14 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.cs @@ -0,0 +1,99 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + + +class Gen<T> +{ + public static object staticLock; + + public static void EnterExitTest() + { + + Gen<T>.staticLock = new object(); + + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(staticLock,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(staticLock); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj new file mode 100644 index 0000000000..ac09daa4fb --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit11.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit11.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs new file mode 100644 index 0000000000..99ea686d4f --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.cs @@ -0,0 +1,176 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static object staticLock; + + public static void EnterExitTest<U>() + { + + Gen<T>.staticLock = new object(); + Gen<U>.staticLock = new object(); + + object monitorT = Gen<T>.staticLock; + object monitorU = Gen<U>.staticLock; + + if(monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0; i<Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } + + + +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj new file mode 100644 index 0000000000..8b03381c81 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit12.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit12.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs new file mode 100644 index 0000000000..e981bf5fea --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.cs @@ -0,0 +1,98 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + public static object staticLock; + + public static void EnterExitTest() + { + staticLock = new object(); + object monitor = staticLock; + + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(staticLock,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(staticLock); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj new file mode 100644 index 0000000000..11ac7323c1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit13.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit13.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs new file mode 100644 index 0000000000..6bc0a8f7db --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.cs @@ -0,0 +1,175 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + public static object staticLock; + public static void EnterExitTest<U>() + { + + Gen<T>.staticLock = new object(); + Gen<U>.staticLock = new object(); + + object monitorT = Gen<T>.staticLock; + object monitorU = Gen<U>.staticLock; + + if(monitorU.Equals(monitorT)) + throw new Exception("Invalid use of test case, T must not be equal to U - POSSIBLE TYPE SYSTEM BUG"); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + // for(int i=0;i<Test.nThreads;i++) + // { + // new MonitorDelegate(myHelper.Consumer).BeginInvoke(monitorT,null,null); + // new MonitorDelegate(myHelper2.Consumer).BeginInvoke(monitorU,null,null); + // } + + for(int i=0; i<Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitorT); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.Consumer(monitorU); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + } + + + +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<double>.EnterExitTest<int>(); + Gen<string>.EnterExitTest<int>(); + Gen<object>.EnterExitTest<int>(); + Gen<Guid>.EnterExitTest<int>(); + Gen<RefX1<int>>.EnterExitTest<int>(); + Gen<RefX1<string>>.EnterExitTest<int>(); + Gen<ValX1<int>>.EnterExitTest<int>(); + Gen<ValX1<string>>.EnterExitTest<int>(); + + Gen<int>.EnterExitTest<double>(); + Gen<string>.EnterExitTest<double>(); + Gen<object>.EnterExitTest<double>(); + Gen<Guid>.EnterExitTest<double>(); + Gen<RefX1<int>>.EnterExitTest<double>(); + Gen<RefX1<string>>.EnterExitTest<double>(); + Gen<ValX1<int>>.EnterExitTest<double>(); + Gen<ValX1<string>>.EnterExitTest<double>(); + + Gen<int>.EnterExitTest<string>(); + Gen<double>.EnterExitTest<string>(); + Gen<object>.EnterExitTest<string>(); + Gen<Guid>.EnterExitTest<string>(); + Gen<RefX1<int>>.EnterExitTest<string>(); + Gen<RefX1<string>>.EnterExitTest<string>(); + Gen<ValX1<int>>.EnterExitTest<string>(); + Gen<ValX1<string>>.EnterExitTest<string>(); + + Gen<int>.EnterExitTest<object>(); + Gen<double>.EnterExitTest<object>(); + Gen<string>.EnterExitTest<object>(); + Gen<Guid>.EnterExitTest<object>(); + Gen<RefX1<int>>.EnterExitTest<object>(); + Gen<RefX1<string>>.EnterExitTest<object>(); + Gen<ValX1<int>>.EnterExitTest<object>(); + Gen<ValX1<string>>.EnterExitTest<object>(); + + Gen<int>.EnterExitTest<Guid>(); + Gen<double>.EnterExitTest<Guid>(); + Gen<string>.EnterExitTest<Guid>(); + Gen<object>.EnterExitTest<Guid>(); + Gen<RefX1<int>>.EnterExitTest<Guid>(); + Gen<RefX1<string>>.EnterExitTest<Guid>(); + Gen<ValX1<int>>.EnterExitTest<Guid>(); + Gen<ValX1<string>>.EnterExitTest<Guid>(); + + Gen<int>.EnterExitTest<RefX1<int>>(); + Gen<double>.EnterExitTest<RefX1<int>>(); + Gen<string>.EnterExitTest<RefX1<int>>(); + Gen<object>.EnterExitTest<RefX1<int>>(); + Gen<Guid>.EnterExitTest<RefX1<int>>(); + Gen<RefX1<string>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<int>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<int>>(); + + Gen<int>.EnterExitTest<RefX1<string>>(); + Gen<double>.EnterExitTest<RefX1<string>>(); + Gen<string>.EnterExitTest<RefX1<string>>(); + Gen<object>.EnterExitTest<RefX1<string>>(); + Gen<Guid>.EnterExitTest<RefX1<string>>(); + Gen<RefX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<int>>.EnterExitTest<RefX1<string>>(); + Gen<ValX1<string>>.EnterExitTest<RefX1<string>>(); + + Gen<int>.EnterExitTest<ValX1<int>>(); + Gen<double>.EnterExitTest<ValX1<int>>(); + Gen<string>.EnterExitTest<ValX1<int>>(); //offending line + Gen<object>.EnterExitTest<ValX1<int>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<int>>(); + Gen<RefX1<int>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + Gen<ValX1<string>>.EnterExitTest<ValX1<int>>(); //offending line + + Gen<int>.EnterExitTest<ValX1<string>>(); //offending line + Gen<double>.EnterExitTest<ValX1<string>>(); //offending line + Gen<string>.EnterExitTest<ValX1<string>>(); //offending line + Gen<object>.EnterExitTest<ValX1<string>>(); //offending line + Gen<Guid>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<RefX1<string>>.EnterExitTest<ValX1<string>>(); //offending line + Gen<ValX1<int>>.EnterExitTest<ValX1<string>>(); //offending line + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj new file mode 100644 index 0000000000..6dcc34f826 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit14.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit14.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs new file mode 100644 index 0000000000..41f913770d --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.cs @@ -0,0 +1,93 @@ +using System; +using System.Threading; + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + public static void EnterExitTest() + { + Gen<T> monitor = new Gen<T>(); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegate[] consumer = new MonitorDelegate[Test.nThreads]; + // for(int i=0;i<Test.nThreads;i++) + // { + // consumer[i] = new MonitorDelegate(myHelper.Consumer); + // consumer[i].BeginInvoke(monitor,null,null); + // } + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.Consumer(monitor); + }); + } + + for(int i=0;i<6;i++) + { + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 10; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.EnterExitTest(); + Gen<double>.EnterExitTest(); + Gen<string>.EnterExitTest(); + Gen<object>.EnterExitTest(); + Gen<Guid>.EnterExitTest(); + + Gen<int[]>.EnterExitTest(); + Gen<double[,]>.EnterExitTest(); + Gen<string[][][]>.EnterExitTest(); + Gen<object[,,,]>.EnterExitTest(); + Gen<Guid[][,,,][]>.EnterExitTest(); + + Gen<RefX1<int>[]>.EnterExitTest(); + Gen<RefX1<double>[,]>.EnterExitTest(); + Gen<RefX1<string>[][][]>.EnterExitTest(); + Gen<RefX1<object>[,,,]>.EnterExitTest(); + Gen<RefX1<Guid>[][,,,][]>.EnterExitTest(); + + Gen<ValX1<int>[]>.EnterExitTest(); + Gen<ValX1<double>[,]>.EnterExitTest(); + Gen<ValX1<string>[][][]>.EnterExitTest(); + Gen<ValX1<object>[,,,]>.EnterExitTest(); + Gen<ValX1<Guid>[][,,,][]>.EnterExitTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj new file mode 100644 index 0000000000..2558d0ddb2 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/EnterExit15.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EnterExit15.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs b/tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs new file mode 100644 index 0000000000..1c14063ff4 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/MonitorHelper.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; +delegate void MonitorDelegate(object monitor); +delegate void MonitorDelegateTS(object monitor,int timeout); + +class TestHelper +{ + private int m_iSharedData; + private int m_iRequestedEntries; + public ManualResetEvent m_Event; + public bool m_bError; + + public bool Error + { + set + { + lock(typeof(TestHelper)) + { + m_bError = value; + } + } + get + { + lock(typeof(TestHelper)) + { + return m_bError; + } + } + } + + public TestHelper(int num) + { + m_Event = new ManualResetEvent(false); + m_iSharedData = 0; + m_iRequestedEntries = num; + m_bError = false; + } + + public void DoWork() + { + int snapshot = m_iSharedData; + Thread.Sleep(5); +#if (DEBUG) + Console.WriteLine("Entering Monitor: " + m_iSharedData); +#endif + m_iSharedData++; + Thread.Sleep(1); + if(m_iSharedData != snapshot + 1) + { + Error = true; + Console.WriteLine("Failure!!!"); + } +#if (DEBUG) + Console.WriteLine("Leaving Monitor: " + m_iSharedData); +#endif + if(m_iSharedData == m_iRequestedEntries) + m_Event.Set(); + } + public void Consumer(object monitor) + { + lock(monitor) + { + DoWork(); + } + } + public void ConsumerTryEnter(object monitor,int timeout) + { + try + { + bool tookLock = false; + + Monitor.TryEnter(monitor,timeout, ref tookLock); + + while(!tookLock) { + Thread.Sleep(0); + Monitor.TryEnter(monitor,timeout, ref tookLock); + } + + DoWork(); + } + finally + { + Monitor.Exit(monitor); + } + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs new file mode 100644 index 0000000000..664522815d --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.cs @@ -0,0 +1,95 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + public static void TryEnterTest() + { + // Gen<T> inst = new Gen<T>(); + Type monitor = typeof(Gen<T>); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegateTS[] consumer = new MonitorDelegateTS[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new MonitorDelegateTS(myHelper.ConsumerTryEnter); + // consumer[i].BeginInvoke(monitor,100,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.ConsumerTryEnter(monitor, 100); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 25; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.TryEnterTest(); + Gen<double>.TryEnterTest(); + Gen<string>.TryEnterTest(); + Gen<object>.TryEnterTest(); + Gen<Guid>.TryEnterTest(); + + Gen<int[]>.TryEnterTest(); + Gen<double[,]>.TryEnterTest(); + Gen<string[][][]>.TryEnterTest(); + Gen<object[,,,]>.TryEnterTest(); + Gen<Guid[][,,,][]>.TryEnterTest(); + + Gen<RefX1<int>[]>.TryEnterTest(); + Gen<RefX1<double>[,]>.TryEnterTest(); + Gen<RefX1<string>[][][]>.TryEnterTest(); + Gen<RefX1<object>[,,,]>.TryEnterTest(); + Gen<RefX1<Guid>[][,,,][]>.TryEnterTest(); + + Gen<ValX1<int>[]>.TryEnterTest(); + Gen<ValX1<double>[,]>.TryEnterTest(); + Gen<ValX1<string>[][][]>.TryEnterTest(); + Gen<ValX1<object>[,,,]>.TryEnterTest(); + Gen<ValX1<Guid>[][,,,][]>.TryEnterTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj new file mode 100644 index 0000000000..0bf7a62d0a --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter01.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryEnter01.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs new file mode 100644 index 0000000000..f4ba633d11 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.cs @@ -0,0 +1,174 @@ +using System; +using System.Threading; + +public struct ValX1<T> {} +public class RefX1<T> {} + +class Gen<T> +{ + + public static void TryEnterTest<U>(bool TisU) + { + Type monitorT = typeof(Gen<T>); + Type monitorU = typeof(Gen<U>); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + + for (int i=0; i<Test.nThreads; i++) + { + // new MonitorDelegateTS(myHelper.ConsumerTryEnter).BeginInvoke(monitorT,100,null,null); + // new MonitorDelegateTS(myHelper2.ConsumerTryEnter).BeginInvoke(monitorU,100,null,null); + ThreadPool.QueueUserWorkItem(state => + { + myHelper.ConsumerTryEnter(monitorT, 100); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.ConsumerTryEnter(monitorU, 100); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + + } + + + +} + +public class Test +{ + public static int nThreads = 25; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.TryEnterTest<int>(true); + Gen<double>.TryEnterTest<int>(false); + Gen<string>.TryEnterTest<int>(false); + Gen<object>.TryEnterTest<int>(false); + Gen<Guid>.TryEnterTest<int>(false); + Gen<RefX1<int>>.TryEnterTest<int>(false); + Gen<RefX1<string>>.TryEnterTest<int>(false); + Gen<ValX1<int>>.TryEnterTest<int>(false); + Gen<ValX1<string>>.TryEnterTest<int>(false); + + Gen<int>.TryEnterTest<double>(false); + Gen<double>.TryEnterTest<double>(true); + Gen<string>.TryEnterTest<double>(false); + Gen<object>.TryEnterTest<double>(false); + Gen<Guid>.TryEnterTest<double>(false); + Gen<RefX1<int>>.TryEnterTest<double>(false); + Gen<RefX1<string>>.TryEnterTest<double>(false); + Gen<ValX1<int>>.TryEnterTest<double>(false); + Gen<ValX1<string>>.TryEnterTest<double>(false); + + Gen<int>.TryEnterTest<string>(false); + Gen<double>.TryEnterTest<string>(false); + Gen<string>.TryEnterTest<string>(true); + Gen<object>.TryEnterTest<string>(false); + Gen<Guid>.TryEnterTest<string>(false); + Gen<RefX1<int>>.TryEnterTest<string>(false); + Gen<RefX1<string>>.TryEnterTest<string>(false); + Gen<ValX1<int>>.TryEnterTest<string>(false); + Gen<ValX1<string>>.TryEnterTest<string>(false); + + Gen<int>.TryEnterTest<object>(false); + Gen<double>.TryEnterTest<object>(false); + Gen<string>.TryEnterTest<object>(false); + Gen<object>.TryEnterTest<object>(true); + Gen<Guid>.TryEnterTest<object>(false); + Gen<RefX1<int>>.TryEnterTest<object>(false); + Gen<RefX1<string>>.TryEnterTest<object>(false); + Gen<ValX1<int>>.TryEnterTest<object>(false); + Gen<ValX1<string>>.TryEnterTest<object>(false); + + Gen<int>.TryEnterTest<Guid>(false); + Gen<double>.TryEnterTest<Guid>(false); + Gen<string>.TryEnterTest<Guid>(false); + Gen<object>.TryEnterTest<Guid>(false); + Gen<Guid>.TryEnterTest<Guid>(true); + Gen<RefX1<int>>.TryEnterTest<Guid>(false); + Gen<RefX1<string>>.TryEnterTest<Guid>(false); + Gen<ValX1<int>>.TryEnterTest<Guid>(false); + Gen<ValX1<string>>.TryEnterTest<Guid>(false); + + Gen<int>.TryEnterTest<RefX1<int>>(false); + Gen<double>.TryEnterTest<RefX1<int>>(false); + Gen<string>.TryEnterTest<RefX1<int>>(false); + Gen<object>.TryEnterTest<RefX1<int>>(false); + Gen<Guid>.TryEnterTest<RefX1<int>>(false); + Gen<RefX1<int>>.TryEnterTest<RefX1<int>>(true); + Gen<RefX1<string>>.TryEnterTest<RefX1<int>>(false); + Gen<ValX1<int>>.TryEnterTest<RefX1<int>>(false); + Gen<ValX1<string>>.TryEnterTest<RefX1<int>>(false); + + Gen<int>.TryEnterTest<RefX1<string>>(false); + Gen<double>.TryEnterTest<RefX1<string>>(false); + Gen<string>.TryEnterTest<RefX1<string>>(false); + Gen<object>.TryEnterTest<RefX1<string>>(false); + Gen<Guid>.TryEnterTest<RefX1<string>>(false); + Gen<RefX1<int>>.TryEnterTest<RefX1<string>>(false); + Gen<RefX1<string>>.TryEnterTest<RefX1<string>>(true); + Gen<ValX1<int>>.TryEnterTest<RefX1<string>>(false); + Gen<ValX1<string>>.TryEnterTest<RefX1<string>>(false); + + Gen<int>.TryEnterTest<ValX1<int>>(false); + Gen<double>.TryEnterTest<ValX1<int>>(false); + Gen<string>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<object>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<Guid>.TryEnterTest<ValX1<int>>(false); + Gen<RefX1<int>>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<RefX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<ValX1<int>>.TryEnterTest<ValX1<int>>(true); + Gen<ValX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line + + Gen<int>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<double>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<string>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<object>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<Guid>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<RefX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<RefX1<string>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<ValX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<ValX1<string>>.TryEnterTest<ValX1<string>>(true); //offending line + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj new file mode 100644 index 0000000000..f5d4824e04 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter03.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryEnter03.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs new file mode 100644 index 0000000000..5c65fe62a1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.cs @@ -0,0 +1,96 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} +struct Gen<T> +{ + public static void TryEnterTest() + { +// #pragma warning disable 219 +// Gen<T> inst = new Gen<T>(); +// #pragma warning restore + Type monitor = typeof(Gen<T>); + TestHelper myHelper = new TestHelper(Test.nThreads); + // MonitorDelegateTS[] consumer = new MonitorDelegateTS[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new MonitorDelegateTS(myHelper.ConsumerTryEnter); + // consumer[i].BeginInvoke(monitor,100,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.ConsumerTryEnter(monitor, 100); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 25; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.TryEnterTest(); + /*Gen<double>.TryEnterTest(); + Gen<string>.TryEnterTest(); + Gen<object>.TryEnterTest(); + Gen<Guid>.TryEnterTest(); + + Gen<int[]>.TryEnterTest(); + Gen<double[,]>.TryEnterTest(); + Gen<string[][][]>.TryEnterTest(); + Gen<object[,,,]>.TryEnterTest(); + Gen<Guid[][,,,][]>.TryEnterTest(); + + Gen<RefX1<int>[]>.TryEnterTest(); + Gen<RefX1<double>[,]>.TryEnterTest(); + Gen<RefX1<string>[][][]>.TryEnterTest(); + Gen<RefX1<object>[,,,]>.TryEnterTest(); + Gen<RefX1<Guid>[][,,,][]>.TryEnterTest(); + + Gen<ValX1<int>[]>.TryEnterTest(); + Gen<ValX1<double>[,]>.TryEnterTest(); + Gen<ValX1<string>[][][]>.TryEnterTest(); + Gen<ValX1<object>[,,,]>.TryEnterTest(); + Gen<ValX1<Guid>[][,,,][]>.TryEnterTest();*/ + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj new file mode 100644 index 0000000000..3063161b6c --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter04.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryEnter04.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs new file mode 100644 index 0000000000..d9a5f41f12 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.cs @@ -0,0 +1,96 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + delegate void StructDelegateTS(object monitor,int timeout); + + public static void TryEnterTest() + { + Type monitor = typeof(Gen<T>); + TestHelper myHelper = new TestHelper(Test.nThreads); + // StructDelegateTS[] consumer = new StructDelegateTS[Test.nThreads]; + // for(int i=0;i<consumer.Length;i++){ + // consumer[i] = new StructDelegateTS(myHelper.ConsumerTryEnter); + // consumer[i].BeginInvoke(monitor,100,null,null); + // } + + for (int i = 0; i < Test.nThreads; i++) + { + ThreadPool.QueueUserWorkItem(state => + { + myHelper.ConsumerTryEnter(monitor, 100); + }); + } + + for(int i=0;i<6;i++){ + if(myHelper.m_Event.WaitOne(10000))//,true)) + break; + if(myHelper.Error == true) + break; + } + Test.Eval(!myHelper.Error); + } +} + +public class Test +{ + public static int nThreads = 25; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.TryEnterTest(); + Gen<double>.TryEnterTest(); + Gen<string>.TryEnterTest(); + Gen<object>.TryEnterTest(); + Gen<Guid>.TryEnterTest(); + + Gen<int[]>.TryEnterTest(); + Gen<double[,]>.TryEnterTest(); + Gen<string[][][]>.TryEnterTest(); + Gen<object[,,,]>.TryEnterTest(); + Gen<Guid[][,,,][]>.TryEnterTest(); + + Gen<RefX1<int>[]>.TryEnterTest(); + Gen<RefX1<double>[,]>.TryEnterTest(); + Gen<RefX1<string>[][][]>.TryEnterTest(); + Gen<RefX1<object>[,,,]>.TryEnterTest(); + Gen<RefX1<Guid>[][,,,][]>.TryEnterTest(); + + Gen<ValX1<int>[]>.TryEnterTest(); + Gen<ValX1<double>[,]>.TryEnterTest(); + Gen<ValX1<string>[][][]>.TryEnterTest(); + Gen<ValX1<object>[,,,]>.TryEnterTest(); + Gen<ValX1<Guid>[][,,,][]>.TryEnterTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj new file mode 100644 index 0000000000..7fe96de43d --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter05.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryEnter05.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs new file mode 100644 index 0000000000..b591fb1366 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.cs @@ -0,0 +1,174 @@ +using System; +using System.Threading; + + +public struct ValX1<T> {} +public class RefX1<T> {} + +struct Gen<T> +{ + + public static void TryEnterTest<U>(bool TisU) + { + Type monitorT = typeof(Gen<T>); + Type monitorU = typeof(Gen<U>); + + TestHelper myHelper = new TestHelper(Test.nThreads); + TestHelper myHelper2 = new TestHelper(Test.nThreads); + WaitHandle[] myWaiter = new WaitHandle[2]; + myWaiter[0] = myHelper.m_Event; + myWaiter[1] = myHelper2.m_Event; + + for (int i=0; i<Test.nThreads; i++) + { + // new MonitorDelegateTS(myHelper.ConsumerTryEnter).BeginInvoke(monitorT,100,null,null); + // new MonitorDelegateTS(myHelper2.ConsumerTryEnter).BeginInvoke(monitorU,100,null,null); + ThreadPool.QueueUserWorkItem(state => + { + myHelper.ConsumerTryEnter(monitorT, 100); + }); + + ThreadPool.QueueUserWorkItem(state => + { + myHelper2.ConsumerTryEnter(monitorU, 100); + }); + } + + for(int i=0;i<6;i++) + { + if(WaitHandle.WaitAll(myWaiter,10000))//,true)) + break; + if(myHelper.Error == true || myHelper2.Error == true) + break; + } + Test.Eval(!(myHelper.Error && myHelper2.Error)); + + } + + + +} + +public class Test +{ + public static int nThreads = 25; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.TryEnterTest<int>(true); + Gen<double>.TryEnterTest<int>(false); + Gen<string>.TryEnterTest<int>(false); + Gen<object>.TryEnterTest<int>(false); + Gen<Guid>.TryEnterTest<int>(false); + Gen<RefX1<int>>.TryEnterTest<int>(false); + Gen<RefX1<string>>.TryEnterTest<int>(false); + Gen<ValX1<int>>.TryEnterTest<int>(false); + Gen<ValX1<string>>.TryEnterTest<int>(false); + + Gen<int>.TryEnterTest<double>(false); + Gen<double>.TryEnterTest<double>(true); + Gen<string>.TryEnterTest<double>(false); + Gen<object>.TryEnterTest<double>(false); + Gen<Guid>.TryEnterTest<double>(false); + Gen<RefX1<int>>.TryEnterTest<double>(false); + Gen<RefX1<string>>.TryEnterTest<double>(false); + Gen<ValX1<int>>.TryEnterTest<double>(false); + Gen<ValX1<string>>.TryEnterTest<double>(false); + + Gen<int>.TryEnterTest<string>(false); + Gen<double>.TryEnterTest<string>(false); + Gen<string>.TryEnterTest<string>(true); + Gen<object>.TryEnterTest<string>(false); + Gen<Guid>.TryEnterTest<string>(false); + Gen<RefX1<int>>.TryEnterTest<string>(false); + Gen<RefX1<string>>.TryEnterTest<string>(false); + Gen<ValX1<int>>.TryEnterTest<string>(false); + Gen<ValX1<string>>.TryEnterTest<string>(false); + + Gen<int>.TryEnterTest<object>(false); + Gen<double>.TryEnterTest<object>(false); + Gen<string>.TryEnterTest<object>(false); + Gen<object>.TryEnterTest<object>(true); + Gen<Guid>.TryEnterTest<object>(false); + Gen<RefX1<int>>.TryEnterTest<object>(false); + Gen<RefX1<string>>.TryEnterTest<object>(false); + Gen<ValX1<int>>.TryEnterTest<object>(false); + Gen<ValX1<string>>.TryEnterTest<object>(false); + + Gen<int>.TryEnterTest<Guid>(false); + Gen<double>.TryEnterTest<Guid>(false); + Gen<string>.TryEnterTest<Guid>(false); + Gen<object>.TryEnterTest<Guid>(false); + Gen<Guid>.TryEnterTest<Guid>(true); + Gen<RefX1<int>>.TryEnterTest<Guid>(false); + Gen<RefX1<string>>.TryEnterTest<Guid>(false); + Gen<ValX1<int>>.TryEnterTest<Guid>(false); + Gen<ValX1<string>>.TryEnterTest<Guid>(false); + + Gen<int>.TryEnterTest<RefX1<int>>(false); + Gen<double>.TryEnterTest<RefX1<int>>(false); + Gen<string>.TryEnterTest<RefX1<int>>(false); + Gen<object>.TryEnterTest<RefX1<int>>(false); + Gen<Guid>.TryEnterTest<RefX1<int>>(false); + Gen<RefX1<int>>.TryEnterTest<RefX1<int>>(true); + Gen<RefX1<string>>.TryEnterTest<RefX1<int>>(false); + Gen<ValX1<int>>.TryEnterTest<RefX1<int>>(false); + Gen<ValX1<string>>.TryEnterTest<RefX1<int>>(false); + + Gen<int>.TryEnterTest<RefX1<string>>(false); + Gen<double>.TryEnterTest<RefX1<string>>(false); + Gen<string>.TryEnterTest<RefX1<string>>(false); + Gen<object>.TryEnterTest<RefX1<string>>(false); + Gen<Guid>.TryEnterTest<RefX1<string>>(false); + Gen<RefX1<int>>.TryEnterTest<RefX1<string>>(false); + Gen<RefX1<string>>.TryEnterTest<RefX1<string>>(true); + Gen<ValX1<int>>.TryEnterTest<RefX1<string>>(false); + Gen<ValX1<string>>.TryEnterTest<RefX1<string>>(false); + + Gen<int>.TryEnterTest<ValX1<int>>(false); + Gen<double>.TryEnterTest<ValX1<int>>(false); + Gen<string>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<object>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<Guid>.TryEnterTest<ValX1<int>>(false); + Gen<RefX1<int>>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<RefX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line + Gen<ValX1<int>>.TryEnterTest<ValX1<int>>(true); + Gen<ValX1<string>>.TryEnterTest<ValX1<int>>(false); //offending line + + Gen<int>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<double>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<string>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<object>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<Guid>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<RefX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<RefX1<string>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<ValX1<int>>.TryEnterTest<ValX1<string>>(false); //offending line + Gen<ValX1<string>>.TryEnterTest<ValX1<string>>(true); //offending line + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj new file mode 100644 index 0000000000..f018ee22ef --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/TryEnter06.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryEnter06.cs" /> + <Compile Include="MonitorHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/Monitor/project.json b/tests/src/baseservices/threading/generics/Monitor/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/Monitor/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/project.json b/tests/src/baseservices/threading/generics/TimerCallback/project.json new file mode 100644 index 0000000000..864cd20ce2 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.Timer": "4.0.0-rc3-23823", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread01.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread01.cs new file mode 100644 index 0000000000..635d0bd0e3 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread01.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; // was long + public static int period = 2; // was long + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj new file mode 100644 index 0000000000..7235f93923 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread01.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread01.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread02.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread02.cs new file mode 100644 index 0000000000..876ff18403 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread02.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj new file mode 100644 index 0000000000..7d8a01446e --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread02.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread02.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread03.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread03.cs new file mode 100644 index 0000000000..b8f69d41bd --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread03.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj new file mode 100644 index 0000000000..198813f89c --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread03.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread03.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread04.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread04.cs new file mode 100644 index 0000000000..f641e5c425 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread04.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj new file mode 100644 index 0000000000..8480ccbbc2 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread04.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread04.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread05.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread05.cs new file mode 100644 index 0000000000..f3f69b5c3c --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread05.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int Xcounter = 0; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj new file mode 100644 index 0000000000..846cdcc2aa --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread05.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread05.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread06.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread06.cs new file mode 100644 index 0000000000..d7723f59ef --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread06.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int Xcounter = 0; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj new file mode 100644 index 0000000000..655d5d559c --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread06.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread06.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread07.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread07.cs new file mode 100644 index 0000000000..6bf78fb0f0 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread07.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj new file mode 100644 index 0000000000..9368e18633 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread07.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread07.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread08.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread08.cs new file mode 100644 index 0000000000..0a50caf940 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread08.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +struct Gen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj new file mode 100644 index 0000000000..52167e1072 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread08.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread08.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread09.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread09.cs new file mode 100644 index 0000000000..d08101a846 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread09.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + Gen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int Xcounter = 0; + public static int counter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj new file mode 100644 index 0000000000..4432725076 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread09.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread09.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread10.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread10.cs new file mode 100644 index 0000000000..eb63125f94 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread10.cs @@ -0,0 +1,90 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj new file mode 100644 index 0000000000..221aee2e93 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread10.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread10.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread11.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread11.cs new file mode 100644 index 0000000000..06b6d05dab --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread11.cs @@ -0,0 +1,90 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +struct Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj new file mode 100644 index 0000000000..fd4dad1b02 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread11.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread11.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread12.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread12.cs new file mode 100644 index 0000000000..19bd8f60a1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread12.cs @@ -0,0 +1,90 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj new file mode 100644 index 0000000000..36ac2245b7 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread12.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread12.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread13.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread13.cs new file mode 100644 index 0000000000..4d74b4a027 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread13.cs @@ -0,0 +1,216 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj new file mode 100644 index 0000000000..9712549472 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread13.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread13.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread14.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread14.cs new file mode 100644 index 0000000000..2cfa565893 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread14.cs @@ -0,0 +1,216 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +struct GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj new file mode 100644 index 0000000000..81496bf708 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread14.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread14.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread15.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread15.cs new file mode 100644 index 0000000000..69aabce4eb --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread15.cs @@ -0,0 +1,216 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public virtual void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj new file mode 100644 index 0000000000..63f07aa992 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread15.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread15.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread16.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread16.cs new file mode 100644 index 0000000000..1eb2eddc29 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread16.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +class Gen : IGen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj new file mode 100644 index 0000000000..5a3858fd1b --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread16.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread16.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread17.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread17.cs new file mode 100644 index 0000000000..ee59e1f77d --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread17.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +struct Gen : IGen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj new file mode 100644 index 0000000000..c6dfdc3e22 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread17.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread17.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread18.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread18.cs new file mode 100644 index 0000000000..652ea65124 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread18.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +class Gen : IGen +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen obj = new Gen(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj new file mode 100644 index 0000000000..c3b4d62d24 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread18.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread18.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread19.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread19.cs new file mode 100644 index 0000000000..2e2455bc51 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread19.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj new file mode 100644 index 0000000000..44e70dbd41 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread19.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread19.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread20.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread20.cs new file mode 100644 index 0000000000..b81271805f --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread20.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +struct Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj new file mode 100644 index 0000000000..362a53f272 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread20.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread20.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread21.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread21.cs new file mode 100644 index 0000000000..a3a908d16a --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread21.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<T> obj = new Gen<T>(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj new file mode 100644 index 0000000000..aeaaee7935 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread21.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread21.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread22.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread22.cs new file mode 100644 index 0000000000..2491bc515e --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread22.cs @@ -0,0 +1,240 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj new file mode 100644 index 0000000000..bdc60d58ea --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread22.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread22.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread23.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread23.cs new file mode 100644 index 0000000000..c89875c948 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread23.cs @@ -0,0 +1,240 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +struct GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj new file mode 100644 index 0000000000..d67aaa5220 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread23.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread23.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread24.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread24.cs new file mode 100644 index 0000000000..14b1651573 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread24.cs @@ -0,0 +1,240 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public virtual void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<int> obj = new GenInt(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public virtual void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<double> obj = new GenDouble(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public virtual void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<string> obj = new GenString(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public virtual void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<object> obj = new GenObject(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public virtual void Target<U>(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + IGen<Guid> obj = new GenGuid(); + + TimerCallback tcb = new TimerCallback(obj.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj new file mode 100644 index 0000000000..ddb4ca4742 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread24.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread24.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread25.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread25.cs new file mode 100644 index 0000000000..8e1b95e264 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread25.cs @@ -0,0 +1,79 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public static void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen<T>.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj new file mode 100644 index 0000000000..5ff4103177 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread25.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread25.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread26.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread26.cs new file mode 100644 index 0000000000..48c9deefd7 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread26.cs @@ -0,0 +1,79 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public static void Target(object p) + { + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen<T>.Target); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj new file mode 100644 index 0000000000..f05ac41311 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread26.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread26.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread27.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread27.cs new file mode 100644 index 0000000000..32a6a125fb --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread27.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen<T>.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj new file mode 100644 index 0000000000..9fbe49c193 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread27.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread27.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread28.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread28.cs new file mode 100644 index 0000000000..cfcd9f60a4 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread28.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen<T>.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj new file mode 100644 index 0000000000..0b9be38589 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread28.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread28.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread29.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread29.cs new file mode 100644 index 0000000000..c9724f3aa2 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread29.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +class Gen +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj new file mode 100644 index 0000000000..63c8e847d8 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread29.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread29.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread30.cs b/tests/src/baseservices/threading/generics/TimerCallback/thread30.cs new file mode 100644 index 0000000000..babec5ca46 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread30.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +struct Gen +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + if (Test.Xcounter>=Test.nThreads) + { + ManualResetEvent evt = (ManualResetEvent) p; + evt.Set(); + } + else + { + Interlocked.Increment(ref Test.Xcounter); + } + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent evt = new ManualResetEvent(false); + + TimerCallback tcb = new TimerCallback(Gen.Target<U>); + Timer timer = new Timer(tcb,evt,Test.delay,Test.period); + + evt.WaitOne(); + timer.Dispose(); + Test.Eval(Test.Xcounter>=Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 2; + public static int nThreads = 5; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj b/tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj new file mode 100644 index 0000000000..f5baa79fe0 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/thread30.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread30.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs new file mode 100644 index 0000000000..ebd38521b0 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.cs @@ -0,0 +1,88 @@ +using System; +using System.Threading; +using System.Diagnostics; + +//namespace TimerCallbackTests ////////////// added this namesp + +class Gen<T> +{ + public static Type objType; + + public void Target(object p) + { + Interlocked.Increment(ref Test.Xcounter); + if (p.GetType() != objType) + { + Test.result = false; + Console.WriteLine("Expected parameter type: " + objType + ", but found type: " + p.GetType()); + } + + if (this.GetType() != objType) + { + Test.result = false; + Console.WriteLine("Expected this type: " + objType + ", but found type: " + this.GetType()); + } + + } + + public static void ThreadPoolTest() + { + Gen<T> obj = new Gen<T>(); + objType = obj.GetType(); + + TimerCallback tcb = new TimerCallback(obj.Target); + Stopwatch testWatch = new Stopwatch(); + testWatch.Start(); + Timer timer = new Timer(tcb,obj,Test.delay,Test.period); + while (testWatch.ElapsedMilliseconds < Test.timeToRun) + { + Thread.Sleep(0); + } + + timer.Dispose(); + testWatch.Stop(); + + if (Test.Xcounter > ((testWatch.ElapsedMilliseconds / Test.period)+2)) + { + Test.result = false; + Console.WriteLine("Expected Timer to run at most " + ((testWatch.ElapsedMilliseconds / Test.period)+2) + " times, but found " + Test.Xcounter + " runs in " + obj.GetType() + " type object."); + } + + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int delay = 0; + public static int period = 30; + public static int Xcounter = 0; + public static bool result = true; + public static int timeToRun = 5000; + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} diff --git a/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj new file mode 100644 index 0000000000..3821d1da35 --- /dev/null +++ b/tests/src/baseservices/threading/generics/TimerCallback/tighttimercallback.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="tighttimercallback.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/project.json b/tests/src/baseservices/threading/generics/WaitCallback/project.json new file mode 100644 index 0000000000..c14efc6fd1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.IO": "4.0.10-beta-23302", + "System.IO.FileSystem": "4.0.0-beta-23302", + "System.IO.FileSystem.Primitives": "4.0.0-beta-23302", + "System.Runtime": "4.0.20-beta-23302", + "System.Runtime.Extensions": "4.0.10-beta-23302", + "System.Runtime.Handles": "4.0.0-beta-23302", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Threading": "4.0.10-beta-23302", + "System.Threading.AccessControl": "4.0.0-rc3-23823", + "System.Globalization.Calendars": "4.0.0-beta-23302", + "System.Globalization": "4.0.10-beta-23302", + "System.Text.Encoding": "4.0.10-beta-23302", + "System.Runtime.InteropServices": "4.0.20-beta-23302", + "System.Collections": "4.0.10-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Reflection": "4.0.10-beta-23302", + "System.Reflection.Primitives": "4.0.0-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs new file mode 100644 index 0000000000..261b95d65a --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread01.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj new file mode 100644 index 0000000000..7235f93923 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread01.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread01.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs new file mode 100644 index 0000000000..e3d707cbd9 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread02.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj new file mode 100644 index 0000000000..7d8a01446e --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread02.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread02.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs new file mode 100644 index 0000000000..09d026a7df --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread03.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj new file mode 100644 index 0000000000..198813f89c --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread03.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread03.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs new file mode 100644 index 0000000000..38d00f3b66 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread04.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj new file mode 100644 index 0000000000..8480ccbbc2 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread04.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread04.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs new file mode 100644 index 0000000000..bf0fb64645 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread05.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj new file mode 100644 index 0000000000..846cdcc2aa --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread05.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread05.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs new file mode 100644 index 0000000000..d031dff8f1 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread06.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj new file mode 100644 index 0000000000..655d5d559c --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread06.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread06.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs new file mode 100644 index 0000000000..bd040a659c --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread07.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj new file mode 100644 index 0000000000..9368e18633 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread07.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread07.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs new file mode 100644 index 0000000000..72caf04e99 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread08.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +struct Gen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj new file mode 100644 index 0000000000..52167e1072 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread08.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread08.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs new file mode 100644 index 0000000000..5376b1dfce --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread09.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj new file mode 100644 index 0000000000..4432725076 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread09.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread09.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs new file mode 100644 index 0000000000..11fc065a8b --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread10.cs @@ -0,0 +1,91 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj new file mode 100644 index 0000000000..221aee2e93 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread10.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread10.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs new file mode 100644 index 0000000000..1a5488bce3 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread11.cs @@ -0,0 +1,91 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +struct Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj new file mode 100644 index 0000000000..fd4dad1b02 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread11.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread11.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs new file mode 100644 index 0000000000..e67c2caa6f --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread12.cs @@ -0,0 +1,91 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj new file mode 100644 index 0000000000..36ac2245b7 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread12.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread12.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs new file mode 100644 index 0000000000..220adfb0e3 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread13.cs @@ -0,0 +1,233 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj new file mode 100644 index 0000000000..9712549472 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread13.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread13.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs new file mode 100644 index 0000000000..032ef73aaf --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread14.cs @@ -0,0 +1,233 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +struct GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +struct GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj new file mode 100644 index 0000000000..81496bf708 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread14.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread14.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs new file mode 100644 index 0000000000..e675f55564 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread15.cs @@ -0,0 +1,233 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public virtual void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest(); + GenDouble.ThreadPoolTest(); + GenString.ThreadPoolTest(); + GenObject.ThreadPoolTest(); + GenGuid.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj new file mode 100644 index 0000000000..63f07aa992 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread15.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread15.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs new file mode 100644 index 0000000000..f5a6c3fa6e --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread16.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +class Gen : IGen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj new file mode 100644 index 0000000000..5a3858fd1b --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread16.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread16.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs new file mode 100644 index 0000000000..b55f7d89a5 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread17.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +struct Gen : IGen +{ + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj new file mode 100644 index 0000000000..c6dfdc3e22 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread17.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread17.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs new file mode 100644 index 0000000000..a9b4b76ef6 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread18.cs @@ -0,0 +1,82 @@ +using System; +using System.Threading; + +interface IGen +{ + void Target<U>(object p); +} + +class Gen : IGen +{ + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen obj = new Gen(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj new file mode 100644 index 0000000000..c3b4d62d24 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread18.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread18.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs new file mode 100644 index 0000000000..e349af58cd --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread19.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) {return t;} + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj new file mode 100644 index 0000000000..44e70dbd41 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread19.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread19.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs new file mode 100644 index 0000000000..0d9fbc4721 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread20.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +struct Gen<T> : IGen<T> +{ + public T Dummy(T t) {return t;} + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj new file mode 100644 index 0000000000..362a53f272 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread20.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread20.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs new file mode 100644 index 0000000000..eabd6fc984 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread21.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading; + + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class Gen<T> : IGen<T> +{ + public T Dummy(T t) {return t;} + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj new file mode 100644 index 0000000000..aeaaee7935 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread21.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread21.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs new file mode 100644 index 0000000000..2ba7e54f2f --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread22.cs @@ -0,0 +1,268 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj new file mode 100644 index 0000000000..bdc60d58ea --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread22.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread22.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs new file mode 100644 index 0000000000..55e3b64f88 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread23.cs @@ -0,0 +1,266 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +struct GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +struct GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +struct GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj new file mode 100644 index 0000000000..d67aaa5220 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread23.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread23.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs new file mode 100644 index 0000000000..1116522006 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread24.cs @@ -0,0 +1,264 @@ +using System; +using System.Threading; + +interface IGen<T> +{ + void Target<U>(object p); + T Dummy(T t); +} + +class GenInt : IGen<int> +{ + public int Dummy(int t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<int> obj = new GenInt(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenDouble : IGen<double> +{ + public double Dummy(double t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<double> obj = new GenDouble(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + + +class GenString : IGen<string> +{ + public string Dummy(string t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<string> obj = new GenString(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenObject : IGen<object> +{ + public object Dummy(object t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<object> obj = new GenObject(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +class GenGuid : IGen<Guid> +{ + public Guid Dummy(Guid t) { return t; } + + public virtual void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + IGen<Guid> obj = new GenGuid(); + + for (int i = 0; i <Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(obj.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + + GenInt.ThreadPoolTest<int>(); + GenDouble.ThreadPoolTest<int>(); + GenString.ThreadPoolTest<int>(); + GenObject.ThreadPoolTest<int>(); + GenGuid.ThreadPoolTest<int>(); + + GenInt.ThreadPoolTest<double>(); + GenDouble.ThreadPoolTest<double>(); + GenString.ThreadPoolTest<double>(); + GenObject.ThreadPoolTest<double>(); + GenGuid.ThreadPoolTest<double>(); + + GenInt.ThreadPoolTest<string>(); + GenDouble.ThreadPoolTest<string>(); + GenString.ThreadPoolTest<string>(); + GenObject.ThreadPoolTest<string>(); + GenGuid.ThreadPoolTest<string>(); + + GenInt.ThreadPoolTest<object>(); + GenDouble.ThreadPoolTest<object>(); + GenString.ThreadPoolTest<object>(); + GenObject.ThreadPoolTest<object>(); + GenGuid.ThreadPoolTest<object>(); + + GenInt.ThreadPoolTest<Guid>(); + GenDouble.ThreadPoolTest<Guid>(); + GenString.ThreadPoolTest<Guid>(); + GenObject.ThreadPoolTest<Guid>(); + GenGuid.ThreadPoolTest<Guid>(); + + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj new file mode 100644 index 0000000000..ddb4ca4742 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread24.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread24.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs new file mode 100644 index 0000000000..a7466d126a --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread25.cs @@ -0,0 +1,81 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public static void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen<T>.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj new file mode 100644 index 0000000000..5ff4103177 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread25.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread25.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs new file mode 100644 index 0000000000..dfbbfc7107 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread26.cs @@ -0,0 +1,83 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public static void Target(object p) + { + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + +#pragma warning disable 219 + Gen<T> obj = new Gen<T>(); +#pragma warning restore + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen<T>.Target); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads = 50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest(); + Gen<double>.ThreadPoolTest(); + Gen<string>.ThreadPoolTest(); + Gen<object>.ThreadPoolTest(); + Gen<Guid>.ThreadPoolTest(); + + Gen<int[]>.ThreadPoolTest(); + Gen<double[,]>.ThreadPoolTest(); + Gen<string[][][]>.ThreadPoolTest(); + Gen<object[,,,]>.ThreadPoolTest(); + Gen<Guid[][,,,][]>.ThreadPoolTest(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj new file mode 100644 index 0000000000..f05ac41311 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread26.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread26.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs new file mode 100644 index 0000000000..f97794a598 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread27.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +class Gen<T> +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + Gen<T> obj = new Gen<T>(); + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen<T>.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj new file mode 100644 index 0000000000..9fbe49c193 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread27.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread27.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs new file mode 100644 index 0000000000..63f5828254 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread28.cs @@ -0,0 +1,77 @@ +using System; +using System.Threading; + +struct Gen<T> +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } +#pragma warning disable 219 + Gen<T> obj = new Gen<T>(); +#pragma warning restore + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen<T>.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen<int>.ThreadPoolTest<object>(); + Gen<double>.ThreadPoolTest<string>(); + Gen<string>.ThreadPoolTest<Guid>(); + Gen<object>.ThreadPoolTest<int>(); + Gen<Guid>.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj new file mode 100644 index 0000000000..0b9be38589 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread28.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread28.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs new file mode 100644 index 0000000000..5bb1305a79 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread29.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +class Gen +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj new file mode 100644 index 0000000000..63c8e847d8 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread29.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread29.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs b/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs new file mode 100644 index 0000000000..bb6be407cb --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread30.cs @@ -0,0 +1,75 @@ +using System; +using System.Threading; + +struct Gen +{ + public static void Target<U>(object p) + { + //dummy line to avoid warnings + Test.Eval(typeof(U)!=p.GetType()); + ManualResetEvent evt = (ManualResetEvent) p; + Interlocked.Increment(ref Test.Xcounter); + evt.Set(); + } + public static void ThreadPoolTest<U>() + { + ManualResetEvent[] evts = new ManualResetEvent[Test.nThreads]; + WaitHandle[] hdls = new WaitHandle[Test.nThreads]; + + for (int i=0; i<Test.nThreads; i++) + { + evts[i] = new ManualResetEvent(false); + hdls[i] = (WaitHandle) evts[i]; + } + + for (int i = 0; i < Test.nThreads; i++) + { + WaitCallback cb = new WaitCallback(Gen.Target<U>); + ThreadPool.QueueUserWorkItem(cb,evts[i]); + } + + WaitHandle.WaitAll(hdls); + Test.Eval(Test.Xcounter==Test.nThreads); + Test.Xcounter = 0; + } +} + +public class Test +{ + public static int nThreads =50; + public static int counter = 0; + public static int Xcounter = 0; + public static bool result = true; + public static void Eval(bool exp) + { + counter++; + if (!exp) + { + result = exp; + Console.WriteLine("Test Failed at location: " + counter); + } + + } + + public static int Main() + { + Gen.ThreadPoolTest<object>(); + Gen.ThreadPoolTest<string>(); + Gen.ThreadPoolTest<Guid>(); + Gen.ThreadPoolTest<int>(); + Gen.ThreadPoolTest<double>(); + + if (result) + { + Console.WriteLine("Test Passed"); + return 100; + } + else + { + Console.WriteLine("Test Failed"); + return 1; + } + } +} + + diff --git a/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj b/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj new file mode 100644 index 0000000000..f5baa79fe0 --- /dev/null +++ b/tests/src/baseservices/threading/generics/WaitCallback/thread30.csproj @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{a1f1c234-d043-412e-bae9-36a26936dab5}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>0</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="thread30.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file |