summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/README.md1
-rw-r--r--Documentation/building/crossgen.md64
-rw-r--r--Documentation/building/debugging-instructions.md93
-rw-r--r--build.cmd2
-rw-r--r--dir.props4
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/debian/Microsoft.NETCore.Runtime.CoreCLR.pkgproj6
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/osx/Microsoft.NETCore.Runtime.CoreCLR.pkgproj6
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/rhel/Microsoft.NETCore.Runtime.CoreCLR.pkgproj6
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/ubuntu/Microsoft.NETCore.Runtime.CoreCLR.pkgproj6
-rw-r--r--src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/win/Microsoft.NETCore.Runtime.CoreCLR.pkgproj6
-rw-r--r--src/ToolBox/SOS/Strike/sosdocsunix.txt2
-rw-r--r--src/binder/applicationcontext.cpp8
-rw-r--r--src/binder/assembly.cpp9
-rw-r--r--src/jit/codegencommon.cpp11
-rw-r--r--src/jit/codegenxarch.cpp4
-rw-r--r--src/jit/compiler.cpp62
-rw-r--r--src/jit/compiler.h8
-rwxr-xr-x[-rw-r--r--]src/jit/gentree.cpp27
-rw-r--r--src/jit/inline.cpp67
-rw-r--r--src/jit/inline.def1
-rw-r--r--src/jit/inline.h21
-rw-r--r--src/jit/inlinepolicy.cpp182
-rw-r--r--src/jit/inlinepolicy.h26
-rw-r--r--src/jit/jitconfigvalues.h2
-rw-r--r--src/jit/lsra.cpp135
-rw-r--r--src/jit/lsra.h3
-rw-r--r--src/jit/morph.cpp32
-rw-r--r--src/jit/utils.cpp63
-rw-r--r--src/jit/utils.h13
-rw-r--r--src/jit/valuenum.cpp4
-rw-r--r--src/md/runtime/metamodelro.cpp10
-rw-r--r--src/mscorlib/mscorlib.shared.sources.props4
-rw-r--r--src/mscorlib/src/Microsoft/Win32/Win32Native.cs15
-rw-r--r--src/mscorlib/src/System/AppDomain.cs13
-rw-r--r--src/mscorlib/src/System/Array.cs23
-rw-r--r--src/mscorlib/src/System/Attribute.cs10
-rw-r--r--src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs8
-rw-r--r--src/mscorlib/src/System/Collections/Generic/Comparer.cs13
-rw-r--r--src/mscorlib/src/System/Convert.cs13
-rw-r--r--src/mscorlib/src/System/DateTime.cs8
-rw-r--r--src/mscorlib/src/System/DefaultBinder.cs9
-rw-r--r--src/mscorlib/src/System/Delegate.cs42
-rw-r--r--src/mscorlib/src/System/Diagnostics/Stacktrace.cs52
-rw-r--r--src/mscorlib/src/System/Environment.cs8
-rw-r--r--src/mscorlib/src/System/Globalization/CompareInfo.cs1
-rw-r--r--src/mscorlib/src/System/Globalization/CultureData.cs9
-rw-r--r--src/mscorlib/src/System/Globalization/CultureInfo.cs29
-rw-r--r--src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs1
-rw-r--r--src/mscorlib/src/System/IAppDomain.cs2
-rw-r--r--src/mscorlib/src/System/IAppDomainPauseManager.cs15
-rw-r--r--src/mscorlib/src/System/IO/Directory.cs15
-rw-r--r--src/mscorlib/src/System/IO/FileInfo.cs17
-rw-r--r--src/mscorlib/src/System/IO/FileStream.cs54
-rw-r--r--src/mscorlib/src/System/IO/Path.cs17
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs7
-rw-r--r--src/mscorlib/src/System/Reflection/ConstructorInfo.cs6
-rw-r--r--src/mscorlib/src/System/Reflection/CustomAttribute.cs14
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs4
-rw-r--r--src/mscorlib/src/System/Reflection/FieldInfo.cs5
-rw-r--r--src/mscorlib/src/System/Reflection/ParameterInfo.cs5
-rw-r--r--src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs11
-rw-r--r--src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs1
-rw-r--r--src/mscorlib/src/System/Security/Principal/GenericIdentity.cs162
-rw-r--r--src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs144
-rw-r--r--src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs23
-rw-r--r--src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs41
-rw-r--r--src/mscorlib/src/System/Security/SecurityContext.cs2
-rw-r--r--src/mscorlib/src/System/String.cs36
-rw-r--r--src/mscorlib/src/System/Text/StringBuilder.cs24
-rw-r--r--src/mscorlib/src/System/Threading/ExecutionContext.cs2
-rw-r--r--src/mscorlib/src/System/Threading/Mutex.cs1
-rw-r--r--src/mscorlib/src/System/Threading/Thread.cs32
-rw-r--r--src/mscorlib/src/System/Threading/ThreadPool.cs12
-rw-r--r--src/mscorlib/src/System/Threading/WaitHandle.cs7
-rw-r--r--src/pal/src/locale/unicode.cpp4
-rw-r--r--src/pal/src/locale/utf8.cpp3201
-rw-r--r--src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.c230
-rw-r--r--src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt2
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.c5
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.c5
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.c5
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt19
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.c154
-rw-r--r--src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat13
-rw-r--r--src/pal/tests/palsuite/paltestlist.txt5
-rw-r--r--src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt3
-rw-r--r--src/tools/crossgen/crossgen.cpp19
-rw-r--r--src/vm/ceeload.cpp10
-rw-r--r--src/vm/class.h15
-rw-r--r--src/vm/clsload.cpp7
-rw-r--r--src/vm/comdelegate.cpp6
-rw-r--r--src/vm/commodule.cpp6
-rw-r--r--src/vm/compile.cpp4
-rw-r--r--src/vm/domainfile.cpp7
-rw-r--r--src/vm/invokeutil.cpp5
-rw-r--r--src/vm/jitinterface.cpp87
-rw-r--r--src/vm/methodtablebuilder.cpp61
-rw-r--r--src/vm/pefile.cpp37
-rw-r--r--src/vm/prestub.cpp8
-rw-r--r--src/vm/reflectioninvocation.cpp29
-rw-r--r--src/vm/securitymeta.cpp9
-rw-r--r--src/vm/staticallocationhelpers.inl7
-rw-r--r--tests/arm64/Tests.lst1065
-rw-r--r--tests/issues.targets2
-rw-r--r--tests/scripts/exclusion.py79
-rw-r--r--tests/src/JIT/CodeGenBringUpTests/struct16args.cs739
-rw-r--r--tests/src/JIT/CodeGenBringUpTests/struct16args.csproj43
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs81
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj50
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config27
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il109
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj44
-rw-r--r--tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config27
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.cs42
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.csproj50
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_3449/app.config (renamed from tests/src/baseservices/threading/readerwriterlockslim/app.config)0
-rw-r--r--tests/src/baseservices/exceptions/simple/HardwareEh.cs6
-rw-r--r--tests/src/baseservices/threading/interlocked/add/add.cs41
-rw-r--r--tests/src/baseservices/threading/interlocked/add/add.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.cs107
-rw-r--r--tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/app.config31
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.cs23
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.cs23
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.cs22
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.cs22
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/checkreturn/project.json (renamed from tests/src/baseservices/threading/readerwriterlockslim/project.json)2
-rw-r--r--tests/src/baseservices/threading/interlocked/common/interlockedhelper_coreclr.cs282
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs148
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.csproj (renamed from tests/src/baseservices/threading/readerwriterlockslim/Upgrader.csproj)10
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.cs361
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.csproj (renamed from tests/src/baseservices/threading/readerwriterlockslim/TryEnterFailureDDBugs124485.csproj)10
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.cs167
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.csproj (renamed from tests/src/baseservices/threading/readerwriterlockslim/SingleReleaseWriteDDBug71632.csproj)10
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.cs168
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs252
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.cs120
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.cs98
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.cs91
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.cs87
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.cs101
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.cs57
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/compareexchange/compareexchangetneg.il95
-rw-r--r--tests/src/baseservices/threading/interlocked/ctorchk/app.config31
-rw-r--r--tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.cs30
-rw-r--r--tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/ctorchk/project.json35
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/app.config31
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/intdec.cs32
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/intdec.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/longdec.cs31
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/longdec.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/decrement/project.json35
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs165
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange2.cs150
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange2.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange3.cs86
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange3.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange4.cs86
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange4.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs165
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs165
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.csproj48
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangedouble.cs99
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangedouble.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangefloat.cs107
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangefloat.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangeobject.cs107
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchangeobject.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchanget.cs42
-rw-r--r--tests/src/baseservices/threading/interlocked/exchange/exchanget.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/app.config31
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/intinc.cs31
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/intinc.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/longinc.cs31
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/longinc.csproj43
-rw-r--r--tests/src/baseservices/threading/interlocked/increment/project.json35
-rw-r--r--tests/src/baseservices/threading/interlocked/read/app.config31
-rw-r--r--tests/src/baseservices/threading/interlocked/read/interlockedread.cs41
-rw-r--r--tests/src/baseservices/threading/interlocked/read/interlockedread.csproj42
-rw-r--r--tests/src/baseservices/threading/interlocked/read/project.json35
-rw-r--r--tests/src/baseservices/threading/interlocked/read/readthreads.cs97
-rw-r--r--tests/src/baseservices/threading/interlocked/read/readthreads.csproj42
-rw-r--r--tests/src/baseservices/threading/monitor/ctorchk/app.config31
-rw-r--r--tests/src/baseservices/threading/monitor/ctorchk/ctorchk.cs30
-rw-r--r--tests/src/baseservices/threading/monitor/ctorchk/ctorchk.csproj42
-rw-r--r--tests/src/baseservices/threading/monitor/ctorchk/project.json35
-rw-r--r--tests/src/baseservices/threading/monitor/enter/monitorenter.cs501
-rw-r--r--tests/src/baseservices/threading/monitor/enter/monitorenter.csproj42
-rw-r--r--tests/src/baseservices/threading/monitor/enter/project.json1
-rw-r--r--tests/src/baseservices/threading/monitor/isentered/app.config31
-rw-r--r--tests/src/baseservices/threading/monitor/isentered/monitorisentered.cs128
-rw-r--r--tests/src/baseservices/threading/monitor/isentered/monitorisentered.csproj42
-rw-r--r--tests/src/baseservices/threading/monitor/isentered/project.json36
-rw-r--r--tests/src/baseservices/threading/monitor/tryenter/app.config31
-rw-r--r--tests/src/baseservices/threading/monitor/tryenter/longtimeout.cs92
-rw-r--r--tests/src/baseservices/threading/monitor/tryenter/longtimeout.csproj42
-rw-r--r--tests/src/baseservices/threading/monitor/tryenter/project.json35
-rw-r--r--tests/src/baseservices/threading/monitor/wait/app.config31
-rw-r--r--tests/src/baseservices/threading/monitor/wait/project.json35
-rw-r--r--tests/src/baseservices/threading/monitor/wait/waitnull.cs26
-rw-r--r--tests/src/baseservices/threading/monitor/wait/waitnull.csproj42
-rw-r--r--tests/src/baseservices/threading/multiinstance/app.config31
-rw-r--r--tests/src/baseservices/threading/multiinstance/multiinstance.cs322
-rw-r--r--tests/src/baseservices/threading/multiinstance/multiinstance.csproj49
-rw-r--r--tests/src/baseservices/threading/multiinstance/project.json36
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.cs52
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.cs59
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.cs113
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj44
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.cs112
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj44
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.cs70
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.cs96
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.cs119
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/app.config31
-rw-r--r--tests/src/baseservices/threading/mutex/abandonedmutex/project.json35
-rw-r--r--tests/src/baseservices/threading/mutex/misc/app.config31
-rw-r--r--tests/src/baseservices/threading/mutex/misc/mutexctor1.cs173
-rw-r--r--tests/src/baseservices/threading/mutex/misc/mutexctor1.csproj48
-rw-r--r--tests/src/baseservices/threading/mutex/misc/mutexctor2.cs104
-rw-r--r--tests/src/baseservices/threading/mutex/misc/mutexctor2.csproj48
-rw-r--r--tests/src/baseservices/threading/mutex/misc/project.json35
-rw-r--r--tests/src/baseservices/threading/mutex/misc/waitone1.cs217
-rw-r--r--tests/src/baseservices/threading/mutex/misc/waitone1.csproj48
-rw-r--r--tests/src/baseservices/threading/mutex/misc/waitone2.cs573
-rw-r--r--tests/src/baseservices/threading/mutex/misc/waitone2.csproj48
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/app.config31
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.cs38
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.cs38
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.cs38
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.cs39
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs40
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.cs42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.cs59
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.cs41
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.cs59
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.cs46
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.cs48
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.csproj43
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.cs85
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.csproj42
-rw-r--r--tests/src/baseservices/threading/mutex/openexisting/project.json35
-rw-r--r--tests/src/baseservices/threading/mutex/openmutexcommon.cs32
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartarray.cs58
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj42
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartclass.cs52
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartclass.csproj42
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartstruct.cs67
-rw-r--r--tests/src/baseservices/threading/paramthreadstart/threadstartstruct.csproj42
-rw-r--r--tests/src/baseservices/threading/readerwriterlockslim/singlereleasewriteddbug71632.cs159
-rw-r--r--tests/src/baseservices/threading/readerwriterlockslim/tryenterfailureddbugs124485.cs87
-rw-r--r--tests/src/baseservices/threading/readerwriterlockslim/upgrader.cs87
-rw-r--r--tests/src/baseservices/threading/regressions/13662/13662-a.cs33
-rw-r--r--tests/src/baseservices/threading/regressions/13662/13662-a.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/13662/13662-b.cs89
-rw-r--r--tests/src/baseservices/threading/regressions/13662/13662-b.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/13662/13662-simple.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/13662/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/13662/project.json36
-rw-r--r--tests/src/baseservices/threading/regressions/13662/simple.cs33
-rw-r--r--tests/src/baseservices/threading/regressions/269336/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/269336/objmonhelper.cs37
-rw-r--r--tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/269336/project.json35
-rw-r--r--tests/src/baseservices/threading/regressions/30032/30032.cs40
-rw-r--r--tests/src/baseservices/threading/regressions/30032/30032.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/30032/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/30032/project.json36
-rw-r--r--tests/src/baseservices/threading/regressions/beta1/347011.cs35
-rw-r--r--tests/src/baseservices/threading/regressions/beta1/347011.csproj43
-rw-r--r--tests/src/baseservices/threading/regressions/beta1/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/beta1/project.json36
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/437017.cs125
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/437017.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/437044.cs119
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/437044.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/beta2/project.json37
-rw-r--r--tests/src/baseservices/threading/regressions/devdiv489437/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/devdiv489437/project.json35
-rw-r--r--tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs52
-rw-r--r--tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/threadex.cs20
-rw-r--r--tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs33
-rw-r--r--tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj42
-rw-r--r--tests/src/baseservices/threading/regressions/whidbey_m3/app.config31
-rw-r--r--tests/src/baseservices/threading/regressions/whidbey_m3/project.json36
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/app.config31
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/project.json35
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.cs69
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.cs99
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.csproj44
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.cs128
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.cs97
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.csproj44
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.cs108
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.csproj44
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.cs65
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.cs93
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.csproj44
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.cs103
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.cs38
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.cs40
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.csproj42
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.cs38
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.csproj42
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.cs39
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.csproj42
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.cs42
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.cs42
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.cs43
-rw-r--r--tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.csproj43
-rw-r--r--tests/src/baseservices/threading/semaphore/semaphorecommon.cs36
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/app.config31
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/project.json35
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/semdemo.cs88
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/semdemo.csproj42
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/semtest.cs190
-rw-r--r--tests/src/baseservices/threading/semaphore/unit/semtest.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/app.config31
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.cs63
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.cs41
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.cs62
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.cs57
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.cs63
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.cs78
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.cs33
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/bindhandle/project.json36
-rw-r--r--tests/src/baseservices/threading/threadpool/ctorchk/app.config31
-rw-r--r--tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.cs30
-rw-r--r--tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/ctorchk/project.json36
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/app.config31
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/project.json36
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/regression_749068.cs137
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/regression_749068.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/unregister01.cs64
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj42
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/unregister03.cs65
-rw-r--r--tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj42
-rw-r--r--tests/src/baseservices/threading/threadstatic/project.json1
-rw-r--r--tests/src/baseservices/threading/threadstatic/threadstatic07.cs221
-rw-r--r--tests/src/baseservices/threading/threadstatic/threadstatic07.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/app.config31
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/project.json35
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/waithandledispose2.cs100
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/waithandledispose2.csproj48
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.cs292
-rw-r--r--tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj48
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/app.config31
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/emptyarray.cs41
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/nullarray.cs52
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/nullarraymember.cs41
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/nullarraymember.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/project.json35
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallemptyarray.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex1.cs60
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex10.cs103
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex10a.cs103
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex11.cs70
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex11.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex11a.cs70
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex11a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex1a.cs60
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex2.cs66
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex2a.cs66
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex3.cs97
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex3a.cs97
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex4.cs87
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex4a.cs87
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex5.cs89
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex5a.cs89
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex6.cs94
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex6a.cs94
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex7.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex7a.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex8.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex8a.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex9.cs100
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex9a.cs100
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitall/waitallnullarray.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/app.config31
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/emptyarray.cs41
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/nullarray.cs41
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/nullarraymember.cs41
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/nullarraymemberwaitany.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/project.json35
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyemptyarray.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs65
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs104
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs104
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.cs65
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex2.cs68
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex2.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.cs68
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs81
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs81
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex4.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex4.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.cs76
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs85
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex5.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs85
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs97
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex6.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.cs97
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs69
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs69
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex8.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs102
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj44
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs102
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitany/waitanynullarray.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waithandlecommon.cs16
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/app.config31
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/project.json35
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex1.cs58
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.cs58
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex2.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex3.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.cs59
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.csproj42
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex4.cs57
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex4.csproj43
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.cs57
-rw-r--r--tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.csproj42
-rw-r--r--tests/testsFailingOutsideWindows.txt1
-rw-r--r--tests/testsUnsupportedOutsideWindows.txt257
-rw-r--r--tests/x86_legacy_backend_issues.targets6
518 files changed, 29069 insertions, 3275 deletions
diff --git a/Documentation/README.md b/Documentation/README.md
index 7cdba870a0..cdb862c534 100644
--- a/Documentation/README.md
+++ b/Documentation/README.md
@@ -57,6 +57,7 @@ Testing and Debugging CoreCLR
- [Testing Changes on Linux, OS X, and FreeBSD](building/unix-test-instructions.md)
- [Testing with CoreFX](building/testing-with-corefx.md)
- [.NET Performance Data Collection Script](https://raw.githubusercontent.com/dotnet/corefx-tools/master/src/performance/perfcollect/perfcollect)
+- [Creating native images](building/crossgen.md)
Book of the Runtime
===================
diff --git a/Documentation/building/crossgen.md b/Documentation/building/crossgen.md
new file mode 100644
index 0000000000..3ee458263a
--- /dev/null
+++ b/Documentation/building/crossgen.md
@@ -0,0 +1,64 @@
+Using CrossGen to Create Native Images
+======================================
+
+Introduction
+------------
+
+When you create a .NET assembly using C# compiler, your assembly contains only MSIL code.
+When the app runs, the JIT compiler translates the MSIL code into native code, before the CPU can execute them.
+This execution model has some advantages. For example, your assembly code can be portable across all platforms and architectures that support .NET Core.
+However, this portability comes with a performance penalty. Your app starts up slower, because the JIT compiler has to spend time to translate the code.
+
+To help make your app start up faster, CoreCLR includes a tool called CrossGen, which can pre-compile the MSIL code into native code.
+
+Getting CrossGen
+----------------
+
+If you build CoreCLR yourself, the CrossGen tool (`crossgen.exe` on Windows, or `crossgen` on other platforms) is created as part of the build, and stored in the same output directory as other CoreCLR binaries.
+If you install CoreCLR using a NuGet package, you can find CrossGen in the `tools` folder of the NuGet package.
+
+Regardless of how you obtain CrossGen, it is very important that it must match other CoreCLR binaries.
+- If you build CrossGen yourself, you should use it with coreclr and mscorlib generated from the same build. Do not attempt to mix CrossGen from one build with binaries generated from another build.
+- If you install CrossGen from NuGet, make sure you use CrossGen from exactly the same NuGet package as the rest of your CoreCLR binaries. Do not attempt to mix binaries from multiple NuGet packages.
+
+If you do not follow the above rules, you are likely to encounter errors while running CrossGen.
+
+Using CrossGen
+--------------
+
+In most cases, the build script automatically runs CrossGen to create the native image for mscorlib.
+When this happens, you will find both `mscorlib.dll` and `mscorlib.ni.dll` in your output directory.
+`mscorlib.dll` is the MSIL assembly created by the C# compiler, while `mscorlib.ni.dll` is the native image that contains CPU-specific code.
+Once the build is done, you only need `mscorlib.ni.dll` to use CoreCLR.
+As a matter of fact, most CoreCLR NuGet packages contain only `mscorlib.ni.dll`, without `mscorlib.dll`
+
+If for some reason you did not get `mscorlib.ni.dll` with the rest of your CoreCLR, you can easily create it yourself using CrossGen.
+First, make sure you have `crossgen.exe` (on Windows) or `crossgen` (other platforms) in the same directory as `mscorlib.dll`.
+Then, run one of the following two commands (first command for Windows, second command for other platforms):
+
+ .\crossgen.exe mscorlib.dll
+ ./crossgen mscorlib.dll
+
+To create native images for other assemblies, the command line is slightly more complex:
+
+ .\crossgen.exe /Platform_Assemblies_Paths "path1;path2;..." assemblyName.dll
+ ./crossgen /Platform_Assemblies_Paths "path1;path2;..." assemblyName.dll
+
+The /Platform_Assemblies_Paths is used to specify the location of all the dependencies of the input assembly.
+You should use full paths for this locations. Relative paths do not always work.
+If there are multiple paths, separate them with semicolons (`;`). On non-Windows platforms, be sure to enclose the path list in quotes to protect the semicolons from the shell.
+
+Using native images
+-------------------
+
+Running CrossGen on an assembly creates a "native image" file, with the extension of `.ni.dll` or `.ni.exe`.
+You should include the native images in your app, at the same location where you normally install the MSIL assemblies.
+Once you have included native images, you do not need to include the original MSIL assemblies in your apps.
+
+Common errors
+-------------
+
+The following are some of the command errors while creating or using native images:
+- "Could not load file or assembly 'mscorlib.dll' or one of its dependencies. The native image could not be loaded, because it was generated for use by a different version of the runtime. (Exception from HRESULT: 0x80131059)": This error indicates that there is a mismatch between CrossGen and mscorlib.ni.dll. Make sure to use CrossGen and mscorlib.ni.dll from the same build or NuGet package.
+- "Error: Could not load file or assembly '...' or one of its dependencies. The system cannot find the file specified. (Exception from HRESULT: 0x80070002)": CrossGen wasn't able to find a particular dependency that it needs. Verify that you have the assembly specified in the error message, and make sure its location is included in `/Platform_Assemblies_Paths`.
+- CoreCLR unable to initialize: While there are many possible causes of this error, one possibility is a mismatch between mscorlib.ni.dll and coreclr.dll (or libcoreclr.so). Make sure they come from the same build or NuGet package.
diff --git a/Documentation/building/debugging-instructions.md b/Documentation/building/debugging-instructions.md
index d2696d1877..2ab4cc1133 100644
--- a/Documentation/building/debugging-instructions.md
+++ b/Documentation/building/debugging-instructions.md
@@ -1,7 +1,7 @@
Debugging CoreCLR
=================
-These instructions will lead you through debugging CoreCLR on Windows. They will be expanded to support Linux and OS X when we have good instructions for that.
+These instructions will lead you through debugging CoreCLR on Windows and Linux. They will be expanded to support OS X when we have good instructions for that.
Debugging CoreCLR on Windows
============================
@@ -41,56 +41,73 @@ You can combine steps 4-8 and pass everything on the lldb command line:
`lldb-3.6 -o "plugin load libsosplugin.so" -o "process launch -s" -o "process handle -s false SIGUSR1 SIGUSR2" -o "breakpoint set -n LoadLibraryExW" corerun HelloWorld.exe linux`
-SOS commands supported by the lldb plugin:
-
- bpmd
- ClrStack
- DumpStackObjects
- DumpMD
- DumpClass
- DumpMT
- DumpArray
- DumpObj
- DumpAssembly
- DumpDomain
- DumpHeap
- DumpLog
- DumpModule
- DumpRuntimeTypes
- DumpVC
- EEHeap
- EHInfo
- FindAppDomain
- GCRoot
- GCInfo
- Help
- IP2MD
- Name2EE
- PrintException
- ThreadState
- Threads
- Token2EE
- VerifyHeap
-
-There are some aliases for the most common commands:
+### SOS commands ###
+
+This is the full list of commands currently supported by SOS. LLDB is case-sensitive unlike windbg.
+
+ Type "soshelp <functionname>" for detailed info on that function.
+
+ Object Inspection Examining code and stacks
+ ----------------------------- -----------------------------
+ DumpObj (dumpobj) Threads (clrthreads)
+ DumpArray ThreadState
+ DumpStackObjects (dso) IP2MD (ip2md)
+ DumpHeap (dumpheap) u (clru)
+ DumpVC DumpStack (dumpstack)
+ GCRoot (gcroot) EEStack (eestack)
+ PrintException (pe) ClrStack (clrstack)
+ GCInfo
+ EHInfo
+ bpmd (bpmd)
+
+ Examining CLR data structures Diagnostic Utilities
+ ----------------------------- -----------------------------
+ DumpDomain VerifyHeap
+ EEHeap (eeheap) FindAppDomain
+ Name2EE (name2ee) DumpLog (dumplog)
+ DumpMT (dumpmt)
+ DumpClass (dumpclass)
+ DumpMD (dumpmd)
+ Token2EE
+ DumpModule (dumpmodule)
+ DumpAssembly
+ DumpRuntimeTypes
+ DumpIL (dumpil)
+ DumpSig
+ DumpSigElem
+
+ Other
+ -----------------------------
+ FAQ
+ Help (soshelp)
+
+###Aliases###
+By default you can reach all the SOS commands by using: _sos [command\_name]_
+However the common commands have been aliased so that you don't need the SOS prefix:
bpmd -> sos bpmd
clrstack -> sos ClrStack
clrthreads -> sos Threads
- dumpheap -> sos DumpHeap
+ dso -> sos DumpStackObjects
+ dumpclass -> sos DumpClass
+ dumpheap -> sos DumpHeap
+ dumpil -> sos DumpIL
dumplog -> sos DumpLog
dumpmd -> sos DumpMD
+ dumpmodule -> sos DumpModule
dumpmt -> sos DumpMT
dumpobj -> sos DumpObj
- dso -> sos DumpStackObjects
+ dumpstack -> sos DumpStack
eeheap -> sos EEHeap
+ eestack -> sos EEStack
gcroot -> sos GCRoot
ip2md -> sos IP2MD
name2ee -> sos Name2EE
pe -> sos PrintException
soshelp -> sos Help
-Problems and limitations of lldb and sos:
+
+### Problems and limitations of lldb and sos ###
Many of the sos commands like clrstack or dso don't work on core dumps because lldb doesn't
return the actual OS thread id for a native thread. The "setsostid" command can be used to work
@@ -98,10 +115,10 @@ around this lldb bug. Use the "clrthreads" to find the os tid and the lldb comma
to find the thread index (#1 for example) for the current thread (* in first column). The first
setsostid argument is the os tid and the second is the thread index: "setsosid ecd5 1".
-The "gcroot" command either crashes lldb 3.6 or returns invalid results. Works fine with lldb 3.7.
+The "gcroot" command either crashes lldb 3.6 or returns invalid results. Works fine with lldb 3.7 and 3.8.
Loading Linux core dumps with lldb 3.7 doesn't work. lldb 3.7 loads OSX and FreeBSD core dumps
-just fine.
+just fine. lldb 3.8 loads all the platform's core dumps without problem.
For more information on SOS commands see: https://msdn.microsoft.com/en-us/library/bb190764(v=vs.110).aspx
diff --git a/build.cmd b/build.cmd
index 6f2edf894c..82fa0a5a7c 100644
--- a/build.cmd
+++ b/build.cmd
@@ -682,7 +682,7 @@ if /i "%__ToolsetDir%" == "" (
exit /b 1
)
-set PATH=%PATH%;%__ToolsetDir%\cpp\bin
+set PATH=%__ToolsetDir%\cpp\bin;%PATH%
set LIB=%__ToolsetDir%\OS\lib;%__ToolsetDir%\cpp\lib
set INCLUDE=^
%__ToolsetDir%\cpp\inc;^
diff --git a/dir.props b/dir.props
index 110eabff47..7863433581 100644
--- a/dir.props
+++ b/dir.props
@@ -77,8 +77,8 @@
<!-- Output paths -->
<PropertyGroup>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">$(RootBinDir)obj</BaseIntermediateOutputPath>
- <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(BaseIntermediateOutputPath)\$(BuildOS).$(BuildArch).$(Configuration)</IntermediateOutputPath>
- <OutputPath Condition="'$(OutputPath)' == ''">$(BaseIntermediateOutputPath)\$(BuildOS).$(BuildArch).$(Configuration)</OutputPath>
+ <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">$(BaseIntermediateOutputPath)\$(BuildOS).$(BuildArch).$(BuildType)</IntermediateOutputPath>
+ <OutputPath Condition="'$(OutputPath)' == ''">$(BaseIntermediateOutputPath)\$(BuildOS).$(BuildArch).$(BuildType)</OutputPath>
<FinalOutputPath Condition="'$(FinalOutputPath)' == ''">$(BinDir)</FinalOutputPath>
</PropertyGroup>
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/debian/Microsoft.NETCore.Runtime.CoreCLR.pkgproj b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/debian/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
index b628723123..989d370b84 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/debian/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/debian/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
@@ -31,14 +31,14 @@
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>
- <!-- Using lib/dotnet here. There is no TFM for this since it is a runtime itself. -->
+ <!-- Using lib/netstandard1.0 here. There is no TFM for this since it is a runtime itself. -->
<File Include="@(ArchitectureSpecificLibFile)">
- <TargetPath>runtimes/$(PackageTargetRuntime)/lib/dotnet</TargetPath>
+ <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
</File>
<!-- No reference: don't permit reference to the implementation from lib -->
<File Include="$(PlaceholderFile)">
- <TargetPath>ref/dotnet</TargetPath>
+ <TargetPath>ref/netstandard1.0</TargetPath>
</File>
<File Include="@(ArchitectureSpecificToolFile)">
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/osx/Microsoft.NETCore.Runtime.CoreCLR.pkgproj b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/osx/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
index 895be95978..aac843b538 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/osx/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/osx/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
@@ -29,14 +29,14 @@
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>
- <!-- Using lib/dotnet here. There is no TFM for this since it is a runtime itself. -->
+ <!-- Using lib/netstandard1.0 here. There is no TFM for this since it is a runtime itself. -->
<File Include="@(ArchitectureSpecificLibFile)">
- <TargetPath>runtimes/$(PackageTargetRuntime)/lib/dotnet</TargetPath>
+ <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
</File>
<!-- No reference: don't permit reference to the implementation from lib -->
<File Include="$(PlaceholderFile)">
- <TargetPath>ref/dotnet</TargetPath>
+ <TargetPath>ref/netstandard1.0</TargetPath>
</File>
<File Include="@(ArchitectureSpecificToolFile)">
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/rhel/Microsoft.NETCore.Runtime.CoreCLR.pkgproj b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/rhel/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
index 5cd175906f..d17f607985 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/rhel/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/rhel/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
@@ -31,14 +31,14 @@
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>
- <!-- Using lib/dotnet here. There is no TFM for this since it is a runtime itself. -->
+ <!-- Using lib/netstandard1.0 here. There is no TFM for this since it is a runtime itself. -->
<File Include="@(ArchitectureSpecificLibFile)">
- <TargetPath>runtimes/$(PackageTargetRuntime)/lib/dotnet</TargetPath>
+ <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
</File>
<!-- No reference: don't permit reference to the implementation from lib -->
<File Include="$(PlaceholderFile)">
- <TargetPath>ref/dotnet</TargetPath>
+ <TargetPath>ref/netstandard1.0</TargetPath>
</File>
<File Include="@(ArchitectureSpecificToolFile)">
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/ubuntu/Microsoft.NETCore.Runtime.CoreCLR.pkgproj b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/ubuntu/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
index de2110ae14..174b823f5f 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/ubuntu/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/ubuntu/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
@@ -31,14 +31,14 @@
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>
- <!-- Using lib/dotnet here. There is no TFM for this since it is a runtime itself. -->
+ <!-- Using lib/netstandard1.0 here. There is no TFM for this since it is a runtime itself. -->
<File Include="@(ArchitectureSpecificLibFile)">
- <TargetPath>runtimes/$(PackageTargetRuntime)/lib/dotnet</TargetPath>
+ <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
</File>
<!-- No reference: don't permit reference to the implementation from lib -->
<File Include="$(PlaceholderFile)">
- <TargetPath>ref/dotnet</TargetPath>
+ <TargetPath>ref/netstandard1.0</TargetPath>
</File>
<File Include="@(ArchitectureSpecificToolFile)">
diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/win/Microsoft.NETCore.Runtime.CoreCLR.pkgproj b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/win/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
index fb2d5bfa7a..4779b7154d 100644
--- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/win/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
+++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/win/Microsoft.NETCore.Runtime.CoreCLR.pkgproj
@@ -29,9 +29,9 @@
<TargetPath>runtimes/$(PackageTargetRuntime)/native</TargetPath>
</File>
- <!-- Using lib/dotnet here. There is no TFM for this since it is a runtime itself. -->
+ <!-- Using lib/netstandard1.0 here. There is no TFM for this since it is a runtime itself. -->
<File Include="@(ArchitectureSpecificLibFile)">
- <TargetPath>runtimes/$(PackageTargetRuntime)/lib/dotnet</TargetPath>
+ <TargetPath>runtimes/$(PackageTargetRuntime)/lib/netstandard1.0</TargetPath>
</File>
<File Include="@(ArchitectureSpecificToolFile)">
@@ -40,7 +40,7 @@
<!-- No reference: don't permit reference to the implementation from lib -->
<File Include="$(PlaceholderFile)">
- <TargetPath>ref/dotnet</TargetPath>
+ <TargetPath>ref/netstandard1.0</TargetPath>
</File>
</ItemGroup>
diff --git a/src/ToolBox/SOS/Strike/sosdocsunix.txt b/src/ToolBox/SOS/Strike/sosdocsunix.txt
index 4a2417b1ac..0c7491b4ff 100644
--- a/src/ToolBox/SOS/Strike/sosdocsunix.txt
+++ b/src/ToolBox/SOS/Strike/sosdocsunix.txt
@@ -29,7 +29,7 @@ DumpStackObjects (dso) IP2MD (ip2md)
DumpHeap (dumpheap) u (clru)
DumpVC DumpStack (dumpstack)
GCRoot (gcroot) EEStack (eestack)
-PrintException (pe) CLRStack (clrstack)
+PrintException (pe) ClrStack (clrstack)
GCInfo
EHInfo
bpmd (bpmd)
diff --git a/src/binder/applicationcontext.cpp b/src/binder/applicationcontext.cpp
index d62091048f..27f860e927 100644
--- a/src/binder/applicationcontext.cpp
+++ b/src/binder/applicationcontext.cpp
@@ -459,13 +459,7 @@ namespace BINDER_SPACE
SAFE_NEW(pNewAssemblyIdentity, AssemblyIdentityUTF8);
sTextualIdentity.SetUTF8(szTextualIdentity);
-
- BOOL fWindowsPhone7 = false;
-#ifdef FEATURE_LEGACYNETCF
- fWindowsPhone7 = RuntimeIsLegacyNetCF(GetAppDomainId());
-#endif // FEATURE_LEGACYNETCF
-
- IF_FAIL_GO(TextualIdentityParser::Parse(sTextualIdentity, pNewAssemblyIdentity, fWindowsPhone7));
+ IF_FAIL_GO(TextualIdentityParser::Parse(sTextualIdentity, pNewAssemblyIdentity));
IF_FAIL_GO(m_assemblyIdentityCache.Add(szTextualIdentity, pNewAssemblyIdentity));
pNewAssemblyIdentity->PopulateUTF8Fields();
diff --git a/src/binder/assembly.cpp b/src/binder/assembly.cpp
index 28827b6c26..f528128187 100644
--- a/src/binder/assembly.cpp
+++ b/src/binder/assembly.cpp
@@ -16,10 +16,6 @@
#include "assembly.hpp"
#include "utils.hpp"
-#ifdef FEATURE_LEGACYNETCF
-extern BOOL RuntimeIsLegacyNetCF(DWORD adid);
-#endif
-
namespace BINDER_SPACE
{
namespace
@@ -286,11 +282,6 @@ Exit:
if (!IsPlatformArchicture(kArchitecture))
return TRUE;
-#ifdef FEATURE_LEGACYNETCF
- if (kArchitecture == peI386 && RuntimeIsLegacyNetCF(0))
- return TRUE;
-#endif
-
return (kArchitecture == GetSystemArchitecture());
}
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp
index b81d81322e..fbd96eb02b 100644
--- a/src/jit/codegencommon.cpp
+++ b/src/jit/codegencommon.cpp
@@ -3903,9 +3903,15 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg,
{
#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
return type;
-#else // defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
+#elif defined(_TARGET_ARM_)
+ LclVarDsc varDsc = compiler->lvaTable[varNum];
+ return varDsc.lvIsHfaRegArg ? varDsc.GetHfaType() : varDsc.lvType;
+
+ // TODO-ARM64: Do we need the above to handle HFA structs on ARM64?
+
+#else // !_TARGET_ARM_
return compiler->lvaTable[varNum].lvType;
-#endif // defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
+#endif // !_TARGET_ARM_
}
} regArgTab [max(MAX_REG_ARG,MAX_FLOAT_REG_ARG)] = { };
@@ -4762,7 +4768,6 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg,
}
/* Finally take care of the remaining arguments that must be enregistered */
-
while (regArgMaskLive)
{
regMaskTP regArgMaskLiveSave = regArgMaskLive;
diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp
index e5962b106a..3dc7d2d80b 100644
--- a/src/jit/codegenxarch.cpp
+++ b/src/jit/codegenxarch.cpp
@@ -7502,6 +7502,10 @@ CodeGen::genIntToFloatCast(GenTreePtr treeNode)
// result if sign-bit of srcType is set.
if (srcType == TYP_ULONG)
{
+ // The instruction sequence below is less accurate than what clang
+ // and gcc generate. However, we keep the current sequence for backward compatiblity.
+ // If we change the instructions below, FloatingPointUtils::convertUInt64ToDobule
+ // should be also updated for consistent conversion result.
assert(dstType == TYP_DOUBLE);
assert(!op1->isContained());
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp
index 0c538e1f1b..1c3946af7d 100644
--- a/src/jit/compiler.cpp
+++ b/src/jit/compiler.cpp
@@ -642,6 +642,7 @@ unsigned Compiler::s_compMethodsCount = 0; // to produce unique label
/* static */
bool Compiler::s_dspMemStats = false;
+bool Compiler::s_inlDumpDataHeader = false;
#endif
#ifndef DEBUGGING_SUPPORT
@@ -1261,9 +1262,13 @@ void Compiler::compInit(ArenaAllocator * pAlloc, InlineInfo * inl
// Inlinee Compile object will only be allocated when needed for the 1st time.
InlineeCompiler = nullptr;
- // Set the inline info and the inline result.
+ // Set the inline info.
impInlineInfo = inlineInfo;
+#ifdef DEBUG
+ inlLastSuccessfulPolicy = nullptr;
+#endif
+
eeInfoInitialized = false;
compDoAggressiveInlining = false;
@@ -4570,6 +4575,61 @@ void Compiler::compCompileFinish()
printf("****** DONE compiling %s\n", info.compFullName);
printf(""); // in our logic this causes a flush
}
+
+ // Inliner data display
+ if (JitConfig.JitInlineDumpData() != 0)
+ {
+ // Don't dump anything if limiting is on and we didn't reach
+ // the limit while inlining.
+ //
+ // This serves to filter out duplicate data.
+ const int limit = JitConfig.JitInlineLimit();
+
+ if ((limit < 0) || (fgInlinedCount == static_cast<unsigned>(limit)))
+ {
+ // If there weren't any successful inlines (no limit, or
+ // limit=0 case), we won't have a successful policy, so
+ // fake one up.
+ if (inlLastSuccessfulPolicy == nullptr)
+ {
+ assert(limit <= 0);
+ const bool isPrejitRoot = (opts.eeFlags & CORJIT_FLG_PREJIT) != 0;
+ inlLastSuccessfulPolicy = InlinePolicy::GetPolicy(this, isPrejitRoot);
+ }
+
+ if (!s_inlDumpDataHeader)
+ {
+ if (limit == 0)
+ {
+ printf("*** Inline Data: Policy=%s JitInlineLimit=%d ***\n",
+ inlLastSuccessfulPolicy->GetName(),
+ limit);
+ printf("Method,Version,HotSize,ColdSize,JitTime");
+ inlLastSuccessfulPolicy->DumpSchema();
+ printf("\n");
+ }
+
+ s_inlDumpDataHeader = true;
+ }
+
+ // We'd really like the method identifier to be unique and
+ // durable across crossgen invocations. Not clear how to
+ // accomplish this, so we'll use the token for now.
+ //
+ // Post processing will have to filter out all data from
+ // methods where the root entry appears multiple times.
+ mdMethodDef currentMethodToken = info.compCompHnd->getMethodDefFromMethod(info.compMethodHnd);
+
+ printf("%08X,%u,%u,%u,%u",
+ currentMethodToken,
+ fgInlinedCount,
+ info.compTotalHotCodeSize,
+ info.compTotalColdCodeSize,
+ 0);
+ inlLastSuccessfulPolicy->DumpData();
+ printf("\n");
+ }
+ }
// Only call _DbgBreakCheck when we are jitting, not when we are ngen-ing
// For ngen the int3 or breakpoint instruction will be right at the
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index 098e28b6a0..1e58ee989d 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -2521,11 +2521,16 @@ public :
unsigned lvaPSPSym; // variable representing the PSPSym
#endif
- InlineInfo * impInlineInfo;
+ InlineInfo* impInlineInfo;
// Get the maximum IL size allowed for an inline
unsigned getImpInlineSize() const { return impInlineSize; }
+#ifdef DEBUG
+ unsigned getInlinedCount() const { return fgInlinedCount; }
+ InlinePolicy* inlLastSuccessfulPolicy;
+#endif
+
// The Compiler* that is the root of the inlining tree of which "this" is a member.
Compiler* impInlineRoot();
@@ -7565,6 +7570,7 @@ public :
#ifdef DEBUG
static bool s_dspMemStats; // Display per-phase memory statistics for every function
+ static bool s_inlDumpDataHeader; // Print header schema for inline data
template<typename T>
T dspPtr(T p)
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp
index d7d2b64dd9..f8a1eeb4b6 100644..100755
--- a/src/jit/gentree.cpp
+++ b/src/jit/gentree.cpp
@@ -9954,7 +9954,7 @@ CHK_OVF:
case TYP_DOUBLE:
if ((tree->gtFlags & GTF_UNSIGNED) && lval1 < 0)
{
- d1 = (double) (unsigned __int64) lval1;
+ d1 = FloatingPointUtils::convertUInt64ToDouble((unsigned __int64)lval1);
}
else
{
@@ -10074,29 +10074,8 @@ CHK_OVF:
lval1 = INT64(d1); goto CNS_LONG;
case TYP_ULONG:
- if (d1 >= 0.0)
- {
- // Work around a C++ issue where it doesn't properly convert large positive doubles
- const double two63 = 2147483648.0 * 4294967296.0;
- if (d1 < two63) {
- lval1 = UINT64(d1);
- }
- else {
- // subtract 0x8000000000000000, do the convert then add it back again
- lval1 = INT64(d1 - two63) + I64(0x8000000000000000);
- }
- goto CNS_LONG;
- }
-
- // This double cast to account for an ECMA spec hole.
- // When converting from a double to an unsigned the ECMA
- // spec states that a conforming implementation should
- // "truncate to zero." However that doesn't make much sense
- // when the double in question is negative and the target
- // is unsigned. gcc converts a negative double to zero when
- // cast to an unsigned. To make gcc conform to MSVC behavior
- // this cast is necessary.
- lval1 = UINT64(INT64(d1)); goto CNS_LONG;
+ lval1 = FloatingPointUtils::convertDoubleToUInt64(d1);
+ goto CNS_LONG;
case TYP_FLOAT:
d1 = forceCastToFloat(d1);
diff --git a/src/jit/inline.cpp b/src/jit/inline.cpp
index 743aae3237..bb321032e1 100644
--- a/src/jit/inline.cpp
+++ b/src/jit/inline.cpp
@@ -329,8 +329,10 @@ InlineContext::InlineContext()
, m_Code(nullptr)
, m_Observation(InlineObservation::CALLEE_UNUSED_INITIAL)
#ifdef DEBUG
+ , m_Policy(nullptr)
, m_Callee(nullptr)
, m_TreeID(0)
+ , m_Ordinal(0)
, m_Success(true)
#endif
{
@@ -396,8 +398,10 @@ InlineContext* InlineContext::NewSuccess(Compiler* compiler,
calleeContext->m_Offset = stmt->AsStmt()->gtStmtILoffsx;
calleeContext->m_Observation = inlineInfo->inlineResult->GetObservation();
#ifdef DEBUG
+ calleeContext->m_Policy = inlineInfo->inlineResult->GetPolicy();
calleeContext->m_Callee = inlineInfo->fncHandle;
calleeContext->m_TreeID = inlineInfo->inlineResult->GetCall()->gtTreeID;
+ calleeContext->m_Ordinal = compiler->getInlinedCount();
#endif
return calleeContext;
@@ -485,11 +489,14 @@ void InlineContext::Dump(Compiler* compiler, int indent)
calleeName = compiler->eeGetMethodFullName(m_Callee);
}
+ mdMethodDef calleeToken =
+ compiler->info.compCompHnd->getMethodDefFromMethod(m_Callee);
+
// Dump this node
if (m_Parent == nullptr)
{
// Root method
- printf("Inlines into %s\n", calleeName);
+ printf("Inlines into %08X %s\n", calleeToken, calleeName);
}
else
{
@@ -504,12 +511,14 @@ void InlineContext::Dump(Compiler* compiler, int indent)
if (m_Offset == BAD_IL_OFFSET)
{
- printf("[IL=???? TR=%06u] [%s%s] %s\n", m_TreeID, inlineResult, inlineReason, calleeName);
+ printf("[%u IL=???? TR=%06u %08X] [%s%s] %s\n", m_Ordinal, m_TreeID, calleeToken,
+ inlineResult, inlineReason, calleeName);
}
else
{
IL_OFFSET offset = jitGetILoffs(m_Offset);
- printf("[IL=%04d TR=%06u] [%s%s] %s\n", offset, m_TreeID, inlineResult, inlineReason, calleeName);
+ printf("[%u IL=%04d TR=%06u %08X] [%s%s] %s\n", m_Ordinal, offset, m_TreeID, calleeToken,
+ inlineResult, inlineReason, calleeName);
}
}
@@ -520,6 +529,51 @@ void InlineContext::Dump(Compiler* compiler, int indent)
}
}
+//------------------------------------------------------------------------
+// DumpData: Dump a successful InlineContext entry, detailed data, and
+// any successful descendant inlines
+//
+// Arguments:
+// compiler - compiler instance doing inlining
+// indent - indentation level for this node
+
+void InlineContext::DumpData(Compiler* compiler, int indent)
+{
+ // Handle fact that siblings are in reverse order.
+ if (m_Sibling != nullptr)
+ {
+ m_Sibling->DumpData(compiler, indent);
+ }
+
+ const char* calleeName = compiler->eeGetMethodFullName(m_Callee);
+
+ if (m_Parent == nullptr)
+ {
+ // Root method... cons up a policy so we can display the name
+ InlinePolicy* policy = InlinePolicy::GetPolicy(compiler, true);
+ printf("\nInlines [%u] into \"%s\" [%s]\n", compiler->getInlinedCount(), calleeName, policy->GetName());
+ }
+ else if (m_Success)
+ {
+ const char* inlineReason = InlGetObservationString(m_Observation);
+
+ for (int i = 0; i < indent; i++)
+ {
+ printf(" ");
+ }
+
+ printf("%u,\"%s\",\"%s\"", m_Ordinal, inlineReason, calleeName);
+ m_Policy->DumpData();
+ printf("\n");
+ }
+
+ // Recurse to first child
+ if (m_Child != nullptr)
+ {
+ m_Child->DumpData(compiler, indent + 2);
+ }
+}
+
#endif // DEBUG
//------------------------------------------------------------------------
@@ -622,6 +676,13 @@ void InlineResult::Report()
#ifdef DEBUG
+ // Stash a pointer to the latest successful policy for later stats
+ // reporting.
+ if (IsSuccess())
+ {
+ m_RootCompiler->inlLastSuccessfulPolicy = GetPolicy();
+ }
+
const char* callee = nullptr;
// Optionally dump the result
diff --git a/src/jit/inline.def b/src/jit/inline.def
index 79fdaf5abb..3881412d91 100644
--- a/src/jit/inline.def
+++ b/src/jit/inline.def
@@ -137,6 +137,7 @@ INLINE_OBSERVATION(LDFLD_NEEDS_HELPER, bool, "ldfld needs helper",
INLINE_OBSERVATION(LDVIRTFN_ON_NON_VIRTUAL, bool, "ldvirtfn on non-virtual", FATAL, CALLSITE)
INLINE_OBSERVATION(NOT_CANDIDATE, bool, "not inline candidate", FATAL, CALLSITE)
INLINE_OBSERVATION(NOT_PROFITABLE_INLINE, bool, "unprofitable inline", FATAL, CALLSITE)
+INLINE_OBSERVATION(OVER_INLINE_LIMIT, bool, "limited by JitInlineLimit", FATAL, CALLSITE)
INLINE_OBSERVATION(RANDOM_REJECT, bool, "random reject", FATAL, CALLSITE)
INLINE_OBSERVATION(REQUIRES_SAME_THIS, bool, "requires same this", FATAL, CALLSITE)
INLINE_OBSERVATION(RETURN_TYPE_MISMATCH, bool, "return type mismatch", FATAL, CALLSITE)
diff --git a/src/jit/inline.h b/src/jit/inline.h
index 1a248ae96c..679218446b 100644
--- a/src/jit/inline.h
+++ b/src/jit/inline.h
@@ -248,6 +248,10 @@ public:
#ifdef DEBUG
// Name of the policy
virtual const char* GetName() const = 0;
+ // Detailed data value dump
+ virtual void DumpData() const { }
+ // Detailed data name dump
+ virtual void DumpSchema() const { }
#endif
protected:
@@ -412,17 +416,23 @@ public:
}
// String describing the decision made
- const char * ResultString() const
+ const char* ResultString() const
{
return InlGetDecisionString(m_Policy->GetDecision());
}
// String describing the reason for the decision
- const char * ReasonString() const
+ const char* ReasonString() const
{
return InlGetObservationString(m_Policy->GetObservation());
}
+ // Get the policy that evaluated this result.
+ InlinePolicy* GetPolicy() const
+ {
+ return m_Policy;
+ }
+
// SetReported indicates that this particular result doesn't need
// to be reported back to the runtime, either because the runtime
// already knows, or we aren't actually inlining yet.
@@ -559,9 +569,12 @@ public:
GenTree* stmt,
InlineResult* inlineResult);
- // Dump the context and all descendants
+ // Dump the full subtree, including failures
void Dump(Compiler* compiler, int indent = 0);
+ // Dump only the success subtree, with rich data
+ void DumpData(Compiler* compiler, int indent = 0);
+
#endif
// Get the parent context for this context.
@@ -590,8 +603,10 @@ private:
InlineObservation m_Observation; // what lead to this inline
#ifdef DEBUG
+ InlinePolicy* m_Policy; // policy that evaluated this inline
CORINFO_METHOD_HANDLE m_Callee; // handle to the method
unsigned m_TreeID; // ID of the GenTreeCall
+ unsigned m_Ordinal; // Ordinal number of this inline
bool m_Success; // true if this was a successful inline
#endif
diff --git a/src/jit/inlinepolicy.cpp b/src/jit/inlinepolicy.cpp
index 87d41cdee3..90564296db 100644
--- a/src/jit/inlinepolicy.cpp
+++ b/src/jit/inlinepolicy.cpp
@@ -177,7 +177,7 @@ void LegacyPolicy::NoteBool(InlineObservation obs, bool value)
// instructions and 6 are loads, it's only 75% loads.
// This allows for CALL, RET, and one more non-ld/st
// instruction.
- if (((m_InstructionCount - m_LoadStoreCount) < 4) ||
+ if (((m_InstructionCount - m_LoadStoreCount) < 4) ||
(((double)m_LoadStoreCount/(double)m_InstructionCount) > .90))
{
m_MethodIsMostlyLoadStore = true;
@@ -664,14 +664,14 @@ void LegacyPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
assert(InlDecisionIsCandidate(m_Decision));
assert(m_Observation == InlineObservation::CALLEE_IS_DISCRETIONARY_INLINE);
- const int calleeNativeSizeEstimate = DetermineNativeSizeEstimate();
- const int callsiteNativeSizeEstimate = DetermineCallsiteNativeSizeEstimate(methodInfo);
- const double multiplier = DetermineMultiplier();
- const int threshold = (int)(callsiteNativeSizeEstimate * multiplier);
+ m_CalleeNativeSizeEstimate = DetermineNativeSizeEstimate();
+ m_CallsiteNativeSizeEstimate = DetermineCallsiteNativeSizeEstimate(methodInfo);
+ m_Multiplier = DetermineMultiplier();
+ const int threshold = (int)(m_CallsiteNativeSizeEstimate * m_Multiplier);
- JITDUMP("calleeNativeSizeEstimate=%d\n", calleeNativeSizeEstimate)
- JITDUMP("callsiteNativeSizeEstimate=%d\n", callsiteNativeSizeEstimate);
- JITDUMP("benefit multiplier=%g\n", multiplier);
+ JITDUMP("calleeNativeSizeEstimate=%d\n", m_CalleeNativeSizeEstimate)
+ JITDUMP("callsiteNativeSizeEstimate=%d\n", m_CallsiteNativeSizeEstimate);
+ JITDUMP("benefit multiplier=%g\n", m_Multiplier);
JITDUMP("threshold=%d\n", threshold);
#if DEBUG
@@ -680,16 +680,16 @@ void LegacyPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
#endif
// Reject if callee size is over the threshold
- if (calleeNativeSizeEstimate > threshold)
+ if (m_CalleeNativeSizeEstimate > threshold)
{
// Inline appears to be unprofitable
JITLOG_THIS(m_RootCompiler,
(LL_INFO100000,
"Native estimate for function size exceedsn threshold"
" for inlining %g > %g (multiplier = %g)\n",
- calleeNativeSizeEstimate / sizeDescaler,
+ m_CalleeNativeSizeEstimate / sizeDescaler,
threshold / sizeDescaler,
- multiplier));
+ m_Multiplier));
// Fail the inline
if (m_IsPrejitRoot)
@@ -708,9 +708,9 @@ void LegacyPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
(LL_INFO100000,
"Native estimate for function size is within threshold"
" for inlining %g <= %g (multiplier = %g)\n",
- calleeNativeSizeEstimate / sizeDescaler,
+ m_CalleeNativeSizeEstimate / sizeDescaler,
threshold / sizeDescaler,
- multiplier));
+ m_Multiplier));
// Update candidacy
if (m_IsPrejitRoot)
@@ -732,6 +732,7 @@ void LegacyPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
// Arguments:
// compiler -- compiler instance doing the inlining (root compiler)
// isPrejitRoot -- true if this compiler is prejitting the root method
+// seed -- seed value for the random number generator
RandomPolicy::RandomPolicy(Compiler* compiler, bool isPrejitRoot, unsigned seed)
: InlinePolicy(isPrejitRoot)
@@ -1084,11 +1085,45 @@ void RandomPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
DiscretionaryPolicy::DiscretionaryPolicy(Compiler* compiler, bool isPrejitRoot)
: LegacyPolicy(compiler, isPrejitRoot)
+ , m_Depth(0)
+ , m_BlockCount(0)
+ , m_Maxstack(0)
+ , m_ArgCount(0)
+ , m_LocalCount(0)
+ , m_ReturnType(CORINFO_TYPE_UNDEF)
+ , m_ThrowCount(0)
+ , m_CallCount(0)
{
// Empty
}
//------------------------------------------------------------------------
+// NoteBool: handle an observed boolean value
+//
+// Arguments:
+// obs - the current obsevation
+// value - the value being observed
+
+void DiscretionaryPolicy::NoteBool(InlineObservation obs, bool value)
+{
+ switch(obs)
+ {
+ case InlineObservation::CALLEE_LOOKS_LIKE_WRAPPER:
+ m_LooksLikeWrapperMethod = value;
+
+ case InlineObservation::CALLEE_ARG_FEEDS_CONSTANT_TEST:
+ m_ArgFeedsConstantTest = value;
+
+ case InlineObservation::CALLEE_ARG_FEEDS_RANGE_CHECK:
+ m_ArgFeedsRangeCheck = value;
+ break;
+
+ default:
+ LegacyPolicy::NoteBool(obs, value);
+ }
+}
+
+//------------------------------------------------------------------------
// NoteInt: handle an observed integer value
//
// Arguments:
@@ -1121,9 +1156,38 @@ void DiscretionaryPolicy::NoteInt(InlineObservation obs, int value)
break;
}
+ case InlineObservation::CALLEE_OPCODE:
+ {
+ OPCODE opcode = static_cast<OPCODE>(value);
+ switch (opcode)
+ {
+ case CEE_THROW:
+ case CEE_RETHROW:
+ m_ThrowCount++;
+ break;
+ case CEE_CALL:
+ case CEE_CALLI:
+ case CEE_CALLVIRT:
+ m_CallCount++;
+ break;
+ default:
+ break;
+ }
+
+ LegacyPolicy::NoteInt(obs, value);
+ break;
+ }
+
case InlineObservation::CALLEE_MAXSTACK:
+ m_Maxstack = value;
+ break;
+
case InlineObservation::CALLEE_NUMBER_OF_BASIC_BLOCKS:
- // Ignore these
+ m_BlockCount = value;
+ break;
+
+ case InlineObservation::CALLSITE_DEPTH:
+ m_Depth = value;
break;
default:
@@ -1146,4 +1210,94 @@ bool DiscretionaryPolicy::PropagateNeverToRuntime() const
return propagate;
}
+//------------------------------------------------------------------------
+// DetermineProfitability: determine if this inline is profitable
+//
+// Arguments:
+// methodInfo -- method info for the callee
+
+void DiscretionaryPolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)
+{
+ // Punt if we're inlining and we've reached the acceptance limit.
+ int limit = JitConfig.JitInlineLimit();
+
+ if (!m_IsPrejitRoot &&
+ (limit >= 0) &&
+ (m_RootCompiler->getInlinedCount() >= static_cast<unsigned>(limit)))
+ {
+ SetFailure(InlineObservation::CALLSITE_OVER_INLINE_LIMIT);
+ return;
+ }
+
+ // Make some additional observations
+ m_ArgCount = methodInfo->args.numArgs;
+ m_LocalCount = methodInfo->locals.numArgs;
+ m_ReturnType = methodInfo->args.retType;
+
+ // delegate to LegacyPolicy for now
+ LegacyPolicy::DetermineProfitability(methodInfo);
+}
+
+//------------------------------------------------------------------------
+// DumpSchema: dump names for all the supporting data for the
+// inline decision in CSV format.
+
+void DiscretionaryPolicy::DumpSchema() const
+{
+ printf(",Codesize");
+ printf(",CallsiteFrequency");
+ printf(",InstructionCount");
+ printf(",LoadStoreCount");
+ printf(",Depth");
+ printf(",BlockCount");
+ printf(",Maxstack");
+ printf(",ArgCount");
+ printf(",LocalCount");
+ printf(",ReturnType");
+ printf(",ThrowCount");
+ printf(",CallCount");
+ printf(",IsForceInline");
+ printf(",IsInstanceCtor");
+ printf(",IsFromPromotableValueClass");
+ printf(",HasSimd");
+ printf(",LooksLikeWrapperMethod");
+ printf(",ArgFeedsConstantTest");
+ printf(",IsMostlyLoadStore");
+ printf(",ArgFeedsRangeCheck");
+ printf(",ConstantFeedsConstantTest");
+ printf(",CalleeNativeSizeEstimate");
+ printf(",CallsiteNativeSizeEstimate");
+}
+
+//------------------------------------------------------------------------
+// DumpData: dump all the supporting data for the inline decision
+// in CSV format.
+
+void DiscretionaryPolicy::DumpData() const
+{
+ printf(",%u", m_CodeSize);
+ printf(",%u", m_CallsiteFrequency);
+ printf(",%u", m_InstructionCount);
+ printf(",%u", m_LoadStoreCount);
+ printf(",%u", m_Depth);
+ printf(",%u", m_BlockCount);
+ printf(",%u", m_Maxstack);
+ printf(",%u", m_ArgCount);
+ printf(",%u", m_LocalCount);
+ printf(",%u", m_ReturnType);
+ printf(",%u", m_ThrowCount);
+ printf(",%u", m_CallCount);
+ printf(",%u", m_IsForceInline ? 1 : 0);
+ printf(",%u", m_IsInstanceCtor ? 1 : 0);
+ printf(",%u", m_IsFromPromotableValueClass ? 1 : 0);
+ printf(",%u", m_HasSimd ? 1 : 0);
+ printf(",%u", m_LooksLikeWrapperMethod ? 1 : 0);
+ printf(",%u", m_ArgFeedsConstantTest ? 1 : 0);
+ printf(",%u", m_MethodIsMostlyLoadStore ? 1 : 0);
+ printf(",%u", m_ArgFeedsRangeCheck ? 1 : 0);
+ printf(",%u", m_ConstantFeedsConstantTest ? 1 : 0);
+ printf(",%d", m_CalleeNativeSizeEstimate);
+ printf(",%d", m_CallsiteNativeSizeEstimate);
+}
+
#endif // DEBUG
diff --git a/src/jit/inlinepolicy.h b/src/jit/inlinepolicy.h
index 8d1d5b2963..99e0c05c01 100644
--- a/src/jit/inlinepolicy.h
+++ b/src/jit/inlinepolicy.h
@@ -48,6 +48,9 @@ public:
, m_CallsiteFrequency(InlineCallsiteFrequency::UNUSED)
, m_InstructionCount(0)
, m_LoadStoreCount(0)
+ , m_CalleeNativeSizeEstimate(0)
+ , m_CallsiteNativeSizeEstimate(0)
+ , m_Multiplier(0.0)
, m_IsForceInline(false)
, m_IsForceInlineKnown(false)
, m_IsInstanceCtor(false)
@@ -99,6 +102,9 @@ protected:
InlineCallsiteFrequency m_CallsiteFrequency;
unsigned m_InstructionCount;
unsigned m_LoadStoreCount;
+ int m_CalleeNativeSizeEstimate;
+ int m_CallsiteNativeSizeEstimate;
+ double m_Multiplier;
bool m_IsForceInline :1;
bool m_IsForceInlineKnown :1;
bool m_IsInstanceCtor :1;
@@ -168,12 +174,32 @@ public:
DiscretionaryPolicy(Compiler* compiler, bool isPrejitRoot);
// Policy observations
+ void NoteBool(InlineObservation obs, bool value) override;
void NoteInt(InlineObservation obs, int value) override;
// Policy policies
bool PropagateNeverToRuntime() const override;
+ // Policy determinations
+ void DetermineProfitability(CORINFO_METHOD_INFO* methodInfo) override;
+
+ // Externalize data
+ void DumpData() const override;
+ void DumpSchema() const override;
+
+ // Miscellaneous
const char* GetName() const override { return "DiscretionaryPolicy"; }
+
+private:
+
+ unsigned m_Depth;
+ unsigned m_BlockCount;
+ unsigned m_Maxstack;
+ unsigned m_ArgCount;
+ unsigned m_LocalCount;
+ CorInfoType m_ReturnType;
+ unsigned m_ThrowCount;
+ unsigned m_CallCount;
};
#endif // DEBUG
diff --git a/src/jit/jitconfigvalues.h b/src/jit/jitconfigvalues.h
index e41dcebd5b..b5be9fd8a0 100644
--- a/src/jit/jitconfigvalues.h
+++ b/src/jit/jitconfigvalues.h
@@ -55,6 +55,8 @@ CONFIG_INTEGER(JitHashDump, W("JitHashDump"), -1) // Same as JitDump, but for a
CONFIG_INTEGER(JitHashDumpIR, W("JitHashDumpIR"), -1) // Same as JitDumpIR, but for a method hash
CONFIG_INTEGER(JitHashHalt, W("JitHashHalt"), -1) // Same as JitHalt, but for a method hash
CONFIG_INTEGER(JitInlineAdditionalMultiplier, W("JitInlineAdditionalMultiplier"), 0)
+CONFIG_INTEGER(JitInlineDumpData, W("JitInlineDumpData"), 0)
+CONFIG_INTEGER(JitInlineLimit, W("JitInlineLimit"), -1)
CONFIG_INTEGER(JitInlinePolicyDiscretionary, W("JitInlinePolicyDiscretionary"), 0)
CONFIG_INTEGER(JitInlinePrintStats, W("JitInlinePrintStats"), 0)
CONFIG_INTEGER(JitInlineSize, W("JITInlineSize"), DEFAULT_MAX_INLINE_SIZE)
diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp
index 127b720594..cef80184dc 100644
--- a/src/jit/lsra.cpp
+++ b/src/jit/lsra.cpp
@@ -1211,25 +1211,18 @@ LinearScan::setBlockSequence()
// We can stop checking now.
checkForCriticalOutEdge = false;
}
+
if (isTraversalLayoutOrder() || isBlockVisited(succ))
{
continue;
}
- // For pred-first order, we prefer layout order, as long as there is an edge between
- // them. Otherwise, we'll add it to the list.
- if (isTraversalPredFirstOrder() && succ == block->bbNext)
- {
- nextBlock = succ;
- BlockSetOps::AddElemD(compiler, readySet, succ->bbNum);
- continue;
- }
// We've now seen a predecessor, so add it to the work list and the "readySet".
// It will be inserted in the worklist according to the specified traversal order
// (i.e. pred-first or random, since layout order is handled above).
if (!BlockSetOps::IsMember(compiler, readySet, succ->bbNum))
{
- addToBlockSequenceWorkList(succ);
+ addToBlockSequenceWorkList(readySet, succ);
BlockSetOps::AddElemD(compiler, readySet, succ->bbNum);
}
}
@@ -1244,6 +1237,7 @@ LinearScan::setBlockSequence()
while (nextBlock == nullptr)
{
nextBlock = getNextCandidateFromWorkList();
+
// TODO-Throughput: We would like to bypass this traversal if we know we've handled all
// the blocks - but fgBBcount does not appear to be updated when blocks are removed.
if (nextBlock == nullptr /* && bbSeqCount != compiler->fgBBcount*/ && !verifiedAllBBs)
@@ -1261,15 +1255,16 @@ LinearScan::setBlockSequence()
{
if (!isBlockVisited(block))
{
- addToBlockSequenceWorkList(block);
+ addToBlockSequenceWorkList(readySet, block);
BlockSetOps::AddElemD(compiler, readySet, block->bbNum);
}
}
+
for (BasicBlock* block = compiler->fgFirstBB; block; block = block->bbNext)
{
if (!isBlockVisited(block))
{
- addToBlockSequenceWorkList(block);
+ addToBlockSequenceWorkList(readySet, block);
BlockSetOps::AddElemD(compiler, readySet, block->bbNum);
}
}
@@ -1286,11 +1281,35 @@ LinearScan::setBlockSequence()
#ifdef DEBUG
// Make sure that we've visited all the blocks.
for( BasicBlock* block = compiler->fgFirstBB;
- block != nullptr;
- block = block->bbNext)
+ block != nullptr;
+ block = block->bbNext)
{
assert(isBlockVisited(block));
}
+
+ JITDUMP("LSRA Block Sequence: ");
+ int i = 1;
+ for (BasicBlock* block = startBlockSequence();
+ block != nullptr;
+ ++i, block = moveToNextBlock())
+ {
+ JITDUMP("BB%02u", block->bbNum);
+
+ if (block->isMaxBBWeight())
+ {
+ JITDUMP("(MAX) ");
+ }
+ else
+ {
+ JITDUMP("(%6s) ", refCntWtd2str(block->getBBWeight(compiler)));
+ }
+
+ if (i % 10 == 0)
+ {
+ JITDUMP("\n ");
+ }
+ }
+ JITDUMP("\n\n");
#endif
}
@@ -1298,8 +1317,9 @@ LinearScan::setBlockSequence()
// compareBlocksForSequencing: Compare two basic blocks for sequencing order.
//
// Arguments:
-// block1 - the first block for comparison
-// block2 - the second block for comparison
+// block1 - the first block for comparison
+// block2 - the second block for comparison
+// useBlockWeights - whether to use block weights for comparison
//
// Return Value:
// -1 if block1 is preferred.
@@ -1308,11 +1328,25 @@ LinearScan::setBlockSequence()
//
// Notes:
// See addToBlockSequenceWorkList.
-// Currently, this is a simplistic method that prioritizes low bbNum.
-static int
-compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2)
-{
- // Prefer LOWER bbnum
+int
+LinearScan::compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2, bool useBlockWeights)
+{
+ if (useBlockWeights)
+ {
+ unsigned weight1 = block1->getBBWeight(compiler);
+ unsigned weight2 = block2->getBBWeight(compiler);
+
+ if (weight1 > weight2)
+ {
+ return -1;
+ }
+ else if (weight1 < weight2)
+ {
+ return 1;
+ }
+ }
+
+ // If weights are the same prefer LOWER bbnum
if (block1->bbNum < block2->bbNum)
{
return -1;
@@ -1331,7 +1365,8 @@ compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2)
// addToBlockSequenceWorkList: Add a BasicBlock to the work list for sequencing.
//
// Arguments:
-// block - the block to be added
+// sequencedBlockSet - the set of blocks that are already sequenced
+// block - the new block to be added
//
// Return Value:
// None.
@@ -1341,22 +1376,66 @@ compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2)
// as we encounter a block whose successors have all been sequenced, in pred-first
// order, or the very next block if we are traversing in random order (once implemented).
// This method uses a comparison method to determine the order in which to place
-// the blocks in the list. Currently, this is a simplistic method based on
-// bbNum. This could be a future candidate for tuning.
+// the blocks in the list. This method queries whether all predecessors of the
+// block are sequenced at the time it is added to the list and if so uses block weights
+// for inserting the block. A block is never inserted ahead of its predecessors.
+// A block at the time of insertion may not have all its predecessors sequenced, in
+// which case it will be sequenced based on its block number. Once a block is inserted,
+// its priority\order will not be changed later once its remaining predecessors are
+// sequenced. This would mean that work list may not be sorted entirely based on
+// block weights alone.
+//
// Note also that, when random traversal order is implemented, this method
// should insert the blocks into the list in random order, so that we can always
// simply select the first block in the list.
void
-LinearScan::addToBlockSequenceWorkList(BasicBlock* block)
+LinearScan::addToBlockSequenceWorkList(BlockSet sequencedBlockSet, BasicBlock* block)
{
+ // The block that is being added is not already sequenced
+ assert(!BlockSetOps::IsMember(compiler, sequencedBlockSet, block->bbNum));
+
+ // Get predSet of block
+ BlockSet BLOCKSET_INIT_NOCOPY(predSet, BlockSetOps::MakeEmpty(compiler));
+ flowList* pred;
+ for (pred = block->bbPreds; pred != nullptr; pred = pred->flNext)
+ {
+ BlockSetOps::AddElemD(compiler, predSet, pred->flBlock->bbNum);
+ }
+
+ // If either a rarely run block or all its preds are already sequenced, use block's weight to sequence
+ bool useBlockWeight = block->isRunRarely() || BlockSetOps::IsSubset(compiler, sequencedBlockSet, predSet);
+
BasicBlockList* prevNode = nullptr;
- BasicBlockList* nextNode;
- for (nextNode = blockSequenceWorkList;
- nextNode != nullptr && compareBlocksForSequencing(nextNode->block, block) <= 0;
- nextNode = nextNode->next)
+ BasicBlockList* nextNode = blockSequenceWorkList;
+
+ while (nextNode != nullptr)
{
+ int seqResult;
+
+ if (nextNode->block->isRunRarely())
+ {
+ // If the block that is yet to be sequenced is a rarely run block, always use block weights for sequencing
+ seqResult = compareBlocksForSequencing(nextNode->block, block, true);
+ }
+ else if (BlockSetOps::IsMember(compiler, predSet, nextNode->block->bbNum))
+ {
+ // always prefer unsequenced pred blocks
+ seqResult = -1;
+ }
+ else
+ {
+ seqResult = compareBlocksForSequencing(nextNode->block, block, useBlockWeight);
+ }
+
+ if (seqResult > 0)
+ {
+ break;
+ }
+
prevNode = nextNode;
+ nextNode = nextNode->next;
}
+
BasicBlockList* newListNode = new (compiler, CMK_LSRA) BasicBlockList(block, nextNode);
if (prevNode == nullptr)
{
diff --git a/src/jit/lsra.h b/src/jit/lsra.h
index 4e53369535..27939d7422 100644
--- a/src/jit/lsra.h
+++ b/src/jit/lsra.h
@@ -981,9 +981,10 @@ private:
// included in the blockSeuqence above, during setBlockSequence().
bool verifiedAllBBs;
void setBlockSequence();
+ int compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2, bool useBlockWeights);
BasicBlockList* blockSequenceWorkList;
bool blockSequencingDone;
- void addToBlockSequenceWorkList(BasicBlock* block);
+ void addToBlockSequenceWorkList(BlockSet sequencedBlockSet, BasicBlock* block);
void removeFromBlockSequenceWorkList(BasicBlockList* listNode, BasicBlockList* prevNode);
BasicBlock* getNextCandidateFromWorkList();
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 23ee8f3ffc..fb9585a38c 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -2587,13 +2587,11 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
regMaskTP fltArgSkippedRegMask = RBM_NONE;
#endif
-#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
- // On x64, every argument takes up exactly 1 slot, regardless of type.
- // Only the first 4 slots are enregistered.
- const unsigned maxRegArgs = MAX_REG_ARG;
-#elif defined(_TARGET_X86_)
- unsigned maxRegArgs = MAX_REG_ARG;
-#endif
+#if defined(_TARGET_X86_)
+ unsigned maxRegArgs = MAX_REG_ARG; // X86: non-const, must be calculated
+#else
+ const unsigned maxRegArgs = MAX_REG_ARG; // other arch: fixed constant number
+#endif
unsigned argSlots = 0;
unsigned nonRegPassedStructSlots = 0;
@@ -3124,12 +3122,12 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
{
size = 1; // Large structs are passed by reference (to a copy)
}
- // TODO-ARM64-NYI: There are some additional rules for size=2 structs,
+ // Note that there are some additional rules for size=2 structs,
// (i.e they cannot be split betwen registers and the stack)
}
else
{
- size = 1; // On ARM64, all primitives fit in a single (64-bit) 'slot'
+ size = 1; // On ARM64, all primitive types fit in a single (64-bit) 'slot'
}
#elif defined(_TARGET_ARM_)
if (isStructArg)
@@ -3415,7 +3413,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
}
}
- // This size has now been computed
+ // The 'size' value has now must have been set. (the original value of zero is an invalid value)
assert(size != 0);
//
@@ -3468,7 +3466,19 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* callNode)
{
isRegArg = intArgRegNum < MAX_REG_ARG;
}
-#else // _TARGET_ARM_
+#elif _TARGET_ARM64_
+ if (passUsingFloatRegs)
+ {
+ // Check if the last register needed is still in the fp argument register range.
+ isRegArg = (nextFltArgRegNum + (size - 1)) < MAX_FLOAT_REG_ARG;
+ }
+ else
+ {
+ // Check if the last register needed is still in the int argument register range.
+ isRegArg = (intArgRegNum + (size - 1)) < maxRegArgs;
+ }
+#else // not _TARGET_ARM_ or _TARGET_ARM64_
+
#if defined(UNIX_AMD64_ABI)
#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp
index e13009f23a..2c3d20cf86 100644
--- a/src/jit/utils.cpp
+++ b/src/jit/utils.cpp
@@ -1544,3 +1544,66 @@ unsigned CountDigits(unsigned num, unsigned base /* = 10 */)
}
#endif // DEBUG
+
+
+double FloatingPointUtils::convertUInt64ToDouble(unsigned __int64 uIntVal) {
+ __int64 s64 = uIntVal;
+ double d;
+ if (s64 < 0) {
+#if defined(_TARGET_XARCH_)
+ // RyuJIT codegen and clang (or gcc) may produce different results for casting uint64 to
+ // double, and the clang result is more accurate. For example,
+ // 1) (double)0x84595161401484A0UL --> 43e08b2a2c280290 (RyuJIT codegen or VC++)
+ // 2) (double)0x84595161401484A0UL --> 43e08b2a2c280291 (clang or gcc)
+ // If the folding optimization below is implemented by simple casting of (double)uint64_val
+ // and it is compiled by clang, casting result can be inconsistent, depending on whether
+ // the folding optimization is triggered or the codegen generates instructions for casting. //
+ // The current solution is to force the same math as the codegen does, so that casting
+ // result is always consistent.
+
+ // d = (double)(int64_t)uint64 + 0x1p64
+ uint64_t adjHex = 0x43F0000000000000UL;
+ d = (double)s64 + *(double*)&adjHex;
+#else
+ d = (double)uIntVal;
+#endif
+ }
+ else
+ {
+ d = (double)uIntVal;
+ }
+ return d;
+}
+
+float FloatingPointUtils::convertUInt64ToFloat(unsigned __int64 u64) {
+ double d = convertUInt64ToDouble(u64);
+ return (float)d;
+}
+
+unsigned __int64 FloatingPointUtils::convertDoubleToUInt64(double d) {
+ unsigned __int64 u64;
+ if (d >= 0.0)
+ {
+ // Work around a C++ issue where it doesn't properly convert large positive doubles
+ const double two63 = 2147483648.0 * 4294967296.0;
+ if (d < two63) {
+ u64 = UINT64(d);
+ }
+ else {
+ // subtract 0x8000000000000000, do the convert then add it back again
+ u64 = INT64(d - two63) + I64(0x8000000000000000);
+ }
+ return u64;
+ }
+
+ // This double cast to account for an ECMA spec hole.
+ // When converting from a double to an unsigned the ECMA
+ // spec states that a conforming implementation should
+ // "truncate to zero." However that doesn't make much sense
+ // when the double in question is negative and the target
+ // is unsigned. gcc converts a negative double to zero when
+ // cast to an unsigned. To make gcc conform to MSVC behavior
+ // this cast is necessary.
+ u64 = UINT64(INT64(d));
+ return u64;
+}
diff --git a/src/jit/utils.h b/src/jit/utils.h
index 25ca684dc8..0c66775451 100644
--- a/src/jit/utils.h
+++ b/src/jit/utils.h
@@ -510,4 +510,17 @@ struct ListNode
}
};
+/*****************************************************************************
+* Floating point utility class
+*/
+class FloatingPointUtils {
+public:
+
+ static double convertUInt64ToDouble(unsigned __int64 u64);
+
+ static float convertUInt64ToFloat(unsigned __int64 u64);
+
+ static unsigned __int64 convertDoubleToUInt64(double d);
+};
+
#endif // _UTILS_H_
diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp
index 63788465dd..16183ac9c6 100644
--- a/src/jit/valuenum.cpp
+++ b/src/jit/valuenum.cpp
@@ -1906,13 +1906,13 @@ ValueNum ValueNumStore::EvalCastForConstantArgs(var_types typ, VNFunc func, Valu
case TYP_FLOAT:
assert(typ == TYP_FLOAT);
if (srcIsUnsigned)
- return VNForFloatCon(float(UINT64(arg0Val)));
+ return VNForFloatCon(FloatingPointUtils::convertUInt64ToFloat(UINT64(arg0Val)));
else
return VNForFloatCon(float(arg0Val));
case TYP_DOUBLE:
assert(typ == TYP_DOUBLE);
if (srcIsUnsigned)
- return VNForDoubleCon(double(UINT64(arg0Val)));
+ return VNForDoubleCon(FloatingPointUtils::convertUInt64ToDouble(UINT64(arg0Val)));
else
return VNForDoubleCon(double(arg0Val));
default:
diff --git a/src/md/runtime/metamodelro.cpp b/src/md/runtime/metamodelro.cpp
index 3f01d105f6..0feb153a2f 100644
--- a/src/md/runtime/metamodelro.cpp
+++ b/src/md/runtime/metamodelro.cpp
@@ -389,10 +389,6 @@ CMiniMd::vSearchTableNotGreater(
return S_OK;
} // CMiniMd::vSearchTableNotGreater
-#if defined(FEATURE_LEGACYNETCF) && defined(FEATURE_METADATA_IN_VM)
-extern BOOL RuntimeIsLegacyNetCF(DWORD adid);
-#endif
-
//*****************************************************************************
// return just the blob value of the first found CA matching the query.
// returns S_FALSE if there is no match
@@ -444,11 +440,5 @@ CMiniMd::CommonGetCustomAttributeByNameEx(
}
ErrExit:
-#if defined(FEATURE_LEGACYNETCF) && defined(FEATURE_METADATA_IN_VM)
- // NetCF ignore malformed custom attribute tables
- if (FAILED(hr) && RuntimeIsLegacyNetCF(0))
- hr = S_FALSE;
-#endif
-
return hr;
} // CMiniMd::CommonGetCustomAttributeByName
diff --git a/src/mscorlib/mscorlib.shared.sources.props b/src/mscorlib/mscorlib.shared.sources.props
index 422d78d601..4713826ffd 100644
--- a/src/mscorlib/mscorlib.shared.sources.props
+++ b/src/mscorlib/mscorlib.shared.sources.props
@@ -1048,12 +1048,8 @@
<InteropTceadaptergenSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\TCEAdapterGen\TCEAdapterGenerator.cs" />
</ItemGroup>
<ItemGroup>
- <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\GenericIdentity.cs" />
- <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\GenericPrincipal.cs" />
<SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\IIdentity.cs" />
<SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\IPrincipal.cs" />
- <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\PrincipalPolicy.cs" />
- <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\TokenAccessLevels.cs" />
<SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\TokenImpersonationLevel.cs" />
</ItemGroup>
<ItemGroup>
diff --git a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
index fd0791cef2..54b0afe0aa 100644
--- a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
+++ b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs
@@ -90,7 +90,9 @@
namespace Microsoft.Win32 {
using System;
using System.Security;
+#if FEATURE_IMPERSONATION
using System.Security.Principal;
+#endif
using System.Text;
using System.Configuration.Assemblies;
using System.Runtime.Remoting;
@@ -2330,7 +2332,7 @@ namespace Microsoft.Win32 {
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal static extern int LsaFreeReturnBuffer(IntPtr handle);
-#if FEATURE_IMPERSONATION || FEATURE_CORECLR
+#if FEATURE_IMPERSONATION
[DllImport (ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern
bool OpenProcessToken (
@@ -2339,17 +2341,6 @@ namespace Microsoft.Win32 {
[Out] out SafeAccessTokenHandle TokenHandle);
#endif
-#if FEATURE_CORECLR
- [DllImport (ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern
- bool OpenThreadToken (
- [In] IntPtr ThreadHandle,
- [In] TokenAccessLevels DesiredAccess,
- [In, MarshalAs(UnmanagedType.Bool)] bool OpenAsSelf,
- [Out] out SafeAccessTokenHandle TokenHandle);
-#endif
-
[DllImport(
ADVAPI32,
EntryPoint="SetNamedSecurityInfoW",
diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs
index bb21e531cf..855564bd3d 100644
--- a/src/mscorlib/src/System/AppDomain.cs
+++ b/src/mscorlib/src/System/AppDomain.cs
@@ -29,7 +29,9 @@ namespace System {
#endif
using System.Security;
using System.Security.Permissions;
+#if FEATURE_IMPERSONATION
using System.Security.Principal;
+#endif
using System.Security.Policy;
using System.Security.Util;
using System.Collections;
@@ -2801,17 +2803,6 @@ namespace System {
#endif // FEATURE_REMOTING
-#if FEATURE_LEGACYNETCFFAS
- public static IAppDomainPauseManager PauseManager
- {
- [System.Security.SecurityCritical]
- get
- {
- return AppDomainPauseManager.Instance;
- }
- }
-#endif // FEATURE_LEGACYNETCFFAS
-
#if !FEATURE_CORECLR
//
// Called by the VM if ICLRExecutionManager::Pause is called with the PAUSE_APP_DOMAINS flag.
diff --git a/src/mscorlib/src/System/Array.cs b/src/mscorlib/src/System/Array.cs
index 8130eeb6c5..ba74f87c33 100644
--- a/src/mscorlib/src/System/Array.cs
+++ b/src/mscorlib/src/System/Array.cs
@@ -1001,14 +1001,7 @@ namespace System {
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));
Contract.EndContractBlock();
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- return MangoArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer);
- else
- return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer);
-#else
return ArraySortHelper<T>.Default.BinarySearch(array, index, length, value, comparer);
-#endif
}
public static TOutput[] ConvertAll<TInput, TOutput>(TInput[] array, Converter<TInput,TOutput> converter) {
@@ -1808,15 +1801,8 @@ namespace System {
return;
}
}
-
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- MangoArraySortHelper<T>.Default.Sort(array, index, length, comparer);
- else
- ArraySortHelper<T>.Default.Sort(array, index, length, comparer);
-#else
+
ArraySortHelper<T>.Default.Sort(array, index, length, comparer);
-#endif
}
}
@@ -1844,14 +1830,7 @@ namespace System {
return;
}
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- MangoArraySortHelper<TKey>.Default.Sort<TValue>(keys, items, index, length, comparer);
- else
- ArraySortHelper<TKey, TValue>.Default.Sort(keys, items, index, length, comparer);
-#else
ArraySortHelper<TKey, TValue>.Default.Sort(keys, items, index, length, comparer);
-#endif
}
}
diff --git a/src/mscorlib/src/System/Attribute.cs b/src/mscorlib/src/System/Attribute.cs
index a9ea1f9d30..78fe095b3c 100644
--- a/src/mscorlib/src/System/Attribute.cs
+++ b/src/mscorlib/src/System/Attribute.cs
@@ -107,13 +107,7 @@ namespace System {
rtPropAccessor = rtPropAccessor.GetParentDefinition();
if (rtPropAccessor != null)
- {
-#if FEATURE_LEGACYNETCF
- // Mimicing NetCF which only looks for public properties.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- return rtPropAccessor.DeclaringType.GetProperty(property.Name, property.PropertyType);
-#endif //FEATURE_LEGACYNETCF
-
+ {
// There is a public overload of Type.GetProperty that takes both a BingingFlags enum and a return type.
// However, we cannot use that because it doesn't accept null for "types".
return rtPropAccessor.DeclaringType.GetProperty(
@@ -123,7 +117,7 @@ namespace System {
property.PropertyType,
propertyParameters, //used for index properties
null);
- }
+ }
}
return null;
diff --git a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
index 0dac902ccd..5570c212f4 100644
--- a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
+++ b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs
@@ -470,15 +470,7 @@ namespace System.Collections.Generic
try
{
-#if FEATURE_LEGACYNETCF
- // Pre-Apollo Windows Phone call the overload that sorts the keys, not values this achieves the same result
- if (comparer == null && CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- comparer = Comparer<T>.Default;
-
- if (comparer == null || (comparer == Comparer<T>.Default && !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)) {
-#else
if (comparer == null || comparer == Comparer<T>.Default) {
-#endif
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
diff --git a/src/mscorlib/src/System/Collections/Generic/Comparer.cs b/src/mscorlib/src/System/Collections/Generic/Comparer.cs
index b4f48bc57f..80c4cef9d6 100644
--- a/src/mscorlib/src/System/Collections/Generic/Comparer.cs
+++ b/src/mscorlib/src/System/Collections/Generic/Comparer.cs
@@ -51,18 +51,9 @@ namespace System.Collections.Generic
RuntimeType t = (RuntimeType)typeof(T);
// If T implements IComparable<T> return a GenericComparer<T>
-#if FEATURE_LEGACYNETCF
- // Pre-Apollo Windows Phone call the overload that sorts the keys, not values this achieves the same result
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- if (t.ImplementInterface(typeof(IComparable<T>))) {
- return (Comparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(GenericComparer<int>), t);
- }
+ if (typeof(IComparable<T>).IsAssignableFrom(t)) {
+ return (Comparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(GenericComparer<int>), t);
}
- else
-#endif
- if (typeof(IComparable<T>).IsAssignableFrom(t)) {
- return (Comparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(GenericComparer<int>), t);
- }
// If T is a Nullable<U> where U implements IComparable<U> return a NullableComparer<U>
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)) {
diff --git a/src/mscorlib/src/System/Convert.cs b/src/mscorlib/src/System/Convert.cs
index 982bddfc03..d1468314f2 100644
--- a/src/mscorlib/src/System/Convert.cs
+++ b/src/mscorlib/src/System/Convert.cs
@@ -2398,17 +2398,6 @@ namespace System {
if (inArray == null)
throw new ArgumentNullException("inArray");
-#if FEATURE_LEGACYNETCF
- Contract.EndContractBlock();
-
- // throw FormatException, to ensure compatibility with Mango Apps.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- if(inArray.Length == 0) {
- throw new FormatException();
- }
- }
-#endif
-
if (length < 0)
throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_Index"));
@@ -2418,9 +2407,7 @@ namespace System {
if (offset > inArray.Length - length)
throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"));
-#if !FEATURE_LEGACYNETCF // Our compat workaround above breaks CCRewrite's rules on valid contracts.
Contract.EndContractBlock();
-#endif
unsafe {
fixed (Char* inArrayPtr = inArray) {
diff --git a/src/mscorlib/src/System/DateTime.cs b/src/mscorlib/src/System/DateTime.cs
index 6a496ac9d2..757623a9aa 100644
--- a/src/mscorlib/src/System/DateTime.cs
+++ b/src/mscorlib/src/System/DateTime.cs
@@ -920,14 +920,6 @@ namespace System {
long ticks = 0;
ticks = GetSystemTimeAsFileTime();
-#if FEATURE_LEGACYNETCF
- // Windows Phone 7.0/7.1 return the ticks up to millisecond, not up to the 100th nanosecond.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- long ticksms = ticks / TicksPerMillisecond;
- ticks = ticksms * TicksPerMillisecond;
- }
-#endif
return new DateTime( ((UInt64)(ticks + FileTimeOffset)) | KindUtc);
}
}
diff --git a/src/mscorlib/src/System/DefaultBinder.cs b/src/mscorlib/src/System/DefaultBinder.cs
index da419d7f36..405055e844 100644
--- a/src/mscorlib/src/System/DefaultBinder.cs
+++ b/src/mscorlib/src/System/DefaultBinder.cs
@@ -596,14 +596,7 @@ namespace System {
// Allow a null indexes array. But if it is not null, every element must be non-null as well.
if (indexes != null && !Contract.ForAll(indexes, delegate(Type t) { return t != null; }))
{
- Exception e; // Written this way to pass the Code Contracts style requirements.
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- e = new NullReferenceException();
- else
-#endif
- e = new ArgumentNullException("indexes");
- throw e;
+ throw new ArgumentNullException("indexes");
}
if (match == null || match.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match");
diff --git a/src/mscorlib/src/System/Delegate.cs b/src/mscorlib/src/System/Delegate.cs
index a786c3079f..110555423c 100644
--- a/src/mscorlib/src/System/Delegate.cs
+++ b/src/mscorlib/src/System/Delegate.cs
@@ -349,23 +349,6 @@ namespace System {
return CreateDelegate(type, target, method, ignoreCase, true);
}
-#if FEATURE_LEGACYNETCF
- private static void CheckGetMethodInfo_Quirk(Type type, Type target, String method, BindingFlags bindingFlags)
- {
- ParameterInfo[] parameters = type.GetMethod("Invoke", BindingFlags.Public | BindingFlags.Instance).GetParameters();
-
- Type[] types = new Type[parameters.Length];
- for (Int32 i = 0; i < parameters.Length; i++)
- types[i] = parameters[i].ParameterType;
-
- MethodInfo mInfo = target.GetMethod(method, bindingFlags, null, types, null);
- if (mInfo == null)
- throw new MissingMethodException(target.FullName, method);
- }
-#endif
-
-
-
// V1 API.
[System.Security.SecuritySafeCritical] // auto-generated
public static Delegate CreateDelegate(Type type, Object target, String method, bool ignoreCase, bool throwOnBindFailure)
@@ -384,15 +367,6 @@ namespace System {
if (!rtType.IsDelegate())
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"),"type");
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- CheckGetMethodInfo_Quirk(type, target.GetType(), method,
- BindingFlags.NonPublic |
- BindingFlags.Public |
- BindingFlags.Instance |
- (ignoreCase?BindingFlags.IgnoreCase:0));
-#endif
-
Delegate d = InternalAlloc(rtType);
// This API existed in v1/v1.1 and only expected to create closed
// instance delegates. Constrain the call to BindToMethodName to such
@@ -450,15 +424,6 @@ namespace System {
if (!rtType.IsDelegate())
throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"),"type");
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- CheckGetMethodInfo_Quirk(type, target, method,
- BindingFlags.NonPublic |
- BindingFlags.Public |
- BindingFlags.Static |
- (ignoreCase?BindingFlags.IgnoreCase:0));
-#endif
-
Delegate d = InternalAlloc(rtType);
// This API existed in v1/v1.1 and only expected to create open
// static delegates. Constrain the call to BindToMethodName to such
@@ -701,13 +666,6 @@ namespace System {
[System.Security.SecurityCritical]
internal static Delegate UnsafeCreateDelegate(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags)
{
-
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- if(rtMethod.IsGenericMethodDefinition)
- throw new MissingMethodException(rtMethod.DeclaringType.FullName, rtMethod.Name);
-#endif
-
Delegate d = InternalAlloc(rtType);
if (d.BindToMethodInfo(firstArgument, rtMethod, rtMethod.GetDeclaringTypeInternal(), flags))
diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
index 897efc427b..85ec034eae 100644
--- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
+++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs
@@ -560,25 +560,41 @@ namespace System.Diagnostics {
sb.Append(']');
}
- // arguments printing
- sb.Append('(');
- ParameterInfo[] pi = mb.GetParameters();
- bool fFirstParam = true;
- for (int j = 0; j < pi.Length; j++)
+ ParameterInfo[] pi = null;
+#if FEATURE_CORECLR
+ try
+ {
+#endif
+ pi = mb.GetParameters();
+#if FEATURE_CORECLR
+ }
+ catch
+ {
+ // The parameter info cannot be loaded, so we don't
+ // append the parameter list.
+ }
+#endif
+ if (pi != null)
{
- if (fFirstParam == false)
- sb.Append(", ");
- else
- fFirstParam = false;
-
- String typeName = "<UnknownType>";
- if (pi[j].ParameterType != null)
- typeName = pi[j].ParameterType.Name;
- sb.Append(typeName);
- sb.Append(' ');
- sb.Append(pi[j].Name);
- }
- sb.Append(')');
+ // arguments printing
+ sb.Append('(');
+ bool fFirstParam = true;
+ for (int j = 0; j < pi.Length; j++)
+ {
+ if (fFirstParam == false)
+ sb.Append(", ");
+ else
+ fFirstParam = false;
+
+ String typeName = "<UnknownType>";
+ if (pi[j].ParameterType != null)
+ typeName = pi[j].ParameterType.Name;
+ sb.Append(typeName);
+ sb.Append(' ');
+ sb.Append(pi[j].Name);
+ }
+ sb.Append(')');
+ }
// source location printing
if (displayFilenames && (sf.GetILOffset() != -1))
diff --git a/src/mscorlib/src/System/Environment.cs b/src/mscorlib/src/System/Environment.cs
index 5828c0f2e4..dcf32b3a94 100644
--- a/src/mscorlib/src/System/Environment.cs
+++ b/src/mscorlib/src/System/Environment.cs
@@ -1147,14 +1147,6 @@ namespace System {
PlatformID id = PlatformID.Unix;
#else
PlatformID id = PlatformID.Win32NT;
-
-#if FEATURE_LEGACYNETCF
- // return platform as WinCE, to ensure apps earlier than WP8 works as expected.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- id = PlatformID.WinCE;
- }
-#endif
#endif // PLATFORM_UNIX
Version v = new Version(osvi.MajorVersion, osvi.MinorVersion, osvi.BuildNumber, (osviEx.ServicePackMajor << 16) |osviEx.ServicePackMinor);
diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.cs b/src/mscorlib/src/System/Globalization/CompareInfo.cs
index 69bc5a567d..05eb061f62 100644
--- a/src/mscorlib/src/System/Globalization/CompareInfo.cs
+++ b/src/mscorlib/src/System/Globalization/CompareInfo.cs
@@ -32,7 +32,6 @@ namespace System.Globalization {
using System.Security.Permissions;
using Microsoft.Win32;
using System.Security;
- using System.Security.Principal;
using System.Diagnostics.Contracts;
//
diff --git a/src/mscorlib/src/System/Globalization/CultureData.cs b/src/mscorlib/src/System/Globalization/CultureData.cs
index c8c5255bfe..a15025c390 100644
--- a/src/mscorlib/src/System/Globalization/CultureData.cs
+++ b/src/mscorlib/src/System/Globalization/CultureData.cs
@@ -19,7 +19,6 @@ namespace System.Globalization
using System.Runtime.Versioning;
using System.Diagnostics.Contracts;
using System.Security;
- using System.Security.Principal;
//
// List of culture data
@@ -1195,14 +1194,6 @@ namespace System.Globalization
{
this.sLocalizedDisplayName = this.SLOCALIZEDLANGUAGE;
}
-#if FEATURE_LEGACYNETCF
- // NetCF renders Invariant DisplayName differently from Windows
- // Quirk it for NetCF apps
- else if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && object.ReferenceEquals(this, s_Invariant))
- {
- this.sLocalizedDisplayName = this.SLOCALIZEDLANGUAGE;
- }
-#endif
else
{
// We have to make the neutral distinction in case the OS returns a specific name
diff --git a/src/mscorlib/src/System/Globalization/CultureInfo.cs b/src/mscorlib/src/System/Globalization/CultureInfo.cs
index 84f6f388cf..7193b8cfd7 100644
--- a/src/mscorlib/src/System/Globalization/CultureInfo.cs
+++ b/src/mscorlib/src/System/Globalization/CultureInfo.cs
@@ -330,24 +330,10 @@ namespace System.Globalization {
}
Contract.EndContractBlock();
-#if FEATURE_LEGACYNETCF
- // Windows Phone 7 and 7.1 do not support Bengali. When running on Windows Phone 8,
- // WinPhone 7.x apps get the old Mango text stack, not the Apollo text stack. The Mango
- // text stack cannot display characters in Bengali, such as the culture's native name.
- // Phone apps are already written to catch an exception here and bypass this culture.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 &&
- (name == "bn" || name == "bn-BD" || name == "bn-IN" || name == "ml" || name == "or"))
- throw new ArgumentException(Environment.GetResourceString("Argument_CultureNotSupported"));
-#endif
-
// Get our data providing record
this.m_cultureData = CultureData.GetCultureData(name, useUserOverride);
if (this.m_cultureData == null) {
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- throw new PlatformNotSupportedException(Environment.GetResourceString("Argument_CultureNotSupported"));
-#endif
throw new CultureNotFoundException("name", name, Environment.GetResourceString("Argument_CultureNotSupported"));
}
@@ -900,21 +886,6 @@ namespace System.Globalization {
}
}
-#if FEATURE_LEGACYNETCF
- //
- // Helper methods to set default thread culture without security demand. Used
- // by NetCF compatibility quirk. See comment in Thread.CurrentUICulture setter for details.
- //
- internal static void SetCurrentUICultureQuirk(CultureInfo value) {
- s_DefaultThreadCurrentUICulture = value;
- }
-
- internal static void SetCurrentCultureQuirk(CultureInfo value) {
- s_DefaultThreadCurrentCulture = value;
- }
-#endif
-
-
////////////////////////////////////////////////////////////////////////
//
// InvariantCulture
diff --git a/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs b/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs
index a5deed71a0..51d785b8cf 100644
--- a/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs
+++ b/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs
@@ -10,7 +10,6 @@ namespace System.Globalization {
using System.Collections.Generic;
using System.Threading;
using System.Security;
- using System.Security.Principal;
using System.Security.Permissions;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
diff --git a/src/mscorlib/src/System/IAppDomain.cs b/src/mscorlib/src/System/IAppDomain.cs
index 14c2d6ffdb..bd8b876577 100644
--- a/src/mscorlib/src/System/IAppDomain.cs
+++ b/src/mscorlib/src/System/IAppDomain.cs
@@ -19,7 +19,9 @@ namespace System {
using SecurityManager = System.Security.SecurityManager;
using System.Security.Permissions;
using IEvidenceFactory = System.Security.IEvidenceFactory;
+#if FEATURE_IMPERSONATION
using System.Security.Principal;
+#endif
using System.Security.Policy;
using System.Security;
using System.Security.Util;
diff --git a/src/mscorlib/src/System/IAppDomainPauseManager.cs b/src/mscorlib/src/System/IAppDomainPauseManager.cs
index 156a05343e..7e031454a4 100644
--- a/src/mscorlib/src/System/IAppDomainPauseManager.cs
+++ b/src/mscorlib/src/System/IAppDomainPauseManager.cs
@@ -20,23 +20,8 @@ namespace System
using System.Runtime.Versioning;
using System.Runtime.CompilerServices;
-#if FEATURE_LEGACYNETCFFAS
[System.Security.SecurityCritical]
- public interface IAppDomainPauseManager
- {
- void Pausing();
- void Paused();
- void Resuming();
- void Resumed();
- }
-#endif
-
- [System.Security.SecurityCritical]
-#if FEATURE_LEGACYNETCFFAS
- public class AppDomainPauseManager : IAppDomainPauseManager
-#else
internal class AppDomainPauseManager
-#endif
{
[System.Security.SecurityCritical]
public AppDomainPauseManager()
diff --git a/src/mscorlib/src/System/IO/Directory.cs b/src/mscorlib/src/System/IO/Directory.cs
index 2a1d4aecc1..95f2f37d2f 100644
--- a/src/mscorlib/src/System/IO/Directory.cs
+++ b/src/mscorlib/src/System/IO/Directory.cs
@@ -61,21 +61,6 @@ namespace System.IO {
throw new ArgumentException(Environment.GetResourceString("Argument_PathEmpty"));
Contract.EndContractBlock();
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly) {
- string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
-
return InternalCreateDirectoryHelper(path, true);
}
diff --git a/src/mscorlib/src/System/IO/FileInfo.cs b/src/mscorlib/src/System/IO/FileInfo.cs
index 3ca3cb6d12..3ab1a5122e 100644
--- a/src/mscorlib/src/System/IO/FileInfo.cs
+++ b/src/mscorlib/src/System/IO/FileInfo.cs
@@ -66,23 +66,6 @@ namespace System.IO {
throw new ArgumentNullException("fileName");
Contract.EndContractBlock();
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly)
- {
- string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
-
Init(fileName, true);
}
diff --git a/src/mscorlib/src/System/IO/FileStream.cs b/src/mscorlib/src/System/IO/FileStream.cs
index 9434acad7c..477b7b81c6 100644
--- a/src/mscorlib/src/System/IO/FileStream.cs
+++ b/src/mscorlib/src/System/IO/FileStream.cs
@@ -377,14 +377,6 @@ namespace System.IO {
{
internal const int DefaultBufferSize = 4096;
-
-#if FEATURE_LEGACYNETCF
- // Mango didn't do support Async IO.
- private static readonly bool _canUseAsync = !CompatibilitySwitches.IsAppEarlierThanWindowsPhone8;
-#else
- private const bool _canUseAsync = true;
-#endif //FEATURE_LEGACYNETCF
-
private byte[] _buffer; // Shared read/write buffer. Alloc on first use.
private String _fileName; // Fully qualified file name.
private bool _isAsync; // Whether we opened the handle for overlapped IO
@@ -414,58 +406,16 @@ namespace System.IO {
[System.Security.SecuritySafeCritical]
public FileStream(String path, FileMode mode)
: this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), FileShare.Read, DefaultBufferSize, FileOptions.None, Path.GetFileName(path), false, false, true) {
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly) {
- string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
}
[System.Security.SecuritySafeCritical]
public FileStream(String path, FileMode mode, FileAccess access)
: this(path, mode, access, FileShare.Read, DefaultBufferSize, FileOptions.None, Path.GetFileName(path), false, false, true) {
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly) {
- string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
}
[System.Security.SecuritySafeCritical]
public FileStream(String path, FileMode mode, FileAccess access, FileShare share)
: this(path, mode, access, share, DefaultBufferSize, FileOptions.None, Path.GetFileName(path), false, false, true) {
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly) {
- string caller = new System.Diagnostics.StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
}
[System.Security.SecuritySafeCritical]
@@ -765,7 +715,7 @@ namespace System.IO {
// WRT async IO, do the right thing for whatever platform we're on.
// This way, someone can easily write code that opens a file
// asynchronously no matter what their platform is.
- if (_canUseAsync && (options & FileOptions.Asynchronous) != 0)
+ if ((options & FileOptions.Asynchronous) != 0)
_isAsync = true;
else
options &= ~FileOptions.Asynchronous;
@@ -953,7 +903,7 @@ namespace System.IO {
int handleType = Win32Native.GetFileType(_handle);
Contract.Assert(handleType == Win32Native.FILE_TYPE_DISK || handleType == Win32Native.FILE_TYPE_PIPE || handleType == Win32Native.FILE_TYPE_CHAR, "FileStream was passed an unknown file type!");
- _isAsync = isAsync && _canUseAsync;
+ _isAsync = isAsync;
_canRead = 0 != (access & FileAccess.Read);
_canWrite = 0 != (access & FileAccess.Write);
_canSeek = handleType == Win32Native.FILE_TYPE_DISK;
diff --git a/src/mscorlib/src/System/IO/Path.cs b/src/mscorlib/src/System/IO/Path.cs
index 509e27be25..0b9c32098e 100644
--- a/src/mscorlib/src/System/IO/Path.cs
+++ b/src/mscorlib/src/System/IO/Path.cs
@@ -163,10 +163,6 @@ namespace System.IO {
if (path != null) {
CheckInvalidPathChars(path);
-#if FEATURE_LEGACYNETCF
- if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
-#endif
-
string normalizedPath = NormalizePath(path, false);
// If there are no permissions for PathDiscovery to this path, we should NOT expand the short paths
@@ -207,24 +203,13 @@ namespace System.IO {
path = normalizedPath;
-#if FEATURE_LEGACYNETCF
- }
-#endif
-
int root = GetRootLength(path);
int i = path.Length;
if (i > root) {
i = path.Length;
if (i == root) return null;
while (i > root && path[--i] != DirectorySeparatorChar && path[i] != AltDirectorySeparatorChar);
- String dir = path.Substring(0, i);
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- if (dir.Length >= MaxPath - 1)
- throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong"));
- }
-#endif
- return dir;
+ return path.Substring(0, i);
}
}
return null;
diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs
index bd8372483e..a271f76d59 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyName.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs
@@ -217,12 +217,7 @@ namespace System.Reflection {
// will fail to load.
public byte[] GetPublicKey()
{
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && _PublicKey == null)
- return EmptyArray<Byte>.Value;
- else
-#endif
- return _PublicKey;
+ return _PublicKey;
}
public void SetPublicKey(byte[] publicKey)
diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
index 5db3a4c159..4d918ed039 100644
--- a/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ConstructorInfo.cs
@@ -562,12 +562,6 @@ namespace System.Reflection
// ctor is generic or on a generic class
else if (declaringType.ContainsGenericParameters)
{
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- throw new ArgumentException(
- String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateGenericEx"), declaringType));
- else
-#endif
throw new MemberAccessException(
String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateGenericEx"), declaringType));
}
diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
index 5512a95e7d..76dd619458 100644
--- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs
+++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs
@@ -1860,20 +1860,6 @@ namespace System.Reflection
IntPtr blobStart = caRecord.blob.Signature;
IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length);
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- try
- {
- // Resolve attribute type from ctor parent token found in decorated decoratedModule scope
- attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;
- }
- catch(Exception)
- {
- return false;
- }
- }
- else
-#endif
// Resolve attribute type from ctor parent token found in decorated decoratedModule scope
attributeType = decoratedModule.ResolveType(scope.GetParentToken(caRecord.tkCtor), null, null) as RuntimeType;
diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
index 67efd072cb..693e2d3660 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs
@@ -56,11 +56,7 @@ namespace System.Reflection.Emit {
// Use this function if client decides to form the custom attribute blob themselves
-#if FEATURE_CORECLR && !FEATURE_LEGACYNETCF
- [System.Security.SecurityCritical]
-#else
[System.Security.SecuritySafeCritical]
-#endif
[System.Runtime.InteropServices.ComVisible(true)]
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.cs b/src/mscorlib/src/System/Reflection/FieldInfo.cs
index 2ca1c5e71e..fca3c25470 100644
--- a/src/mscorlib/src/System/Reflection/FieldInfo.cs
+++ b/src/mscorlib/src/System/Reflection/FieldInfo.cs
@@ -517,11 +517,6 @@ namespace System.Reflection
{
if (target == null)
{
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- throw new ArgumentNullException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg"));
- else
-#endif
throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg"));
}
else
diff --git a/src/mscorlib/src/System/Reflection/ParameterInfo.cs b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
index 591575f6ca..6ab0321f66 100644
--- a/src/mscorlib/src/System/Reflection/ParameterInfo.cs
+++ b/src/mscorlib/src/System/Reflection/ParameterInfo.cs
@@ -578,11 +578,6 @@ namespace System.Reflection
if (defaultValue == DBNull.Value)
{
#region Handle case if no default value was found
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- defaultValue = null;
- else
-#endif
if (IsOptional)
{
// If the argument is marked as optional then the default value is Missing.Value.
diff --git a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
index 83718fef9f..fe0c5a5c45 100644
--- a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
+++ b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs
@@ -220,17 +220,6 @@ namespace System.Resources {
[System.Security.SecurityCritical]
internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref UltimateResourceFallbackLocation fallbackLocation)
{
-
-#if FEATURE_LEGACYNETCF
- // Windows Phone 7.0/7.1 ignore NeutralResourceLanguage attribute and
- // defaults fallbackLocation to MainAssembly
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- fallbackLocation = UltimateResourceFallbackLocation.MainAssembly;
- return CultureInfo.InvariantCulture;
- }
-#endif
-
Contract.Assert(a != null, "assembly != null");
string cultureName = null;
short fallback = 0;
diff --git a/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs b/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs
index a590e78c1a..8f25bda617 100644
--- a/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs
+++ b/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs
@@ -15,7 +15,6 @@ namespace System.Security {
using System.Diagnostics.Contracts;
#if !FEATURE_PAL
using Microsoft.Win32.SafeHandles;
- using System.Security.Principal;
#endif
//FrameSecurityDescriptor.cs
//
diff --git a/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs b/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs
deleted file mode 100644
index 0cc80f296c..0000000000
--- a/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-//
-//
-// A generic identity
-//
-
-namespace System.Security.Principal
-{
- using System;
- using System.Diagnostics.Contracts;
-
-// Claims feature is not available in Silverlight
-#if !FEATURE_CORECLR
- using System.Security.Claims;
- using System.Collections.Generic;
- using System.Runtime.Serialization;
-#endif
-
- [Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
-
-#if!FEATURE_CORECLR
- public class GenericIdentity : ClaimsIdentity {
-#else
- public class GenericIdentity : IIdentity {
-#endif
-
- private string m_name;
- private string m_type;
-
-#if !FEATURE_CORECLR
- [SecuritySafeCritical]
-#endif
- public GenericIdentity (string name) {
- if (name == null)
- throw new ArgumentNullException("name");
- Contract.EndContractBlock();
-
- m_name = name;
- m_type = "";
-
-#if !FEATURE_CORECLR
- AddNameClaim();
-#endif
- }
-
-#if !FEATURE_CORECLR
- [SecuritySafeCritical]
-#endif
- public GenericIdentity (string name, string type) {
- if (name == null)
- throw new ArgumentNullException("name");
- if (type == null)
- throw new ArgumentNullException("type");
- Contract.EndContractBlock();
-
- m_name = name;
- m_type = type;
-
-#if !FEATURE_CORECLR
- AddNameClaim();
-#endif
- }
-
-#if !FEATURE_CORECLR
- GenericIdentity()
- : base()
- { }
-#endif
-
-#if !FEATURE_CORECLR
-
- protected GenericIdentity(GenericIdentity identity)
- : base(identity)
- {
- m_name = identity.m_name;
- m_type = identity.m_type;
- }
-
- /// <summary>
- /// Returns a new instance of <see cref="GenericIdentity"/> with values copied from this object.
- /// </summary>
- public override ClaimsIdentity Clone()
- {
- return new GenericIdentity(this);
- }
-
- public override IEnumerable<Claim> Claims
- {
- get
- {
- return base.Claims;
- }
- }
-
-#endif
-
-#if !FEATURE_CORECLR
- public override string Name {
-#else
- public virtual string Name {
-#endif
- get {
- return m_name;
- }
- }
-
-#if !FEATURE_CORECLR
- public override string AuthenticationType {
-#else
- public virtual string AuthenticationType {
-#endif
- get {
- return m_type;
- }
- }
-
-#if !FEATURE_CORECLR
- public override bool IsAuthenticated {
-#else
- public virtual bool IsAuthenticated {
-#endif
- get {
- return !m_name.Equals("");
- }
- }
-
-#if !FEATURE_CORECLR
- [OnDeserialized()]
- private void OnDeserializedMethod(StreamingContext context)
- {
- // GenericIdentities that have been deserialized from a .net 4.0 runtime, will not have any claims.
- // In this case add a name claim, otherwise assume it was deserialized.
- bool claimFound = false;
- foreach (Claim c in base.Claims)
- {
- claimFound = true;
- break;
- }
-
- if (!claimFound)
- {
- AddNameClaim();
- }
- }
-
- [SecuritySafeCritical]
- private void AddNameClaim()
- {
- if (m_name != null)
- {
- base.AddClaim(new Claim(base.NameClaimType, m_name, ClaimValueTypes.String, ClaimsIdentity.DefaultIssuer, ClaimsIdentity.DefaultIssuer, this));
- }
- }
-#endif // #if !FEATURE_CORECLR
- }
-}
diff --git a/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs b/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs
deleted file mode 100644
index 582ae536b3..0000000000
--- a/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-//
-//
-
-namespace System.Security.Principal
-{
- using System;
- using System.Diagnostics.Contracts;
-
-#if !FEATURE_CORECLR
- using System.Collections.Generic;
- using System.Runtime.Serialization;
- using System.Security.Claims;
-#endif
-
- [Serializable]
- [System.Runtime.InteropServices.ComVisible(true)]
-
-#if !FEATURE_CORECLR
- public class GenericPrincipal : ClaimsPrincipal {
-#else
- public class GenericPrincipal : IPrincipal {
-#endif
- private IIdentity m_identity;
- private string[] m_roles;
-
- public GenericPrincipal(IIdentity identity, string[] roles) {
- if (identity == null)
- throw new ArgumentNullException("identity");
- Contract.EndContractBlock();
-
- m_identity = identity;
- if (roles != null) {
- m_roles = new string[roles.Length];
- for (int i = 0; i < roles.Length; ++i) {
- m_roles[i] = roles[i];
- }
- }
- else {
- m_roles = null;
- }
-
-#if !FEATURE_CORECLR
- AddIdentityWithRoles(m_identity, m_roles);
- }
-
- [OnDeserialized()]
- private void OnDeserializedMethod(StreamingContext context)
- {
- // Here it the matrix of possible serializations
- //
- // Version From | Version To | ClaimsIdentities | Roles
- // ============ ========== ================ ========================================================
- // 4.0 4.5 None We always need to add a ClaimsIdentity, if Roles add them
- //
- // 4.5 4.5 Yes There should be a ClaimsIdentity, DebugAssert if this is not the case
- // If there are roles, attach them to the first ClaimsIdentity.
- // If there is no non-null ClaimsIdentity, add one. However, this is unusual and may be an issue.
-
- ClaimsIdentity firstNonNullIdentity = null;
- foreach (var identity in base.Identities)
- {
- if (identity != null)
- {
- firstNonNullIdentity = identity;
- break;
- }
- }
-
- if (m_roles != null && m_roles.Length > 0 && firstNonNullIdentity != null)
- {
- firstNonNullIdentity.ExternalClaims.Add(new RoleClaimProvider(ClaimsIdentity.DefaultIssuer, m_roles, firstNonNullIdentity).Claims);
- }
- else if (firstNonNullIdentity == null)
- {
- AddIdentityWithRoles(m_identity, m_roles);
- }
- }
-
- /// <summary>
- /// helper method to add roles
- /// </summary>
- [SecuritySafeCritical]
- void AddIdentityWithRoles(IIdentity identity, string[] roles)
- {
- ClaimsIdentity claimsIdentity = identity as ClaimsIdentity;
-
- if (claimsIdentity != null)
- {
- claimsIdentity = claimsIdentity.Clone();
- }
- else
- {
- claimsIdentity = new ClaimsIdentity(identity);
- }
-
- // if roles are not null then we need to add a provider
- if (roles != null && roles.Length > 0)
- {
- claimsIdentity.ExternalClaims.Add(new RoleClaimProvider(ClaimsIdentity.DefaultIssuer, roles, claimsIdentity).Claims);
- }
-
- base.AddIdentity(claimsIdentity);
- }
-#else
- }
-#endif
-
-
-#if !FEATURE_CORECLR
- public override IIdentity Identity {
-#else
- public virtual IIdentity Identity {
-#endif
- get { return m_identity; }
- }
-
-#if !FEATURE_CORECLR
- public override bool IsInRole(string role) {
-#else
- public virtual bool IsInRole (string role) {
-#endif
- if (role == null || m_roles == null)
- return false;
-
- for (int i = 0; i < m_roles.Length; ++i) {
- if (m_roles[i] != null && String.Compare(m_roles[i], role, StringComparison.OrdinalIgnoreCase) == 0)
- return true;
- }
-
-#if !FEATURE_CORECLR
- // it may be the case a ClaimsIdentity was passed in as the IIdentity which may have contained claims, they need to be checked.
- return base.IsInRole(role);
-#else
- return false;
-#endif
- }
- }
-}
diff --git a/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs b/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs
deleted file mode 100644
index 5391c36114..0000000000
--- a/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-//
-//
-// Enum describing what type of principal to create by default (assuming no
-// principal has been set on the AppDomain).
-//
-
-namespace System.Security.Principal
-{
- [Serializable]
-[System.Runtime.InteropServices.ComVisible(true)]
- public enum PrincipalPolicy {
- // Note: it's important that the default policy has the value 0.
- UnauthenticatedPrincipal = 0,
- NoPrincipal = 1,
- WindowsPrincipal = 2,
- }
-}
diff --git a/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs b/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs
deleted file mode 100644
index fb94a6276f..0000000000
--- a/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-//
-
-namespace System.Security.Principal
-{
-
- [Serializable]
- [Flags]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum TokenAccessLevels {
- AssignPrimary = 0x00000001,
- Duplicate = 0x00000002,
- Impersonate = 0x00000004,
- Query = 0x00000008,
- QuerySource = 0x00000010,
- AdjustPrivileges = 0x00000020,
- AdjustGroups = 0x00000040,
- AdjustDefault = 0x00000080,
- AdjustSessionId = 0x00000100,
-
- Read = 0x00020000 | Query,
-
- Write = 0x00020000 | AdjustPrivileges | AdjustGroups | AdjustDefault,
-
- AllAccess = 0x000F0000 |
- AssignPrimary |
- Duplicate |
- Impersonate |
- Query |
- QuerySource |
- AdjustPrivileges |
- AdjustGroups |
- AdjustDefault |
- AdjustSessionId,
-
- MaximumAllowed = 0x02000000
- }
-}
diff --git a/src/mscorlib/src/System/Security/SecurityContext.cs b/src/mscorlib/src/System/Security/SecurityContext.cs
index 4b482b6c09..e422a312df 100644
--- a/src/mscorlib/src/System/Security/SecurityContext.cs
+++ b/src/mscorlib/src/System/Security/SecurityContext.cs
@@ -17,7 +17,9 @@ namespace System.Security
using Microsoft.Win32.SafeHandles;
using System.Threading;
using System.Runtime.Remoting;
+#if FEATURE_IMPERSONATION
using System.Security.Principal;
+#endif
using System.Collections;
using System.Runtime.Serialization;
using System.Security.Permissions;
diff --git a/src/mscorlib/src/System/String.cs b/src/mscorlib/src/System/String.cs
index 727679d524..9c4c9e0ad5 100644
--- a/src/mscorlib/src/System/String.cs
+++ b/src/mscorlib/src/System/String.cs
@@ -2736,22 +2736,6 @@ namespace System {
Contract.EndContractBlock();
return this;
}
-
- private static bool IsBOMWhitespace(char c)
- {
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && c == '\xFEFF')
- {
- // Dev11 450846 quirk:
- // NetCF treats the BOM as a whitespace character when performing trim operations.
- return true;
- }
- else
-#endif
- {
- return false;
- }
- }
// Trims the whitespace from both ends of the string. Whitespace is defined by
// Char.IsWhiteSpace.
@@ -2775,13 +2759,13 @@ namespace System {
//Trim specified characters.
if (trimType !=TrimTail) {
for (start=0; start < this.Length; start++) {
- if (!Char.IsWhiteSpace(this[start]) && !IsBOMWhitespace(this[start])) break;
+ if (!Char.IsWhiteSpace(this[start])) break;
}
}
if (trimType !=TrimHead) {
for (end= Length -1; end >= start; end--) {
- if (!Char.IsWhiteSpace(this[end]) && !IsBOMWhitespace(this[start])) break;
+ if (!Char.IsWhiteSpace(this[end])) break;
}
}
@@ -2966,21 +2950,7 @@ namespace System {
Contract.Ensures(Contract.Result<String>() != null);
Contract.EndContractBlock();
- string s = ReplaceInternal(oldValue, newValue);
-#if FEATURE_LEGACYNETCF
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhoneMango)
- {
- int i = s.IndexOf('\0');
- if (i > 0)
- return s.Substring(0, i);
- else
- return s;
- }
- else
-#endif
- {
- return s;
- }
+ return ReplaceInternal(oldValue, newValue);
}
[System.Security.SecuritySafeCritical] // auto-generated
diff --git a/src/mscorlib/src/System/Text/StringBuilder.cs b/src/mscorlib/src/System/Text/StringBuilder.cs
index 317f82d251..e5d0fcdab0 100644
--- a/src/mscorlib/src/System/Text/StringBuilder.cs
+++ b/src/mscorlib/src/System/Text/StringBuilder.cs
@@ -581,22 +581,14 @@ namespace System.Text {
// Appends an array of characters at the end of this string builder. The capacity is adjusted as needed.
[System.Security.SecuritySafeCritical] // auto-generated
public StringBuilder Append(char[] value, int startIndex, int charCount) {
- // in NetCF arguments pretty much don't matter as long as count is 0
- // we need to check this twice, as this is a contract area and we can't return from here
-#if FEATURE_LEGACYNETCF
- if (startIndex < 0 && !(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (charCount == 0))) {
-#else
if (startIndex < 0) {
-#endif //FEATURE_LEGACYNETCF
throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
}
if (charCount<0) {
throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
}
-#if !FEATURE_LEGACYNETCF // Avoid contract problems with compat switch above.
Contract.Ensures(Contract.Result<StringBuilder>() != null);
Contract.EndContractBlock();
-#endif
// in NetCF arguments pretty much don't matter as long as count is 0
if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (charCount == 0))
@@ -685,22 +677,14 @@ namespace System.Text {
// count at the end of this string builder.
[System.Security.SecuritySafeCritical] // auto-generated
public StringBuilder Append(String value, int startIndex, int count) {
- // in NetCF arguments pretty much don't matter as long as count is 0
- // we need to check this twice, as this is a contract area and we can't return from here
-#if FEATURE_LEGACYNETCF
- if (startIndex < 0 && !(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (count == 0))) {
-#else
if (startIndex < 0) {
-#endif //FEATURE_LEGACYNETCF
throw new ArgumentOutOfRangeException("startIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
}
if (count < 0) {
throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"));
}
-#if !FEATURE_LEGACYNETCF // The use of CompatibilitySwitches above prevents us from marking this as a precondition.
Contract.Ensures(Contract.Result<StringBuilder>() != null);
-#endif
// in NetCF arguments pretty much don't matter as long as count is 0
if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8 && (count == 0)){
@@ -1435,14 +1419,6 @@ namespace System.Text {
if (s == null) {
IFormattable formattableArg = arg as IFormattable;
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
- // TimeSpan does not implement IFormattable in Mango
- if(arg is TimeSpan) {
- formattableArg = null;
- }
- }
-#endif
if (formattableArg != null) {
if (sFmt == null && fmt != null) {
sFmt = fmt.ToString();
diff --git a/src/mscorlib/src/System/Threading/ExecutionContext.cs b/src/mscorlib/src/System/Threading/ExecutionContext.cs
index fb96d933f5..34cf0ae0cf 100644
--- a/src/mscorlib/src/System/Threading/ExecutionContext.cs
+++ b/src/mscorlib/src/System/Threading/ExecutionContext.cs
@@ -14,7 +14,9 @@ namespace System.Threading
using System;
using System.Security;
using System.Runtime.Remoting;
+#if FEATURE_IMPERSONATION
using System.Security.Principal;
+#endif
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs
index 6095a0036c..b656b6bc01 100644
--- a/src/mscorlib/src/System/Threading/Mutex.cs
+++ b/src/mscorlib/src/System/Threading/Mutex.cs
@@ -23,7 +23,6 @@ namespace System.Threading
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.Versioning;
- using System.Security.Principal;
using System.Security;
using System.Diagnostics.Contracts;
diff --git a/src/mscorlib/src/System/Threading/Thread.cs b/src/mscorlib/src/System/Threading/Thread.cs
index 7871e91773..bec60326f6 100644
--- a/src/mscorlib/src/System/Threading/Thread.cs
+++ b/src/mscorlib/src/System/Threading/Thread.cs
@@ -517,22 +517,6 @@ namespace System.Threading {
#pragma warning restore 618
public void Abort()
{
-#if FEATURE_LEGACYNETCF
- if(CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- System.Reflection.Assembly callingAssembly = System.Reflection.Assembly.GetCallingAssembly();
- if(callingAssembly != null && !callingAssembly.IsProfileAssembly)
- {
- string caller = new StackFrame(1).GetMethod().FullName;
- string callee = System.Reflection.MethodBase.GetCurrentMethod().FullName;
- throw new MethodAccessException(String.Format(
- CultureInfo.CurrentCulture,
- Environment.GetResourceString("Arg_MethodAccessException_WithCaller"),
- caller,
- callee));
- }
- }
-#endif // FEATURE_LEGACYNETCF
AbortInternal();
}
@@ -1104,14 +1088,6 @@ namespace System.Threading {
nativeInitCultureAccessors();
#endif
-#if FEATURE_LEGACYNETCF && !FEATURE_COREFX_GLOBALIZATION
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- // Maintain legacy NetCF Behavior where setting the value for one thread impacts all threads.
- CultureInfo.SetCurrentUICultureQuirk(value);
- return;
- }
-#endif
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
if (s_asyncLocalCurrentUICulture == null)
@@ -1219,14 +1195,6 @@ namespace System.Threading {
nativeInitCultureAccessors();
#endif
-#if FEATURE_LEGACYNETCF && !FEATURE_COREFX_GLOBALIZATION
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- {
- // See comment in CurrentUICulture setter
- CultureInfo.SetCurrentCultureQuirk(value);
- return;
- }
-#endif
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
if (s_asyncLocalCurrentCulture == null)
diff --git a/src/mscorlib/src/System/Threading/ThreadPool.cs b/src/mscorlib/src/System/Threading/ThreadPool.cs
index f9d8e7da98..2ee7b76f89 100644
--- a/src/mscorlib/src/System/Threading/ThreadPool.cs
+++ b/src/mscorlib/src/System/Threading/ThreadPool.cs
@@ -1830,12 +1830,6 @@ namespace System.Threading
[CLSCompliant(false)]
unsafe public static bool UnsafeQueueNativeOverlapped(NativeOverlapped* overlapped)
{
-#if FEATURE_CORECLR && !FEATURE_LEGACYNETCF
- if(Environment.OSVersion.Platform == PlatformID.MacOSX)
- throw new NotSupportedException(Environment.GetResourceString("Arg_NotSupportedException"));
- Contract.EndContractBlock();
-#endif
-
return PostQueuedCompletionStatus(overlapped);
}
@@ -1934,12 +1928,6 @@ namespace System.Threading
#pragma warning restore 618
public static bool BindHandle(SafeHandle osHandle)
{
- #if FEATURE_CORECLR && !FEATURE_LEGACYNETCF
- if(Environment.OSVersion.Platform == PlatformID.MacOSX)
- throw new NotSupportedException(Environment.GetResourceString("Arg_NotSupportedException"));
- Contract.EndContractBlock();
- #endif
-
if (osHandle == null)
throw new ArgumentNullException("osHandle");
diff --git a/src/mscorlib/src/System/Threading/WaitHandle.cs b/src/mscorlib/src/System/Threading/WaitHandle.cs
index 6bca19125d..30d6872741 100644
--- a/src/mscorlib/src/System/Threading/WaitHandle.cs
+++ b/src/mscorlib/src/System/Threading/WaitHandle.cs
@@ -329,13 +329,6 @@ namespace System.Threading
waitHandles = null;
#endif
-#if FEATURE_LEGACYNETCF
- // WinCE did not support "wait all." It turns out that this resulted in NetCF's WaitAll implementation always returning true.
- // Unfortunately, some apps took a dependency on that, so we have to replicate the behavior here.
- if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
- return true;
-#endif
-
int ret = WaitMultiple(internalWaitHandles, millisecondsTimeout, exitContext, true /* waitall*/ );
if(AppDomainPauseManager.IsPaused)
diff --git a/src/pal/src/locale/unicode.cpp b/src/pal/src/locale/unicode.cpp
index c9cd15a9ea..3c119744b0 100644
--- a/src/pal/src/locale/unicode.cpp
+++ b/src/pal/src/locale/unicode.cpp
@@ -928,6 +928,10 @@ ReleaseString:
{
CFRelease(cfString);
}
+#else /*HAVE_COREFOUNDATION */
+ ERROR( "This code page is not in the system.\n" );
+ SetLastError( ERROR_INVALID_PARAMETER );
+ goto EXIT;
#endif /* HAVE_COREFOUNDATION */
EXIT:
diff --git a/src/pal/src/locale/utf8.cpp b/src/pal/src/locale/utf8.cpp
index 1260618427..87493a9673 100644
--- a/src/pal/src/locale/utf8.cpp
+++ b/src/pal/src/locale/utf8.cpp
@@ -11,7 +11,7 @@ Module Name:
unicode/utf8.c
Abstract:
- Functions to encode and decode UTF-8 strings
+ Functions to encode and decode UTF-8 strings. This is a port of the C# version from mscorlib.
Revision History:
@@ -20,556 +20,2885 @@ Revision History:
--*/
#include "pal/utf8.h"
-#include "pal/dbgmsg.h"
-#include "pal/unicode_data.h"
-//
-// Constant Declarations.
-//
+#define FASTLOOP
-#define ASCII 0x007f
+struct CharUnicodeInfo
+{
+ static const WCHAR HIGH_SURROGATE_START = 0xd800;
+ static const WCHAR HIGH_SURROGATE_END = 0xdbff;
+ static const WCHAR LOW_SURROGATE_START = 0xdc00;
+ static const WCHAR LOW_SURROGATE_END = 0xdfff;
+};
-#define UTF8_2_MAX 0x07ff // max UTF8 2-byte sequence (32 * 64 = 2048)
-#define UTF8_1ST_OF_2 0xc0 // 110x xxxx
-#define UTF8_1ST_OF_3 0xe0 // 1110 xxxx
-#define UTF8_1ST_OF_4 0xf0 // 1111 xxxx
-#define UTF8_TRAIL 0x80 // 10xx xxxx
+struct Char
+{
+ // Test if the wide character is a high surrogate
+ static bool IsHighSurrogate(const WCHAR c)
+ {
+ return (c & 0xFC00) == CharUnicodeInfo::HIGH_SURROGATE_START;
+ }
-#define HIGHER_6_BIT(u) ((u) >> 12)
-#define MIDDLE_6_BIT(u) (((u) & 0x0fc0) >> 6)
-#define LOWER_6_BIT(u) ((u) & 0x003f)
+ // Test if the wide character is a low surrogate
+ static bool IsLowSurrogate(const WCHAR c)
+ {
+ return (c & 0xFC00) == CharUnicodeInfo::LOW_SURROGATE_START;
+ }
-#define BIT7(a) ((a) & 0x80)
-#define BIT6(a) ((a) & 0x40)
+ // Test if the wide character is a low surrogate
+ static bool IsSurrogate(const WCHAR c)
+ {
+ return (c & 0xF800) == CharUnicodeInfo::HIGH_SURROGATE_START;
+ }
-#define HIGH_SURROGATE_START 0xd800
-#define HIGH_SURROGATE_END 0xdbff
-#define LOW_SURROGATE_START 0xdc00
-#define LOW_SURROGATE_END 0xdfff
+ // Test if the wide character is a high surrogate
+ static bool IsHighSurrogate(const WCHAR* s, int index)
+ {
+ return IsHighSurrogate(s[index]);
+ }
+ // Test if the wide character is a low surrogate
+ static bool IsLowSurrogate(const WCHAR* s, int index)
+ {
+ return IsLowSurrogate(s[index]);
+ }
-////////////////////////////////////////////////////////////////////////////
-//
-// UTF8ToUnicode
-//
-// Maps a UTF-8 character string to its wide character string counterpart.
-//
-////////////////////////////////////////////////////////////////////////////
+ // Test if the wide character is a low surrogate
+ static bool IsSurrogate(const WCHAR* s, int index)
+ {
+ return IsSurrogate(s[index]);
+ }
+};
-int UTF8ToUnicode(
- LPCSTR lpSrcStr,
- int cchSrc,
- LPWSTR lpDestStr,
- int cchDest,
- DWORD dwFlags
- )
+class ArgumentException
{
- int nTB = 0; // # trail bytes to follow
- int cchWC = 0; // # of Unicode code points generated
- CONST BYTE* pUTF8 = (CONST BYTE*)lpSrcStr;
- DWORD dwUnicodeChar = 0; // Our character with room for full surrogate char
- BOOL bSurrogatePair = FALSE; // Indicate we're collecting a surrogate pair
- BOOL bCheckInvalidBytes = (dwFlags & MB_ERR_INVALID_CHARS);
- BYTE UTF8;
-
- // Note that we can't test destination buffer length here because we may have to
- // iterate through thousands of broken characters which won't be output, even though
- // the buffer has no more room.
- while (cchSrc--)
- {
- //
- // See if there are any trail bytes.
- //
- if (BIT7(*pUTF8) == 0)
+
+public:
+ ArgumentException(LPCSTR message)
+ {
+ }
+
+ ArgumentException(LPCSTR message, LPCSTR argName)
+ {
+ }
+};
+
+class ArgumentNullException : public ArgumentException
+{
+public:
+ ArgumentNullException(LPCSTR argName)
+ : ArgumentException("Argument is NULL", argName)
+ {
+
+ }
+};
+
+class ArgumentOutOfRangeException : public ArgumentException
+{
+public:
+ ArgumentOutOfRangeException(LPCSTR argName, LPCSTR message)
+ : ArgumentException(message, argName)
+ {
+
+ }
+};
+
+class InsufficientBufferException : public ArgumentException
+{
+public:
+ InsufficientBufferException(LPCSTR message, LPCSTR argName)
+ : ArgumentException(message, argName)
+ {
+
+ }
+};
+
+class Contract
+{
+public:
+ static void Assert(bool cond, LPCSTR str)
+ {
+ if (!cond)
{
- //
- // Found ASCII.
- //
- if (cchDest)
+ throw ArgumentException(str);
+ }
+ }
+
+ static void EndContractBlock()
+ {
+ }
+};
+
+class DecoderFallbackException : public ArgumentException
+{
+ BYTE *bytesUnknown;
+ int index;
+
+public:
+ DecoderFallbackException(
+ LPCSTR message, BYTE bytesUnknown[], int index) : ArgumentException(message)
+ {
+ this->bytesUnknown = bytesUnknown;
+ this->index = index;
+ }
+
+ BYTE *BytesUnknown()
+ {
+ return (bytesUnknown);
+ }
+
+ int GetIndex()
+ {
+ return index;
+ }
+};
+
+class DecoderFallbackBuffer;
+
+class DecoderFallback
+{
+public:
+
+ // Fallback
+ //
+ // Return the appropriate unicode string alternative to the character that need to fall back.
+
+ virtual DecoderFallbackBuffer* CreateFallbackBuffer() = 0;
+
+ // Maximum number of characters that this instance of this fallback could return
+
+ virtual int GetMaxCharCount() = 0;
+};
+
+class DecoderReplacementFallback : public DecoderFallback
+{
+ // Our variables
+ WCHAR strDefault[2];
+ int strDefaultLength;
+
+public:
+ // Construction. Default replacement fallback uses no best fit and ? replacement string
+ DecoderReplacementFallback() : DecoderReplacementFallback(W("?"))
+ {
+ }
+
+ DecoderReplacementFallback(const WCHAR* replacement)
+ {
+ // Must not be null
+ if (replacement == nullptr)
+ throw ArgumentNullException("replacement");
+ Contract::EndContractBlock();
+
+ // Make sure it doesn't have bad surrogate pairs
+ bool bFoundHigh = false;
+ int replacementLength = PAL_wcslen((const WCHAR *)replacement);
+ for (int i = 0; i < replacementLength; i++)
+ {
+ // Found a surrogate?
+ if (Char::IsSurrogate(replacement, i))
{
- // In this function always test buffer size before using it
- if (cchWC >= cchDest)
+ // High or Low?
+ if (Char::IsHighSurrogate(replacement, i))
{
- // Error: Buffer too small, we didn't process this character
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return (0);
+ // if already had a high one, stop
+ if (bFoundHigh)
+ break; // break & throw at the bFoundHIgh below
+ bFoundHigh = true;
+ }
+ else
+ {
+ // Low, did we have a high?
+ if (!bFoundHigh)
+ {
+ // Didn't have one, make if fail when we stop
+ bFoundHigh = true;
+ break;
+ }
+
+ // Clear flag
+ bFoundHigh = false;
}
- lpDestStr[cchWC] = (WCHAR)*pUTF8;
}
- nTB = bSurrogatePair = 0;
- cchWC++;
+ // If last was high we're in trouble (not surrogate so not low surrogate, so break)
+ else if (bFoundHigh)
+ break;
}
- else if (BIT6(*pUTF8) == 0)
+ if (bFoundHigh)
+ throw ArgumentException("String 'replacement' contains invalid Unicode code points.", "replacement");
+
+ wcscpy_s(strDefault, sizeof(strDefault), replacement);
+ strDefaultLength = replacementLength;
+ }
+
+ WCHAR* GetDefaultString()
+ {
+ return strDefault;
+ }
+
+ virtual DecoderFallbackBuffer* CreateFallbackBuffer();
+
+ // Maximum number of characters that this instance of this fallback could return
+ virtual int GetMaxCharCount()
+ {
+ return strDefaultLength;
+ }
+};
+
+class DecoderFallbackBuffer
+{
+ friend class UTF8Encoding;
+ // Most implimentations will probably need an implimenation-specific constructor
+
+ // internal methods that cannot be overriden that let us do our fallback thing
+ // These wrap the internal methods so that we can check for people doing stuff that's incorrect
+
+public:
+ virtual bool Fallback(BYTE bytesUnknown[], int index, int size) = 0;
+
+ // Get next character
+ virtual WCHAR GetNextChar() = 0;
+
+ //Back up a character
+ virtual bool MovePrevious() = 0;
+
+ // How many chars left in this fallback?
+ virtual int GetRemaining() = 0;
+
+ // Clear the buffer
+ virtual void Reset()
+ {
+ while (GetNextChar() != (WCHAR)0);
+ }
+
+ // Internal items to help us figure out what we're doing as far as error messages, etc.
+ // These help us with our performance and messages internally
+protected:
+ BYTE* byteStart;
+ WCHAR* charEnd;
+
+ // Internal reset
+ void InternalReset()
+ {
+ byteStart = nullptr;
+ Reset();
+ }
+
+ // Set the above values
+ // This can't be part of the constructor because EncoderFallbacks would have to know how to impliment these.
+ void InternalInitialize(BYTE* byteStart, WCHAR* charEnd)
+ {
+ this->byteStart = byteStart;
+ this->charEnd = charEnd;
+ }
+
+ // Fallback the current byte by sticking it into the remaining char buffer.
+ // This can only be called by our encodings (other have to use the public fallback methods), so
+ // we can use our DecoderNLS here too (except we don't).
+ // Returns true if we are successful, false if we can't fallback the character (no buffer space)
+ // So caller needs to throw buffer space if return false.
+ // Right now this has both bytes and bytes[], since we might have extra bytes, hence the
+ // array, and we might need the index, hence the byte*
+ // Don't touch ref chars unless we succeed
+ virtual bool InternalFallback(BYTE bytes[], BYTE* pBytes, WCHAR** chars, int size)
+ {
+
+ Contract::Assert(byteStart != nullptr, "[DecoderFallback.InternalFallback]Used InternalFallback without calling InternalInitialize");
+
+ // See if there's a fallback character and we have an output buffer then copy our string.
+ if (this->Fallback(bytes, (int)(pBytes - byteStart - size), size))
{
- //
- // Found a trail byte.
- // Note : Ignore the trail byte if there was no lead byte.
- //
- if (nTB != 0)
+ // Copy the chars to our output
+ WCHAR ch;
+ WCHAR* charTemp = *chars;
+ bool bHighSurrogate = false;
+ while ((ch = GetNextChar()) != 0)
{
- //
- // Decrement the trail byte counter.
- //
- nTB--;
+ // Make sure no mixed up surrogates
+ if (Char::IsSurrogate(ch))
+ {
+ if (Char::IsHighSurrogate(ch))
+ {
+ // High Surrogate
+ if (bHighSurrogate)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
+ bHighSurrogate = true;
+ }
+ else
+ {
+ // Low surrogate
+ if (bHighSurrogate == false)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
+ bHighSurrogate = false;
+ }
+ }
+
+ if (charTemp >= charEnd)
+ {
+ // No buffer space
+ return false;
+ }
+
+ *(charTemp++) = ch;
+ }
+
+ // Need to make sure that bHighSurrogate isn't true
+ if (bHighSurrogate)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
- // Add room for trail byte and add the trail byte falue
- dwUnicodeChar <<= 6;
- dwUnicodeChar |= LOWER_6_BIT(*pUTF8);
+ // Now we aren't going to be false, so its OK to update chars
+ chars = &charTemp;
+ }
+
+ return true;
+ }
- // If we're done then we may need to store the data
- if (nTB == 0)
+ // This version just counts the fallback and doesn't actually copy anything.
+ virtual int InternalFallback(BYTE bytes[], BYTE* pBytes, int size)
+ // Right now this has both bytes[] and BYTE* bytes, since we might have extra bytes, hence the
+ // array, and we might need the index, hence the byte*
+ {
+
+ Contract::Assert(byteStart != nullptr, "[DecoderFallback.InternalFallback]Used InternalFallback without calling InternalInitialize");
+
+ // See if there's a fallback character and we have an output buffer then copy our string.
+ if (this->Fallback(bytes, (int)(pBytes - byteStart - size), size))
+ {
+ int count = 0;
+
+ WCHAR ch;
+ bool bHighSurrogate = false;
+ while ((ch = GetNextChar()) != 0)
+ {
+ // Make sure no mixed up surrogates
+ if (Char::IsSurrogate(ch))
{
- if (bSurrogatePair)
+ if (Char::IsHighSurrogate(ch))
{
- if (cchDest)
- {
- if ((cchWC + 1) >= cchDest)
- {
- // Error: Buffer too small, we didn't process this character
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return (0);
- }
-
- lpDestStr[cchWC] = (WCHAR)
- (((dwUnicodeChar - 0x10000) >> 10) + HIGH_SURROGATE_START);
-
- lpDestStr[cchWC+1] = (WCHAR)
- ((dwUnicodeChar - 0x10000)%0x400 + LOW_SURROGATE_START);
- }
-
- //
- // End of sequence. Advance the output counter, turn off surrogateness
- //
- cchWC += 2;
- bSurrogatePair = FALSE;
+ // High Surrogate
+ if (bHighSurrogate)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
+ bHighSurrogate = true;
}
else
{
- if (cchDest)
- {
-
- if (cchWC >= cchDest)
- {
- // Error: Buffer too small, we didn't process this character
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return (0);
- }
-
- lpDestStr[cchWC] = (WCHAR)dwUnicodeChar;
- }
+ // Low surrogate
+ if (bHighSurrogate == false)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
+ bHighSurrogate = false;
+ }
+ }
+
+ count++;
+ }
+
+ // Need to make sure that bHighSurrogate isn't true
+ if (bHighSurrogate)
+ throw ArgumentException("String 'chars' contains invalid Unicode code points.");
+
+ return count;
+ }
+
+ // If no fallback return 0
+ return 0;
+ }
+
+ // private helper methods
+ void ThrowLastBytesRecursive(BYTE bytesUnknown[])
+ {
+ throw ArgumentException("Recursive fallback not allowed");
+ }
+};
+
+class DecoderReplacementFallbackBuffer : public DecoderFallbackBuffer
+{
+ // Store our default string
+ WCHAR strDefault[4];
+ int strDefaultLength;
+ int fallbackCount = -1;
+ int fallbackIndex = -1;
+
+public:
+ // Construction
+ DecoderReplacementFallbackBuffer(DecoderReplacementFallback* fallback)
+ {
+ // 2X in case we're a surrogate pair
+ wcscpy_s(strDefault, sizeof(strDefault), fallback->GetDefaultString());
+ wcscat_s(strDefault, sizeof(strDefault), fallback->GetDefaultString());
+ strDefaultLength = 2 * PAL_wcslen((const WCHAR *)fallback->GetDefaultString());
+
+ }
+
+ // Fallback Methods
+ virtual bool Fallback(BYTE bytesUnknown[], int index, int size)
+ {
+ // We expect no previous fallback in our buffer
+ // We can't call recursively but others might (note, we don't test on last char!!!)
+ if (fallbackCount >= 1)
+ {
+ ThrowLastBytesRecursive(bytesUnknown);
+ }
+
+ // Go ahead and get our fallback
+ if (strDefaultLength == 0)
+ return false;
+
+ fallbackCount = strDefaultLength;
+ fallbackIndex = -1;
+
+ return true;
+ }
+
+ virtual WCHAR GetNextChar()
+ {
+ // We want it to get < 0 because == 0 means that the current/last character is a fallback
+ // and we need to detect recursion. We could have a flag but we already have this counter.
+ fallbackCount--;
+ fallbackIndex++;
+
+ // Do we have anything left? 0 is now last fallback char, negative is nothing left
+ if (fallbackCount < 0)
+ return '\0';
+
+ // Need to get it out of the buffer.
+ // Make sure it didn't wrap from the fast count-- path
+ if (fallbackCount == INT_MAX)
+ {
+ fallbackCount = -1;
+ return '\0';
+ }
+
+ // Now make sure its in the expected range
+ Contract::Assert(fallbackIndex < strDefaultLength && fallbackIndex >= 0,
+ "Index exceeds buffer range");
+
+ return strDefault[fallbackIndex];
+ }
+
+ virtual bool MovePrevious()
+ {
+ // Back up one, only if we just processed the last character (or earlier)
+ if (fallbackCount >= -1 && fallbackIndex >= 0)
+ {
+ fallbackIndex--;
+ fallbackCount++;
+ return true;
+ }
+
+ // Return false 'cause we couldn't do it.
+ return false;
+ }
+
+ // How many characters left to output?
+ virtual int GetRemaining()
+ {
+ // Our count is 0 for 1 character left.
+ return (fallbackCount < 0) ? 0 : fallbackCount;
+ }
+
+ // Clear the buffer
+ virtual void Reset()
+ {
+ fallbackCount = -1;
+ fallbackIndex = -1;
+ byteStart = nullptr;
+ }
+
+ // This version just counts the fallback and doesn't actually copy anything.
+ virtual int InternalFallback(BYTE bytes[], BYTE* pBytes, int size)
+ // Right now this has both bytes and bytes[], since we might have extra bytes, hence the
+ // array, and we might need the index, hence the byte*
+ {
+ // return our replacement string Length
+ return strDefaultLength;
+ }
+};
+
+class DecoderExceptionFallbackBuffer : public DecoderFallbackBuffer
+{
+public:
+ DecoderExceptionFallbackBuffer()
+ {
+ }
+
+ virtual bool Fallback(BYTE bytesUnknown[], int index, int size)
+ {
+ throw DecoderFallbackException(
+ "Unable to translate UTF-8 character to Unicode", bytesUnknown, index);
+ }
+
+ virtual WCHAR GetNextChar()
+ {
+ return 0;
+ }
+
+ virtual bool MovePrevious()
+ {
+ // Exception fallback doesn't have anywhere to back up to.
+ return false;
+ }
+
+ // Exceptions are always empty
+ virtual int GetRemaining()
+ {
+ return 0;
+ }
+
+};
+
+class DecoderExceptionFallback : public DecoderFallback
+{
+ // Construction
+public:
+ DecoderExceptionFallback()
+ {
+ }
+
+ virtual DecoderFallbackBuffer* CreateFallbackBuffer()
+ {
+ return new DecoderExceptionFallbackBuffer();
+ }
+
+ // Maximum number of characters that this instance of this fallback could return
+ virtual int GetMaxCharCount()
+ {
+ return 0;
+ }
+};
+
+DecoderFallbackBuffer* DecoderReplacementFallback::CreateFallbackBuffer()
+{
+ return new DecoderReplacementFallbackBuffer(this);
+}
+
+class EncoderFallbackException : public ArgumentException
+{
+ WCHAR charUnknown;
+ WCHAR charUnknownHigh;
+ WCHAR charUnknownLow;
+ int index;
+
+public:
+ EncoderFallbackException(
+ LPCSTR message, WCHAR charUnknown, int index) : ArgumentException(message)
+ {
+ this->charUnknown = charUnknown;
+ this->index = index;
+ }
+
+ EncoderFallbackException(
+ LPCSTR message, WCHAR charUnknownHigh, WCHAR charUnknownLow, int index) : ArgumentException(message)
+ {
+ if (!Char::IsHighSurrogate(charUnknownHigh))
+ {
+ throw ArgumentOutOfRangeException("charUnknownHigh",
+ "Argument out of range 0xD800..0xDBFF");
+ }
+ if (!Char::IsLowSurrogate(charUnknownLow))
+ {
+ throw ArgumentOutOfRangeException("charUnknownLow",
+ "Argument out of range 0xDC00..0xDFFF");
+ }
+ Contract::EndContractBlock();
+
+ this->charUnknownHigh = charUnknownHigh;
+ this->charUnknownLow = charUnknownLow;
+ this->index = index;
+ }
+
+ WCHAR GetCharUnknown()
+ {
+ return (charUnknown);
+ }
+
+ WCHAR GetCharUnknownHigh()
+ {
+ return (charUnknownHigh);
+ }
- //
- // End of sequence. Advance the output counter.
- //
- cchWC++;
+ WCHAR GetCharUnknownLow()
+ {
+ return (charUnknownLow);
+ }
+
+ int GetIndex()
+ {
+ return index;
+ }
+
+ // Return true if the unknown character is a surrogate pair.
+ bool IsUnknownSurrogate()
+ {
+ return (charUnknownHigh != '\0');
+ }
+};
+
+class EncoderFallbackBuffer;
+
+class EncoderFallback
+{
+public:
+
+ // Fallback
+ //
+ // Return the appropriate unicode string alternative to the character that need to fall back.
+
+ virtual EncoderFallbackBuffer* CreateFallbackBuffer() = 0;
+
+ // Maximum number of characters that this instance of this fallback could return
+ virtual int GetMaxCharCount() = 0;
+};
+
+class EncoderReplacementFallback : public EncoderFallback
+{
+ // Our variables
+ WCHAR strDefault[2];
+ int strDefaultLength;
+
+public:
+ // Construction. Default replacement fallback uses no best fit and ? replacement string
+ EncoderReplacementFallback() : EncoderReplacementFallback(W("?"))
+ {
+ }
+
+ EncoderReplacementFallback(const WCHAR* replacement)
+ {
+ // Must not be null
+ if (replacement == nullptr)
+ throw ArgumentNullException("replacement");
+ Contract::EndContractBlock();
+
+ // Make sure it doesn't have bad surrogate pairs
+ bool bFoundHigh = false;
+ int replacementLength = PAL_wcslen((const WCHAR *)replacement);
+ for (int i = 0; i < replacementLength; i++)
+ {
+ // Found a surrogate?
+ if (Char::IsSurrogate(replacement, i))
+ {
+ // High or Low?
+ if (Char::IsHighSurrogate(replacement, i))
+ {
+ // if already had a high one, stop
+ if (bFoundHigh)
+ break; // break & throw at the bFoundHIgh below
+ bFoundHigh = true;
+ }
+ else
+ {
+ // Low, did we have a high?
+ if (!bFoundHigh)
+ {
+ // Didn't have one, make if fail when we stop
+ bFoundHigh = true;
+ break;
}
-
+
+ // Clear flag
+ bFoundHigh = false;
}
+ }
+ // If last was high we're in trouble (not surrogate so not low surrogate, so break)
+ else if (bFoundHigh)
+ break;
+ }
+ if (bFoundHigh)
+ throw ArgumentException("String 'replacement' contains invalid Unicode code points.", "replacement");
+
+ wcscpy_s(strDefault, sizeof(strDefault), replacement);
+ strDefaultLength = replacementLength;
+ }
+
+ WCHAR* GetDefaultString()
+ {
+ return strDefault;
+ }
+
+ virtual EncoderFallbackBuffer* CreateFallbackBuffer();
+
+ // Maximum number of characters that this instance of this fallback could return
+ virtual int GetMaxCharCount()
+ {
+ return strDefaultLength;
+ }
+};
+
+class EncoderFallbackBuffer
+{
+ friend class UTF8Encoding;
+ // Most implementations will probably need an implemenation-specific constructor
+
+ // Public methods that cannot be overriden that let us do our fallback thing
+ // These wrap the internal methods so that we can check for people doing stuff that is incorrect
+
+public:
+ virtual bool Fallback(WCHAR charUnknown, int index) = 0;
+
+ virtual bool Fallback(WCHAR charUnknownHigh, WCHAR charUnknownLow, int index) = 0;
+
+ // Get next character
+ virtual WCHAR GetNextChar() = 0;
+
+ // Back up a character
+ virtual bool MovePrevious() = 0;
+
+ // How many chars left in this fallback?
+ virtual int GetRemaining() = 0;
+
+ // Not sure if this should be public or not.
+ // Clear the buffer
+ virtual void Reset()
+ {
+ while (GetNextChar() != (WCHAR)0);
+ }
+
+ // Internal items to help us figure out what we're doing as far as error messages, etc.
+ // These help us with our performance and messages internally
+protected:
+ WCHAR* charStart;
+ WCHAR* charEnd;
+ bool setEncoder;
+ bool bUsedEncoder;
+ bool bFallingBack = false;
+ int iRecursionCount = 0;
+ static const int iMaxRecursion = 250;
+
+ // Internal Reset
+ // For example, what if someone fails a conversion and wants to reset one of our fallback buffers?
+ void InternalReset()
+ {
+ charStart = nullptr;
+ bFallingBack = false;
+ iRecursionCount = 0;
+ Reset();
+ }
+
+ // Set the above values
+ // This can't be part of the constructor because EncoderFallbacks would have to know how to impliment these.
+ void InternalInitialize(WCHAR* charStart, WCHAR* charEnd, bool setEncoder)
+ {
+ this->charStart = charStart;
+ this->charEnd = charEnd;
+ this->setEncoder = setEncoder;
+ this->bUsedEncoder = false;
+ this->bFallingBack = false;
+ this->iRecursionCount = 0;
+ }
+
+ WCHAR InternalGetNextChar()
+ {
+ WCHAR ch = GetNextChar();
+ bFallingBack = (ch != 0);
+ if (ch == 0) iRecursionCount = 0;
+ return ch;
+ }
+
+ // Fallback the current character using the remaining buffer and encoder if necessary
+ // This can only be called by our encodings (other have to use the public fallback methods), so
+ // we can use our EncoderNLS here too.
+ // setEncoder is true if we're calling from a GetBytes method, false if we're calling from a GetByteCount
+ //
+ // Note that this could also change the contents of this->encoder, which is the same
+ // object that the caller is using, so the caller could mess up the encoder for us
+ // if they aren't careful.
+ virtual bool InternalFallback(WCHAR ch, WCHAR** chars)
+ {
+ // Shouldn't have null charStart
+ Contract::Assert(charStart != nullptr,
+ "[EncoderFallback.InternalFallbackBuffer]Fallback buffer is not initialized");
+
+ // Get our index, remember chars was preincremented to point at next char, so have to -1
+ int index = (int)(*chars - charStart) - 1;
+ // See if it was a high surrogate
+ if (Char::IsHighSurrogate(ch))
+ {
+ // See if there's a low surrogate to go with it
+ if (*chars >= this->charEnd)
+ {
+ // Nothing left in input buffer
+ // No input, return 0
}
else
{
- if (bCheckInvalidBytes)
+ // Might have a low surrogate
+ WCHAR cNext = **chars;
+ if (Char::IsLowSurrogate(cNext))
{
- SetLastError(ERROR_NO_UNICODE_TRANSLATION);
- return (0);
+ // If already falling back then fail
+ if (bFallingBack && iRecursionCount++ > iMaxRecursion)
+ ThrowLastCharRecursive(ch, cNext);
+
+ // Next is a surrogate, add it as surrogate pair, and increment chars
+ (*chars)++;
+ bFallingBack = Fallback(ch, cNext, index);
+ return bFallingBack;
}
-
- // error - not expecting a trail byte. That is, there is a trailing byte without leading byte.
- bSurrogatePair = FALSE;
+
+ // Next isn't a low surrogate, just fallback the high surrogate
+ }
+ }
+
+ // If already falling back then fail
+ if (bFallingBack && iRecursionCount++ > iMaxRecursion)
+ ThrowLastCharRecursive((int)ch);
+
+ // Fall back our char
+ bFallingBack = Fallback(ch, index);
+
+ return bFallingBack;
+ }
+
+ // private helper methods
+ void ThrowLastCharRecursive(WCHAR highSurrogate, WCHAR lowSurrogate)
+ {
+ // Throw it, using our complete character
+ throw ArgumentException("Recursive fallback not allowed", "chars");
+ }
+
+ void ThrowLastCharRecursive(int utf32Char)
+ {
+ throw ArgumentException("Recursive fallback not allowed", "chars");
+ }
+
+};
+
+class EncoderReplacementFallbackBuffer : public EncoderFallbackBuffer
+{
+ // Store our default string
+ WCHAR strDefault[4];
+ int strDefaultLength;
+ int fallbackCount = -1;
+ int fallbackIndex = -1;
+public:
+ // Construction
+ EncoderReplacementFallbackBuffer(EncoderReplacementFallback* fallback)
+ {
+ // 2X in case we're a surrogate pair
+ wcscpy_s(strDefault, sizeof(strDefault), fallback->GetDefaultString());
+ wcscat_s(strDefault, sizeof(strDefault), fallback->GetDefaultString());
+ strDefaultLength = 2 * PAL_wcslen((const WCHAR *)fallback->GetDefaultString());
+
+ }
+
+ // Fallback Methods
+ virtual bool Fallback(WCHAR charUnknown, int index)
+ {
+ // If we had a buffer already we're being recursive, throw, it's probably at the suspect
+ // character in our array.
+ if (fallbackCount >= 1)
+ {
+ // If we're recursive we may still have something in our buffer that makes this a surrogate
+ if (Char::IsHighSurrogate(charUnknown) && fallbackCount >= 0 &&
+ Char::IsLowSurrogate(strDefault[fallbackIndex + 1]))
+ ThrowLastCharRecursive(charUnknown, strDefault[fallbackIndex + 1]);
+
+ // Nope, just one character
+ ThrowLastCharRecursive((int)charUnknown);
+ }
+
+ // Go ahead and get our fallback
+ // Divide by 2 because we aren't a surrogate pair
+ fallbackCount = strDefaultLength / 2;
+ fallbackIndex = -1;
+
+ return fallbackCount != 0;
+ }
+
+ virtual bool Fallback(WCHAR charUnknownHigh, WCHAR charUnknownLow, int index)
+ {
+ // Double check input surrogate pair
+ if (!Char::IsHighSurrogate(charUnknownHigh))
+ throw ArgumentOutOfRangeException("charUnknownHigh",
+ "Argument out of range 0xD800..0xDBFF");
+
+ if (!Char::IsLowSurrogate(charUnknownLow))
+ throw ArgumentOutOfRangeException("charUnknownLow",
+ "Argument out of range 0xDC00..0xDFFF");
+ Contract::EndContractBlock();
+
+ // If we had a buffer already we're being recursive, throw, it's probably at the suspect
+ // character in our array.
+ if (fallbackCount >= 1)
+ ThrowLastCharRecursive(charUnknownHigh, charUnknownLow);
+
+ // Go ahead and get our fallback
+ fallbackCount = strDefaultLength;
+ fallbackIndex = -1;
+
+ return fallbackCount != 0;
+ }
+
+ virtual WCHAR GetNextChar()
+ {
+ // We want it to get < 0 because == 0 means that the current/last character is a fallback
+ // and we need to detect recursion. We could have a flag but we already have this counter.
+ fallbackCount--;
+ fallbackIndex++;
+
+ // Do we have anything left? 0 is now last fallback char, negative is nothing left
+ if (fallbackCount < 0)
+ return '\0';
+
+ // Need to get it out of the buffer.
+ // Make sure it didn't wrap from the fast count-- path
+ if (fallbackCount == INT_MAX)
+ {
+ fallbackCount = -1;
+ return '\0';
+ }
+
+ // Now make sure its in the expected range
+ Contract::Assert(fallbackIndex < strDefaultLength && fallbackIndex >= 0,
+ "Index exceeds buffer range");
+
+ return strDefault[fallbackIndex];
+ }
+
+ virtual bool MovePrevious()
+ {
+ // Back up one, only if we just processed the last character (or earlier)
+ if (fallbackCount >= -1 && fallbackIndex >= 0)
+ {
+ fallbackIndex--;
+ fallbackCount++;
+ return true;
+ }
+
+ // Return false 'cause we couldn't do it.
+ return false;
+ }
+
+ // How many characters left to output?
+ virtual int GetRemaining()
+ {
+ // Our count is 0 for 1 character left.
+ return (fallbackCount < 0) ? 0 : fallbackCount;
+ }
+
+ // Clear the buffer
+ virtual void Reset()
+ {
+ fallbackCount = -1;
+ fallbackIndex = 0;
+ charStart = nullptr;
+ bFallingBack = false;
+ }
+};
+
+class EncoderExceptionFallbackBuffer : public EncoderFallbackBuffer
+{
+public:
+ EncoderExceptionFallbackBuffer()
+ {
+ }
+
+ virtual bool Fallback(WCHAR charUnknown, int index)
+ {
+ // Fall back our char
+ throw EncoderFallbackException("Unable to translate Unicode character to UTF-8", charUnknown, index);
+ }
+
+ virtual bool Fallback(WCHAR charUnknownHigh, WCHAR charUnknownLow, int index)
+ {
+ if (!Char::IsHighSurrogate(charUnknownHigh))
+ {
+ throw ArgumentOutOfRangeException("charUnknownHigh",
+ "Argument out of range 0xD800..0xDBFF");
+ }
+ if (!Char::IsLowSurrogate(charUnknownLow))
+ {
+ throw ArgumentOutOfRangeException("charUnknownLow",
+ "Argument out of range 0xDC00..0xDFFF");
+ }
+ Contract::EndContractBlock();
+
+ //int iTemp = Char::ConvertToUtf32(charUnknownHigh, charUnknownLow);
+
+ // Fall back our char
+ throw EncoderFallbackException(
+ "Unable to translate Unicode character to UTF-8", charUnknownHigh, charUnknownLow, index);
+ }
+
+ virtual WCHAR GetNextChar()
+ {
+ return 0;
+ }
+
+ virtual bool MovePrevious()
+ {
+ // Exception fallback doesn't have anywhere to back up to.
+ return false;
+ }
+
+ // Exceptions are always empty
+ virtual int GetRemaining()
+ {
+ return 0;
+ }
+};
+
+class EncoderExceptionFallback : public EncoderFallback
+{
+ // Construction
+public:
+ EncoderExceptionFallback()
+ {
+ }
+
+ virtual EncoderFallbackBuffer* CreateFallbackBuffer()
+ {
+ return new EncoderExceptionFallbackBuffer();
+ }
+
+ // Maximum number of characters that this instance of this fallback could return
+ virtual int GetMaxCharCount()
+ {
+ return 0;
+ }
+};
+
+EncoderFallbackBuffer* EncoderReplacementFallback::CreateFallbackBuffer()
+{
+ return new EncoderReplacementFallbackBuffer(this);
+}
+
+class UTF8Encoding
+{
+ EncoderFallback* encoderFallback;
+ // Instances of the two possible fallbacks. The constructor parameter
+ // determines which one to use.
+ EncoderReplacementFallback encoderReplacementFallback;
+ EncoderExceptionFallback encoderExceptionFallback;
+
+ DecoderFallback* decoderFallback;
+ // Instances of the two possible fallbacks. The constructor parameter
+ // determines which one to use.
+ DecoderReplacementFallback decoderReplacementFallback;
+ DecoderExceptionFallback decoderExceptionFallback;
+
+ bool InRange(WCHAR c, WCHAR begin, WCHAR end)
+ {
+ return begin <= c && c <= end;
+ }
+
+ size_t PtrDiff(void* ptr1, void* ptr2)
+ {
+ return (BYTE*)ptr2 - (BYTE*)ptr1;
+ }
+
+ void ThrowBytesOverflow()
+ {
+ // Special message to include fallback type in case fallback's GetMaxCharCount is broken
+ // This happens if user has implimented an encoder fallback with a broken GetMaxCharCount
+ throw InsufficientBufferException("The output byte buffer is too small to contain the encoded data", "bytes");
+ }
+
+ void ThrowBytesOverflow(bool nothingEncoded)
+ {
+ // Special message to include fallback type in case fallback's GetMaxCharCount is broken
+ // This happens if user has implimented an encoder fallback with a broken GetMaxCharCount
+ if (nothingEncoded){
+ ThrowBytesOverflow();
+ }
+ }
+
+ void ThrowCharsOverflow()
+ {
+ // Special message to include fallback type in case fallback's GetMaxCharCount is broken
+ // This happens if user has implimented a decoder fallback with a broken GetMaxCharCount
+ throw InsufficientBufferException("The output char buffer is too small to contain the encoded data", "chars");
+ }
+
+ void ThrowCharsOverflow(bool nothingEncoded)
+ {
+ // Special message to include fallback type in case fallback's GetMaxCharCount is broken
+ // This happens if user has implimented an decoder fallback with a broken GetMaxCharCount
+ if (nothingEncoded){
+ ThrowCharsOverflow();
+ }
+ }
+
+ int FallbackInvalidByteSequence(BYTE* pSrc, int ch, DecoderFallbackBuffer *fallback)
+ {
+ // Get our byte[]
+ BYTE *bytesUnknown;
+ int size = GetBytesUnknown(pSrc, ch, &bytesUnknown);
+
+ // Do the actual fallback
+ int count = fallback->InternalFallback(bytesUnknown, pSrc, size);
+
+ // # of fallback chars expected.
+ // Note that we only get here for "long" sequences, and have already unreserved
+ // the count that we prereserved for the input bytes
+ return count;
+ }
+
+ int GetBytesUnknown(BYTE* pSrc, int ch, BYTE **bytesUnknown)
+ {
+ int size;
+ BYTE bytes[3];
+
+ // See if it was a plain char
+ // (have to check >= 0 because we have all sorts of wierd bit flags)
+ if (ch < 0x100 && ch >= 0)
+ {
+ pSrc--;
+ bytes[0] = (BYTE)ch;
+ size = 1;
+ }
+ // See if its an unfinished 2 byte sequence
+ else if ((ch & (SupplimentarySeq | ThreeByteSeq)) == 0)
+ {
+ pSrc--;
+ bytes[0] = (BYTE)((ch & 0x1F) | 0xc0);
+ size = 1;
+ }
+ // So now we're either 2nd byte of 3 or 4 byte sequence or
+ // we hit a non-trail byte or we ran out of space for 3rd byte of 4 byte sequence
+ // 1st check if its a 4 byte sequence
+ else if ((ch & SupplimentarySeq) != 0)
+ {
+ // 3rd byte of 4 byte sequence?
+ if ((ch & (FinalByte >> 6)) != 0)
+ {
+ // 3rd byte of 4 byte sequence
+ pSrc -= 3;
+ bytes[0] = (BYTE)(((ch >> 12) & 0x07) | 0xF0);
+ bytes[1] = (BYTE)(((ch >> 6) & 0x3F) | 0x80);
+ bytes[2] = (BYTE)(((ch)& 0x3F) | 0x80);
+ size = 3;
+ }
+ else if ((ch & (FinalByte >> 12)) != 0)
+ {
+ // 2nd byte of a 4 byte sequence
+ pSrc -= 2;
+ bytes[0] = (BYTE)(((ch >> 6) & 0x07) | 0xF0);
+ bytes[1] = (BYTE)(((ch)& 0x3F) | 0x80);
+ size = 2;
+ }
+ else
+ {
+ // 4th byte of a 4 byte sequence
+ pSrc--;
+ bytes[0] = (BYTE)(((ch)& 0x07) | 0xF0);
+ size = 1;
}
}
else
{
- //
- // Found a lead byte.
- //
- if (nTB > 0)
+ // 2nd byte of 3 byte sequence?
+ if ((ch & (FinalByte >> 6)) != 0)
{
- // error - A leading byte before the previous sequence is completed.
- if (bCheckInvalidBytes)
- {
- SetLastError(ERROR_NO_UNICODE_TRANSLATION);
- return (0);
- }
- //
- // Error - previous sequence not finished.
- //
- nTB = 0;
- bSurrogatePair = FALSE;
- // Put this character back so that we can start over another sequence.
- cchSrc++;
- pUTF8--;
+ // So its 2nd byte of a 3 byte sequence
+ pSrc -= 2;
+ bytes[0] = (BYTE)(((ch >> 6) & 0x0F) | 0xE0);
+ bytes[1] = (BYTE)(((ch)& 0x3F) | 0x80);
+ size = 2;
}
else
{
- //
- // Calculate the number of bytes to follow.
- // Look for the first 0 from left to right.
- //
- UTF8 = *pUTF8;
- while (BIT7(UTF8) != 0)
- {
- UTF8 <<= 1;
- nTB++;
+ // 1st byte of a 3 byte sequence
+ pSrc--;
+ bytes[0] = (BYTE)(((ch)& 0x0F) | 0xE0);
+ size = 1;
+ }
+ }
+
+ *bytesUnknown = bytes;
+ return size;
+ }
+
+public:
+
+ UTF8Encoding(bool isThrowException)
+ : encoderReplacementFallback(W("\xFFFD"))
+ {
+ if (isThrowException)
+ {
+ encoderFallback = &encoderExceptionFallback;
+ decoderFallback = &decoderExceptionFallback;
+ }
+ else
+ {
+ encoderFallback = &encoderReplacementFallback;
+ decoderFallback = &decoderReplacementFallback;
+ }
+ }
+
+ // These are bitmasks used to maintain the state in the decoder. They occupy the higher bits
+ // while the actual character is being built in the lower bits. They are shifted together
+ // with the actual bits of the character.
+
+ // bits 30 & 31 are used for pending bits fixup
+ const int FinalByte = 1 << 29;
+ const int SupplimentarySeq = 1 << 28;
+ const int ThreeByteSeq = 1 << 27;
+
+ int GetCharCount(BYTE* bytes, int count)
+ {
+ Contract::Assert(bytes != nullptr, "[UTF8Encoding.GetCharCount]bytes!=nullptr");
+ Contract::Assert(count >= 0, "[UTF8Encoding.GetCharCount]count >=0");
+
+ // Initialize stuff
+ BYTE *pSrc = bytes;
+ BYTE *pEnd = pSrc + count;
+
+ // Start by assuming we have as many as count, charCount always includes the adjustment
+ // for the character being decoded
+ int charCount = count;
+ int ch = 0;
+ DecoderFallbackBuffer *fallback = nullptr;
+
+ for (;;)
+ {
+ // SLOWLOOP: does all range checks, handles all special cases, but it is slow
+ if (pSrc >= pEnd) {
+ break;
+ }
+
+ // read next byte. The JIT optimization seems to be getting confused when
+ // compiling "ch = *pSrc++;", so rather use "ch = *pSrc; pSrc++;" instead
+ int cha = *pSrc;
+
+ if (ch == 0) {
+ // no pending bits
+ goto ReadChar;
+ }
+
+ pSrc++;
+
+ // we are expecting to see trailing bytes like 10vvvvvv
+ if ((cha & 0xC0) != 0x80) {
+ // This can be a valid starting byte for another UTF8 byte sequence, so let's put
+ // the current byte back, and try to see if this is a valid byte for another UTF8 byte sequence
+ pSrc--;
+ charCount += (ch >> 30);
+ goto InvalidByteSequence;
+ }
+
+ // fold in the new byte
+ ch = (ch << 6) | (cha & 0x3F);
+
+ if ((ch & FinalByte) == 0) {
+ Contract::Assert((ch & (SupplimentarySeq | ThreeByteSeq)) != 0,
+ "[UTF8Encoding.GetChars]Invariant volation");
+
+ if ((ch & SupplimentarySeq) != 0) {
+ if ((ch & (FinalByte >> 6)) != 0) {
+ // this is 3rd byte (of 4 byte supplimentary) - nothing to do
+ continue;
+ }
+
+ // 2nd byte, check for non-shortest form of supplimentary char and the valid
+ // supplimentary characters in range 0x010000 - 0x10FFFF at the same time
+ if (!InRange(ch & 0x1F0, 0x10, 0x100)) {
+ goto InvalidByteSequence;
+ }
+ }
+ else {
+ // Must be 2nd byte of a 3-byte sequence
+ // check for non-shortest form of 3 byte seq
+ if ((ch & (0x1F << 5)) == 0 || // non-shortest form
+ (ch & (0xF800 >> 6)) == (0xD800 >> 6)) // illegal individually encoded surrogate
+ {
+ goto InvalidByteSequence;
+ }
}
+ continue;
+ }
- // Recover the data from the byte
- UTF8 >>= nTB;
+ // ready to punch
- //
- // Check for non-shortest form.
- //
- switch (nTB)
- {
- case 1:
- nTB = 0;
- break;
- case 2:
- // Make sure that bit 8 ~ bit 11 is not all zero.
- // 110XXXXx 10xxxxxx
- if ((*pUTF8 & 0x1e) == 0)
- {
- nTB = 0;
+ // adjust for surrogates in non-shortest form
+ if ((ch & (SupplimentarySeq | 0x1F0000)) == SupplimentarySeq) {
+ charCount--;
+ }
+ goto EncodeChar;
+
+ InvalidByteSequence:
+ // this code fragment should be close to the gotos referencing it
+ // Have to do fallback for invalid bytes
+ if (fallback == nullptr)
+ {
+ fallback = decoderFallback->CreateFallbackBuffer();
+ fallback->InternalInitialize(bytes, nullptr);
+ }
+ charCount += FallbackInvalidByteSequence(pSrc, ch, fallback);
+
+ ch = 0;
+ continue;
+
+ ReadChar:
+ ch = *pSrc;
+ pSrc++;
+
+ ProcessChar:
+ if (ch > 0x7F) {
+ // If its > 0x7F, its start of a new multi-byte sequence
+
+ // Long sequence, so unreserve our char.
+ charCount--;
+
+ // bit 6 has to be non-zero for start of multibyte chars.
+ if ((ch & 0x40) == 0) {
+ // Unexpected trail byte
+ goto InvalidByteSequence;
+ }
+
+ // start a new long code
+ if ((ch & 0x20) != 0) {
+ if ((ch & 0x10) != 0) {
+ // 4 byte encoding - supplimentary character (2 surrogates)
+
+ ch &= 0x0F;
+
+ // check that bit 4 is zero and the valid supplimentary character
+ // range 0x000000 - 0x10FFFF at the same time
+ if (ch > 0x04) {
+ ch |= 0xf0;
+ goto InvalidByteSequence;
}
+
+ // Add bit flags so that when we check new characters & rotate we'll be flagged correctly.
+ // Final byte flag, count fix if we don't make final byte & supplimentary sequence flag.
+ ch |= (FinalByte >> 3 * 6) | // Final byte is 3 more bytes from now
+ (1 << 30) | // If it dies on next byte we'll need an extra char
+ (3 << (30 - 2 * 6)) | // If it dies on last byte we'll need to subtract a char
+ (SupplimentarySeq) | (SupplimentarySeq >> 6) |
+ (SupplimentarySeq >> 2 * 6) | (SupplimentarySeq >> 3 * 6);
+
+ // Our character count will be 2 characters for these 4 bytes, so subtract another char
+ charCount--;
+ }
+ else {
+ // 3 byte encoding
+ // Add bit flags so that when we check new characters & rotate we'll be flagged correctly.
+ ch = (ch & 0x0F) | ((FinalByte >> 2 * 6) | (1 << 30) |
+ (ThreeByteSeq) | (ThreeByteSeq >> 6) | (ThreeByteSeq >> 2 * 6));
+
+ // We'll expect 1 character for these 3 bytes, so subtract another char.
+ charCount--;
+ }
+ }
+ else {
+ // 2 byte encoding
+
+ ch &= 0x1F;
+
+ // check for non-shortest form
+ if (ch <= 1) {
+ ch |= 0xc0;
+ goto InvalidByteSequence;
+ }
+
+ // Add bit flags so we'll be flagged correctly
+ ch |= (FinalByte >> 6);
+ }
+ continue;
+ }
+
+ EncodeChar:
+
+#ifdef FASTLOOP
+ int availableBytes = PtrDiff(pEnd, pSrc);
+
+ // don't fall into the fast decoding loop if we don't have enough bytes
+ if (availableBytes <= 13) {
+ // try to get over the remainder of the ascii characters fast though
+ BYTE* pLocalEnd = pEnd; // hint to get pLocalEnd enregistered
+ while (pSrc < pLocalEnd) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F)
+ goto ProcessChar;
+ }
+ // we are done
+ ch = 0;
+ break;
+ }
+
+ // To compute the upper bound, assume that all characters are ASCII characters at this point,
+ // the boundary will be decreased for every non-ASCII character we encounter
+ // Also, we need 7 chars reserve for the unrolled ansi decoding loop and for decoding of multibyte sequences
+ BYTE *pStop = pSrc + availableBytes - 7;
+
+ while (pSrc < pStop) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+
+ // get pSrc 2-byte aligned
+ if (((int)pSrc & 0x1) != 0) {
+ ch = *pSrc;
+ pSrc++;
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ }
+
+ // get pSrc 4-byte aligned
+ if (((int)pSrc & 0x2) != 0) {
+ ch = *(USHORT*)pSrc;
+ if ((ch & 0x8080) != 0) {
+ goto LongCodeWithMask16;
+ }
+ pSrc += 2;
+ }
+
+
+ // Run 8 + 8 characters at a time!
+ while (pSrc < pStop) {
+ ch = *(int*)pSrc;
+ int chb = *(int*)(pSrc + 4);
+ if (((ch | chb) & (int)0x80808080) != 0) {
+ goto LongCodeWithMask32;
+ }
+ pSrc += 8;
+
+ // This is a really small loop - unroll it
+ if (pSrc >= pStop)
break;
- case 3:
- // Look ahead to check for non-shortest form.
- // 1110XXXX 10Xxxxxx 10xxxxxx
- if (cchSrc >= 2)
+
+ ch = *(int*)pSrc;
+ chb = *(int*)(pSrc + 4);
+ if (((ch | chb) & (int)0x80808080) != 0) {
+ goto LongCodeWithMask32;
+ }
+ pSrc += 8;
+ }
+ break;
+
+#if BIGENDIAN
+ LongCodeWithMask32 :
+ // be careful about the sign extension
+ ch = (int)(((uint)ch) >> 16);
+ LongCodeWithMask16:
+ ch = (int)(((uint)ch) >> 8);
+#else // BIGENDIAN
+ LongCodeWithMask32:
+ LongCodeWithMask16:
+ ch &= 0xFF;
+#endif // BIGENDIAN
+ pSrc++;
+ if (ch <= 0x7F) {
+ continue;
+ }
+
+ LongCode:
+ int chc = *pSrc;
+ pSrc++;
+
+ if (
+ // bit 6 has to be zero
+ (ch & 0x40) == 0 ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (chc & 0xC0) != 0x80)
+ {
+ goto BadLongCode;
+ }
+
+ chc &= 0x3F;
+
+ // start a new long code
+ if ((ch & 0x20) != 0) {
+
+ // fold the first two bytes together
+ chc |= (ch & 0x0F) << 6;
+
+ if ((ch & 0x10) != 0) {
+ // 4 byte encoding - surrogate
+ ch = *pSrc;
+ if (
+ // check that bit 4 is zero, the non-shortest form of surrogate
+ // and the valid surrogate range 0x000000 - 0x10FFFF at the same time
+ !InRange(chc >> 4, 0x01, 0x10) ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (ch & 0xC0) != 0x80)
{
- if (((*pUTF8 & 0x0f) == 0) && (*(pUTF8 + 1) & 0x20) == 0)
- {
- nTB = 0;
- }
+ goto BadLongCode;
}
- break;
- case 4:
- //
- // This is a surrogate unicode pair
- //
- if (cchSrc >= 3)
+
+ chc = (chc << 6) | (ch & 0x3F);
+
+ ch = *(pSrc + 1);
+ // we are expecting to see trailing bytes like 10vvvvvv
+ if ((ch & 0xC0) != 0x80) {
+ goto BadLongCode;
+ }
+ pSrc += 2;
+
+ // extra byte
+ charCount--;
+ }
+ else {
+ // 3 byte encoding
+ ch = *pSrc;
+ if (
+ // check for non-shortest form of 3 byte seq
+ (chc & (0x1F << 5)) == 0 ||
+ // Can't have surrogates here.
+ (chc & (0xF800 >> 6)) == (0xD800 >> 6) ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (ch & 0xC0) != 0x80)
{
- WORD word = (((WORD)*pUTF8) << 8) | *(pUTF8 + 1);
- // Look ahead to check for non-shortest form.
- // 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx
- // Check if the 5 X bits are all zero.
- // 0x0730 == 00000111 00110000
- if ( (word & 0x0730) == 0 ||
- // If the 21st bit is 1, we have extra work
- ( (word & 0x0400) == 0x0400 &&
- // The 21st bit is 1.
- // Make sure that the resulting Unicode is within the valid surrogate range.
- // The 4 byte code sequence can hold up to 21 bits, and the maximum valid code point range
- // that Unicode (with surrogate) could represent are from U+000000 ~ U+10FFFF.
- // Therefore, if the 21 bit (the most significant bit) is 1, we should verify that the 17 ~ 20
- // bit are all zero.
- // I.e., in 11110XXX 10XXxxxx 10xxxxxx 10xxxxxx,
- // XXXXX can only be 10000.
- // 0x0330 = 0000 0011 0011 0000
- (word & 0x0330) != 0 ) )
- {
- // Not shortest form
- nTB = 0;
- }
- else
- {
- // A real surrogate pair
- bSurrogatePair = TRUE;
- }
- }
- break;
- default:
- //
- // If the bits is greater than 4, this is an invalid
- // UTF8 lead byte.
- //
- nTB = 0;
- break;
+ goto BadLongCode;
+ }
+ pSrc++;
+
+ // extra byte
+ charCount--;
+ }
}
+ else {
+ // 2 byte encoding
- if (nTB != 0)
- {
- //
- // Store the value from the first byte and decrement
- // the number of bytes to follow.
- //
- dwUnicodeChar = UTF8;
- nTB--;
- } else
- {
- if (bCheckInvalidBytes)
- {
- SetLastError(ERROR_NO_UNICODE_TRANSLATION);
- return (0);
+ // check for non-shortest form
+ if ((ch & 0x1E) == 0) {
+ goto BadLongCode;
}
}
+
+ // extra byte
+ charCount--;
}
+#endif // FASTLOOP
+
+ // no pending bits at this point
+ ch = 0;
+ continue;
+
+ BadLongCode:
+ pSrc -= 2;
+ ch = 0;
+ continue;
}
- pUTF8++;
- }
- if ((bCheckInvalidBytes && nTB != 0) || (cchWC == 0))
- {
- // About (cchWC == 0):
- // Because we now throw away non-shortest form, it is possible that we generate 0 chars.
- // In this case, we have to set error to ERROR_NO_UNICODE_TRANSLATION so that we conform
- // to the spec of MultiByteToWideChar.
- SetLastError(ERROR_NO_UNICODE_TRANSLATION);
- return (0);
+ // May have a problem if we have to flush
+ if (ch != 0)
+ {
+ // We were already adjusting for these, so need to unadjust
+ charCount += (ch >> 30);
+ // Have to do fallback for invalid bytes
+ if (fallback == nullptr)
+ {
+ fallback = decoderFallback->CreateFallbackBuffer();
+ fallback->InternalInitialize(bytes, nullptr);
+ }
+ charCount += FallbackInvalidByteSequence(pSrc, ch, fallback);
+ }
+
+ // Shouldn't have anything in fallback buffer for GetCharCount
+ // (don't have to check m_throwOnOverflow for count)
+ Contract::Assert(fallback == nullptr || fallback->GetRemaining() == 0,
+ "[UTF8Encoding.GetCharCount]Expected empty fallback buffer at end");
+
+ return charCount;
+
}
- //
- // Return the number of Unicode characters written.
- //
- return (cchWC);
-}
+ int GetChars(BYTE* bytes, int byteCount, WCHAR* chars, int charCount)
+ {
+ Contract::Assert(chars != nullptr, "[UTF8Encoding.GetChars]chars!=nullptr");
+ Contract::Assert(byteCount >= 0, "[UTF8Encoding.GetChars]byteCount >=0");
+ Contract::Assert(charCount >= 0, "[UTF8Encoding.GetChars]charCount >=0");
+ Contract::Assert(bytes != nullptr, "[UTF8Encoding.GetChars]bytes!=nullptr");
-////////////////////////////////////////////////////////////////////////////
-//
-// UnicodeToUTF8
-//
-// Maps a Unicode character string to its UTF-8 string counterpart.
-//
-////////////////////////////////////////////////////////////////////////////
+ BYTE *pSrc = bytes;
+ WCHAR *pTarget = chars;
-int UnicodeToUTF8(
- LPCWSTR lpSrcStr,
- int cchSrc,
- LPSTR lpDestStr,
- int cchDest)
-{
- LPCWSTR lpWC = lpSrcStr;
- int cchU8 = 0; // # of UTF8 chars generated
- DWORD dwSurrogateChar;
- WCHAR wchHighSurrogate = 0;
- BOOL bHandled;
+ BYTE *pEnd = pSrc + byteCount;
+ WCHAR *pAllocatedBufferEnd = pTarget + charCount;
+ int ch = 0;
- while ((cchSrc--) && ((cchDest == 0) || (cchU8 < cchDest)))
- {
- bHandled = FALSE;
+ DecoderFallbackBuffer *fallback = nullptr;
- //
- // Check if high surrogate is available
- //
- if ((*lpWC >= HIGH_SURROGATE_START) && (*lpWC <= HIGH_SURROGATE_END))
+ for (;;)
{
- if (cchDest)
- {
- // Another high surrogate, then treat the 1st as normal
- // Unicode character.
- if (wchHighSurrogate)
- {
- if ((cchU8 + 2) < cchDest)
- {
- lpDestStr[cchU8++] = UTF8_1ST_OF_3 | HIGHER_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | MIDDLE_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | LOWER_6_BIT(wchHighSurrogate);
+ // SLOWLOOP: does all range checks, handles all special cases, but it is slow
+
+ if (pSrc >= pEnd) {
+ break;
+ }
+
+ // read next byte. The JIT optimization seems to be getting confused when
+ // compiling "ch = *pSrc++;", so rather use "ch = *pSrc; pSrc++;" instead
+ int cha = *pSrc;
+
+ if (ch == 0) {
+ // no pending bits
+ goto ReadChar;
+ }
+
+ pSrc++;
+
+ // we are expecting to see trailing bytes like 10vvvvvv
+ if ((cha & 0xC0) != 0x80) {
+ // This can be a valid starting byte for another UTF8 byte sequence, so let's put
+ // the current byte back, and try to see if this is a valid byte for another UTF8 byte sequence
+ pSrc--;
+ goto InvalidByteSequence;
+ }
+
+ // fold in the new byte
+ ch = (ch << 6) | (cha & 0x3F);
+
+ if ((ch & FinalByte) == 0) {
+ // Not at last byte yet
+ Contract::Assert((ch & (SupplimentarySeq | ThreeByteSeq)) != 0,
+ "[UTF8Encoding.GetChars]Invariant volation");
+
+ if ((ch & SupplimentarySeq) != 0) {
+ // Its a 4-byte supplimentary sequence
+ if ((ch & (FinalByte >> 6)) != 0) {
+ // this is 3rd byte of 4 byte sequence - nothing to do
+ continue;
}
- else
+
+ // 2nd byte of 4 bytes
+ // check for non-shortest form of surrogate and the valid surrogate
+ // range 0x000000 - 0x10FFFF at the same time
+ if (!InRange(ch & 0x1F0, 0x10, 0x100)) {
+ goto InvalidByteSequence;
+ }
+ }
+ else {
+ // Must be 2nd byte of a 3-byte sequence
+ // check for non-shortest form of 3 byte seq
+ if ((ch & (0x1F << 5)) == 0 || // non-shortest form
+ (ch & (0xF800 >> 6)) == (0xD800 >> 6)) // illegal individually encoded surrogate
{
- // not enough buffer
- cchSrc++;
- break;
+ goto InvalidByteSequence;
}
}
+ continue;
}
- else
+
+ // ready to punch
+
+ // surrogate in shortest form?
+ // Might be possible to get rid of this? Already did non-shortest check for 4-byte sequence when reading 2nd byte?
+ if ((ch & (SupplimentarySeq | 0x1F0000)) > SupplimentarySeq) {
+ // let the range check for the second char throw the exception
+ if (pTarget < pAllocatedBufferEnd) {
+ *pTarget = (WCHAR)(((ch >> 10) & 0x7FF) +
+ (SHORT)((CharUnicodeInfo::HIGH_SURROGATE_START - (0x10000 >> 10))));
+ pTarget++;
+
+ ch = (ch & 0x3FF) +
+ (int)(CharUnicodeInfo::LOW_SURROGATE_START);
+ }
+ }
+
+ goto EncodeChar;
+
+ InvalidByteSequence:
+ // this code fragment should be close to the gotos referencing it
+ // Have to do fallback for invalid bytes
+ if (fallback == nullptr)
+ {
+ fallback = decoderFallback->CreateFallbackBuffer();
+ fallback->InternalInitialize(bytes, pAllocatedBufferEnd);
+ }
+ // This'll back us up the appropriate # of bytes if we didn't get anywhere
+ if (!FallbackInvalidByteSequence(pSrc, ch, fallback))
{
- cchU8 += 3;
+ // Ran out of buffer space
+ // Need to throw an exception?
+ Contract::Assert(pSrc >= bytes || pTarget == chars,
+ "[UTF8Encoding.GetChars]Expected to throw or remain in byte buffer after fallback");
+ fallback->InternalReset();
+ ThrowCharsOverflow(pTarget == chars);
+ ch = 0;
+ break;
+ }
+ Contract::Assert(pSrc >= bytes,
+ "[UTF8Encoding.GetChars]Expected invalid byte sequence to have remained within the byte array");
+ ch = 0;
+ continue;
+
+ ReadChar:
+ ch = *pSrc;
+ pSrc++;
+
+ ProcessChar:
+ if (ch > 0x7F) {
+ // If its > 0x7F, its start of a new multi-byte sequence
+
+ // bit 6 has to be non-zero
+ if ((ch & 0x40) == 0) {
+ goto InvalidByteSequence;
+ }
+
+ // start a new long code
+ if ((ch & 0x20) != 0) {
+ if ((ch & 0x10) != 0) {
+ // 4 byte encoding - supplimentary character (2 surrogates)
+
+ ch &= 0x0F;
+
+ // check that bit 4 is zero and the valid supplimentary character
+ // range 0x000000 - 0x10FFFF at the same time
+ if (ch > 0x04) {
+ ch |= 0xf0;
+ goto InvalidByteSequence;
+ }
+
+ ch |= (FinalByte >> 3 * 6) | (1 << 30) | (3 << (30 - 2 * 6)) |
+ (SupplimentarySeq) | (SupplimentarySeq >> 6) |
+ (SupplimentarySeq >> 2 * 6) | (SupplimentarySeq >> 3 * 6);
+ }
+ else {
+ // 3 byte encoding
+ ch = (ch & 0x0F) | ((FinalByte >> 2 * 6) | (1 << 30) |
+ (ThreeByteSeq) | (ThreeByteSeq >> 6) | (ThreeByteSeq >> 2 * 6));
+ }
+ }
+ else {
+ // 2 byte encoding
+
+ ch &= 0x1F;
+
+ // check for non-shortest form
+ if (ch <= 1) {
+ ch |= 0xc0;
+ goto InvalidByteSequence;
+ }
+
+ ch |= (FinalByte >> 6);
+ }
+ continue;
+ }
+
+ EncodeChar:
+ // write the pending character
+ if (pTarget >= pAllocatedBufferEnd)
+ {
+ // Fix chars so we make sure to throw if we didn't output anything
+ ch &= 0x1fffff;
+ if (ch > 0x7f)
+ {
+ if (ch > 0x7ff)
+ {
+ if (ch >= CharUnicodeInfo::LOW_SURROGATE_START &&
+ ch <= CharUnicodeInfo::LOW_SURROGATE_END)
+ {
+ pSrc--; // It was 4 bytes
+ pTarget--; // 1 was stored already, but we can't remember 1/2, so back up
+ }
+ else if (ch > 0xffff)
+ {
+ pSrc--; // It was 4 bytes, nothing was stored
+ }
+ pSrc--; // It was at least 3 bytes
+ }
+ pSrc--; // It was at least 2 bytes
+ }
+ pSrc--;
+
+ // Throw that we don't have enough room (pSrc could be < chars if we had started to process
+ // a 4 byte sequence alredy)
+ Contract::Assert(pSrc >= bytes || pTarget == chars,
+ "[UTF8Encoding.GetChars]Expected pSrc to be within input buffer or throw due to no output]");
+ ThrowCharsOverflow(pTarget == chars);
+
+ // Don't store ch in decoder, we already backed up to its start
+ ch = 0;
+
+ // Didn't throw, just use this buffer size.
+ break;
+ }
+ *pTarget = (WCHAR)ch;
+ pTarget++;
+
+#ifdef FASTLOOP
+ int availableChars = PtrDiff(pAllocatedBufferEnd, pTarget);
+ int availableBytes = PtrDiff(pEnd, pSrc);
+
+ // don't fall into the fast decoding loop if we don't have enough bytes
+ // Test for availableChars is done because pStop would be <= pTarget.
+ if (availableBytes <= 13) {
+ // we may need as many as 1 character per byte
+ if (availableChars < availableBytes) {
+ // not enough output room. no pending bits at this point
+ ch = 0;
+ continue;
+ }
+
+ // try to get over the remainder of the ascii characters fast though
+ BYTE* pLocalEnd = pEnd; // hint to get pLocalEnd enregistered
+ while (pSrc < pLocalEnd) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F)
+ goto ProcessChar;
+
+ *pTarget = (char)ch;
+ pTarget++;
+ }
+ // we are done
+ ch = 0;
+ break;
+ }
+
+ // we may need as many as 1 character per byte, so reduce the byte count if necessary.
+ // If availableChars is too small, pStop will be before pTarget and we won't do fast loop.
+ if (availableChars < availableBytes) {
+ availableBytes = availableChars;
+ }
+
+ // To compute the upper bound, assume that all characters are ASCII characters at this point,
+ // the boundary will be decreased for every non-ASCII character we encounter
+ // Also, we need 7 chars reserve for the unrolled ansi decoding loop and for decoding of multibyte sequences
+ WCHAR *pStop = pTarget + availableBytes - 7;
+
+ while (pTarget < pStop) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ *pTarget = (WCHAR)ch;
+ pTarget++;
+
+ // get pSrc to be 2-byte aligned
+ if ((((int)pSrc) & 0x1) != 0) {
+ ch = *pSrc;
+ pSrc++;
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ *pTarget = (char)ch;
+ pTarget++;
+ }
+
+ // get pSrc to be 4-byte aligned
+ if ((((int)pSrc) & 0x2) != 0) {
+ ch = *(USHORT*)pSrc;
+ if ((ch & 0x8080) != 0) {
+ goto LongCodeWithMask16;
+ }
+
+ // Unfortunately, this is endianess sensitive
+#if BIGENDIAN
+ *pTarget = (WCHAR)((ch >> 8) & 0x7F);
+ pSrc += 2;
+ *(pTarget + 1) = (WCHAR)(ch & 0x7F);
+ pTarget += 2;
+#else // BIGENDIAN
+ *pTarget = (WCHAR)(ch & 0x7F);
+ pSrc += 2;
+ *(pTarget + 1) = (WCHAR)((ch >> 8) & 0x7F);
+ pTarget += 2;
+#endif // BIGENDIAN
+ }
+
+ // Run 8 characters at a time!
+ while (pTarget < pStop) {
+ ch = *(int*)pSrc;
+ int chb = *(int*)(pSrc + 4);
+ if (((ch | chb) & (int)0x80808080) != 0) {
+ goto LongCodeWithMask32;
+ }
+
+ // Unfortunately, this is endianess sensitive
+#if BIGENDIAN
+ *pTarget = (WCHAR)((ch >> 24) & 0x7F);
+ *(pTarget + 1) = (WCHAR)((ch >> 16) & 0x7F);
+ *(pTarget + 2) = (WCHAR)((ch >> 8) & 0x7F);
+ *(pTarget + 3) = (WCHAR)(ch & 0x7F);
+ pSrc += 8;
+ *(pTarget + 4) = (WCHAR)((chb >> 24) & 0x7F);
+ *(pTarget + 5) = (WCHAR)((chb >> 16) & 0x7F);
+ *(pTarget + 6) = (WCHAR)((chb >> 8) & 0x7F);
+ *(pTarget + 7) = (WCHAR)(chb & 0x7F);
+ pTarget += 8;
+#else // BIGENDIAN
+ *pTarget = (WCHAR)(ch & 0x7F);
+ *(pTarget + 1) = (WCHAR)((ch >> 8) & 0x7F);
+ *(pTarget + 2) = (WCHAR)((ch >> 16) & 0x7F);
+ *(pTarget + 3) = (WCHAR)((ch >> 24) & 0x7F);
+ pSrc += 8;
+ *(pTarget + 4) = (WCHAR)(chb & 0x7F);
+ *(pTarget + 5) = (WCHAR)((chb >> 8) & 0x7F);
+ *(pTarget + 6) = (WCHAR)((chb >> 16) & 0x7F);
+ *(pTarget + 7) = (WCHAR)((chb >> 24) & 0x7F);
+ pTarget += 8;
+#endif // BIGENDIAN
+ }
+ break;
+
+#if BIGENDIAN
+ LongCodeWithMask32 :
+ // be careful about the sign extension
+ ch = (int)(((uint)ch) >> 16);
+ LongCodeWithMask16:
+ ch = (int)(((uint)ch) >> 8);
+#else // BIGENDIAN
+ LongCodeWithMask32:
+ LongCodeWithMask16:
+ ch &= 0xFF;
+#endif // BIGENDIAN
+ pSrc++;
+ if (ch <= 0x7F) {
+ *pTarget = (WCHAR)ch;
+ pTarget++;
+ continue;
+ }
+
+ LongCode:
+ int chc = *pSrc;
+ pSrc++;
+
+ if (
+ // bit 6 has to be zero
+ (ch & 0x40) == 0 ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (chc & 0xC0) != 0x80)
+ {
+ goto BadLongCode;
+ }
+
+ chc &= 0x3F;
+
+ // start a new long code
+ if ((ch & 0x20) != 0) {
+
+ // fold the first two bytes together
+ chc |= (ch & 0x0F) << 6;
+
+ if ((ch & 0x10) != 0) {
+ // 4 byte encoding - surrogate
+ ch = *pSrc;
+ if (
+ // check that bit 4 is zero, the non-shortest form of surrogate
+ // and the valid surrogate range 0x000000 - 0x10FFFF at the same time
+ !InRange(chc >> 4, 0x01, 0x10) ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (ch & 0xC0) != 0x80)
+ {
+ goto BadLongCode;
+ }
+
+ chc = (chc << 6) | (ch & 0x3F);
+
+ ch = *(pSrc + 1);
+ // we are expecting to see trailing bytes like 10vvvvvv
+ if ((ch & 0xC0) != 0x80) {
+ goto BadLongCode;
+ }
+ pSrc += 2;
+
+ ch = (chc << 6) | (ch & 0x3F);
+
+ *pTarget = (char)(((ch >> 10) & 0x7FF) +
+ (SHORT)(CharUnicodeInfo::HIGH_SURROGATE_START - (0x10000 >> 10)));
+ pTarget++;
+
+ ch = (ch & 0x3FF) +
+ (SHORT)(CharUnicodeInfo::LOW_SURROGATE_START);
+
+ // extra byte, we're already planning 2 chars for 2 of these bytes,
+ // but the big loop is testing the target against pStop, so we need
+ // to subtract 2 more or we risk overrunning the input. Subtract
+ // one here and one below.
+ pStop--;
+ }
+ else {
+ // 3 byte encoding
+ ch = *pSrc;
+ if (
+ // check for non-shortest form of 3 byte seq
+ (chc & (0x1F << 5)) == 0 ||
+ // Can't have surrogates here.
+ (chc & (0xF800 >> 6)) == (0xD800 >> 6) ||
+ // we are expecting to see trailing bytes like 10vvvvvv
+ (ch & 0xC0) != 0x80)
+ {
+ goto BadLongCode;
+ }
+ pSrc++;
+
+ ch = (chc << 6) | (ch & 0x3F);
+
+ // extra byte, we're only expecting 1 char for each of these 3 bytes,
+ // but the loop is testing the target (not source) against pStop, so
+ // we need to subtract 2 more or we risk overrunning the input.
+ // Subtract 1 here and one more below
+ pStop--;
+ }
+ }
+ else {
+ // 2 byte encoding
+
+ ch &= 0x1F;
+
+ // check for non-shortest form
+ if (ch <= 1) {
+ goto BadLongCode;
+ }
+ ch = (ch << 6) | chc;
+ }
+
+ *pTarget = (WCHAR)ch;
+ pTarget++;
+
+ // extra byte, we're only expecting 1 char for each of these 2 bytes,
+ // but the loop is testing the target (not source) against pStop.
+ // subtract an extra count from pStop so that we don't overrun the input.
+ pStop--;
}
- wchHighSurrogate = *lpWC;
- bHandled = TRUE;
+#endif // FASTLOOP
+
+ Contract::Assert(pTarget <= pAllocatedBufferEnd, "[UTF8Encoding.GetChars]pTarget <= pAllocatedBufferEnd");
+
+ // no pending bits at this point
+ ch = 0;
+ continue;
+
+ BadLongCode:
+ pSrc -= 2;
+ ch = 0;
+ continue;
}
- if (!bHandled && wchHighSurrogate)
+ if (ch != 0)
{
- if ((*lpWC >= LOW_SURROGATE_START) && (*lpWC <= LOW_SURROGATE_END))
+ // Have to do fallback for invalid bytes
+ if (fallback == nullptr)
{
- // wheee, valid surrogate pairs
-
- if (cchDest)
- {
- if ((cchU8 + 3) < cchDest)
- {
- dwSurrogateChar = (((wchHighSurrogate-0xD800) << 10) + (*lpWC - 0xDC00) + 0x10000);
-
- lpDestStr[cchU8++] = (UTF8_1ST_OF_4 |
- (unsigned char)(dwSurrogateChar >> 18)); // 3 bits from 1st byte
-
- lpDestStr[cchU8++] = (UTF8_TRAIL |
- (unsigned char)((dwSurrogateChar >> 12) & 0x3f)); // 6 bits from 2nd byte
-
- lpDestStr[cchU8++] = (UTF8_TRAIL |
- (unsigned char)((dwSurrogateChar >> 6) & 0x3f)); // 6 bits from 3rd byte
-
- lpDestStr[cchU8++] = (UTF8_TRAIL |
- (unsigned char)(0x3f & dwSurrogateChar)); // 6 bits from 4th byte
- }
- else
- {
- // not enough buffer
- cchSrc++;
- break;
- }
- }
- else
- {
- // we already counted 3 previously (in high surrogate)
- cchU8 ++;
- }
+ fallback = decoderFallback->CreateFallbackBuffer();
+ fallback->InternalInitialize(bytes, pAllocatedBufferEnd);
+ }
+
+ // This'll back us up the appropriate # of bytes if we didn't get anywhere
+ if (!FallbackInvalidByteSequence(pSrc, ch, fallback))
+ {
+ Contract::Assert(pSrc >= bytes || pTarget == chars,
+ "[UTF8Encoding.GetChars]Expected to throw or remain in byte buffer while flushing");
- bHandled = TRUE;
+ // Ran out of buffer space
+ // Need to throw an exception?
+ fallback->InternalReset();
+ ThrowCharsOverflow(pTarget == chars);
}
- else
+ Contract::Assert(pSrc >= bytes,
+ "[UTF8Encoding.GetChars]Expected flushing invalid byte sequence to have remained within the byte array");
+ ch = 0;
+ }
+
+ // Shouldn't have anything in fallback buffer for GetChars
+ // (don't have to check m_throwOnOverflow for chars)
+ Contract::Assert(fallback == nullptr || fallback->GetRemaining() == 0,
+ "[UTF8Encoding.GetChars]Expected empty fallback buffer at end");
+
+ return PtrDiff(pTarget, chars);
+ }
+
+ int GetBytes(WCHAR* chars, int charCount, BYTE* bytes, int byteCount)
+ {
+ Contract::Assert(chars != nullptr, "[UTF8Encoding.GetBytes]chars!=nullptr");
+ Contract::Assert(byteCount >= 0, "[UTF8Encoding.GetBytes]byteCount >=0");
+ Contract::Assert(charCount >= 0, "[UTF8Encoding.GetBytes]charCount >=0");
+ Contract::Assert(bytes != nullptr, "[UTF8Encoding.GetBytes]bytes!=nullptr");
+
+ // For fallback we may need a fallback buffer.
+ // We wait to initialize it though in case we don't have any broken input unicode
+ EncoderFallbackBuffer* fallbackBuffer = nullptr;
+ WCHAR *pSrc = chars;
+ BYTE *pTarget = bytes;
+
+ WCHAR *pEnd = pSrc + charCount;
+ BYTE *pAllocatedBufferEnd = pTarget + byteCount;
+
+ int ch = 0;
+
+ // assume that JIT will enregister pSrc, pTarget and ch
+
+ for (;;) {
+ // SLOWLOOP: does all range checks, handles all special cases, but it is slow
+
+ if (pSrc >= pEnd) {
+
+ if (ch == 0) {
+ // Check if there's anything left to get out of the fallback buffer
+ ch = fallbackBuffer != nullptr ? fallbackBuffer->InternalGetNextChar() : 0;
+ if (ch > 0) {
+ goto ProcessChar;
+ }
+ }
+ else {
+ // Case of leftover surrogates in the fallback buffer
+ if (fallbackBuffer != nullptr && fallbackBuffer->bFallingBack) {
+ Contract::Assert(ch >= 0xD800 && ch <= 0xDBFF,
+ "[UTF8Encoding.GetBytes]expected high surrogate"); //, not 0x" + ((int)ch).ToString("X4", CultureInfo.InvariantCulture));
+
+ int cha = ch;
+
+ ch = fallbackBuffer->InternalGetNextChar();
+
+ if (InRange(ch, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ ch = ch + (cha << 10) + (0x10000 - CharUnicodeInfo::LOW_SURROGATE_START - (CharUnicodeInfo::HIGH_SURROGATE_START << 10));
+ goto EncodeChar;
+ }
+ else if (ch > 0){
+ goto ProcessChar;
+ }
+ else {
+ break;
+ }
+ }
+ }
+
+ // attempt to encode the partial surrogate (will fail or ignore)
+ if (ch > 0)
+ goto EncodeChar;
+
+ // We're done
+ break;
+ }
+
+ if (ch > 0) {
+ // We have a high surrogate left over from a previous loop.
+ Contract::Assert(ch >= 0xD800 && ch <= 0xDBFF,
+ "[UTF8Encoding.GetBytes]expected high surrogate");//, not 0x" + ((int)ch).ToString("X4", CultureInfo.InvariantCulture));
+
+ // use separate helper variables for local contexts so that the jit optimizations
+ // won't get confused about the variable lifetimes
+ int cha = *pSrc;
+
+ // In previous byte, we encountered a high surrogate, so we are expecting a low surrogate here.
+ // if (IsLowSurrogate(cha)) {
+ if (InRange(cha, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ ch = cha + (ch << 10) +
+ (0x10000
+ - CharUnicodeInfo::LOW_SURROGATE_START
+ - (CharUnicodeInfo::HIGH_SURROGATE_START << 10));
+
+ pSrc++;
+ }
+ // else ch is still high surrogate and encoding will fail
+
+ // attempt to encode the surrogate or partial surrogate
+ goto EncodeChar;
+ }
+
+ // If we've used a fallback, then we have to check for it
+ if (fallbackBuffer != nullptr)
{
- // Bad Surrogate pair : ERROR
- // Just process wchHighSurrogate , and the code below will
- // process the current code point
- if (cchDest)
- {
- if ((cchU8 + 2) < cchDest)
- {
- lpDestStr[cchU8++] = UTF8_1ST_OF_3 | HIGHER_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | MIDDLE_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | LOWER_6_BIT(wchHighSurrogate);
- }
- else
- {
- // not enough buffer
- cchSrc++;
- break;
- }
- }
+ ch = fallbackBuffer->InternalGetNextChar();
+ if (ch > 0) goto ProcessChar;
}
- wchHighSurrogate = 0;
- }
+ // read next char. The JIT optimization seems to be getting confused when
+ // compiling "ch = *pSrc++;", so rather use "ch = *pSrc; pSrc++;" instead
+ ch = *pSrc;
+ pSrc++;
- if (!bHandled)
- {
- if (*lpWC <= ASCII)
+ ProcessChar:
+ if (InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::HIGH_SURROGATE_END)) {
+ continue;
+ }
+ // either good char or partial surrogate
+
+ EncodeChar:
+ // throw exception on partial surrogate if necessary
+ if (InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END))
{
- //
- // Found ASCII.
- //
- if (cchDest)
+ // Lone surrogates aren't allowed, we have to do fallback for them
+ // Have to make a fallback buffer if we don't have one
+ if (fallbackBuffer == nullptr)
{
- if (cchU8 < cchDest)
- {
- lpDestStr[cchU8] = (char)*lpWC;
- }
- else
- {
- //
- // Error - buffer too small.
- //
- cchSrc++;
- break;
+ // wait on fallbacks if we can
+ // For fallback we may need a fallback buffer
+ fallbackBuffer = encoderFallback->CreateFallbackBuffer();
+
+ // Set our internal fallback interesting things.
+ fallbackBuffer->InternalInitialize(chars, pEnd, true);
+ }
+
+ // Do our fallback. Actually we already know its a mixed up surrogate,
+ // so the ref pSrc isn't gonna do anything.
+ fallbackBuffer->InternalFallback((WCHAR)ch, &pSrc);
+
+ // Ignore it if we don't throw
+ ch = 0;
+ continue;
+ }
+
+ // Count bytes needed
+ int bytesNeeded = 1;
+ if (ch > 0x7F) {
+ if (ch > 0x7FF) {
+ if (ch > 0xFFFF) {
+ bytesNeeded++; // 4 bytes (surrogate pair)
}
+ bytesNeeded++; // 3 bytes (800-FFFF)
}
- cchU8++;
+ bytesNeeded++; // 2 bytes (80-7FF)
}
- else if (*lpWC <= UTF8_2_MAX)
- {
- //
- // Found 2 byte sequence if < 0x07ff (11 bits).
- //
- if (cchDest)
+
+ if (pTarget > pAllocatedBufferEnd - bytesNeeded) {
+ // Left over surrogate from last time will cause pSrc == chars, so we'll throw
+ if (fallbackBuffer != nullptr && fallbackBuffer->bFallingBack)
{
- if ((cchU8 + 1) < cchDest)
- {
- //
- // Use upper 5 bits in first byte.
- // Use lower 6 bits in second byte.
- //
- lpDestStr[cchU8++] = UTF8_1ST_OF_2 | (*lpWC >> 6);
- lpDestStr[cchU8++] = UTF8_TRAIL | LOWER_6_BIT(*lpWC);
+ fallbackBuffer->MovePrevious(); // Didn't use this fallback char
+ if (ch > 0xFFFF)
+ fallbackBuffer->MovePrevious(); // Was surrogate, didn't use 2nd part either
+ }
+ else
+ {
+ pSrc--; // Didn't use this char
+ if (ch > 0xFFFF)
+ pSrc--; // Was surrogate, didn't use 2nd part either
+ }
+ Contract::Assert(pSrc >= chars || pTarget == bytes,
+ "[UTF8Encoding.GetBytes]Expected pSrc to be within buffer or to throw with insufficient room.");
+ ThrowBytesOverflow(pTarget == bytes); // Throw if we must
+ ch = 0; // Nothing left over (we backed up to start of pair if supplimentary)
+ break;
+ }
+
+ if (ch <= 0x7F) {
+ *pTarget = (BYTE)ch;
+ }
+ else {
+ // use separate helper variables for local contexts so that the jit optimizations
+ // won't get confused about the variable lifetimes
+ int chb;
+ if (ch <= 0x7FF) {
+ // 2 BYTE encoding
+ chb = (BYTE)(0xC0 | (ch >> 6));
+ }
+ else
+ {
+ if (ch <= 0xFFFF) {
+ chb = (BYTE)(0xE0 | (ch >> 12));
}
else
{
- //
- // Error - buffer too small.
- //
- cchSrc++;
- break;
+ *pTarget = (BYTE)(0xF0 | (ch >> 18));
+ pTarget++;
+
+ chb = 0x80 | ((ch >> 12) & 0x3F);
}
+ *pTarget = (BYTE)chb;
+ pTarget++;
+
+ chb = 0x80 | ((ch >> 6) & 0x3F);
}
- else
- {
- cchU8 += 2;
+ *pTarget = (BYTE)chb;
+ pTarget++;
+
+ *pTarget = (BYTE)0x80 | (ch & 0x3F);
+ }
+ pTarget++;
+
+
+#ifdef FASTLOOP
+ // If still have fallback don't do fast loop
+ if (fallbackBuffer != nullptr && (ch = fallbackBuffer->InternalGetNextChar()) != 0)
+ goto ProcessChar;
+
+ int availableChars = PtrDiff(pEnd, pSrc);
+ int availableBytes = PtrDiff(pAllocatedBufferEnd, pTarget);
+
+ // don't fall into the fast decoding loop if we don't have enough characters
+ // Note that if we don't have enough bytes, pStop will prevent us from entering the fast loop.
+ if (availableChars <= 13) {
+ // we are hoping for 1 BYTE per char
+ if (availableBytes < availableChars) {
+ // not enough output room. no pending bits at this point
+ ch = 0;
+ continue;
}
+
+ // try to get over the remainder of the ascii characters fast though
+ WCHAR* pLocalEnd = pEnd; // hint to get pLocalEnd enregistered
+ while (pSrc < pLocalEnd) {
+ ch = *pSrc;
+ pSrc++;
+
+ // Not ASCII, need more than 1 BYTE per char
+ if (ch > 0x7F)
+ goto ProcessChar;
+
+ *pTarget = (BYTE)ch;
+ pTarget++;
+ }
+ // we are done, let ch be 0 to clear encoder
+ ch = 0;
+ break;
}
- else
+
+ // we need at least 1 BYTE per character, but Convert might allow us to convert
+ // only part of the input, so try as much as we can. Reduce charCount if necessary
+ if (availableBytes < availableChars)
{
- //
- // Found 3 byte sequence.
- //
- if (cchDest)
- {
- if ((cchU8 + 2) < cchDest)
- {
- //
- // Use upper 4 bits in first byte.
- // Use middle 6 bits in second byte.
- // Use lower 6 bits in third byte.
- //
- lpDestStr[cchU8++] = UTF8_1ST_OF_3 | HIGHER_6_BIT(*lpWC);
- lpDestStr[cchU8++] = UTF8_TRAIL | MIDDLE_6_BIT(*lpWC);
- lpDestStr[cchU8++] = UTF8_TRAIL | LOWER_6_BIT(*lpWC);
+ availableChars = availableBytes;
+ }
+
+ // FASTLOOP:
+ // - optimistic range checks
+ // - fallbacks to the slow loop for all special cases, exception throwing, etc.
+
+ // To compute the upper bound, assume that all characters are ASCII characters at this point,
+ // the boundary will be decreased for every non-ASCII character we encounter
+ // Also, we need 5 chars reserve for the unrolled ansi decoding loop and for decoding of surrogates
+ // If there aren't enough bytes for the output, then pStop will be <= pSrc and will bypass the loop.
+ WCHAR *pStop = pSrc + availableChars - 5;
+
+ while (pSrc < pStop) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ *pTarget = (BYTE)ch;
+ pTarget++;
+
+ // get pSrc aligned
+ if (((size_t)pSrc & 0x2) != 0) {
+ ch = *pSrc;
+ pSrc++;
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ *pTarget = (BYTE)ch;
+ pTarget++;
+ }
+
+ // Run 4 characters at a time!
+ while (pSrc < pStop) {
+ ch = *(int*)pSrc;
+ int chc = *(int*)(pSrc + 2);
+ if (((ch | chc) & (int)0xFF80FF80) != 0) {
+ goto LongCodeWithMask;
+ }
+
+ // Unfortunately, this is endianess sensitive
+#if BIGENDIAN
+ *pTarget = (BYTE)(ch >> 16);
+ *(pTarget + 1) = (BYTE)ch;
+ pSrc += 4;
+ *(pTarget + 2) = (BYTE)(chc >> 16);
+ *(pTarget + 3) = (BYTE)chc;
+ pTarget += 4;
+#else // BIGENDIAN
+ *pTarget = (BYTE)ch;
+ *(pTarget + 1) = (BYTE)(ch >> 16);
+ pSrc += 4;
+ *(pTarget + 2) = (BYTE)chc;
+ *(pTarget + 3) = (BYTE)(chc >> 16);
+ pTarget += 4;
+#endif // BIGENDIAN
+ }
+ continue;
+
+ LongCodeWithMask:
+#if BIGENDIAN
+ // be careful about the sign extension
+ ch = (int)(((uint)ch) >> 16);
+#else // BIGENDIAN
+ ch = (WCHAR)ch;
+#endif // BIGENDIAN
+ pSrc++;
+
+ if (ch > 0x7F) {
+ goto LongCode;
+ }
+ *pTarget = (BYTE)ch;
+ pTarget++;
+ continue;
+
+ LongCode:
+ // use separate helper variables for slow and fast loop so that the jit optimizations
+ // won't get confused about the variable lifetimes
+ int chd;
+ if (ch <= 0x7FF) {
+ // 2 BYTE encoding
+ chd = 0xC0 | (ch >> 6);
+ }
+ else {
+ if (!InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ // 3 BYTE encoding
+ chd = 0xE0 | (ch >> 12);
}
else
{
- //
- // Error - buffer too small.
- //
- cchSrc++;
- break;
+ // 4 BYTE encoding - high surrogate + low surrogate
+ if (ch > CharUnicodeInfo::HIGH_SURROGATE_END) {
+ // low without high -> bad, try again in slow loop
+ pSrc -= 1;
+ break;
+ }
+
+ chd = *pSrc;
+ pSrc++;
+
+ // if (!IsLowSurrogate(chd)) {
+ if (!InRange(chd, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ // high not followed by low -> bad, try again in slow loop
+ pSrc -= 2;
+ break;
+ }
+
+ ch = chd + (ch << 10) +
+ (0x10000
+ - CharUnicodeInfo::LOW_SURROGATE_START
+ - (CharUnicodeInfo::HIGH_SURROGATE_START << 10));
+
+ *pTarget = (BYTE)(0xF0 | (ch >> 18));
+ // pStop - this BYTE is compensated by the second surrogate character
+ // 2 input chars require 4 output bytes. 2 have been anticipated already
+ // and 2 more will be accounted for by the 2 pStop-- calls below.
+ pTarget++;
+
+ chd = 0x80 | ((ch >> 12) & 0x3F);
}
+ *pTarget = (BYTE)chd;
+ pStop--; // 3 BYTE sequence for 1 char, so need pStop-- and the one below too.
+ pTarget++;
+
+ chd = 0x80 | ((ch >> 6) & 0x3F);
}
- else
- {
- cchU8 += 3;
- }
+ *pTarget = (BYTE)chd;
+ pStop--; // 2 BYTE sequence for 1 char so need pStop--.
+ pTarget++;
+
+ *pTarget = (BYTE)(0x80 | (ch & 0x3F));
+ // pStop - this BYTE is already included
+ pTarget++;
}
+
+ Contract::Assert(pTarget <= pAllocatedBufferEnd, "[UTF8Encoding.GetBytes]pTarget <= pAllocatedBufferEnd");
+
+#endif // FASTLOOP
+
+ // no pending char at this point
+ ch = 0;
}
- lpWC++;
+ return (int)(pTarget - bytes);
}
- //
- // If the last character was a high surrogate, then handle it as a normal
- // unicode character.
- //
- if ((cchSrc < 0) && (wchHighSurrogate != 0))
+ int GetByteCount(WCHAR *chars, int count)
{
- if (cchDest)
- {
- if ((cchU8 + 2) < cchDest)
+ // For fallback we may need a fallback buffer.
+ // We wait to initialize it though in case we don't have any broken input unicode
+ EncoderFallbackBuffer* fallbackBuffer = nullptr;
+ WCHAR *pSrc = chars;
+ WCHAR *pEnd = pSrc + count;
+
+ // Start by assuming we have as many as count
+ int byteCount = count;
+
+ int ch = 0;
+
+ for (;;) {
+ // SLOWLOOP: does all range checks, handles all special cases, but it is slow
+ if (pSrc >= pEnd) {
+
+ if (ch == 0) {
+ // Unroll any fallback that happens at the end
+ ch = fallbackBuffer != nullptr ? fallbackBuffer->InternalGetNextChar() : 0;
+ if (ch > 0) {
+ byteCount++;
+ goto ProcessChar;
+ }
+ }
+ else {
+ // Case of surrogates in the fallback.
+ if (fallbackBuffer != nullptr && fallbackBuffer->bFallingBack) {
+ Contract::Assert(ch >= 0xD800 && ch <= 0xDBFF,
+ "[UTF8Encoding.GetBytes]expected high surrogate");// , not 0x" + ((int)ch).ToString("X4", CultureInfo.InvariantCulture));
+
+ ch = fallbackBuffer->InternalGetNextChar();
+ byteCount++;
+
+ if (InRange(ch, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ ch = 0xfffd;
+ byteCount++;
+ goto EncodeChar;
+ }
+ else if (ch > 0){
+ goto ProcessChar;
+ }
+ else {
+ byteCount--; // ignore last one.
+ break;
+ }
+ }
+ }
+
+ if (ch <= 0) {
+ break;
+ }
+
+ // attempt to encode the partial surrogate (will fallback or ignore it), it'll also subtract 1.
+ byteCount++;
+ goto EncodeChar;
+ }
+
+ if (ch > 0) {
+ Contract::Assert(ch >= 0xD800 && ch <= 0xDBFF,
+ "[UTF8Encoding.GetBytes]expected high surrogate"); // , not 0x" + ((int)ch).ToString("X4", CultureInfo.InvariantCulture));
+
+ // use separate helper variables for local contexts so that the jit optimizations
+ // won't get confused about the variable lifetimes
+ int cha = *pSrc;
+
+ // count the pending surrogate
+ byteCount++;
+
+ // In previous byte, we encountered a high surrogate, so we are expecting a low surrogate here.
+ // if (IsLowSurrogate(cha)) {
+ if (InRange(cha, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ // Don't need a real # because we're just counting, anything > 0x7ff ('cept surrogate) will do.
+ ch = 0xfffd;
+ // ch = cha + (ch << 10) +
+ // (0x10000
+ // - CharUnicodeInfo::LOW_SURROGATE_START
+ // - (CharUnicodeInfo::HIGH_SURROGATE_START << 10) );
+
+ // Use this next char
+ pSrc++;
+ }
+ // else ch is still high surrogate and encoding will fail (so don't add count)
+
+ // attempt to encode the surrogate or partial surrogate
+ goto EncodeChar;
+ }
+
+ // If we've used a fallback, then we have to check for it
+ if (fallbackBuffer != nullptr)
{
- lpDestStr[cchU8++] = UTF8_1ST_OF_3 | HIGHER_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | MIDDLE_6_BIT(wchHighSurrogate);
- lpDestStr[cchU8++] = UTF8_TRAIL | LOWER_6_BIT(wchHighSurrogate);
+ ch = fallbackBuffer->InternalGetNextChar();
+ if (ch > 0)
+ {
+ // We have an extra byte we weren't expecting.
+ byteCount++;
+ goto ProcessChar;
+ }
}
- else
+
+ // read next char. The JIT optimization seems to be getting confused when
+ // compiling "ch = *pSrc++;", so rather use "ch = *pSrc; pSrc++;" instead
+ ch = *pSrc;
+ pSrc++;
+
+ ProcessChar:
+ if (InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::HIGH_SURROGATE_END)) {
+ // we will count this surrogate next time around
+ byteCount--;
+ continue;
+ }
+ // either good char or partial surrogate
+
+ EncodeChar:
+ // throw exception on partial surrogate if necessary
+ if (InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END))
{
- cchSrc++;
+ // Lone surrogates aren't allowed
+ // Have to make a fallback buffer if we don't have one
+ if (fallbackBuffer == nullptr)
+ {
+ // wait on fallbacks if we can
+ // For fallback we may need a fallback buffer
+ fallbackBuffer = encoderFallback->CreateFallbackBuffer();
+
+ // Set our internal fallback interesting things.
+ fallbackBuffer->InternalInitialize(chars, chars + count, false);
+ }
+
+ // Do our fallback. Actually we already know its a mixed up surrogate,
+ // so the ref pSrc isn't gonna do anything.
+ fallbackBuffer->InternalFallback((WCHAR)ch, &pSrc);
+
+ // Ignore it if we don't throw (we had preallocated this ch)
+ byteCount--;
+ ch = 0;
+ continue;
+ }
+
+ // Count them
+ if (ch > 0x7F) {
+ if (ch > 0x7FF) {
+ // the extra surrogate byte was compensated by the second surrogate character
+ // (2 surrogates make 4 bytes. We've already counted 2 bytes, 1 per char)
+ byteCount++;
+ }
+ byteCount++;
+ }
+
+#if WIN64
+ // check for overflow
+ if (byteCount < 0) {
+ break;
+ }
+#endif
+
+#ifdef FASTLOOP
+ // If still have fallback don't do fast loop
+ if (fallbackBuffer != nullptr && (ch = fallbackBuffer->InternalGetNextChar()) != 0)
+ {
+ // We're reserving 1 byte for each char by default
+ byteCount++;
+ goto ProcessChar;
+ }
+
+ int availableChars = PtrDiff(pEnd, pSrc);
+
+ // don't fall into the fast decoding loop if we don't have enough characters
+ if (availableChars <= 13) {
+ // try to get over the remainder of the ascii characters fast though
+ WCHAR* pLocalEnd = pEnd; // hint to get pLocalEnd enregistered
+ while (pSrc < pLocalEnd) {
+ ch = *pSrc;
+ pSrc++;
+ if (ch > 0x7F)
+ goto ProcessChar;
+ }
+
+ // we are done
+ break;
+ }
+
+#if WIN64
+ // make sure that we won't get a silent overflow inside the fast loop
+ // (Fall out to slow loop if we have this many characters)
+ availableChars &= 0x0FFFFFFF;
+#endif
+
+ // To compute the upper bound, assume that all characters are ASCII characters at this point,
+ // the boundary will be decreased for every non-ASCII character we encounter
+ // Also, we need 3 + 4 chars reserve for the unrolled ansi decoding loop and for decoding of surrogates
+ WCHAR *pStop = pSrc + availableChars - (3 + 4);
+
+ while (pSrc < pStop) {
+ ch = *pSrc;
+ pSrc++;
+
+ if (ch > 0x7F) // Not ASCII
+ {
+ if (ch > 0x7FF) // Not 2 Byte
+ {
+ if ((ch & 0xF800) == 0xD800) // See if its a Surrogate
+ goto LongCode;
+ byteCount++;
+ }
+ byteCount++;
+ }
+
+ // get pSrc aligned
+ if (((int)pSrc & 0x2) != 0) {
+ ch = *pSrc;
+ pSrc++;
+ if (ch > 0x7F) // Not ASCII
+ {
+ if (ch > 0x7FF) // Not 2 Byte
+ {
+ if ((ch & 0xF800) == 0xD800) // See if its a Surrogate
+ goto LongCode;
+ byteCount++;
+ }
+ byteCount++;
+ }
+ }
+
+ // Run 2 * 4 characters at a time!
+ while (pSrc < pStop) {
+ ch = *(int*)pSrc;
+ int chc = *(int*)(pSrc + 2);
+ if (((ch | chc) & (int)0xFF80FF80) != 0) // See if not ASCII
+ {
+ if (((ch | chc) & (int)0xF800F800) != 0) // See if not 2 Byte
+ {
+ goto LongCodeWithMask;
+ }
+
+
+ if ((ch & (int)0xFF800000) != 0) // Actually 0x07800780 is all we care about (4 bits)
+ byteCount++;
+ if ((ch & (int)0xFF80) != 0)
+ byteCount++;
+ if ((chc & (int)0xFF800000) != 0)
+ byteCount++;
+ if ((chc & (int)0xFF80) != 0)
+ byteCount++;
+ }
+ pSrc += 4;
+
+ ch = *(int*)pSrc;
+ chc = *(int*)(pSrc + 2);
+ if (((ch | chc) & (int)0xFF80FF80) != 0) // See if not ASCII
+ {
+ if (((ch | chc) & (int)0xF800F800) != 0) // See if not 2 Byte
+ {
+ goto LongCodeWithMask;
+ }
+
+ if ((ch & (int)0xFF800000) != 0)
+ byteCount++;
+ if ((ch & (int)0xFF80) != 0)
+ byteCount++;
+ if ((chc & (int)0xFF800000) != 0)
+ byteCount++;
+ if ((chc & (int)0xFF80) != 0)
+ byteCount++;
+ }
+ pSrc += 4;
+ }
+ break;
+
+ LongCodeWithMask:
+#if BIGENDIAN
+ // be careful about the sign extension
+ ch = (int)(((uint)ch) >> 16);
+#else // BIGENDIAN
+ ch = (WCHAR)ch;
+#endif // BIGENDIAN
+ pSrc++;
+
+ if (ch <= 0x7F) {
+ continue;
+ }
+
+ LongCode:
+ // use separate helper variables for slow and fast loop so that the jit optimizations
+ // won't get confused about the variable lifetimes
+ if (ch > 0x7FF) {
+ if (InRange(ch, CharUnicodeInfo::HIGH_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END)) {
+ // 4 byte encoding - high surrogate + low surrogate
+
+ int chd = *pSrc;
+ if (
+ ch > CharUnicodeInfo::HIGH_SURROGATE_END ||
+ !InRange(chd, CharUnicodeInfo::LOW_SURROGATE_START, CharUnicodeInfo::LOW_SURROGATE_END))
+ {
+ // Back up and drop out to slow loop to figure out error
+ pSrc--;
+ break;
+ }
+ pSrc++;
+
+ // byteCount - this byte is compensated by the second surrogate character
+ }
+ byteCount++;
+ }
+ byteCount++;
+
+ // byteCount - the last byte is already included
}
+#endif // FASTLOOP
+
+ // no pending char at this point
+ ch = 0;
+ }
+
+#if WIN64
+ // check for overflow
+ if (byteCount < 0) {
+ throw ArgumentException("Conversion buffer overflow.");
}
+#endif
+
+ Contract::Assert(fallbackBuffer == nullptr || fallbackBuffer->GetRemaining() == 0,
+ "[UTF8Encoding.GetByteCount]Expected Empty fallback buffer");
+
+ return byteCount;
}
- //
- // Make sure the destination buffer was large enough.
- //
- if (cchDest && (cchSrc >= 0))
- {
+};
+
+
+////////////////////////////////////////////////////////////////////////////
+//
+// UTF8ToUnicode
+//
+// Maps a UTF-8 character string to its wide character string counterpart.
+//
+////////////////////////////////////////////////////////////////////////////
+
+int UTF8ToUnicode(
+ LPCSTR lpSrcStr,
+ int cchSrc,
+ LPWSTR lpDestStr,
+ int cchDest,
+ DWORD dwFlags
+ )
+{
+ int ret;
+ UTF8Encoding enc(dwFlags & MB_ERR_INVALID_CHARS);
+ try {
+ ret = enc.GetCharCount((BYTE*)lpSrcStr, cchSrc);
+ if (cchDest){
+ if (ret > cchDest){
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ ret = 0;
+ }
+ enc.GetChars((BYTE*)lpSrcStr, cchSrc, (WCHAR*)lpDestStr, ret);
+ }
+ }
+ catch (const InsufficientBufferException& e){
SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return (0);
+ return 0;
+ }
+ catch (const DecoderFallbackException& e){
+ SetLastError(ERROR_NO_UNICODE_TRANSLATION);
+ return 0;
+ }
+ catch (const ArgumentException& e){
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
}
+ return ret;
+}
- //
- // Return the number of UTF-8 characters written.
- //
- return (cchU8);
+////////////////////////////////////////////////////////////////////////////
+//
+// UnicodeToUTF8
+//
+// Maps a Unicode character string to its UTF-8 string counterpart.
+//
+////////////////////////////////////////////////////////////////////////////
+
+int UnicodeToUTF8(
+ LPCWSTR lpSrcStr,
+ int cchSrc,
+ LPSTR lpDestStr,
+ int cchDest)
+{
+ int ret;
+ UTF8Encoding enc(false);
+ try{
+ ret = enc.GetByteCount((WCHAR*)lpSrcStr, cchSrc);
+ if (cchDest){
+ if (ret > cchDest){
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ ret = 0;
+ }
+ enc.GetBytes((WCHAR*)lpSrcStr, cchSrc, (BYTE*)lpDestStr, ret);
+ }
+ }
+ catch (const InsufficientBufferException& e){
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ return 0;
+ }
+ catch (const EncoderFallbackException& e){
+ SetLastError(ERROR_NO_UNICODE_TRANSLATION);
+ return 0;
+ }
+ catch (const ArgumentException& e){
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+ return ret;
}
diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt
index 1962ade358..0b8ae6062e 100644
--- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt
+++ b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt
@@ -3,4 +3,4 @@ cmake_minimum_required(VERSION 2.8.12.2)
add_subdirectory(test1)
add_subdirectory(test2)
add_subdirectory(test3)
-
+add_subdirectory(test4)
diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt
new file mode 100644
index 0000000000..3d167dff7c
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test4.c
+)
+
+add_executable(paltest_multibytetowidechar_test4
+ ${SOURCES}
+)
+
+add_dependencies(paltest_multibytetowidechar_test4 coreclrpal)
+
+target_link_libraries(paltest_multibytetowidechar_test4
+ pthread
+ m
+ coreclrpal
+) \ No newline at end of file
diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.c b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.c
new file mode 100644
index 0000000000..2ba606cf35
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.c
@@ -0,0 +1,230 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*============================================================================
+**
+** Source: test4.c
+**
+** Purpose: Tests MultiByteToWideChar with a UTF-8 encoding
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ int ret;
+ int ret2;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ const char * const utf8Strings[] =
+ {
+ // Correct strings
+
+ // Empty string
+ "",
+ // 1 byte encoded 1 character long string
+ "A",
+ // 2 byte encoded 1 character long string
+ "\xC2\x80",
+ // 3 byte encoded 1 character long string
+ "\xE0\xA0\x80",
+ // 1 byte encoded characters only
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ // valid 2 byte encoded characters only
+ "\xC2\x80\xC3\xBF\xC7\x81\xDF\xBF",
+ // valid 3 byte encoded characters only
+ "\xE0\xA0\x80\xE1\xB6\x88\xE1\x80\x80\xEF\xBF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char
+ "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one
+ "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one
+ "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char
+ "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char
+ "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one
+ "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one
+ "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char
+ "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF",
+ // surrogates
+ "\xF0\x90\x80\x80\xF0\x90\x89\x80\xF3\x80\x8E\xB0\xF4\x8F\xBF\xBF",
+
+ // Strings with errors
+ // Incomplete 2 byte encoded character 1 byte missing standalone
+ "\xC2",
+ // Incomplete 3 byte encoded character 1 byte missing standalone
+ "\xE0\xA0",
+ // Incomplete 3 byte encoded character 2 bytes missing standalone
+ "\xE0",
+ // Incomplete surrogate character 1 byte missing standalone
+ "\xF0\x90\x80",
+ // Incomplete surrogate character 2 bytes missing standalone
+ "\xF0\x90",
+ // Incomplete surrogate character 3 bytes missing standalone
+ "\xF0",
+ // Trailing byte with no lead byte standalone
+ "\x80",
+ // Incomplete 2 byte encoded character 1 byte missing between 1 byte chars
+ "\x41\xC2\x42",
+ // Incomplete 3 byte encoded character 1 byte missing between 1 byte chars
+ "\x41\xE0\xA0\x42",
+ // Incomplete 3 byte encoded character 2 bytes missing between 1 byte chars
+ "\x41\xE0\x42",
+ // Trailing byte with no lead byte between 1 byte chars
+ "\x41\x80\x42",
+ // Incomplete 2 byte encoded character 1 byte missing before 1 byte char
+ "\xC2\x42",
+ // Incomplete 3 byte encoded character 1 byte missing before 1 byte char
+ "\xE0\xA0\x42",
+ // Incomplete 3 byte encoded character 2 bytes missing before 1 byte char
+ "\xE0\x42",
+ // Trailing byte with no lead byte before 1 byte char
+ "\x80\x42",
+ // Incomplete 2 byte encoded character 1 byte missing after 1 byte char
+ "\x41\xC2",
+ // Incomplete 3 byte encoded character 1 byte missing after 1 byte char
+ "\x41\xE0\xA0",
+ // Incomplete 3 byte encoded character 2 bytes missing after 1 byte char
+ "\x41\xE0",
+ // Trailing byte with no lead byte after 1 byte char
+ "\x41\x80",
+ // Incomplete 2 byte encoded character 1 byte missing between 2 byte chars
+ "\xC2\x80\xC2\xC3\xBF",
+ // Incomplete 3 byte encoded character 1 byte missing between 2 byte chars
+ "\xC2\x80\xE0\xA0\xC3\xBF",
+ // Incomplete 3 byte encoded character 2 bytes missing between 2 byte chars
+ "\xC2\x80\xE0\xC3\xBF",
+ // Trailing byte with no lead byte between 2 byte chars
+ "\xC2\x80\x80\xC3\xBF",
+ // 2 byte encoded character in non-shortest form encodings (these are not allowed)
+ "\xC0\x80",
+ // 3 byte encoded character in non-shortest form encodings (these are not allowed)
+ "\xE0\x80\x80",
+ // 4 byte encoded character in non-shortest form encodings (these are not allowed)
+ "\xF0\x80\x80\x80",
+ };
+
+ const WCHAR * const unicodeStrings[] =
+ {
+ // Empty string
+ W(""),
+ // 1 byte encoded 1 character long string
+ W("A"),
+ // 2 byte encoded 1 character long string
+ W("\x0080"),
+ // 3 byte encoded 1 character long string
+ W("\x0800"),
+ // 1 byte encoded characters only
+ W("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+ // 2 byte encoded characters only
+ W("\x0080\x00FF\x01C1\x07FF"),
+ // valid 3 byte encoded characters only
+ W("\x0800\x1D88\x1000\xFFFF"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char
+ W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one
+ W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one
+ W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char
+ W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char
+ W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one
+ W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one
+ W("\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char
+ W("\x0080\x00FF\x0043\x0044\x01C1\x07FF"),
+ // surrogates
+ W("\xD800\xDC00\xD800\xDE40\xDAC0\xDFB0\xDBFF\xDFFF"),
+
+ // Strings with errors
+ // Incomplete 2 byte encoded character standalone
+ W(""),
+ // Incomplete 3 byte encoded character 1 byte missing standalone
+ W(""),
+ // Incomplete 3 byte encoded character 2 bytes missing standalone
+ W(""),
+ // Incomplete surrogate character 1 byte missing standalone
+ W(""),
+ // Incomplete surrogate character 2 bytes missing standalone
+ W(""),
+ // Incomplete surrogate character 3 bytes missing standalone
+ W(""),
+ // Trailing byte with no lead byte standalone
+ W(""),
+ // Incomplete 2 byte encoded character 1 byte missing between 1 byte chars
+ W("\x0041\x0042"),
+ // Incomplete 3 byte encoded character 1 byte missing between 1 byte chars
+ W("\x0041\x0042"),
+ // Incomplete 3 byte encoded character 2 bytes missing between 1 byte chars
+ W("\x0041\x0042"),
+ // Trailing byte with no lead byte between 1 byte chars
+ W("\x0041\x0042"),
+ // Incomplete 2 byte encoded character 1 byte missing before 1 byte char
+ W("\x0042"),
+ // Incomplete 3 byte encoded character 1 byte missing before 1 byte char
+ W("\x0042"),
+ // Incomplete 3 byte encoded character 2 bytes missing before 1 byte char
+ W("\x0042"),
+ // Trailing byte with no lead byte before 1 byte char
+ W("\x0042"),
+ // Incomplete 2 byte encoded character 1 byte missing after 1 byte char
+ W("\x0041"),
+ // Incomplete 3 byte encoded character 1 byte missing after 1 byte char
+ W("\x0041"),
+ // Incomplete 3 byte encoded character 2 bytes missing after 1 byte char
+ W("\x0041"),
+ // Trailing byte with no lead byte after 1 byte char
+ W("\x0041"),
+ // Incomplete 2 byte encoded character 1 byte missing between 2 byte chars
+ W("\x0080\x00FF"),
+ // Incomplete 3 byte encoded character 1 byte missing between 2 byte chars
+ W("\x0080\x00FF"),
+ // Incomplete 3 byte encoded character 2 bytes missing between 2 byte chars
+ W("\x0080\x00FF"),
+ // Trailing byte with no lead byte between 2 byte chars
+ W("\x0080\x00FF"),
+ // 2 byte encoded character in non-shortest form encodings (these are not allowed)
+ W(""),
+ // 3 byte encoded character in non-shortest form encodings (these are not allowed)
+ W(""),
+ // 4 byte encoded character in non-shortest form encodings (these are not allowed)
+ W(""),
+ };
+
+ for (int i = 0; i < (sizeof(utf8Strings) / sizeof(utf8Strings[0])); i++)
+ {
+ ret = MultiByteToWideChar(CP_UTF8, 0, utf8Strings[i], -1, NULL, 0);
+ WCHAR* wideBuffer = malloc(ret * sizeof(WCHAR));
+ ret2 = MultiByteToWideChar(CP_UTF8, 0, utf8Strings[i], -1, wideBuffer, ret);
+ if (ret != ret2)
+ {
+ Fail("MultiByteToWideChar string %d: returned different string length for empty and real dest buffers!\n"
+ "Got %d for the empty one, %d for real one.\n", i, ret2, ret);
+ }
+
+ if (wcscmp(wideBuffer, unicodeStrings[i]) != 0)
+ {
+ Fail("MultiByteToWideChar string %d: the resulting string doesn't match the expected one!\n", i);
+ }
+
+ free(wideBuffer);
+ }
+
+ PAL_Terminate();
+
+ return PASS;
+} \ No newline at end of file
diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat
new file mode 100644
index 0000000000..e95f413904
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat
@@ -0,0 +1,13 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = Locale Information
+Function = MultiByteToWideChar
+Name = Test #4 for MultiByteToWideChar
+TYPE = DEFAULT
+EXE1 = test4
+Description
+=Tests MultiByteToWideChar with UTF-8 encoded strings
+=containing various corner cases \ No newline at end of file
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt
index a3847f8ca9..dc5d5131ec 100644
--- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt
@@ -4,4 +4,4 @@ add_subdirectory(test1)
add_subdirectory(test2)
add_subdirectory(test3)
add_subdirectory(test4)
-
+add_subdirectory(test5)
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.c b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.c
index f04a7aeca0..cd763f33be 100644
--- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.c
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.c
@@ -27,11 +27,6 @@ int __cdecl main(int argc, char *argv[])
/* These codepages are currently supported by the PAL */
int codePages[] ={
CP_ACP,
-// 932,
- 949,
- 950,
- 1252,
- 1258,
CP_UTF8
};
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.c b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.c
index 372037b686..f5d40ae903 100644
--- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.c
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.c
@@ -27,11 +27,6 @@ int __cdecl main(int argc, char *argv[])
/* These codepages are currently supported by the PAL */
int codePages[] ={
CP_ACP,
-// 932,
- 949,
- 950,
- 1252,
- 1258,
CP_UTF8
};
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.c b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.c
index 7f0936ade9..ecd26addb4 100644
--- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.c
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.c
@@ -29,11 +29,6 @@ int __cdecl main(int argc, char *argv[])
/* These codepages are currently supported by the PAL */
int codePages[] ={
CP_ACP,
-// 932,
- 949,
- 950,
- 1252,
- 1258,
CP_UTF8
};
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt
new file mode 100644
index 0000000000..6ca2a628bf
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8.12.2)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(SOURCES
+ test5.c
+)
+
+add_executable(paltest_widechartomultibyte_test5
+ ${SOURCES}
+)
+
+add_dependencies(paltest_widechartomultibyte_test5 coreclrpal)
+
+target_link_libraries(paltest_widechartomultibyte_test5
+ pthread
+ m
+ coreclrpal
+) \ No newline at end of file
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.c b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.c
new file mode 100644
index 0000000000..3ca0d90d0f
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.c
@@ -0,0 +1,154 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+/*============================================================================
+**
+** Source: test4.c
+**
+** Purpose: Tests WideCharMultiByte with UTF-8 encoding
+**
+**
+**==========================================================================*/
+
+#include <palsuite.h>
+
+int __cdecl main(int argc, char *argv[])
+{
+ int ret;
+ int ret2;
+
+ if (PAL_Initialize(argc, argv))
+ {
+ return FAIL;
+ }
+
+ const WCHAR * const unicodeStrings[] =
+ {
+ // Correct strings
+
+ // Empty string
+ W(""),
+ // 1 byte encoded 1 character long string
+ W("A"),
+ // 2 byte encoded 1 character long string
+ W("\x0080"),
+ // 3 byte encoded 1 character long string
+ W("\x0800"),
+ // 1 byte encoded characters only
+ W("ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+ // 2 byte encoded characters only
+ W("\x0080\x00FF\x01C1\x07FF"),
+ // valid 3 byte encoded characters only
+ W("\x0800\x1D88\x1000\xFFFF"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char
+ W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one
+ W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one
+ W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"),
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char
+ W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char
+ W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one
+ W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one
+ W("\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"),
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char
+ W("\x0080\x00FF\x0043\x0044\x01C1\x07FF"),
+ // Surrogates
+ W("\xD800\xDC00\xD800\xDE40\xDAC0\xDFB0\xDBFF\xDFFF"),
+
+ // Strings with errors
+
+ // Single high surrogate
+ W("\xD800"),
+ // Single low surrogate
+ W("\xDC00"),
+ // Character followed by single high surrogate
+ W("\x0041\xD800"),
+ // Character followed by single low surrogate
+ W("\x0041\xDC00"),
+ // Single high surrogate between two characters
+ W("\x0041\xD800\x0042"),
+ // Single low surrogate between two characters
+ W("\x0041\xDC00\x0042"),
+ };
+
+ const char * const utf8Strings[] =
+ {
+ // Correct strings
+
+ // Empty string
+ "",
+ // 1 byte encoded 1 character long string
+ "A",
+ // 2 byte encoded 1 character long string
+ "\xC2\x80",
+ // 3 byte encoded 1 character long string
+ "\xE0\xA0\x80",
+ // 1 byte encoded characters only
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ // valid 2 byte encoded characters only
+ "\xC2\x80\xC3\xBF\xC7\x81\xDF\xBF",
+ // valid 3 byte encoded characters only
+ "\xE0\xA0\x80\xE1\xB6\x88\xE1\x80\x80\xEF\xBF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char
+ "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one
+ "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one
+ "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45",
+ // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char
+ "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char
+ "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one
+ "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one
+ "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46",
+ // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char
+ "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF",
+ // Surrogates
+ "\xF0\x90\x80\x80\xF0\x90\x89\x80\xF3\x80\x8E\xB0\xF4\x8F\xBF\xBF",
+
+ // Strings with errors
+
+ // Single high surrogate
+ "\xEF\xBF\xBD",
+ // Single low surrogate
+ "\xEF\xBF\xBD",
+ // Character followed by single high surrogate
+ "\x41\xEF\xBF\xBD",
+ // Character followed by single low surrogate
+ "\x41\xEF\xBF\xBD",
+ // Single high surrogate between two characters
+ "\x41\xEF\xBF\xBD\x42",
+ // Single low surrogate between two characters
+ "\x41\xEF\xBF\xBD\x42",
+ };
+
+ for (int i = 0; i < (sizeof(unicodeStrings) / sizeof(unicodeStrings[0])); i++)
+ {
+ ret = WideCharToMultiByte(CP_UTF8, 0, unicodeStrings[i], -1, NULL, 0, NULL, NULL);
+ CHAR* utf8Buffer = malloc(ret * sizeof(CHAR));
+ ret2 = WideCharToMultiByte(CP_UTF8, 0, unicodeStrings[i], -1, utf8Buffer, ret, NULL, NULL);
+ if (ret != ret2)
+ {
+ Fail("WideCharToMultiByte string %d: returned different string length for empty and real dest buffers!\n"
+ "Got %d for the empty one, %d for real one.\n", i, ret2, ret);
+ }
+
+ if (strcmp(utf8Buffer, utf8Strings[i]) != 0)
+ {
+ Fail("WideCharToMultiByte string %d: the resulting string doesn't match the expected one!\n", i);
+ }
+
+ free(utf8Buffer);
+ }
+
+ PAL_Terminate();
+
+ return PASS;
+} \ No newline at end of file
diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat
new file mode 100644
index 0000000000..485d9401e5
--- /dev/null
+++ b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat
@@ -0,0 +1,13 @@
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+#
+
+Version = 1.0
+Section = Locale Information
+Function = WideCharToMultiByte
+Name = Test #5 for WideCharToMultiByte
+TYPE = DEFAULT
+EXE1 = test5
+Description
+=Tests WideCharToMultiByte conversion to UTF-8
+=containing various corner cases \ No newline at end of file
diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt
index 44386ac30e..94ac16ab5f 100644
--- a/src/pal/tests/palsuite/paltestlist.txt
+++ b/src/pal/tests/palsuite/paltestlist.txt
@@ -628,6 +628,11 @@ locale_info/IsValidCodePage/test1/paltest_isvalidcodepage_test1
locale_info/MultiByteToWideChar/test1/paltest_multibytetowidechar_test1
locale_info/MultiByteToWideChar/test2/paltest_multibytetowidechar_test2
locale_info/MultiByteToWideChar/test3/paltest_multibytetowidechar_test3
+locale_info/MultiByteToWideChar/test4/paltest_multibytetowidechar_test4
+locale_info/WideCharToMultiByte/test1/paltest_widechartomultibyte_test1
+locale_info/WideCharToMultiByte/test2/paltest_widechartomultibyte_test2
+locale_info/WideCharToMultiByte/test3/paltest_widechartomultibyte_test3
+locale_info/WideCharToMultiByte/test5/paltest_widechartomultibyte_test5
miscellaneous/CharNextA/test1/paltest_charnexta_test1
miscellaneous/CharNextA/test2/paltest_charnexta_test2
miscellaneous/CharNextExA/test1/paltest_charnextexa_test1
diff --git a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
index e7ccda5e7f..ac0a2ee4eb 100644
--- a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
+++ b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt
@@ -134,9 +134,6 @@ locale_info/GetUserDefaultLCID/test1/paltest_getuserdefaultlcid_test1
locale_info/IsValidCodePage/test2/paltest_isvalidcodepage_test2
locale_info/IsValidLocale/test1/paltest_isvalidlocale_test1
locale_info/SetThreadLocale/test1/paltest_setthreadlocale_test1
-locale_info/WideCharToMultiByte/test1/paltest_widechartomultibyte_test1
-locale_info/WideCharToMultiByte/test2/paltest_widechartomultibyte_test2
-locale_info/WideCharToMultiByte/test3/paltest_widechartomultibyte_test3
locale_info/WideCharToMultiByte/test4/paltest_widechartomultibyte_test4
miscellaneous/FormatMessageW/test4/paltest_formatmessagew_test4
miscellaneous/FormatMessageW/test5/paltest_formatmessagew_test5
diff --git a/src/tools/crossgen/crossgen.cpp b/src/tools/crossgen/crossgen.cpp
index 2e8e3334fe..699835409d 100644
--- a/src/tools/crossgen/crossgen.cpp
+++ b/src/tools/crossgen/crossgen.cpp
@@ -159,11 +159,6 @@ void PrintUsageHelper()
W(" /ReadyToRun - Generate images resilient to the runtime and\n")
W(" dependency versions\n")
#endif
-#ifdef FEATURE_LEGACYNETCF
- W(" Compatability Modes\n")
- W(" /PreWP8App - Set the Windows Phone 8 \"Quirks\" mode, namely AppDomainCompatSwitch=\n")
- W(" WindowsPhone_3.7.0.0 or WindowsPhone_3.8.0.0.\n")
-#endif
#ifdef FEATURE_WINMD_RESILIENT
W(" WinMD Parameters\n")
W(" /WinMDResilient - Generate images resilient to WinMD dependency changes.\n")
@@ -532,12 +527,6 @@ int _cdecl wmain(int argc, __in_ecount(argc) WCHAR **argv)
// fulltrust behaviour.
}
#endif
-#ifdef FEATURE_LEGACYNETCF
- else if (MatchParameter(*argv, W("PreWP8App")))
- {
- dwFlags |= NGENWORKER_FLAGS_APPCOMPATWP8;
- }
-#endif
#ifdef FEATURE_WINMD_RESILIENT
else if (MatchParameter(*argv, W("WinMDResilient")))
{
@@ -850,6 +839,14 @@ int _cdecl wmain(int argc, __in_ecount(argc) WCHAR **argv)
#ifdef FEATURE_CORECLR
SString ssTPAList;
+
+ if (fCreatePDB)
+ {
+ // While creating PDB, assembly binder gives preference to files in TPA.
+ // This can create difficulties if the input file is not in TPA.
+ // To avoid this issue, put the input file as the first item in TPA.
+ ssTPAList.Append(pwzFilename);
+ }
// Are we compiling mscorlib.dll?
bool fCompilingMscorlib = StringEndsWith((LPWSTR)pwzFilename, W("mscorlib.dll"));
diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp
index 3d64ebc8bc..3e46941959 100644
--- a/src/vm/ceeload.cpp
+++ b/src/vm/ceeload.cpp
@@ -2902,12 +2902,6 @@ BOOL Module::IsNoStringInterning()
// Default is string interning
BOOL fNoStringInterning = FALSE;
-#ifdef FEATURE_LEGACYNETCF
- // NetCF ignored this attribute
- if (GetAppDomain()->GetAppDomainCompatMode() != BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
-#endif
-
HRESULT hr;
// This flag applies to assembly, but it is stored on module so it can be cached in ngen image
@@ -2941,10 +2935,6 @@ BOOL Module::IsNoStringInterning()
}
}
-#ifdef FEATURE_LEGACYNETCF
- }
-#endif
-
#ifdef _DEBUG
static ConfigDWORD g_NoStringInterning;
DWORD dwOverride = g_NoStringInterning.val(CLRConfig::INTERNAL_NoStringInterning);
diff --git a/src/vm/class.h b/src/vm/class.h
index cad0e0f49c..78c09000e3 100644
--- a/src/vm/class.h
+++ b/src/vm/class.h
@@ -1677,18 +1677,6 @@ public:
/* no op */
}
#endif
-#ifdef FEATURE_LEGACYNETCF
- DWORD IsTypeValidOnNetCF()
- {
- LIMITED_METHOD_CONTRACT;
- return (m_VMFlags & VMFLAG_TYPE_VALID_ON_NETCF);
- }
- void SetTypeValidOnNetCF()
- {
- WRAPPER_NO_CONTRACT;
- FastInterlockOr(EnsureWritablePages(&m_VMFlags), VMFLAG_TYPE_VALID_ON_NETCF);
- }
-#endif
DWORD HasNonPublicFields()
{
LIMITED_METHOD_CONTRACT;
@@ -2159,9 +2147,6 @@ public:
#ifdef FEATURE_REMOTING
VMFLAG_CANNOT_BE_BLITTED_BY_OBJECT_CLONER = 0x00000100, // This class has GC type fields, or implements ISerializable or has non-Serializable fields
#endif
-#ifdef FEATURE_LEGACYNETCF
- VMFLAG_TYPE_VALID_ON_NETCF = 0x00000100, // This type would succesfully load on NetCF
-#endif
VMFLAG_IS_EQUIVALENT_TYPE = 0x00000200,
diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp
index 086f202873..1b8b3eed58 100644
--- a/src/vm/clsload.cpp
+++ b/src/vm/clsload.cpp
@@ -4473,12 +4473,7 @@ VOID ClassLoader::AddAvailableClassHaveLock(
// been obfuscated so that they have duplicate private typedefs.
// We must allow this for old assemblies for app compat reasons
#ifdef FEATURE_CORECLR
-#ifdef FEATURE_LEGACYNETCF
- if (!RuntimeIsLegacyNetCF(0))
-#endif
- {
- pModule->GetAssembly()->ThrowBadImageException(pszNameSpace, pszName, BFA_MULT_TYPE_SAME_NAME);
- }
+ pModule->GetAssembly()->ThrowBadImageException(pszNameSpace, pszName, BFA_MULT_TYPE_SAME_NAME);
#else
LPCSTR pszVersion = NULL;
if (FAILED(pModule->GetMDImport()->GetVersionString(&pszVersion)))
diff --git a/src/vm/comdelegate.cpp b/src/vm/comdelegate.cpp
index 27a2d00735..5b0a952cd3 100644
--- a/src/vm/comdelegate.cpp
+++ b/src/vm/comdelegate.cpp
@@ -698,12 +698,6 @@ FCIMPL5(FC_BOOL_RET, COMDelegate::BindToMethodName,
// performance gain in some reflection emit scenarios.
MethodTable::AllowMethodDataCaching();
-#ifdef FEATURE_LEGACYNETCF
- // NetCF has done relaxed signature matching unconditionally
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- flags |= DBF_RelaxedSignature;
-#endif
-
TypeHandle targetType((gc.target != NULL) ? gc.target->GetTrueMethodTable() : NULL);
// get the invoke of the delegate
MethodTable * pDelegateType = gc.refThis->GetMethodTable();
diff --git a/src/vm/commodule.cpp b/src/vm/commodule.cpp
index 41e7aa16e2..7cab6b54f2 100644
--- a/src/vm/commodule.cpp
+++ b/src/vm/commodule.cpp
@@ -871,12 +871,6 @@ void QCALLTYPE COMModule::GetType(QCall::ModuleHandle pModule, LPCWSTR wszName,
BOOL prohibitAsmQualifiedName = TRUE;
-#ifdef FEATURE_LEGACYNETCF
- // // NetCF type name parser allowed assembly name to be overriden here
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- prohibitAsmQualifiedName = FALSE;
-#endif
-
// Load the class from this assembly (fail if it is in a different one).
retTypeHandle = TypeName::GetTypeManaged(wszName, pAssembly, bThrowOnError, bIgnoreCase, pAssembly->IsIntrospectionOnly(), prohibitAsmQualifiedName, NULL, FALSE, &keepAlive);
}
diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp
index 88e1d284a8..4548f8d5c7 100644
--- a/src/vm/compile.cpp
+++ b/src/vm/compile.cpp
@@ -4812,8 +4812,10 @@ HRESULT __stdcall CreatePdb(CORINFO_ASSEMBLY_HANDLE hAssembly, BSTR pNativeImage
if (!fAtLeastOneNativeModuleFound)
{
GetSvcLogger()->Printf(
+ W("Loaded image '%s' (for input file '%s') is not a native image.\n"),
+ pAssembly->GetManifestFile()->GetPath().GetUnicode(),
pNativeImagePath);
- return E_FAIL;
+ return CORDBG_E_NO_IMAGE_AVAILABLE;
}
GetSvcLogger()->Printf(
diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp
index 5c77d608a8..e16f9d8ab5 100644
--- a/src/vm/domainfile.cpp
+++ b/src/vm/domainfile.cpp
@@ -3804,13 +3804,6 @@ DWORD DomainAssembly::ComputeDebuggingConfig()
{
dacfFlags |= DACF_USER_OVERRIDE;
}
-#ifdef FEATURE_LEGACYNETCF
- else
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
- // NetCF did not respect the DebuggableAttribute
- }
-#endif
else
{
IfFailThrow(GetDebuggingCustomAttributes(&dacfFlags));
diff --git a/src/vm/invokeutil.cpp b/src/vm/invokeutil.cpp
index 2211dfeffd..42e5a86249 100644
--- a/src/vm/invokeutil.cpp
+++ b/src/vm/invokeutil.cpp
@@ -2016,11 +2016,6 @@ AccessCheckOptions::AccessCheckType InvokeUtil::GetInvocationAccessCheckType(BOO
// There is no security concern because we are in Full Trust.
return AccessCheckOptions::kRestrictedMemberAccessNoTransparency;
-#ifdef FEATURE_LEGACYNETCF
- if (pAppDomain->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- return AccessCheckOptions::kRestrictedMemberAccess;
-#endif // FEATURE_LEGACYNETCF
-
return AccessCheckOptions::kMemberAccess;
#else // !FEATURE_CORECLR
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 9c47f6d944..0a5154aa4f 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -1453,43 +1453,6 @@ static CorInfoHelpFunc getInstanceFieldHelper(FieldDesc * pField, CORINFO_ACCESS
return (CorInfoHelpFunc)helper;
}
-#ifdef FEATURE_LEGACYNETCF
-void CheckValidTypeOnNetCF(MethodTable * pMT)
-{
- STANDARD_VM_CONTRACT;
-
- // Do this quirk for application assemblies only
- if (pMT->GetAssembly()->GetManifestFile()->IsProfileAssembly())
- return;
-
- if (pMT->GetClass()->IsTypeValidOnNetCF())
- return;
-
- DWORD dwStaticsSizeOnNetCF = 0;
-
- //
- // NetCF had 64k limit on total size of statics per class. This limit
- // is easy to reach by initialized data in C#. Apps took dependency
- // on type load exceptions being thrown in this case.
- //
- ApproxFieldDescIterator fieldIterator(pMT, ApproxFieldDescIterator::STATIC_FIELDS);
- for (FieldDesc *pFD = fieldIterator.Next(); pFD != NULL; pFD = fieldIterator.Next())
- {
- DWORD fldSize = pFD->LoadSize();
-
- // Simulate NetCF behaviour that caused size to wrap around
- dwStaticsSizeOnNetCF += (UINT16)fldSize;
-
- if (dwStaticsSizeOnNetCF > 0xFFFF)
- COMPlusThrow(kTypeLoadException);
- }
-
- // Cache the result of the check
- pMT->GetClass()->SetTypeValidOnNetCF();
-}
-#endif // FEATURE_LEGACYNETCF
-
-
/*********************************************************************/
void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
CORINFO_METHOD_HANDLE callerHandle,
@@ -1520,11 +1483,6 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
pResult->offset = pField->GetOffset();
if (pField->IsStatic())
{
-#ifdef FEATURE_LEGACYNETCF
- if (pFieldMT->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- CheckValidTypeOnNetCF(pFieldMT);
-#endif
-
fieldFlags |= CORINFO_FLG_FIELD_STATIC;
if (pField->IsRVA())
@@ -3943,18 +3901,6 @@ CorInfoInitClassResult CEEInfo::initClass(
if (pFD == NULL)
{
-#ifdef FEATURE_LEGACYNETCF
- // For methods, NetCF always triggers static constructor as side-effect of JITing, essentially ignoring before field init.
- if (pTypeToInitMT->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
- // This quirk assumes that RunCCTorAsIfNGenImageExists() is TRUE. It would need to be replicated in more places
- // if it was not the case.
- _ASSERTE(pTypeToInitMT->RunCCTorAsIfNGenImageExists());
-
- fIgnoreBeforeFieldInit = true;
- }
-#endif
-
if (!fIgnoreBeforeFieldInit && pTypeToInitMT->GetClass()->IsBeforeFieldInit())
{
// We can wait for field accesses to run .cctor
@@ -7304,20 +7250,6 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
{
Module * pCalleeModule = pCallee->GetModule();
-#ifdef FEATURE_LEGACYNETCF
- if (m_pMethodBeingCompiled->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
- // NetCF did not allow cross-assembly inlining (except for mscorlib)
- // and leaf methods
- Assembly * pCalleeAssembly = pCalleeModule->GetAssembly();
- Assembly * pOrigCallerAssembly = pOrigCallerModule->GetAssembly();
- if ((pCalleeAssembly != pOrigCallerAssembly) && !pCalleeAssembly->IsSystem())
- {
- dwRestrictions |= INLINE_RESPECT_BOUNDARY;
- }
- }
-#endif // FEATURE_LEGACYNETCF
-
#ifdef FEATURE_PREJIT
Assembly * pCalleeAssembly = pCalleeModule->GetAssembly();
@@ -7946,17 +7878,6 @@ bool CEEInfo::canTailCall (CORINFO_METHOD_HANDLE hCaller,
_ASSERTE((pExactCallee == NULL) || pExactCallee->GetModule());
_ASSERTE((pExactCallee == NULL) || pExactCallee->GetModule()->GetClassLoader());
-#ifdef FEATURE_LEGACYNETCF
- // NetCF did not implement tail calls
- if (m_pMethodBeingCompiled->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
-
- result = false;
- szFailReason = "Windows Phone OS 7 compatibility";
- goto exit;
- }
-#endif // FEATURE_LEGACYNETCF
-
// If the caller is the static constructor (.cctor) of a class which has a ComImport base class
// somewhere up the class hierarchy, then we cannot make the call into a tailcall. See
// RegisterObjectCreationCallback() in ExtensibleClassFactory.cpp for more information.
@@ -11736,14 +11657,6 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr,
}
}
-#ifdef FEATURE_LEGACYNETCF
- // for "AppDomainCompatSwitch" == "WindowsPhone_3.7.0.0" or "AppDomainCompatSwitch" == "WindowsPhone_3.8.0.0"
- // This is when we need to generate code that more closely resembles
- // what the WinPhone 7.0/7.1/7.5 NetCF JIT used to generate.
- if (ftn->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- flags |= CORJIT_FLG_NETCF_QUIRKS;
-#endif // FEATURE_LEGACYNETCF
-
return flags;
}
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp
index 5d291081c7..8a5c19043c 100644
--- a/src/vm/methodtablebuilder.cpp
+++ b/src/vm/methodtablebuilder.cpp
@@ -952,23 +952,9 @@ MethodTableBuilder::MethodSignature::SignaturesEquivalent(
{
STANDARD_VM_CONTRACT;
-#ifdef FEATURE_LEGACYNETCF
- BaseDomain::AppDomainCompatMode compatMode1 = sig1.GetModule()->GetDomain()->GetAppDomainCompatMode();
- BaseDomain::AppDomainCompatMode compatMode2 = sig2.GetModule()->GetDomain()->GetAppDomainCompatMode();
-
- if ((compatMode1 == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8) || (compatMode2 == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8))
- {
- return S_OK == MetaSig::CompareMethodSigsNT(
- sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
- sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution());
- }
- else
-#endif
- {
- return !!MetaSig::CompareMethodSigs(
- sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
- sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution());
- }
+ return !!MetaSig::CompareMethodSigs(
+ sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
+ sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution());
}
//*******************************************************************************
@@ -979,27 +965,11 @@ MethodTableBuilder::MethodSignature::SignaturesExactlyEqual(
{
STANDARD_VM_CONTRACT;
-#ifdef FEATURE_LEGACYNETCF
- BaseDomain::AppDomainCompatMode compatMode1 = sig1.GetModule()->GetDomain()->GetAppDomainCompatMode();
- BaseDomain::AppDomainCompatMode compatMode2 = sig2.GetModule()->GetDomain()->GetAppDomainCompatMode();
-
- if ((compatMode1 == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8) || (compatMode2 == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8))
- {
- TokenPairList newVisited = TokenPairList::AdjustForTypeEquivalenceForbiddenScope(NULL);
- return S_OK == MetaSig::CompareMethodSigsNT(
- sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
- sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution(),
- &newVisited);
- }
- else
-#endif
- {
- TokenPairList newVisited = TokenPairList::AdjustForTypeEquivalenceForbiddenScope(NULL);
- return !!MetaSig::CompareMethodSigs(
- sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
- sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution(),
- &newVisited);
- }
+ TokenPairList newVisited = TokenPairList::AdjustForTypeEquivalenceForbiddenScope(NULL);
+ return !!MetaSig::CompareMethodSigs(
+ sig1.GetSignature(), static_cast<DWORD>(sig1.GetSignatureLength()), sig1.GetModule(), &sig1.GetSubstitution(),
+ sig2.GetSignature(), static_cast<DWORD>(sig2.GetSignatureLength()), sig2.GetModule(), &sig2.GetSubstitution(),
+ &newVisited);
}
//*******************************************************************************
@@ -3896,13 +3866,6 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList,
BOOL fFieldRequiresAlign8 = HasParent() ? GetParentMethodTable()->RequiresAlign8() : FALSE;
#endif
-#ifdef FEATURE_LEGACYNETCF
- BOOL fNetCFCompat = GetModule()->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8;
- DWORD dwStaticsSizeOnNetCF = 0;
-#else
- const BOOL fNetCFCompat = FALSE;
-#endif
-
for (i = 0; i < bmtMetaData->cFields; i++)
{
PCCOR_SIGNATURE pMemberSignature;
@@ -4400,8 +4363,7 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList,
);
// Check if the ValueType field containing non-publics is overlapped
- if (!fNetCFCompat
- && HasExplicitFieldOffsetLayout()
+ if (HasExplicitFieldOffsetLayout()
&& pLayoutFieldInfo != NULL
&& pLayoutFieldInfo->m_fIsOverlapped
&& pByValueClass != NULL
@@ -11498,11 +11460,6 @@ void MethodTableBuilder::VerifyVirtualMethodsImplemented(MethodTable::MethodData
return;
#endif // FEATURE_COMINTEROP
-#ifdef FEATURE_LEGACYNETCF
- if (GetModule()->GetDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- return;
-#endif
-
// Since interfaces aren't laid out in the vtable for stub dispatch, what we need to do
// is try to find an implementation for every interface contract by iterating through
// the interfaces not declared on a parent.
diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp
index 220a3bbb91..f4abb5f2f5 100644
--- a/src/vm/pefile.cpp
+++ b/src/vm/pefile.cpp
@@ -306,11 +306,6 @@ void PEFile::ValidateImagePlatformNeutrality()
fMachineOk = (machine == IMAGE_FILE_MACHINE_I386);
fPlatformFlagsOk = ((kind & (peILonly | pe32Plus | pe32BitRequired)) == peILonly);
-
-#ifdef FEATURE_LEGACYNETCF
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- fPlatformFlagsOk = ((kind & (peILonly | pe32Plus)) == peILonly);
-#endif
if (!(fMachineOk &&
fPlatformFlagsOk))
@@ -561,14 +556,6 @@ static void ValidatePEFileMachineType(PEFile *peFile)
if (actualMachineType != IMAGE_FILE_MACHINE_NATIVE)
{
-#ifdef FEATURE_LEGACYNETCF
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8)
- {
- if (actualMachineType == IMAGE_FILE_MACHINE_I386 && ((peKind & peILonly)) == peILonly)
- return;
- }
-#endif
-
#ifdef _TARGET_AMD64_
// v4.0 64-bit compatibility workaround. The 64-bit v4.0 CLR's Reflection.Load(byte[]) api does not detect cpu-matches. We should consider fixing that in
// the next SxS release. In the meantime, this bypass will retain compat for 64-bit v4.0 CLR for target platforms that existed at the time.
@@ -4344,33 +4331,11 @@ void PEAssembly::VerifyStrongName()
#endif // !defined(FEATURE_CORECLR)
else
{
-#if defined(FEATURE_CORECLR)
+#ifdef FEATURE_CORECLR
// Runtime policy on CoreCLR is to skip verification of ALL assemblies
m_flags |= PEFILE_SKIP_MODULE_HASH_CHECKS;
m_fStrongNameVerified = TRUE;
#else
-
-#ifdef FEATURE_CORECLR
- BOOL skip = FALSE;
-
- // Skip verification for assemblies from the trusted path
- if (IsSystem() || m_bIsOnTpaList)
- skip = TRUE;
-
-#ifdef FEATURE_LEGACYNETCF
- // crossgen should skip verification for Mango
- if (RuntimeIsLegacyNetCF(0))
- skip = TRUE;
-#endif
-
- if (skip)
- {
- m_flags |= PEFILE_SKIP_MODULE_HASH_CHECKS;
- m_fStrongNameVerified = TRUE;
- return;
- }
-#endif // FEATURE_CORECLR
-
DWORD verifyOutputFlags = 0;
HRESULT hr = GetILimage()->VerifyStrongName(&verifyOutputFlags);
diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp
index 2bedb83571..aeb9c3063a 100644
--- a/src/vm/prestub.cpp
+++ b/src/vm/prestub.cpp
@@ -780,15 +780,19 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
CONTRACT_END;
SigTypeContext typeContext;
+ MethodTable* pStubMT;
if (pTargetMD->HasMethodInstantiation())
{
// The pHiddenArg shall be a MethodDesc*
- SigTypeContext::InitTypeContext(static_cast<MethodDesc *>(pHiddenArg), &typeContext);
+ MethodDesc* pMD = static_cast<MethodDesc *>(pHiddenArg);
+ SigTypeContext::InitTypeContext(pMD, &typeContext);
+ pStubMT = pMD->GetMethodTable();
}
else
{
// The pHiddenArg shall be a MethodTable*
SigTypeContext::InitTypeContext(TypeHandle::FromPtr(pHiddenArg), &typeContext);
+ pStubMT = static_cast<MethodTable *>(pHiddenArg);
}
MetaSig msig(pTargetMD);
@@ -837,7 +841,7 @@ Stub * CreateInstantiatingILStub(MethodDesc* pTargetMD, void* pHiddenArg)
pTargetMD->GetSig(&pSig,&cbSig);
PTR_Module pLoaderModule = pTargetMD->GetLoaderModule();
MethodDesc * pStubMD = ILStubCache::CreateAndLinkNewILStubMethodDesc(pTargetMD->GetLoaderAllocator(),
- pLoaderModule->GetILStubCache()->GetOrCreateStubMethodTable(pLoaderModule),
+ pStubMT,
ILSTUB_INSTANTIATINGSTUB,
pTargetMD->GetModule(),
pSig, cbSig,
diff --git a/src/vm/reflectioninvocation.cpp b/src/vm/reflectioninvocation.cpp
index edbb678502..164da1395e 100644
--- a/src/vm/reflectioninvocation.cpp
+++ b/src/vm/reflectioninvocation.cpp
@@ -521,34 +521,8 @@ FCIMPL6(Object*, RuntimeTypeHandle::CreateInstance, ReflectClassBaseObject* refT
HELPER_METHOD_FRAME_BEGIN_RET_2(rv, refThis);
-#ifdef FEATURE_LEGACYNETCF
- BOOL fNetCFCompat = GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8;
-#else
- const BOOL fNetCFCompat = FALSE;
-#endif
-
MethodTable* pVMT;
bool bNeedAccessCheck;
-
- if (fNetCFCompat && !thisTH.IsNull() && thisTH.IsArray())
- {
- ArrayTypeDesc *atd = thisTH.AsArray();
- if (atd->GetTypeParam().IsArray())
- {
- // We could do this, but Mango doesn't support creating
- // arrays of arrays here
- COMPlusThrow(kMissingMethodException,W("Arg_NoDefCTor"));
- }
-
- INT32 rank = atd->GetRank();
- INT32* lengths = (INT32*) _alloca(sizeof(INT32) * rank);
- for (INT32 i = 0; i < rank; ++i)
- {
- lengths[i] = 0;
- }
- rv = AllocateArrayEx(thisTH, lengths, rank);
- goto Exit;
- }
// Get the type information associated with refThis
if (thisTH.IsNull() || thisTH.IsTypeDesc())
@@ -736,8 +710,7 @@ FCIMPL6(Object*, RuntimeTypeHandle::CreateInstance, ReflectClassBaseObject* refT
}
}
}
-
-Exit:
+
HELPER_METHOD_FRAME_END();
return OBJECTREFToObject(rv);
}
diff --git a/src/vm/securitymeta.cpp b/src/vm/securitymeta.cpp
index 114a710463..85c81f75db 100644
--- a/src/vm/securitymeta.cpp
+++ b/src/vm/securitymeta.cpp
@@ -1612,15 +1612,6 @@ void ModuleSecurityDescriptor::VerifyDataComputed()
AssemblySecurityDescriptor *pAssemSecDesc = static_cast<AssemblySecurityDescriptor*>(pAssembly->GetSecurityDescriptor());
-#ifdef FEATURE_LEGACYNETCF
- // Legacy Mango apps have incorrect transparency attributes, so quirk to ignore them and force
- // opportunistic criticality
- if (GetAppDomain()->GetAppDomainCompatMode() == BaseDomain::APPDOMAINCOMPAT_APP_EARLIER_THAN_WP8 && !pAssemSecDesc->IsMicrosoftPlatform())
- {
- moduleFlags = ModuleSecurityDescriptorFlags_IsOpportunisticallyCritical | ModuleSecurityDescriptorFlags_IsAPTCA;
- }
-#endif // FEATURE_LEGACYNETCF
-
// We shouldn't be both all transparent and all critical
const ModuleSecurityDescriptorFlags invalidMask = ModuleSecurityDescriptorFlags_IsAllCritical |
ModuleSecurityDescriptorFlags_IsAllTransparent;
diff --git a/src/vm/staticallocationhelpers.inl b/src/vm/staticallocationhelpers.inl
index a6440f62cc..26c2573762 100644
--- a/src/vm/staticallocationhelpers.inl
+++ b/src/vm/staticallocationhelpers.inl
@@ -122,13 +122,6 @@ static BOOL GetStaticFieldElementTypeForFieldDef(Module * pModule, IMDInternalIm
HRESULT hr = pImport->GetCustomAttributeByName((mdToken)field,
g_ThreadStaticAttributeClassName,
NULL, NULL);
-
-#if defined(FEATURE_LEGACYNETCF)
- // Replicate quirk from code:CMiniMd::CommonGetCustomAttributeByNameEx
- if (FAILED(hr) && RuntimeIsLegacyNetCF(0))
- hr = S_FALSE;
-#endif
-
IfFailThrow(hr);
// Use one set of variables for regular statics, and the other set for thread statics
diff --git a/tests/arm64/Tests.lst b/tests/arm64/Tests.lst
index 0ba69d58a9..38f3b1b767 100644
--- a/tests/arm64/Tests.lst
+++ b/tests/arm64/Tests.lst
@@ -130,21 +130,21 @@ RelativePath=GC\Scenarios\FinalizeTimeout\FinalizeTimeout\FinalizeTimeout.exe
WorkingDir=GC\Scenarios\FinalizeTimeout\FinalizeTimeout
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
+Categories=Pri0;UNSTABLE;ISSUE_3515
HostStyle=Any
[MarshalBoolArrayTest.exe_19]
RelativePath=Interop\ArrayMarshalling\BoolArray\MarshalBoolArrayTest\MarshalBoolArrayTest.exe
WorkingDir=Interop\ArrayMarshalling\BoolArray\MarshalBoolArrayTest
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[MarshalArrayByValTest.exe_20]
RelativePath=Interop\ArrayMarshalling\ByValArray\MarshalArrayByValTest\MarshalArrayByValTest.exe
WorkingDir=Interop\ArrayMarshalling\ByValArray\MarshalArrayByValTest
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[Castable.exe_21]
RelativePath=Interop\ICastable\Castable\Castable.exe
@@ -165,21 +165,21 @@ RelativePath=Interop\PrimitiveMarshalling\Bool\BoolTest\BoolTest.exe
WorkingDir=Interop\PrimitiveMarshalling\Bool\BoolTest
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[PInvokeUIntPtrTest.exe_24]
RelativePath=Interop\PrimitiveMarshalling\UIntPtr\PInvokeUIntPtrTest\PInvokeUIntPtrTest.exe
WorkingDir=Interop\PrimitiveMarshalling\UIntPtr\PInvokeUIntPtrTest
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[MarshalBoolArray.exe_25]
RelativePath=Interop\ReversePInvoke\Marshalling\MarshalBoolArray\MarshalBoolArray.exe
WorkingDir=Interop\ReversePInvoke\Marshalling\MarshalBoolArray
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;RT;NATIVE_INTEROP
+Categories=Pri0;RT;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[Not-Int32.exe_26]
RelativePath=JIT\BBT\Scenario4\Not-Int32\Not-Int32.exe
@@ -1840,20 +1840,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[badldsfld_il_d.exe_263]
-RelativePath=JIT\Directed\coverage\importer\Desktop\badldsfld_il_d\badldsfld_il_d.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\badldsfld_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[badldsfld_il_r.exe_264]
-RelativePath=JIT\Directed\coverage\importer\Desktop\badldsfld_il_r\badldsfld_il_r.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\badldsfld_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[badtailcall_il_d.exe_265]
RelativePath=JIT\Directed\coverage\importer\Desktop\badtailcall_il_d\badtailcall_il_d.exe
WorkingDir=JIT\Directed\coverage\importer\Desktop\badtailcall_il_d
@@ -1868,20 +1854,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[bleref_il_d.exe_267]
-RelativePath=JIT\Directed\coverage\importer\Desktop\bleref_il_d\bleref_il_d.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\bleref_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[bleref_il_r.exe_268]
-RelativePath=JIT\Directed\coverage\importer\Desktop\bleref_il_r\bleref_il_r.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\bleref_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[byrefsubbyref1_il_d.exe_269]
RelativePath=JIT\Directed\coverage\importer\Desktop\byrefsubbyref1_il_d\byrefsubbyref1_il_d.exe
WorkingDir=JIT\Directed\coverage\importer\Desktop\byrefsubbyref1_il_d
@@ -1924,20 +1896,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[ldelemnullarr1_il_d.exe_275]
-RelativePath=JIT\Directed\coverage\importer\Desktop\ldelemnullarr1_il_d\ldelemnullarr1_il_d.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\ldelemnullarr1_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[ldelemnullarr1_il_r.exe_276]
-RelativePath=JIT\Directed\coverage\importer\Desktop\ldelemnullarr1_il_r\ldelemnullarr1_il_r.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\ldelemnullarr1_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[ldelemnullarr2_il_d.exe_277]
RelativePath=JIT\Directed\coverage\importer\Desktop\ldelemnullarr2_il_d\ldelemnullarr2_il_d.exe
WorkingDir=JIT\Directed\coverage\importer\Desktop\ldelemnullarr2_il_d
@@ -2008,20 +1966,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[nonrefsdarr_il_d.exe_287]
-RelativePath=JIT\Directed\coverage\importer\Desktop\nonrefsdarr_il_d\nonrefsdarr_il_d.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\nonrefsdarr_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[nonrefsdarr_il_r.exe_288]
-RelativePath=JIT\Directed\coverage\importer\Desktop\nonrefsdarr_il_r\nonrefsdarr_il_r.exe
-WorkingDir=JIT\Directed\coverage\importer\Desktop\nonrefsdarr_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[nullsdarr_il_d.exe_289]
RelativePath=JIT\Directed\coverage\importer\Desktop\nullsdarr_il_d\nullsdarr_il_d.exe
WorkingDir=JIT\Directed\coverage\importer\Desktop\nullsdarr_il_d
@@ -2897,34 +2841,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[rva_rvastatic1.exe_414]
-RelativePath=JIT\Directed\intrinsic\interlocked\rva_rvastatic1\rva_rvastatic1.exe
-WorkingDir=JIT\Directed\intrinsic\interlocked\rva_rvastatic1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rva_rvastatic2.exe_415]
-RelativePath=JIT\Directed\intrinsic\interlocked\rva_rvastatic2\rva_rvastatic2.exe
-WorkingDir=JIT\Directed\intrinsic\interlocked\rva_rvastatic2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rva_rvastatic3.exe_416]
-RelativePath=JIT\Directed\intrinsic\interlocked\rva_rvastatic3\rva_rvastatic3.exe
-WorkingDir=JIT\Directed\intrinsic\interlocked\rva_rvastatic3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rva_rvastatic4.exe_417]
-RelativePath=JIT\Directed\intrinsic\interlocked\rva_rvastatic4\rva_rvastatic4.exe
-WorkingDir=JIT\Directed\intrinsic\interlocked\rva_rvastatic4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[pow0_cs_d.exe_418]
RelativePath=JIT\Directed\intrinsic\pow\pow0_cs_d\pow0_cs_d.exe
WorkingDir=JIT\Directed\intrinsic\pow\pow0_cs_d
@@ -3149,13 +3065,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[lifetime2.exe_450]
-RelativePath=JIT\Directed\lifetime\lifetime2\lifetime2.exe
-WorkingDir=JIT\Directed\lifetime\lifetime2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;JIT;EXPECTED_FAIL;NEED_TRIAGE
-HostStyle=Any
[localloc3_cs_d.exe_451]
RelativePath=JIT\Directed\localloc\localloc3_cs_d\localloc3_cs_d.exe
WorkingDir=JIT\Directed\localloc\localloc3_cs_d
@@ -3968,13 +3877,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[object-pin.exe_567]
-RelativePath=JIT\Directed\pinning\object-pin\object-pin\object-pin.exe
-WorkingDir=JIT\Directed\pinning\object-pin\object-pin
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
-HostStyle=Any
[calli_excep.exe_568]
RelativePath=JIT\Directed\pinvoke\calli_excep\calli_excep.exe
WorkingDir=JIT\Directed\pinvoke\calli_excep
@@ -3989,13 +3891,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[preemptive_cooperative.exe_570]
-RelativePath=JIT\Directed\pinvoke\preemptive_cooperative\preemptive_cooperative.exe
-WorkingDir=JIT\Directed\pinvoke\preemptive_cooperative
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;ISSUE_3704
-HostStyle=Any
[sin.exe_571]
RelativePath=JIT\Directed\pinvoke\sin\sin.exe
WorkingDir=JIT\Directed\pinvoke\sin
@@ -4563,13 +4458,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[extended.exe_652]
-RelativePath=JIT\Directed\RVAInit\extended\extended.exe
-WorkingDir=JIT\Directed\RVAInit\extended
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[gcref1.exe_653]
RelativePath=JIT\Directed\RVAInit\gcref1\gcref1.exe
WorkingDir=JIT\Directed\RVAInit\gcref1
@@ -4598,13 +4486,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[overlap.exe_657]
-RelativePath=JIT\Directed\RVAInit\overlap\overlap.exe
-WorkingDir=JIT\Directed\RVAInit\overlap
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[simple.exe_658]
RelativePath=JIT\Directed\RVAInit\simple\simple.exe
WorkingDir=JIT\Directed\RVAInit\simple
@@ -4612,41 +4493,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[rvastatic1.exe_659]
-RelativePath=JIT\Directed\rvastatics\rvastatic1\rvastatic1.exe
-WorkingDir=JIT\Directed\rvastatics\rvastatic1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rvastatic2.exe_660]
-RelativePath=JIT\Directed\rvastatics\rvastatic2\rvastatic2.exe
-WorkingDir=JIT\Directed\rvastatics\rvastatic2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rvastatic3.exe_661]
-RelativePath=JIT\Directed\rvastatics\rvastatic3\rvastatic3.exe
-WorkingDir=JIT\Directed\rvastatics\rvastatic3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rvastatic4.exe_662]
-RelativePath=JIT\Directed\rvastatics\rvastatic4\rvastatic4.exe
-WorkingDir=JIT\Directed\rvastatics\rvastatic4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[rvastatic5.exe_663]
-RelativePath=JIT\Directed\rvastatics\rvastatic5\rvastatic5.exe
-WorkingDir=JIT\Directed\rvastatics\rvastatic5
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[int16_cs_d.exe_664]
RelativePath=JIT\Directed\shift\int16_cs_d\int16_cs_d.exe
WorkingDir=JIT\Directed\shift\int16_cs_d
@@ -5121,7 +4967,7 @@ RelativePath=JIT\Directed\StructABI\StructABI\StructABI.exe
WorkingDir=JIT\Directed\StructABI\StructABI
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;JIT;NATIVE_INTEROP;ISSUE_2988;NEED_TRIAGE
+Categories=Pri0;JIT;EXPECTED_FAIL;NATIVE_INTEROP;ISSUE_2988;NEED_TRIAGE
HostStyle=Any
[SP1.exe_732]
RelativePath=JIT\Directed\StructPromote\SP1\SP1.exe
@@ -5242,20 +5088,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[mutualrecurthd-tls.exe_749]
-RelativePath=JIT\Directed\tls\mutualrecurthd-tls\mutualrecurthd-tls.exe
-WorkingDir=JIT\Directed\tls\mutualrecurthd-tls
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
-HostStyle=Any
-[test-tls.exe_750]
-RelativePath=JIT\Directed\tls\test-tls\test-tls.exe
-WorkingDir=JIT\Directed\tls\test-tls
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
-HostStyle=Any
[TypedReference.exe_751]
RelativePath=JIT\Directed\TypedReference\TypedReference\TypedReference.exe
WorkingDir=JIT\Directed\TypedReference\TypedReference
@@ -8084,13 +7916,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[conv_ovf_i8_i.exe_1155]
-RelativePath=JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i\conv_ovf_i8_i.exe
-WorkingDir=JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[conv_ovf_i8_i4.exe_1156]
RelativePath=JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i4\conv_ovf_i8_i4.exe
WorkingDir=JIT\IL_Conformance\Old\Conformance_Base\conv_ovf_i8_i4
@@ -9162,13 +8987,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[rem_r4.exe_1309]
-RelativePath=JIT\IL_Conformance\Old\Conformance_Base\rem_r4\rem_r4.exe
-WorkingDir=JIT\IL_Conformance\Old\Conformance_Base\rem_r4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[rem_r8.exe_1310]
RelativePath=JIT\IL_Conformance\Old\Conformance_Base\rem_r8\rem_r8.exe
WorkingDir=JIT\IL_Conformance\Old\Conformance_Base\rem_r8
@@ -9573,14 +9391,14 @@ RelativePath=JIT\IL_Conformance\Old\directed\ldarg_s_r4\ldarg_s_r4.exe
WorkingDir=JIT\IL_Conformance\Old\directed\ldarg_s_r4
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[ldarg_s_r8.exe_1368]
RelativePath=JIT\IL_Conformance\Old\directed\ldarg_s_r8\ldarg_s_r8.exe
WorkingDir=JIT\IL_Conformance\Old\directed\ldarg_s_r8
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[ldloca_s_i1.exe_1369]
RelativePath=JIT\IL_Conformance\Old\directed\ldloca_s_i1\ldloca_s_i1.exe
@@ -10553,28 +10371,28 @@ RelativePath=JIT\jit64\hfa\main\testA\hfa_nd0A_d\hfa_nd0A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nd0A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd0A_r.exe_1508]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nd0A_r\hfa_nd0A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nd0A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd1A_d.exe_1509]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nd1A_d\hfa_nd1A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nd1A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd1A_r.exe_1510]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nd1A_r\hfa_nd1A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nd1A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd2A_d.exe_1511]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nd2A_d\hfa_nd2A_d.exe
@@ -10595,28 +10413,28 @@ RelativePath=JIT\jit64\hfa\main\testA\hfa_nf0A_d\hfa_nf0A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nf0A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf0A_r.exe_1514]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nf0A_r\hfa_nf0A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nf0A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf1A_d.exe_1515]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nf1A_d\hfa_nf1A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nf1A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf1A_r.exe_1516]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nf1A_r\hfa_nf1A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_nf1A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf2A_d.exe_1517]
RelativePath=JIT\jit64\hfa\main\testA\hfa_nf2A_d\hfa_nf2A_d.exe
@@ -10637,28 +10455,28 @@ RelativePath=JIT\jit64\hfa\main\testA\hfa_sd0A_d\hfa_sd0A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sd0A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd0A_r.exe_1520]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sd0A_r\hfa_sd0A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sd0A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd1A_d.exe_1521]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sd1A_d\hfa_sd1A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sd1A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd1A_r.exe_1522]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sd1A_r\hfa_sd1A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sd1A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd2A_d.exe_1523]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sd2A_d\hfa_sd2A_d.exe
@@ -10679,28 +10497,28 @@ RelativePath=JIT\jit64\hfa\main\testA\hfa_sf0A_d\hfa_sf0A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sf0A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf0A_r.exe_1526]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sf0A_r\hfa_sf0A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sf0A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf1A_d.exe_1527]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sf1A_d\hfa_sf1A_d.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sf1A_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf1A_r.exe_1528]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sf1A_r\hfa_sf1A_r.exe
WorkingDir=JIT\jit64\hfa\main\testA\hfa_sf1A_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf2A_d.exe_1529]
RelativePath=JIT\jit64\hfa\main\testA\hfa_sf2A_d\hfa_sf2A_d.exe
@@ -10721,14 +10539,14 @@ RelativePath=JIT\jit64\hfa\main\testB\hfa_nd0B_d\hfa_nd0B_d.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_nd0B_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd0B_r.exe_1532]
RelativePath=JIT\jit64\hfa\main\testB\hfa_nd0B_r\hfa_nd0B_r.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_nd0B_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nd2B_d.exe_1533]
RelativePath=JIT\jit64\hfa\main\testB\hfa_nd2B_d\hfa_nd2B_d.exe
@@ -10749,14 +10567,14 @@ RelativePath=JIT\jit64\hfa\main\testB\hfa_nf0B_d\hfa_nf0B_d.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_nf0B_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf0B_r.exe_1536]
RelativePath=JIT\jit64\hfa\main\testB\hfa_nf0B_r\hfa_nf0B_r.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_nf0B_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_nf2B_d.exe_1537]
RelativePath=JIT\jit64\hfa\main\testB\hfa_nf2B_d\hfa_nf2B_d.exe
@@ -10777,14 +10595,14 @@ RelativePath=JIT\jit64\hfa\main\testB\hfa_sd0B_d\hfa_sd0B_d.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_sd0B_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd0B_r.exe_1540]
RelativePath=JIT\jit64\hfa\main\testB\hfa_sd0B_r\hfa_sd0B_r.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_sd0B_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sd2B_d.exe_1541]
RelativePath=JIT\jit64\hfa\main\testB\hfa_sd2B_d\hfa_sd2B_d.exe
@@ -10805,14 +10623,14 @@ RelativePath=JIT\jit64\hfa\main\testB\hfa_sf0B_d\hfa_sf0B_d.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_sf0B_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf0B_r.exe_1544]
RelativePath=JIT\jit64\hfa\main\testB\hfa_sf0B_r\hfa_sf0B_r.exe
WorkingDir=JIT\jit64\hfa\main\testB\hfa_sf0B_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[hfa_sf2B_d.exe_1545]
RelativePath=JIT\jit64\hfa\main\testB\hfa_sf2B_d\hfa_sf2B_d.exe
@@ -10861,14 +10679,14 @@ RelativePath=JIT\jit64\hfa\main\testC\hfa_nd2C_d\hfa_nd2C_d.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_nd2C_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nd2C_r.exe_1552]
RelativePath=JIT\jit64\hfa\main\testC\hfa_nd2C_r\hfa_nd2C_r.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_nd2C_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nf0C_d.exe_1553]
RelativePath=JIT\jit64\hfa\main\testC\hfa_nf0C_d\hfa_nf0C_d.exe
@@ -10903,14 +10721,14 @@ RelativePath=JIT\jit64\hfa\main\testC\hfa_nf2C_d\hfa_nf2C_d.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_nf2C_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nf2C_r.exe_1558]
RelativePath=JIT\jit64\hfa\main\testC\hfa_nf2C_r\hfa_nf2C_r.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_nf2C_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sd0C_d.exe_1559]
RelativePath=JIT\jit64\hfa\main\testC\hfa_sd0C_d\hfa_sd0C_d.exe
@@ -10945,14 +10763,14 @@ RelativePath=JIT\jit64\hfa\main\testC\hfa_sd2C_d\hfa_sd2C_d.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_sd2C_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sd2C_r.exe_1564]
RelativePath=JIT\jit64\hfa\main\testC\hfa_sd2C_r\hfa_sd2C_r.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_sd2C_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sf0C_d.exe_1565]
RelativePath=JIT\jit64\hfa\main\testC\hfa_sf0C_d\hfa_sf0C_d.exe
@@ -10987,14 +10805,14 @@ RelativePath=JIT\jit64\hfa\main\testC\hfa_sf2C_d\hfa_sf2C_d.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_sf2C_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sf2C_r.exe_1570]
RelativePath=JIT\jit64\hfa\main\testC\hfa_sf2C_r\hfa_sf2C_r.exe
WorkingDir=JIT\jit64\hfa\main\testC\hfa_sf2C_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nd0E_d.exe_1571]
RelativePath=JIT\jit64\hfa\main\testE\hfa_nd0E_d\hfa_nd0E_d.exe
@@ -11029,14 +10847,14 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_nd2E_d\hfa_nd2E_d.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nd2E_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nd2E_r.exe_1576]
RelativePath=JIT\jit64\hfa\main\testE\hfa_nd2E_r\hfa_nd2E_r.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nd2E_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nf0E_d.exe_1577]
RelativePath=JIT\jit64\hfa\main\testE\hfa_nf0E_d\hfa_nf0E_d.exe
@@ -11071,14 +10889,14 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_nf2E_d\hfa_nf2E_d.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nf2E_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nf2E_r.exe_1582]
RelativePath=JIT\jit64\hfa\main\testE\hfa_nf2E_r\hfa_nf2E_r.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_nf2E_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sd0E_d.exe_1583]
RelativePath=JIT\jit64\hfa\main\testE\hfa_sd0E_d\hfa_sd0E_d.exe
@@ -11113,14 +10931,14 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sd2E_d\hfa_sd2E_d.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sd2E_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sd2E_r.exe_1588]
RelativePath=JIT\jit64\hfa\main\testE\hfa_sd2E_r\hfa_sd2E_r.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sd2E_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sf0E_d.exe_1589]
RelativePath=JIT\jit64\hfa\main\testE\hfa_sf0E_d\hfa_sf0E_d.exe
@@ -11155,14 +10973,14 @@ RelativePath=JIT\jit64\hfa\main\testE\hfa_sf2E_d\hfa_sf2E_d.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sf2E_d
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_sf2E_r.exe_1594]
RelativePath=JIT\jit64\hfa\main\testE\hfa_sf2E_r\hfa_sf2E_r.exe
WorkingDir=JIT\jit64\hfa\main\testE\hfa_sf2E_r
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[hfa_nd0G_d.exe_1595]
RelativePath=JIT\jit64\hfa\main\testG\hfa_nd0G_d\hfa_nd0G_d.exe
@@ -11808,27 +11626,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[verify01_dynamic.exe_1687]
-RelativePath=JIT\jit64\localloc\verify\verify01_dynamic\verify01_dynamic.exe
-WorkingDir=JIT\jit64\localloc\verify\verify01_dynamic
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[verify01_large.exe_1688]
-RelativePath=JIT\jit64\localloc\verify\verify01_large\verify01_large.exe
-WorkingDir=JIT\jit64\localloc\verify\verify01_large
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[verify01_small.exe_1689]
-RelativePath=JIT\jit64\localloc\verify\verify01_small\verify01_small.exe
-WorkingDir=JIT\jit64\localloc\verify\verify01_small
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[zeroinit01_large.exe_1690]
RelativePath=JIT\jit64\localloc\zeroinit\zeroinit01_large\zeroinit01_large.exe
WorkingDir=JIT\jit64\localloc\zeroinit\zeroinit01_large
@@ -11848,21 +11645,21 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i00\mcc_i00.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i00
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[mcc_i01.exe_1693]
RelativePath=JIT\jit64\mcc\interop\mcc_i01\mcc_i01.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i01
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[mcc_i02.exe_1694]
RelativePath=JIT\jit64\mcc\interop\mcc_i02\mcc_i02.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i02
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_FAIL;NATIVE_INTEROP
HostStyle=Any
[mcc_i03.exe_1695]
RelativePath=JIT\jit64\mcc\interop\mcc_i03\mcc_i03.exe
@@ -11876,28 +11673,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i04\mcc_i04.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i04
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i05.exe_1697]
RelativePath=JIT\jit64\mcc\interop\mcc_i05\mcc_i05.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i05
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i06.exe_1698]
RelativePath=JIT\jit64\mcc\interop\mcc_i06\mcc_i06.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i06
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i07.exe_1699]
RelativePath=JIT\jit64\mcc\interop\mcc_i07\mcc_i07.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i07
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i10.exe_1700]
RelativePath=JIT\jit64\mcc\interop\mcc_i10\mcc_i10.exe
@@ -11932,28 +11729,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i14\mcc_i14.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i14
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i15.exe_1705]
RelativePath=JIT\jit64\mcc\interop\mcc_i15\mcc_i15.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i15
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i16.exe_1706]
RelativePath=JIT\jit64\mcc\interop\mcc_i16\mcc_i16.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i16
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i17.exe_1707]
RelativePath=JIT\jit64\mcc\interop\mcc_i17\mcc_i17.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i17
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i30.exe_1708]
RelativePath=JIT\jit64\mcc\interop\mcc_i30\mcc_i30.exe
@@ -11988,28 +11785,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i34\mcc_i34.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i34
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i35.exe_1713]
RelativePath=JIT\jit64\mcc\interop\mcc_i35\mcc_i35.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i35
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i36.exe_1714]
RelativePath=JIT\jit64\mcc\interop\mcc_i36\mcc_i36.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i36
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i37.exe_1715]
RelativePath=JIT\jit64\mcc\interop\mcc_i37\mcc_i37.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i37
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;NATIVE_INTEROP
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i50.exe_1716]
RelativePath=JIT\jit64\mcc\interop\mcc_i50\mcc_i50.exe
@@ -12044,28 +11841,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i54\mcc_i54.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i54
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i55.exe_1721]
RelativePath=JIT\jit64\mcc\interop\mcc_i55\mcc_i55.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i55
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i56.exe_1722]
RelativePath=JIT\jit64\mcc\interop\mcc_i56\mcc_i56.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i56
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i57.exe_1723]
RelativePath=JIT\jit64\mcc\interop\mcc_i57\mcc_i57.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i57
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i60.exe_1724]
RelativePath=JIT\jit64\mcc\interop\mcc_i60\mcc_i60.exe
@@ -12100,28 +11897,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i64\mcc_i64.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i64
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i65.exe_1729]
RelativePath=JIT\jit64\mcc\interop\mcc_i65\mcc_i65.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i65
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i66.exe_1730]
RelativePath=JIT\jit64\mcc\interop\mcc_i66\mcc_i66.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i66
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i67.exe_1731]
RelativePath=JIT\jit64\mcc\interop\mcc_i67\mcc_i67.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i67
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i70.exe_1732]
RelativePath=JIT\jit64\mcc\interop\mcc_i70\mcc_i70.exe
@@ -12156,28 +11953,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i74\mcc_i74.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i74
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i75.exe_1737]
RelativePath=JIT\jit64\mcc\interop\mcc_i75\mcc_i75.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i75
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i76.exe_1738]
RelativePath=JIT\jit64\mcc\interop\mcc_i76\mcc_i76.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i76
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i77.exe_1739]
RelativePath=JIT\jit64\mcc\interop\mcc_i77\mcc_i77.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i77
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[mcc_i80.exe_1740]
RelativePath=JIT\jit64\mcc\interop\mcc_i80\mcc_i80.exe
@@ -12212,28 +12009,28 @@ RelativePath=JIT\jit64\mcc\interop\mcc_i84\mcc_i84.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i84
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i85.exe_1745]
RelativePath=JIT\jit64\mcc\interop\mcc_i85\mcc_i85.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i85
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i86.exe_1746]
RelativePath=JIT\jit64\mcc\interop\mcc_i86\mcc_i86.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i86
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[mcc_i87.exe_1747]
RelativePath=JIT\jit64\mcc\interop\mcc_i87\mcc_i87.exe
WorkingDir=JIT\jit64\mcc\interop\mcc_i87
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[CGRecurseAAA_d.exe_1748]
RelativePath=JIT\jit64\opt\cg\CGRecurse\CGRecurseAAA_d\CGRecurseAAA_d.exe
@@ -13320,13 +13117,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b21220.exe_1903]
-RelativePath=JIT\jit64\regress\ndpw\21220\b21220\b21220.exe
-WorkingDir=JIT\jit64\regress\ndpw\21220\b21220
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[test.exe_1904]
RelativePath=JIT\jit64\regress\phoenix\62322\test\test.exe
WorkingDir=JIT\jit64\regress\phoenix\62322\test
@@ -13334,20 +13124,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[test1.exe_1905]
-RelativePath=JIT\jit64\regress\vsw\102754\test1\test1.exe
-WorkingDir=JIT\jit64\regress\vsw\102754\test1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[test2.exe_1906]
-RelativePath=JIT\jit64\regress\vsw\102754\test2\test2.exe
-WorkingDir=JIT\jit64\regress\vsw\102754\test2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[test.exe_1907]
RelativePath=JIT\jit64\regress\vsw\102964\test\test.exe
WorkingDir=JIT\jit64\regress\vsw\102964\test
@@ -16139,14 +15915,14 @@ RelativePath=JIT\Methodical\Arrays\huge\_il_dbghuge_r4\_il_dbghuge_r4.exe
WorkingDir=JIT\Methodical\Arrays\huge\_il_dbghuge_r4
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[_il_dbghuge_r8.exe_2306]
RelativePath=JIT\Methodical\Arrays\huge\_il_dbghuge_r8\_il_dbghuge_r8.exe
WorkingDir=JIT\Methodical\Arrays\huge\_il_dbghuge_r8
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[_il_dbghuge_struct.exe_2307]
RelativePath=JIT\Methodical\Arrays\huge\_il_dbghuge_struct\_il_dbghuge_struct.exe
@@ -16188,14 +15964,14 @@ RelativePath=JIT\Methodical\Arrays\huge\_il_relhuge_r4\_il_relhuge_r4.exe
WorkingDir=JIT\Methodical\Arrays\huge\_il_relhuge_r4
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[_il_relhuge_r8.exe_2313]
RelativePath=JIT\Methodical\Arrays\huge\_il_relhuge_r8\_il_relhuge_r8.exe
WorkingDir=JIT\Methodical\Arrays\huge\_il_relhuge_r8
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;EXPECTED_PASS
HostStyle=Any
[_il_relhuge_struct.exe_2314]
RelativePath=JIT\Methodical\Arrays\huge\_il_relhuge_struct\_il_relhuge_struct.exe
@@ -16484,13 +16260,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_il_dbgarrres.exe_2355]
-RelativePath=JIT\Methodical\Arrays\misc\_il_dbgarrres\_il_dbgarrres.exe
-WorkingDir=JIT\Methodical\Arrays\misc\_il_dbgarrres
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_dbggcarr.exe_2356]
RelativePath=JIT\Methodical\Arrays\misc\_il_dbggcarr\_il_dbggcarr.exe
WorkingDir=JIT\Methodical\Arrays\misc\_il_dbggcarr
@@ -16540,13 +16309,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_il_relarrres.exe_2363]
-RelativePath=JIT\Methodical\Arrays\misc\_il_relarrres\_il_relarrres.exe
-WorkingDir=JIT\Methodical\Arrays\misc\_il_relarrres
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relgcarr.exe_2364]
RelativePath=JIT\Methodical\Arrays\misc\_il_relgcarr\_il_relgcarr.exe
WorkingDir=JIT\Methodical\Arrays\misc\_il_relgcarr
@@ -17548,27 +17310,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_dbgsin_cs_il.exe_2507]
-RelativePath=JIT\Methodical\Boxing\xlang\_dbgsin_cs_il\_dbgsin_cs_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_dbgsin_cs_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_dbgsin_il_cs.exe_2508]
-RelativePath=JIT\Methodical\Boxing\xlang\_dbgsin_il_cs\_dbgsin_il_cs.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_dbgsin_il_cs
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_dbgsin_il_il.exe_2509]
-RelativePath=JIT\Methodical\Boxing\xlang\_dbgsin_il_il\_dbgsin_il_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_dbgsin_il_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_odbgsin_cs_cs.exe_2510]
RelativePath=JIT\Methodical\Boxing\xlang\_odbgsin_cs_cs\_odbgsin_cs_cs.exe
WorkingDir=JIT\Methodical\Boxing\xlang\_odbgsin_cs_cs
@@ -17576,27 +17317,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_odbgsin_cs_il.exe_2511]
-RelativePath=JIT\Methodical\Boxing\xlang\_odbgsin_cs_il\_odbgsin_cs_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_odbgsin_cs_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_odbgsin_il_cs.exe_2512]
-RelativePath=JIT\Methodical\Boxing\xlang\_odbgsin_il_cs\_odbgsin_il_cs.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_odbgsin_il_cs
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_odbgsin_il_il.exe_2513]
-RelativePath=JIT\Methodical\Boxing\xlang\_odbgsin_il_il\_odbgsin_il_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_odbgsin_il_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_orelsin_cs_cs.exe_2514]
RelativePath=JIT\Methodical\Boxing\xlang\_orelsin_cs_cs\_orelsin_cs_cs.exe
WorkingDir=JIT\Methodical\Boxing\xlang\_orelsin_cs_cs
@@ -17604,27 +17324,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_orelsin_cs_il.exe_2515]
-RelativePath=JIT\Methodical\Boxing\xlang\_orelsin_cs_il\_orelsin_cs_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_orelsin_cs_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_orelsin_il_cs.exe_2516]
-RelativePath=JIT\Methodical\Boxing\xlang\_orelsin_il_cs\_orelsin_il_cs.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_orelsin_il_cs
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_orelsin_il_il.exe_2517]
-RelativePath=JIT\Methodical\Boxing\xlang\_orelsin_il_il\_orelsin_il_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_orelsin_il_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_relsin_cs_cs.exe_2518]
RelativePath=JIT\Methodical\Boxing\xlang\_relsin_cs_cs\_relsin_cs_cs.exe
WorkingDir=JIT\Methodical\Boxing\xlang\_relsin_cs_cs
@@ -17632,27 +17331,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[_relsin_cs_il.exe_2519]
-RelativePath=JIT\Methodical\Boxing\xlang\_relsin_cs_il\_relsin_cs_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_relsin_cs_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_relsin_il_cs.exe_2520]
-RelativePath=JIT\Methodical\Boxing\xlang\_relsin_il_cs\_relsin_il_cs.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_relsin_il_cs
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_relsin_il_il.exe_2521]
-RelativePath=JIT\Methodical\Boxing\xlang\_relsin_il_il\_relsin_il_il.exe
-WorkingDir=JIT\Methodical\Boxing\xlang\_relsin_il_il
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_dbgarrays.exe_2522]
RelativePath=JIT\Methodical\casts\array\_il_dbgarrays\_il_dbgarrays.exe
WorkingDir=JIT\Methodical\casts\array\_il_dbgarrays
@@ -18297,34 +17975,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[global_il_d.exe_2614]
-RelativePath=JIT\Methodical\cctor\misc\global_il_d\global_il_d.exe
-WorkingDir=JIT\Methodical\cctor\misc\global_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[global_il_r.exe_2615]
-RelativePath=JIT\Methodical\cctor\misc\global_il_r\global_il_r.exe
-WorkingDir=JIT\Methodical\cctor\misc\global_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[tail_il_d.exe_2616]
-RelativePath=JIT\Methodical\cctor\misc\tail_il_d\tail_il_d.exe
-WorkingDir=JIT\Methodical\cctor\misc\tail_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[tail_il_r.exe_2617]
-RelativePath=JIT\Methodical\cctor\misc\tail_il_r\tail_il_r.exe
-WorkingDir=JIT\Methodical\cctor\misc\tail_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[threads1_cs_d.exe_2618]
RelativePath=JIT\Methodical\cctor\misc\threads1_cs_d\threads1_cs_d.exe
WorkingDir=JIT\Methodical\cctor\misc\threads1_cs_d
@@ -18381,20 +18031,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[threads3_il_d.exe_2626]
-RelativePath=JIT\Methodical\cctor\misc\threads3_il_d\threads3_il_d.exe
-WorkingDir=JIT\Methodical\cctor\misc\threads3_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[threads3_il_r.exe_2627]
-RelativePath=JIT\Methodical\cctor\misc\threads3_il_r\threads3_il_r.exe
-WorkingDir=JIT\Methodical\cctor\misc\threads3_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[throw_cs_d.exe_2628]
RelativePath=JIT\Methodical\cctor\misc\throw_cs_d\throw_cs_d.exe
WorkingDir=JIT\Methodical\cctor\misc\throw_cs_d
@@ -18514,20 +18150,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[precise3_il_d.exe_2645]
-RelativePath=JIT\Methodical\cctor\simple\precise3_il_d\precise3_il_d.exe
-WorkingDir=JIT\Methodical\cctor\simple\precise3_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[precise3_il_r.exe_2646]
-RelativePath=JIT\Methodical\cctor\simple\precise3_il_r\precise3_il_r.exe
-WorkingDir=JIT\Methodical\cctor\simple\precise3_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[precise4_cs_d.exe_2647]
RelativePath=JIT\Methodical\cctor\simple\precise4_cs_d\precise4_cs_d.exe
WorkingDir=JIT\Methodical\cctor\simple\precise4_cs_d
@@ -18745,20 +18367,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_simpleoddpower_il_d.exe_2678]
-RelativePath=JIT\Methodical\delegate\_simpleoddpower_il_d\_simpleoddpower_il_d.exe
-WorkingDir=JIT\Methodical\delegate\_simpleoddpower_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;REL_PASS
-HostStyle=Any
-[_simpleoddpower_il_r.exe_2679]
-RelativePath=JIT\Methodical\delegate\_simpleoddpower_il_r\_simpleoddpower_il_r.exe
-WorkingDir=JIT\Methodical\delegate\_simpleoddpower_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL;REL_PASS
-HostStyle=Any
[decimaldiv_cs_d.exe_2680]
RelativePath=JIT\Methodical\divrem\div\decimaldiv_cs_d\decimaldiv_cs_d.exe
WorkingDir=JIT\Methodical\divrem\div\decimaldiv_cs_d
@@ -20005,20 +19613,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[badcodeafterfinally_d.exe_2858]
-RelativePath=JIT\Methodical\eh\deadcode\badcodeafterfinally_d\badcodeafterfinally_d.exe
-WorkingDir=JIT\Methodical\eh\deadcode\badcodeafterfinally_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[badcodeafterfinally_r.exe_2859]
-RelativePath=JIT\Methodical\eh\deadcode\badcodeafterfinally_r\badcodeafterfinally_r.exe
-WorkingDir=JIT\Methodical\eh\deadcode\badcodeafterfinally_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[badcodeaftertry_d.exe_2860]
RelativePath=JIT\Methodical\eh\deadcode\badcodeaftertry_d\badcodeaftertry_d.exe
WorkingDir=JIT\Methodical\eh\deadcode\badcodeaftertry_d
@@ -28692,83 +28286,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[switch1.exe_4099]
-RelativePath=JIT\Methodical\switch\switch1\switch1.exe
-WorkingDir=JIT\Methodical\switch\switch1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch10.exe_4100]
-RelativePath=JIT\Methodical\switch\switch10\switch10.exe
-WorkingDir=JIT\Methodical\switch\switch10
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch11.exe_4101]
-RelativePath=JIT\Methodical\switch\switch11\switch11.exe
-WorkingDir=JIT\Methodical\switch\switch11
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch2.exe_4102]
-RelativePath=JIT\Methodical\switch\switch2\switch2.exe
-WorkingDir=JIT\Methodical\switch\switch2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch3.exe_4103]
-RelativePath=JIT\Methodical\switch\switch3\switch3.exe
-WorkingDir=JIT\Methodical\switch\switch3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch4.exe_4104]
-RelativePath=JIT\Methodical\switch\switch4\switch4.exe
-WorkingDir=JIT\Methodical\switch\switch4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch5.exe_4105]
-RelativePath=JIT\Methodical\switch\switch5\switch5.exe
-WorkingDir=JIT\Methodical\switch\switch5
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch6.exe_4106]
-RelativePath=JIT\Methodical\switch\switch6\switch6.exe
-WorkingDir=JIT\Methodical\switch\switch6
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch7.exe_4107]
-RelativePath=JIT\Methodical\switch\switch7\switch7.exe
-WorkingDir=JIT\Methodical\switch\switch7
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch8.exe_4108]
-RelativePath=JIT\Methodical\switch\switch8\switch8.exe
-WorkingDir=JIT\Methodical\switch\switch8
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[switch9.exe_4109]
-RelativePath=JIT\Methodical\switch\switch9\switch9.exe
-WorkingDir=JIT\Methodical\switch\switch9
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relthread-race.exe_4110]
RelativePath=JIT\Methodical\tailcall\Desktop\_il_relthread-race\_il_relthread-race.exe
WorkingDir=JIT\Methodical\tailcall\Desktop\_il_relthread-race
@@ -28916,20 +28433,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_dbgpointer.exe_4131]
-RelativePath=JIT\Methodical\tailcall\_il_dbgpointer\_il_dbgpointer.exe
-WorkingDir=JIT\Methodical\tailcall\_il_dbgpointer
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_il_dbgpointer_i.exe_4132]
-RelativePath=JIT\Methodical\tailcall\_il_dbgpointer_i\_il_dbgpointer_i.exe
-WorkingDir=JIT\Methodical\tailcall\_il_dbgpointer_i
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_dbgrecurse_ep.exe_4133]
RelativePath=JIT\Methodical\tailcall\_il_dbgrecurse_ep\_il_dbgrecurse_ep.exe
WorkingDir=JIT\Methodical\tailcall\_il_dbgrecurse_ep
@@ -28937,13 +28440,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_dbgrecurse_ep_void.exe_4134]
-RelativePath=JIT\Methodical\tailcall\_il_dbgrecurse_ep_void\_il_dbgrecurse_ep_void.exe
-WorkingDir=JIT\Methodical\tailcall\_il_dbgrecurse_ep_void
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_dbgreference_i.exe_4135]
RelativePath=JIT\Methodical\tailcall\_il_dbgreference_i\_il_dbgreference_i.exe
WorkingDir=JIT\Methodical\tailcall\_il_dbgreference_i
@@ -29007,13 +28503,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_dbgtest_void.exe_4144]
-RelativePath=JIT\Methodical\tailcall\_il_dbgtest_void\_il_dbgtest_void.exe
-WorkingDir=JIT\Methodical\tailcall\_il_dbgtest_void
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relcompat_enum.exe_4145]
RelativePath=JIT\Methodical\tailcall\_il_relcompat_enum\_il_relcompat_enum.exe
WorkingDir=JIT\Methodical\tailcall\_il_relcompat_enum
@@ -29154,20 +28643,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_relpointer.exe_4165]
-RelativePath=JIT\Methodical\tailcall\_il_relpointer\_il_relpointer.exe
-WorkingDir=JIT\Methodical\tailcall\_il_relpointer
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[_il_relpointer_i.exe_4166]
-RelativePath=JIT\Methodical\tailcall\_il_relpointer_i\_il_relpointer_i.exe
-WorkingDir=JIT\Methodical\tailcall\_il_relpointer_i
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relrecurse_ep.exe_4167]
RelativePath=JIT\Methodical\tailcall\_il_relrecurse_ep\_il_relrecurse_ep.exe
WorkingDir=JIT\Methodical\tailcall\_il_relrecurse_ep
@@ -29175,13 +28650,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_relrecurse_ep_void.exe_4168]
-RelativePath=JIT\Methodical\tailcall\_il_relrecurse_ep_void\_il_relrecurse_ep_void.exe
-WorkingDir=JIT\Methodical\tailcall\_il_relrecurse_ep_void
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relreference_i.exe_4169]
RelativePath=JIT\Methodical\tailcall\_il_relreference_i\_il_relreference_i.exe
WorkingDir=JIT\Methodical\tailcall\_il_relreference_i
@@ -29245,13 +28713,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_reltest_void.exe_4178]
-RelativePath=JIT\Methodical\tailcall\_il_reltest_void\_il_reltest_void.exe
-WorkingDir=JIT\Methodical\tailcall\_il_reltest_void
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[delegateParamCallTarget.exe_4179]
RelativePath=JIT\Methodical\tailcall_v4\delegateParamCallTarget\delegateParamCallTarget.exe
WorkingDir=JIT\Methodical\tailcall_v4\delegateParamCallTarget
@@ -29518,34 +28979,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS;ISSUE_2925
HostStyle=Any
-[fault_il_d.exe_4217]
-RelativePath=JIT\Methodical\varargs\seh\fault_il_d\fault_il_d.exe
-WorkingDir=JIT\Methodical\varargs\seh\fault_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[fault_il_r.exe_4218]
-RelativePath=JIT\Methodical\varargs\seh\fault_il_r\fault_il_r.exe
-WorkingDir=JIT\Methodical\varargs\seh\fault_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[filter_il_d.exe_4219]
-RelativePath=JIT\Methodical\varargs\seh\filter_il_d\filter_il_d.exe
-WorkingDir=JIT\Methodical\varargs\seh\filter_il_d
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[filter_il_r.exe_4220]
-RelativePath=JIT\Methodical\varargs\seh\filter_il_r\filter_il_r.exe
-WorkingDir=JIT\Methodical\varargs\seh\filter_il_r
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_dbgcall.exe_4221]
RelativePath=JIT\Methodical\VT\callconv\_dbgcall\_dbgcall.exe
WorkingDir=JIT\Methodical\VT\callconv\_dbgcall
@@ -30561,13 +29994,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_dbglocalloc.exe_4366]
-RelativePath=JIT\Methodical\xxobj\operand\_il_dbglocalloc\_il_dbglocalloc.exe
-WorkingDir=JIT\Methodical\xxobj\operand\_il_dbglocalloc
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_dbgmdarray.exe_4367]
RelativePath=JIT\Methodical\xxobj\operand\_il_dbgmdarray\_il_dbgmdarray.exe
WorkingDir=JIT\Methodical\xxobj\operand\_il_dbgmdarray
@@ -30603,13 +30029,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[_il_rellocalloc.exe_4372]
-RelativePath=JIT\Methodical\xxobj\operand\_il_rellocalloc\_il_rellocalloc.exe
-WorkingDir=JIT\Methodical\xxobj\operand\_il_rellocalloc
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[_il_relmdarray.exe_4373]
RelativePath=JIT\Methodical\xxobj\operand\_il_relmdarray\_il_relmdarray.exe
WorkingDir=JIT\Methodical\xxobj\operand\_il_relmdarray
@@ -31303,13 +30722,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[TailcallVerifyWithPrefix.exe_4472]
-RelativePath=JIT\opt\Tailcall\TailcallVerifyWithPrefix\TailcallVerifyWithPrefix.exe
-WorkingDir=JIT\opt\Tailcall\TailcallVerifyWithPrefix
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[bigvtbl_cs_d.exe_4473]
RelativePath=JIT\opt\virtualstubdispatch\bigvtbl\bigvtbl_cs_d\bigvtbl_cs_d.exe
WorkingDir=JIT\opt\virtualstubdispatch\bigvtbl\bigvtbl_cs_d
@@ -31819,7 +31231,7 @@ RelativePath=JIT\Performance\CodeQuality\Serialization\Deserialize\Deserialize.e
WorkingDir=JIT\Performance\CodeQuality\Serialization\Deserialize
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
+Categories=Pri0;UNSTABLE
HostStyle=Any
[Serialize.exe_4546]
RelativePath=JIT\Performance\CodeQuality\Serialization\Serialize\Serialize.exe
@@ -31898,13 +31310,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b14426.exe_4557]
-RelativePath=JIT\Regression\CLR-x86-EJIT\V1-M09.5-PDC\b14426\b14426\b14426.exe
-WorkingDir=JIT\Regression\CLR-x86-EJIT\V1-M09.5-PDC\b14426\b14426
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_PASS
-HostStyle=Any
[b16935.exe_4558]
RelativePath=JIT\Regression\CLR-x86-EJIT\V1-M09.5-PDC\b16935\b16935\b16935.exe
WorkingDir=JIT\Regression\CLR-x86-EJIT\V1-M09.5-PDC\b16935\b16935
@@ -31919,13 +31324,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[b07847.exe_4560]
-RelativePath=JIT\Regression\CLR-x86-EJIT\v1-m10\b07847\b07847\b07847.exe
-WorkingDir=JIT\Regression\CLR-x86-EJIT\v1-m10\b07847\b07847
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b40089.exe_4561]
RelativePath=JIT\Regression\CLR-x86-EJIT\V1-M11-Beta1\b40089\b40089\b40089.exe
WorkingDir=JIT\Regression\CLR-x86-EJIT\V1-M11-Beta1\b40089\b40089
@@ -32080,13 +31478,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b13621.exe_4583]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b13621\b13621\b13621.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b13621\b13621
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_PASS
-HostStyle=Any
[b13647.exe_4584]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b13647\b13647\b13647.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b13647\b13647
@@ -32227,13 +31618,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b15307.exe_4604]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b15307\b15307\b15307.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b15307\b15307
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_PASS
-HostStyle=Any
[b15468.exe_4605]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b15468\b15468\b15468.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b15468\b15468
@@ -32283,13 +31667,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[b16102.exe_4612]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b16102\b16102\b16102.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b16102\b16102
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b16294.exe_4613]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M09\b16294\b16294\b16294.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M09\b16294\b16294
@@ -33669,13 +33046,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b04914.exe_4810]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M10\b04914\b04914\b04914.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M10\b04914\b04914
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_PASS
-HostStyle=Any
[b05214.exe_4811]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M10\b05214\b05214\b05214.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M10\b05214\b05214
@@ -34936,13 +34306,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b49644.exe_4991]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b49644\b49644\b49644.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b49644\b49644
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b49717.exe_4992]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b49717\b49717\b49717.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M11-Beta1\b49717\b49717
@@ -35881,13 +35244,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b57367.exe_5126]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b57367\b57367\b57367.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b57367\b57367
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b57492.exe_5127]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b57492\b57492\b57492.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b57492\b57492
@@ -36308,13 +35664,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b65423.exe_5187]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b65423\b65423\b65423.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b65423\b65423
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b66226.exe_5188]
RelativePath=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b66226\b66226\b66226.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1-M12-Beta2\b66226\b66226
@@ -37547,20 +36896,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;UNSTABLE;GC_GEN0
HostStyle=Any
-[b101136.exe_5364]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b101136\b101136\b101136.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b101136\b101136
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
-[b102637.exe_5365]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b102637\b102637\b102637.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b102637\b102637
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b102879.exe_5366]
RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b102879\b102879\b102879.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-Beta1\b102879\b102879
@@ -37715,13 +37050,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[b03689.exe_5388]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-M01\b03689\b03689\b03689.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-M01\b03689\b03689
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b04319.exe_5389]
RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-M01\b04319\b04319\b04319.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-M01\b04319\b04319
@@ -37785,13 +37113,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b08046.exe_5398]
-RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-M01\b08046\b08046\b08046.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-M01\b08046\b08046
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b11762.exe_5399]
RelativePath=JIT\Regression\CLR-x86-JIT\V1.2-M01\b11762\b11762\b11762.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V1.2-M01\b11762\b11762
@@ -38051,13 +37372,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b399444a.exe_5436]
-RelativePath=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b399444\b399444a\b399444a.exe
-WorkingDir=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b399444\b399444a
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_PASS
-HostStyle=Any
[b399444b.exe_5437]
RelativePath=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b399444\b399444b\b399444b.exe
WorkingDir=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b399444\b399444b
@@ -38513,13 +37827,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;EXPECTED_PASS
HostStyle=Any
-[dev10_865840.exe_5502]
-RelativePath=JIT\Regression\Dev11\dev10_865840\dev10_865840\dev10_865840.exe
-WorkingDir=JIT\Regression\Dev11\dev10_865840\dev10_865840
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[loopvt.exe_5503]
RelativePath=JIT\Regression\Dev11\dev10_94677\loopvt\loopvt.exe
WorkingDir=JIT\Regression\Dev11\dev10_94677\loopvt
@@ -39682,13 +38989,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b108129.exe_5669]
-RelativePath=JIT\Regression\VS-ia64-JIT\V1.2-M02\b108129\b108129\b108129.exe
-WorkingDir=JIT\Regression\VS-ia64-JIT\V1.2-M02\b108129\b108129
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b10828.exe_5670]
RelativePath=JIT\Regression\VS-ia64-JIT\V1.2-M02\b10828\b10828\b10828.exe
WorkingDir=JIT\Regression\VS-ia64-JIT\V1.2-M02\b10828\b10828
@@ -39955,13 +39255,6 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
-[b410474.exe_5708]
-RelativePath=JIT\Regression\VS-ia64-JIT\V2.0-Beta2\b410474\b410474\b410474.exe
-WorkingDir=JIT\Regression\VS-ia64-JIT\V2.0-Beta2\b410474\b410474
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri0;EXPECTED_FAIL
-HostStyle=Any
[b431098.exe_5709]
RelativePath=JIT\Regression\VS-ia64-JIT\V2.0-Beta2\b431098\b431098\b431098.exe
WorkingDir=JIT\Regression\VS-ia64-JIT\V2.0-Beta2\b431098\b431098
@@ -40681,7 +39974,7 @@ RelativePath=Loader\NativeLibs\FromNativePaths\FromNativePaths.exe
WorkingDir=Loader\NativeLibs\FromNativePaths
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;RT;EXPECTED_FAIL;NEW_PASS
+Categories=Pri0;RT;EXPECTED_PASS;NATIVE_INTEROP
HostStyle=Any
[main.exe_5812]
RelativePath=Loader\regressions\classloader\main\main.exe
@@ -40709,7 +40002,7 @@ RelativePath=managed\Compilation\Compilation\Compilation.exe
WorkingDir=managed\Compilation\Compilation
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri0;RT;NATIVE_INTEROP
+Categories=Pri0;RT;UNSTABLE;NATIVE_INTEROP;LONG_RUNNING
HostStyle=Any
[test.exe_5816]
RelativePath=Regressions\assemblyref\test\test.exe
@@ -58671,7 +57964,7 @@ RelativePath=JIT\Regression\clr-x64-JIT\v4.0\devdiv374539\DevDiv_374539\DevDiv_3
WorkingDir=JIT\Regression\clr-x64-JIT\v4.0\devdiv374539\DevDiv_374539
Expected=100
MaxAllowedDurationSeconds=600
-Categories=Pri1;EXPECTED_PASS
+Categories=Pri1;EXPECTED_PASS;LONG_RUNNING
HostStyle=Any
[repro177066.exe_8381]
RelativePath=Loader\binding\assemblies\assemblybugs\177066w\repro177066\repro177066.exe
@@ -59142,185 +58435,3 @@ Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri1;RT;EXPECTED_PASS
HostStyle=Any
-[CheckAddInt_1.exe_8447]
-RelativePath=baseservices\threading\interlocked\add\CheckAddInt_1\CheckAddInt_1.exe
-WorkingDir=baseservices\threading\interlocked\add\CheckAddInt_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[CheckAddInt_2.exe_8448]
-RelativePath=baseservices\threading\interlocked\add\CheckAddInt_2\CheckAddInt_2.exe
-WorkingDir=baseservices\threading\interlocked\add\CheckAddInt_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[CompareExchangeLong_1.exe_8449]
-RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_1\CompareExchangeLong_1.exe
-WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[CompareExchangeLong_2.exe_8450]
-RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_2\CompareExchangeLong_2.exe
-WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[CompareExchangeLong_3.exe_8451]
-RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_3\CompareExchangeLong_3.exe
-WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[CompareExchangeLong_4.exe_8452]
-RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_4\CompareExchangeLong_4.exe
-WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeLong_4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartBool_1.exe_8453]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartBool_1\ThreadStartBool_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartBool_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartBool_2.exe_8454]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartBool_2\ThreadStartBool_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartBool_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDecimal_1.exe_8455]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDecimal_1\ThreadStartDecimal_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDecimal_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDecimal_2.exe_8456]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDecimal_2\ThreadStartDecimal_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDecimal_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDecimal_3.exe_8457]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDecimal_3\ThreadStartDecimal_3.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDecimal_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDouble_1.exe_8458]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDouble_1\ThreadStartDouble_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDouble_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDouble_2.exe_8459]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDouble_2\ThreadStartDouble_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDouble_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartDouble_3.exe_8460]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartDouble_3\ThreadStartDouble_3.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartDouble_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartObject_1.exe_8461]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartObject_1\ThreadStartObject_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartObject_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartObject_2.exe_8462]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartObject_2\ThreadStartObject_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartObject_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartSByte_1.exe_8463]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartSByte_1\ThreadStartSByte_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartSByte_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartSByte_2.exe_8464]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartSByte_2\ThreadStartSByte_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartSByte_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartSByte_3.exe_8465]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartSByte_3\ThreadStartSByte_3.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartSByte_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartString_1.exe_8466]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartString_1\ThreadStartString_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartString_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartString_2.exe_8467]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartString_2\ThreadStartString_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartString_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartString_3.exe_8468]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartString_3\ThreadStartString_3.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartString_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartString_4.exe_8469]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartString_4\ThreadStartString_4.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartString_4
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartULong_1.exe_8470]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartULong_1\ThreadStartULong_1.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartULong_1
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartULong_2.exe_8471]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartULong_2\ThreadStartULong_2.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartULong_2
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
-[ThreadStartULong_3.exe_8472]
-RelativePath=baseservices\threading\paramthreadstart\ThreadStartULong_3\ThreadStartULong_3.exe
-WorkingDir=baseservices\threading\paramthreadstart\ThreadStartULong_3
-Expected=100
-MaxAllowedDurationSeconds=600
-Categories=Pri2;RT;NATIVE_INTEROP
-HostStyle=Any
diff --git a/tests/issues.targets b/tests/issues.targets
index 4132d9a130..a87655a60a 100644
--- a/tests/issues.targets
+++ b/tests/issues.targets
@@ -1,7 +1,7 @@
<Project DefaultTargets = "GetListOfTestCmds"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemGroup Condition="'$(XunitTestBinBase)' != ''">
- <ExcludeList Include="$(XunitTestBinBase)\JIT\Directed\lifetime\**\lifetime2.cmd" >
+ <ExcludeList Include="$(XunitTestBinBase)\JIT\Directed\lifetime\lifetime2\lifetime2.cmd" >
<Issue>1037</Issue>
</ExcludeList>
<ExcludeList Include="$(XunitTestBinBase)\JIT\Regression\CLR-x86-EJIT\V1-M09.5-PDC\b14426\b14426\*" >
diff --git a/tests/scripts/exclusion.py b/tests/scripts/exclusion.py
new file mode 100644
index 0000000000..87ea48521e
--- /dev/null
+++ b/tests/scripts/exclusion.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+## Licensed to the .NET Foundation under one or more agreements.
+## The .NET Foundation licenses this file to you under the MIT license.
+## See the LICENSE file in the project root for more information.
+#
+##
+# Title :exclusion.py
+#
+# Script to create a new list file from the old list file by refelcting
+# exclusion project file (issues.target)
+#
+################################################################################
+
+import os
+import os.path
+import sys
+import re
+
+###############################################################################
+# Main
+################################################################################
+
+if __name__ == "__main__":
+ print "Starting exclusion"
+ print "- - - - - - - - - - - - - - - - - - - - - - - - - - - -"
+ print
+
+ if len(sys.argv) == 3:
+ # Update test file in place
+ issuesFile = sys.argv[1]
+ oldTestFile = sys.argv[2]
+ newTestFile = oldTestFile
+ elif len(sys.argv) == 4:
+ issuesFile = sys.argv[1]
+ oldTestFile = sys.argv[2]
+ newTestFile = sys.argv[3]
+ else:
+ print "Ex usage: python exclusion.py <issues profile file> <old lst file> {<new lst file>}"
+ exit(1)
+
+ with open(issuesFile) as issuesFileHandle:
+ issues = issuesFileHandle.readlines()
+
+ with open(oldTestFile) as oldTestsHandle:
+ oldTests = oldTestsHandle.readlines()
+
+ # Build exculsion set from issues
+ exclusions = set()
+ for i in range(len(issues)):
+ matchObj = re.search( r'(XunitTestBinBase\)\\)(.+)(\\)(.+)\"', issues[i])
+ if matchObj:
+ exclusions.add(matchObj.group(2));
+ print "Exclusions list from " + issuesFile + ": ", len(exclusions)
+
+ # Build new test by copying old test except the exclusion
+ removed = 0
+ with open(newTestFile, 'w') as newTestsHandle:
+ j = 0
+ while(j < len(oldTests)):
+ currLine = oldTests[j]
+ matchObj = re.search( r'[(.+)]', currLine)
+ if matchObj:
+ nextLine = oldTests[j+1]
+ matchObj = re.search( r'(RelativePath=)(.+)(\\)(.+)(.exe)', nextLine)
+ if matchObj:
+ relPath = matchObj.group(2)
+ if (relPath in exclusions):
+ # Skip to the next item. Currently each test consists of 7 lines.
+ removed += 1
+ j += 7
+ continue
+
+ newTestsHandle.write(currLine)
+ j += 1
+
+ print "Removed Tests: ", removed
+ print newTestFile + " is successfuly built."
+
diff --git a/tests/src/JIT/CodeGenBringUpTests/struct16args.cs b/tests/src/JIT/CodeGenBringUpTests/struct16args.cs
new file mode 100644
index 0000000000..c39a95e705
--- /dev/null
+++ b/tests/src/JIT/CodeGenBringUpTests/struct16args.cs
@@ -0,0 +1,739 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+//
+
+
+using System;
+using System.Runtime.CompilerServices;
+
+public struct Point
+{
+ public int w;
+ public int x;
+ public int y;
+ public int z;
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public Point(int a, int b, int c, int d) { w=a; x=a; y=b; z=d; }
+
+ public int W
+ {
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ get { return this.w; }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ set { this.w = value; }
+ }
+
+ public int X
+ {
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ get { return this.x; }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ set { this.x = value; }
+ }
+
+ public int Y
+ {
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ get { return this.y; }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ set { this.y = value; }
+ }
+
+ public int Z
+ {
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ get { return this.z; }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ set { this.z = value; }
+ }
+
+ // Returns true if this represents 'origin' otherwise false.
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public bool StructInstMethod() { return (x==0 && y == 0 && z==0); }
+
+}
+
+public class BringUpTest
+{
+ const int Pass = 100;
+ const int Fail = -1;
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_4S(Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_4S");
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_4S4I(Point p0, Point p1, Point p2, Point p3, int i0, int i1, int i2, int i3)
+ {
+ Console.Write("method_4S4I");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (i2 != 5)
+ return Fail;
+
+ if (i3 != 7)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_4I4S(int i0, int i1, int i2, int i3, Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_4I4S");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (i2 != 5)
+ return Fail;
+
+ if (i3 != 7)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_1I4S(int i0, Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_1I4S");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_2I4S(int i0, int i1, Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_2I4S");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_3I4S(int i0, int i1, int i2, Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_3I4S");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (i2 != 5)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_2I4S2D(int i0, int i1, Point p0, Point p1, Point p2, Point p3, double d0, double d1)
+ {
+ Console.Write("method_2I4S2D");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (d0 != 11.0d)
+ return Fail;
+
+ if (d1 != 13.0d)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_2I2D4S(int i0, int i1, double d0, double d1, Point p0, Point p1, Point p2, Point p3)
+ {
+ Console.Write("method_2I2D4S");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (d0 != 11.0d)
+ return Fail;
+
+ if (d1 != 13.0d)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ public static int method_2I2D4S2D(int i0, int i1, double d0, double d1, Point p0, Point p1, Point p2, Point p3, double d2, double d3)
+ {
+ Console.Write("method_2I2D4S2D");
+
+ if (i0 != 2)
+ return Fail;
+
+ if (i1 != 3)
+ return Fail;
+
+ if (d0 != 11.0d)
+ return Fail;
+
+ if (d1 != 13.0d)
+ return Fail;
+
+ if (d2 != 15.0d)
+ return Fail;
+
+ if (d3 != 17.0d)
+ return Fail;
+
+ if (p0.W != 0)
+ return Fail;
+
+ if (p0.X != 0)
+ return Fail;
+
+ if (p0.Y != 0)
+ return Fail;
+
+ if (p0.Z != 0)
+ return Fail;
+
+ if (p1.W != 1)
+ return Fail;
+
+ if (p1.X != 1)
+ return Fail;
+
+ if (p1.Y != 1)
+ return Fail;
+
+ if (p1.Z != 1)
+ return Fail;
+
+ if (p2.W != 9)
+ return Fail;
+
+ if (p2.X != 99)
+ return Fail;
+
+ if (p2.Y != 999)
+ return Fail;
+
+ if (p2.Z != 9999)
+ return Fail;
+
+ if (p3.W != 10)
+ return Fail;
+
+ if (p3.X != 100)
+ return Fail;
+
+ if (p3.Y != 1000)
+ return Fail;
+
+ if (p3.Z != 10000)
+ return Fail;
+
+ Console.WriteLine(" Pass");
+
+ return Pass;
+ }
+
+ public static int Main()
+ {
+ int i0 = 2;
+ int i1 = 3;
+ int i2 = 5;
+ int i3 = 7;
+
+ double d0 = 11.0d;
+ double d1 = 13.0d;
+ double d2 = 15.0d;
+ double d3 = 17.0d;
+
+ Point p0;
+ Point p1;
+ Point p2;
+ Point p3;
+
+ p0.w = 0;
+ p0.x = 0;
+ p0.y = 0;
+ p0.z = 0;
+
+ p1.w = 1;
+ p1.x = 1;
+ p1.y = 1;
+ p1.z = 1;
+
+ p2.w = 9;
+ p2.x = 99;
+ p2.y = 999;
+ p2.z = 9999;
+
+ p3.w = 10;
+ p3.x = 100;
+ p3.y = 1000;
+ p3.z = 10000;
+
+ if (method_4S(p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_4S4I(p0,p1,p2,p3, i0,i1,i2,i3) != Pass)
+ return Fail;
+
+ if (method_4I4S(i0,i1,i2,i3, p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_1I4S(i0, p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_2I4S(i0,i1, p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_3I4S(i0,i1,i2, p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_2I4S2D(i0,i1, p0,p1,p2,p3, d0,d1) != Pass)
+ return Fail;
+
+ if (method_2I2D4S(i0,i1, d0,d1, p0,p1,p2,p3) != Pass)
+ return Fail;
+
+ if (method_2I2D4S2D(i0,i1, d0,d1, p0,p1,p2,p3, d2,d3) != Pass)
+ return Fail;
+
+ return Pass;
+ }
+}
diff --git a/tests/src/JIT/CodeGenBringUpTests/struct16args.csproj b/tests/src/JIT/CodeGenBringUpTests/struct16args.csproj
new file mode 100644
index 0000000000..0d72e6e62f
--- /dev/null
+++ b/tests/src/JIT/CodeGenBringUpTests/struct16args.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ </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>
+ <None Include="$(JitPackagesConfigFileDirectory)threading+thread\project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="struct16args.cs" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)threading+thread\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)threading+thread\project.lock.json</ProjectLockJson>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs
new file mode 100644
index 0000000000..a7a96b1078
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.cs
@@ -0,0 +1,81 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Program
+{
+ static bool flag;
+
+ static int Main(string[] args)
+ {
+ flag = true;
+ return Test();
+ }
+
+ public static int Test()
+ {
+ try
+ {
+ Repro();
+ }
+ catch (NullReferenceException)
+ {
+ Console.WriteLine("Failure");
+ return 101;
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("Success");
+ return 100;
+ }
+
+ Console.WriteLine("Failure");
+ return 101;
+ }
+
+ private static void Repro()
+ {
+ string str = GetString();
+ object info = null;
+
+ if (str != null)
+ {
+ info = str.Length;
+ }
+ try
+ {
+ ThrowException();
+ if (str != null)
+ {
+ Console.WriteLine(info);
+ }
+ }
+ catch (Exception)
+ {
+ // The bug was that the jit was removing this check causing a NullReferenceException.
+ if (str != null)
+ {
+ Console.WriteLine(str.Length);
+ }
+ throw;
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static void ThrowException()
+ {
+ if (flag)
+ {
+ throw new Exception();
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static string GetString()
+ {
+ return flag ? (string) null : "test";
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj
new file mode 100644
index 0000000000..215ae14a71
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/DevDiv_150265.csproj
@@ -0,0 +1,50 @@
+<?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>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ </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>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="DevDiv_150265.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" />
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config
new file mode 100644
index 0000000000..8077c95440
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150265/app.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration> \ No newline at end of file
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il
new file mode 100644
index 0000000000..9bfe429ed0
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.il
@@ -0,0 +1,109 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// This il tests importation of unbox[_any] when there are pending evaluations on the stack that side-effect
+// the arguments of the unbox.
+
+.assembly extern mscorlib { }
+
+.assembly extern System.Runtime
+{
+ .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
+ .ver 4:1:0:0
+}
+.assembly extern System.Console
+{
+ .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
+ .ver 4:0:0:0
+}
+.assembly DevDiv_150586
+{
+}
+
+
+.class private auto ansi beforefieldinit Bug.Program
+ extends [System.Runtime]System.Object
+{
+ .method private hidebysig static string
+ GetResourceString(string category,
+ [out] object& foundObj) cil managed
+ {
+ // Code size 20 (0x14)
+ .maxstack 8
+ IL_0000: ldarg.1
+ IL_0001: ldc.i4.0
+ IL_0002: box [System.Runtime]System.Boolean
+ IL_0007: stind.ref
+ IL_0008: ldstr "Hello world"
+ IL_000d: ldarg.0
+ IL_000e: call string [System.Runtime]System.String::Concat(string,
+ string)
+ IL_0013: ret
+ } // end of method Program::GetResourceString
+
+ .method private hidebysig static string
+ RString() cil managed
+ {
+ // Code size 38 (0x26)
+ .maxstack 2
+ .locals init ([0] object foundObj,
+ [1] bool V_1)
+ IL_0000: ldstr ""
+ IL_0005: ldloca.s foundObj
+ IL_0007: call string Bug.Program::GetResourceString(string,
+ object&)
+ IL_000c: ldloc.0
+ IL_000d: unbox.any [System.Runtime]System.Boolean
+ IL_0012: stloc.1
+ IL_0013: ldloca.s V_1
+ IL_0015: constrained. [System.Runtime]System.Boolean
+ IL_001b: callvirt instance string [System.Runtime]System.Object::ToString()
+ IL_0020: call string [System.Runtime]System.String::Concat(string,
+ string)
+ IL_0025: ret
+ } // end of method Program::RString
+
+ .method private hidebysig static int32
+ Main(string[] args) cil managed
+ {
+ .entrypoint
+ // Code size 39 (0x27)
+ .maxstack 1
+ .locals init ([0] int32 V_0)
+ .try
+ {
+ IL_0000: call string Bug.Program::RString()
+ IL_0005: pop
+ IL_0006: leave.s IL_0018
+
+ } // end .try
+ catch [System.Runtime]System.Exception
+ {
+ IL_0008: pop
+ IL_0009: ldstr "Fail"
+ IL_000e: call void [System.Console]System.Console::WriteLine(string)
+ IL_0013: ldc.i4.s 101
+ IL_0015: stloc.0
+ IL_0016: leave.s IL_0025
+
+ } // end handler
+ IL_0018: ldstr "Pass"
+ IL_001d: call void [System.Console]System.Console::WriteLine(string)
+ IL_0022: ldc.i4.s 100
+ IL_0024: ret
+
+ IL_0025: ldloc.0
+ IL_0026: ret
+ } // end of method Program::Main
+
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [System.Runtime]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method Program::.ctor
+
+} // end of class Bug.Program
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj
new file mode 100644
index 0000000000..39fd714170
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/DevDiv_150586.ilproj
@@ -0,0 +1,44 @@
+<?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>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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 .0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </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>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="DevDiv_150586.il" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config
new file mode 100644
index 0000000000..8077c95440
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/DevDiv_150586/app.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration> \ No newline at end of file
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.cs b/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.cs
new file mode 100644
index 0000000000..30c88815a5
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information
+
+using System;
+
+public class Program
+{
+ // RyuJIT codegen and clang (or gcc) may produce different results for casting uint64 to
+ // double, and the clang result is more accurate. For example,
+ // 1) (double)0x84595161401484A0UL --> 43e08b2a2c280290 (RyuJIT codegen or VC++)
+ // 2) (double)0x84595161401484A0UL --> 43e08b2a2c280291 (clang or gcc)
+ // Constant folding in RyuJIT simply does (double)0x84595161401484A0UL in its C++ implementation.
+ // If it is compiled by clang, the example unsigned value and cast tree node are folded into
+ // 43e08b2a2c280291, which is different from what the codegen produces. To fix this inconsistency,
+ // the constant folding is forced to have the same behavior as the codegen, and the result
+ // must be always 43e08b2a2c280290.
+ public static int Main(string[] args)
+ {
+ //Check if the test is being executed on ARMARCH
+ bool isProcessorArmArch = false;
+ string processorArchEnvVar = null;
+ processorArchEnvVar = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
+
+ if ((processorArchEnvVar != null)
+ && (processorArchEnvVar.Equals("ARM", StringComparison.CurrentCultureIgnoreCase)
+ || processorArchEnvVar.Equals("ARM64", StringComparison.CurrentCultureIgnoreCase)))
+ {
+ isProcessorArmArch = true;
+ }
+
+ ulong u64 = 0x84595161401484A0UL;
+ double f64 = (double)u64;
+ long h64 = BitConverter.DoubleToInt64Bits(f64);
+ long expected_h64 = isProcessorArmArch ? 0x43e08b2a2c280291L : 0x43e08b2a2c280290L;
+ if (h64 != expected_h64) {
+ Console.WriteLine(String.Format("Expected: 0x{0:x}\nActual: 0x{1:x}", expected_h64, h64));
+ return -1;
+ }
+ return 100;
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.csproj
new file mode 100644
index 0000000000..8f33be95db
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_3449/GitHub_3449.csproj
@@ -0,0 +1,50 @@
+<?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>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ </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>
+ <PropertyGroup>
+ <DebugType></DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="$(JitPackagesConfigFileDirectory)minimal\project.json" />
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ProjectJson>$(JitPackagesConfigFileDirectory)minimal\project.json</ProjectJson>
+ <ProjectLockJson>$(JitPackagesConfigFileDirectory)minimal\project.lock.json</ProjectLockJson>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/app.config b/tests/src/JIT/Regression/JitBlue/GitHub_3449/app.config
index 62803f5972..62803f5972 100644
--- a/tests/src/baseservices/threading/readerwriterlockslim/app.config
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_3449/app.config
diff --git a/tests/src/baseservices/exceptions/simple/HardwareEh.cs b/tests/src/baseservices/exceptions/simple/HardwareEh.cs
index 216c4697cc..3d5cd9a2ad 100644
--- a/tests/src/baseservices/exceptions/simple/HardwareEh.cs
+++ b/tests/src/baseservices/exceptions/simple/HardwareEh.cs
@@ -59,7 +59,7 @@ public class HardwareEh
retVal = PosTest9() && retVal;
// The current stack overflow behavior is to rip the process
// retVal = PosTest10() && retVal;
- retVal = PosTest11() && retVal;
+// retVal = PosTest11() && retVal;
retVal = PosTest12() && retVal;
retVal = PosTest13() && retVal;
retVal = PosTest14() && retVal;
@@ -115,7 +115,7 @@ public class HardwareEh
public bool PosTest8() { return ExceptionTest(8, "OverflowException (int64)", typeof(OverflowException), new TestDelegate(ILHelper.Int64Overflow) ); }
public bool PosTest9() { return ExceptionTest(9, "OverflowException (int32)", typeof(OverflowException), new TestDelegate(ILHelper.Int32Overflow) ); }
// public bool PosTest10() { return ExceptionTest(10, "StackOverflow", typeof(StackOverflowException), new TestDelegate( GobbleStack )); }
- public bool PosTest11() { return ExceptionTest(11, "OutOfMemory", typeof(OutOfMemoryException),
+/* public bool PosTest11() { return ExceptionTest(11, "OutOfMemory", typeof(OutOfMemoryException),
delegate()
{
List<object> list;
@@ -125,7 +125,7 @@ public class HardwareEh
// allocate memory (86 meg chunks)
list.Add( new byte[8388608]);
}
- } ); }
+ } ); } */
public bool PosTest12() { return ExceptionTest(12, "IndexOutOfRange (single dim [less than])", typeof(IndexOutOfRangeException),
delegate()
{
diff --git a/tests/src/baseservices/threading/interlocked/add/add.cs b/tests/src/baseservices/threading/interlocked/add/add.cs
new file mode 100644
index 0000000000..52bbb1782d
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/add/add.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Test
+{
+
+ public static int Main()
+ {
+ int retVal = 100;
+
+ int val = 20;
+ int adder= 5;
+ int foo = Interlocked.Add(ref val, adder);
+ Console.WriteLine("NewValue: " + val);
+ Console.WriteLine("OldValue: " + foo);
+ //if(foo != 20 && val != 25)
+ if ((val != 25) || (foo != val))
+ retVal = -1;
+
+ long val1 = 20;
+ long adder1= 5;
+ long foo1 = Interlocked.Add(ref val1, adder1);
+ Console.WriteLine("NewValue: " + val1);
+ Console.WriteLine("OldValue: " + foo1);
+ //if(foo1 != 20 && val1 != 25)
+ if ((val1 != 25) || (foo1 != val1))
+ retVal = -1;
+
+ if (retVal == 100)
+ Console.WriteLine("Test passed");
+ else
+ Console.WriteLine("Test failed");
+
+ return retVal;
+
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/add/add.csproj b/tests/src/baseservices/threading/interlocked/add/add.csproj
new file mode 100644
index 0000000000..2b37a7f1cd
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/add/add.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="add.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/add/interlockedaddintwithsubtract.cs b/tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.cs
new file mode 100644
index 0000000000..b103ec519e
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.cs
@@ -0,0 +1,107 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+//Regression for DevDiv Bugs 48020
+namespace ExchangeAdd
+{
+ class InterlockedAddInt
+ {
+ static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: InterlockedAddIntWithSubtract " +
+ "/loops:<int> /addVal:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int loops=100;
+ int valueToAdd = 0;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/loops:"))
+ {
+ loops = Convert.ToInt32(args[i].Substring(7));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/addval:"))
+ {
+ valueToAdd = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+ }
+
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe(loops, valueToAdd);
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (tsi.Total == tsi.Expected * threads.Length)
+ rValue = 100;
+ Console.WriteLine("Expected: " + (tsi.Expected * threads.Length));
+ Console.WriteLine("Actual: " + tsi.Total);
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private int totalValue = 0;
+ private int numberOfIterations;
+ private int valueToAdd;
+ private int valueToSubtract;
+ public ThreadSafe(): this(100,100) { }
+ public ThreadSafe(int loops, int iAdd)
+ {
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ valueToAdd = iAdd;
+ valueToSubtract = 0-iAdd;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorker()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ {
+ Interlocked.Add(ref totalValue, valueToAdd);
+ Interlocked.Add(ref totalValue, valueToSubtract);
+ }
+
+ }
+ public int Expected
+ {
+ get
+ {
+ return (0);
+ }
+ }
+ public int Total
+ {
+ get { return totalValue; }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.csproj b/tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.csproj
new file mode 100644
index 0000000000..dd02d2707b
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/add/interlockedaddintwithsubtract.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/loops:500000 /addVal:1</CLRTestExecutionArguments>
+ </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="InterlockedAddIntWithSubtract.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/checkreturn/app.config b/tests/src/baseservices/threading/interlocked/checkreturn/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.cs b/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.cs
new file mode 100644
index 0000000000..8ef3cd94e5
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.cs
@@ -0,0 +1,23 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ IntTest testInt = new IntTest(100, 10);
+
+ Console.WriteLine("Check Inc Returnt: {0}", rValue = testInt.CheckDecReturn());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.csproj b/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.csproj
new file mode 100644
index 0000000000..149300c068
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/intdeccheckreturn.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="IntDecCheckReturn.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/checkreturn/intinccheckreturn.cs b/tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.cs
new file mode 100644
index 0000000000..6fd08999ea
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.cs
@@ -0,0 +1,23 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ IntTest testInt = new IntTest(100, 10);
+
+ Console.WriteLine("Check Inc Returnt: {0}", rValue = testInt.CheckIncReturn());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.csproj b/tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.csproj
new file mode 100644
index 0000000000..d51f71108f
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/intinccheckreturn.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="IntIncCheckReturn.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/checkreturn/longdeccheckreturn.cs b/tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.cs
new file mode 100644
index 0000000000..8a39c6a87d
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ LongTest testLong = new LongTest();
+
+ Console.WriteLine("Check Decrement: {0}", rValue = testLong.CheckDecReturn());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.csproj b/tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.csproj
new file mode 100644
index 0000000000..52e0d889d3
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/longdeccheckreturn.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="LongDecCheckReturn.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/checkreturn/longinccheckreturn.cs b/tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.cs
new file mode 100644
index 0000000000..1a5a59c15a
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ LongTest testLong = new LongTest();
+
+ Console.WriteLine("Check Decrement: {0}", rValue = testLong.CheckIncReturn());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.csproj b/tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.csproj
new file mode 100644
index 0000000000..dd3709f642
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/longinccheckreturn.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="LongIncCheckReturn.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/readerwriterlockslim/project.json b/tests/src/baseservices/threading/interlocked/checkreturn/project.json
index a2e84dc340..21a7fa4381 100644
--- a/tests/src/baseservices/threading/readerwriterlockslim/project.json
+++ b/tests/src/baseservices/threading/interlocked/checkreturn/project.json
@@ -32,4 +32,4 @@
"frameworks": {
"dnxcore50": {}
}
-}
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/common/interlockedhelper_coreclr.cs b/tests/src/baseservices/threading/interlocked/common/interlockedhelper_coreclr.cs
new file mode 100644
index 0000000000..f9d39a3812
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/common/interlockedhelper_coreclr.cs
@@ -0,0 +1,282 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ ///
+ class LongTest
+ {
+ long sharedValue;
+ int iterations;
+ ManualResetEvent signal;
+ Thread[] threads;
+ public LongTest() { }
+ public LongTest(int LoopValue, int NumberOfThreads)
+ {
+ threads = new Thread[NumberOfThreads];
+ iterations = LoopValue;
+ signal = new ManualResetEvent(false);
+ }
+ public int Inc()
+ {
+ sharedValue = 0;
+ long expectedValue = iterations * threads.Length;
+
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(this.SimpleIncrement));
+ threads[i].Start();
+ }
+
+ Thread.Sleep(100);
+ signal.Set();
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+ if (sharedValue == expectedValue)
+ return 100;
+
+ return -1;
+ }
+ public int Dec()
+ {
+ sharedValue = iterations * threads.Length;
+
+ int expectedValue = 0;
+
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(this.SimpleDecrement));
+ threads[i].Start();
+ }
+
+ Thread.Sleep(100);
+ signal.Set();
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (sharedValue == expectedValue)
+ return 100;
+
+ return -1;
+ }
+ private void SimpleIncrement()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < iterations; i++)
+ Interlocked.Increment(ref sharedValue);
+ }
+ private void SimpleDecrement()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < iterations; i++)
+ Interlocked.Decrement(ref sharedValue);
+ }
+ public int CheckIncReturn()
+ {
+ long sharedValue;
+ int rValue = 0;
+
+ foreach (long val in LongVals)
+ {
+ sharedValue = val;
+
+ Console.WriteLine("Test for Inc with value {0}", val);
+ Console.WriteLine("Expected : {0}", val + 1);
+ long returnV = Interlocked.Increment(ref sharedValue);
+ if (val + 1 != returnV )
+ {
+ Console.WriteLine("Failed: Return value is wrong: {0}", returnV);
+ rValue = -1;
+ }
+ if (val + 1 != sharedValue)
+ {
+ Console.WriteLine("Failed: refence value is wrong: {0}", sharedValue);
+ rValue = -2;
+ }
+ }
+
+ if (rValue == 0)
+ rValue = 100;
+
+ return rValue;
+ }
+ public int CheckDecReturn()
+ {
+ long sharedValue;
+ int rValue =0;
+ foreach (long val in LongVals)
+ {
+ sharedValue = val;
+
+ Console.WriteLine("Test for Dec with value {0}", val);
+ Console.WriteLine("Expected : {0}", val - 1);
+ long returnV = Interlocked.Decrement(ref sharedValue);
+ if (val - 1 != returnV)
+ {
+ Console.WriteLine("Failed: Return value is wrong: {0}", returnV);
+ rValue = -1;
+ }
+ if (val -1 != sharedValue)
+ {
+ Console.WriteLine("Failed: refence value is wrong: {0}", sharedValue);
+ rValue = -2;
+ }
+ }
+ if(rValue == 0)
+ rValue = 100;
+ return rValue;
+ }
+ long[] LongVals = new long[5]
+ {
+ Int64.MinValue,
+ Int64.MaxValue,
+ 0,
+ -1,
+ 1
+ };
+ }
+
+
+
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ ///
+ class IntTest
+ {
+ int sharedValue;
+ int iterations;
+ ManualResetEvent signal;
+ Thread[] threads;
+ public IntTest(int LoopValue, int NumberOfThreads)
+ {
+ threads = new Thread[NumberOfThreads];
+ iterations = LoopValue;
+ signal = new ManualResetEvent(false);
+ }
+ public int Inc()
+ {
+ sharedValue = 0;
+
+ int expectedValue = iterations * threads.Length;
+
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(this.SimpleIncrement));
+ threads[i].Start();
+ }
+
+ Thread.Sleep(100);
+ signal.Set();
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (sharedValue == expectedValue)
+ return 100;
+
+ return -1;
+ }
+ public int Dec()
+ {
+ sharedValue = iterations * threads.Length;
+
+ int expectedValue = 0;
+
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(this.SimpleDecrement));
+ threads[i].Start();
+ }
+
+ Thread.Sleep(100);
+ signal.Set();
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (sharedValue == expectedValue)
+ return 100;
+
+ return -1;
+ }
+ private void SimpleIncrement()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < iterations; i++)
+ Interlocked.Increment(ref sharedValue);
+ }
+ private void SimpleDecrement()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < iterations; i++)
+ Interlocked.Decrement(ref sharedValue);
+ }
+ public int CheckIncReturn()
+ {
+ int sharedValue;
+ int rValue = 0;
+
+ foreach (int val in IntVals)
+ {
+ sharedValue = val;
+ Console.WriteLine("Test for Inc with value {0}", val);
+ Console.WriteLine("Expected : {0}", val - 1);
+ int returnV = Interlocked.Increment(ref sharedValue);
+ if (val + 1 != returnV )
+ {
+ Console.WriteLine("Failed: Return value is wrong: {0}", returnV);
+ rValue = -1;
+ }
+ if (val + 1 != sharedValue)
+ {
+ Console.WriteLine("Failed: refence value is wrong: {0}", sharedValue);
+ rValue = -2;
+ }
+ }
+
+ if (rValue == 0)
+ rValue = 100;
+
+ return rValue;
+ }
+ public int CheckDecReturn()
+ {
+ int sharedValue;
+ int rValue =0;
+ foreach (int val in IntVals)
+ {
+ sharedValue = val;
+ Console.WriteLine("Test for Dec with value {0}", val);
+ Console.WriteLine("Expected : {0}", val - 1);
+ int returnV = Interlocked.Decrement(ref sharedValue);
+ if (val - 1 != returnV)
+ {
+ Console.WriteLine("Failed: Return value is wrong: {0}", returnV);
+ rValue = -1;
+ }
+ if (val -1 != sharedValue)
+ {
+ Console.WriteLine("Failed: refence value is wrong: {0}", sharedValue);
+ rValue = -2;
+ }
+ }
+ if(rValue == 0)
+ rValue = 100;
+ return rValue;
+ }
+ int[] IntVals = new int[5]
+ {
+ Int32.MinValue,
+ Int32.MaxValue,
+ 0,
+ -1,
+ 1
+ };
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs
new file mode 100644
index 0000000000..b7c1da2d76
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs
@@ -0,0 +1,148 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+/// <summary>
+/// System.Threading.Interlocked.CompareExchange(Double,Double,Double)
+/// </summary>
+///
+
+// This test makes sure that CompareExchange(Double, Double, Double)
+// plays nicely with another thread accessing shared state directly
+public class InterlockedCompareExchange1
+{
+ public static double globalValue = 0.0;
+ public Thread threadA;
+ public Thread threadB;
+ public double state;
+
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Using another thread to change the value of variable in this thread");
+
+
+ try
+ {
+ // Spin up two new threads
+ threadA = new Thread(new ThreadStart(TestComChange));
+ threadB = new Thread(new ThreadStart(changeGlobal));
+ // Start Thread A
+ // Thread A runs TestComChange
+ threadA.Start();
+ // Block calling thread until spawned Thread A completes
+ threadA.Join();
+ // Once Thread A completes, block
+ // calling thread until Thread B completes as well
+ threadB.Join();
+ // now, the final value of globalValue and state should be -0.1
+ if (globalValue != -0.1 && state != -0.1)
+ {
+ TestLibrary.TestFramework.LogError("001", "The method did not works, the result is" + globalValue + " " + state);
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+ #endregion
+
+ #region Negetive Test Cases
+ public bool NegTest1()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest1: ");
+
+ try
+ {
+
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("101", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ InterlockedCompareExchange1 test = new InterlockedCompareExchange1();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedCompareExchange1");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+ public void TestComChange()
+ {
+ // loop 20 times. On the 0-9th times,
+ // only Thread A is accessing globalValue. it keeps
+ // checking if globalValue is 10, which it isn't (it
+ // starts at 0). but, on the 10th time, it starts
+ // Thread B, which at some point runs changeGlobal,
+ // setting globalValue to 10. After Thread B sets
+ // it to 10, the CompareExchange will fire, setting
+ // globalValue to -0.1. Thereafter, CompareExchange
+ // will see that globalValue is not 10, and keep
+ // returning -0.1 to state. each time thru the loop,
+ // Thread A does a sleep(10) so that Thread B has a
+ // chance to do its thing.
+ int i = 0;
+ while (i < 20)
+ {
+ if (i == 10)
+ {
+ threadB.Start();
+ }
+ state = Interlocked.CompareExchange(ref globalValue, -0.1, 10.0);
+ i++;
+ Thread.Sleep(10);
+ }
+ }
+ public void changeGlobal()
+ {
+ // Thread B is the only place this runs
+ // When it runs, it simply sets globalValue to 10.
+ // It should only do this once Thread A tells Thread B
+ // to start.
+ globalValue = 10.0;
+ }
+}
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/Upgrader.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.csproj
index 9f9937cff2..e62814a2ca 100644
--- a/tests/src/baseservices/threading/readerwriterlockslim/Upgrader.csproj
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.csproj
@@ -13,9 +13,6 @@
<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>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
@@ -30,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<!-- Add Compile Object Here -->
- <Compile Include="upgrader.cs" />
+ <Compile Include="CompareExchange1_cti.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -40,7 +37,10 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.cs
new file mode 100644
index 0000000000..19c307839e
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.cs
@@ -0,0 +1,361 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This tests CompareExchange(object, object, object).
+// It just casts a bunch of different value types to object,
+// then makes sure CompareExchange works on those objects.
+public class InterlockedCompareExchange2
+{
+ private const int c_NUM_LOOPS = 100;
+ private const int c_MIN_STRING_LEN = 5;
+ private const int c_MAX_STRING_LEN = 128;
+
+ public static int Main()
+ {
+ InterlockedCompareExchange2 test = new InterlockedCompareExchange2();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedCompareExchange2");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+
+ return retVal;
+ }
+
+ // This particular test is for when the comparands are equal and the
+ // switch should take place.
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ object location;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object Interlocked.CompareExchange(object&,object, object) where comparand is equal");
+
+ try
+ {
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Byte");
+ location = (object)TestLibrary.Generator.GetByte();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetByte()
+ ) && retVal;
+ // Note that (&&) performs a logical-AND of
+ // its bool operands, but only evaluates its second
+ // operand if necessary. When ExchangeObjects is first
+ // called (above), retVal (RHS)
+ // is true, as it was initialized above. If ExchangeObjects
+ // returns true, then it checks retVal (RHS), it is also true,
+ // so retVal (LHS) gets set to true. This stays this
+ // way so long as ExchangeObjects returns true in this and
+ // subsequent calls.
+ // If some time ExchangeObjects returns false (0), this
+ // expression does not check retVal (RHS), and instead
+ // retVal (LHS) becomes false. Next call to ExchangeObjects,
+ // retVal (RHS) is false even if ExchangeObjects returns true, so
+ // retVal (both RHS and LHS) remains false for all
+ // subsequent calls to ExchangeObjects. As such, if any one of
+ // the many calls to ExchangeObjects fails, retVal returns false
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Byte[]");
+ byte[] bArr1 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ byte[] bArr2 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ TestLibrary.Generator.GetBytes(bArr1);
+ TestLibrary.Generator.GetBytes(bArr2);
+ location = (object)bArr1;
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)bArr2
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int16");
+ location = (object)TestLibrary.Generator.GetInt16();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetInt16()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int32");
+ location = (object)TestLibrary.Generator.GetInt32();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetInt32()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int64");
+ location = (object)(object)TestLibrary.Generator.GetInt64();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetInt64()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Single");
+ location = (object)(object)TestLibrary.Generator.GetSingle();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetSingle()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Double");
+ location = (object)(object)TestLibrary.Generator.GetDouble();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetDouble()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == string");
+ location = TestLibrary.Generator.GetString(false, c_MIN_STRING_LEN, c_MAX_STRING_LEN);
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetString(false, c_MIN_STRING_LEN, c_MAX_STRING_LEN)
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == char");
+ location = TestLibrary.Generator.GetChar();
+ retVal = ExchangeObjects(
+ true,
+ location,
+ location,
+ (object)TestLibrary.Generator.GetChar()
+ ) && retVal;
+
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ // This particular test is for when the comparands are not equal and the
+ // switch should not take place.
+ public bool PosTest2()
+ {
+ bool retVal = true;
+ object location;
+ object other;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object Interlocked.CompareExchange(object&,object, object) where comparand are not equal");
+
+ try
+ {
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Byte");
+ location = (object)TestLibrary.Generator.GetByte();
+ other = (object)TestLibrary.Generator.GetByte();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((byte)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Byte[]");
+ byte[] bArr1 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ byte[] bArr2 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ byte[] bArr3 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ TestLibrary.Generator.GetBytes(bArr1);
+ TestLibrary.Generator.GetBytes(bArr2);
+ TestLibrary.Generator.GetBytes(bArr3);
+ location = (object)bArr1;
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)bArr2,
+ (object)bArr3
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Int16");
+ location = (object)TestLibrary.Generator.GetInt16();
+ other = (object)TestLibrary.Generator.GetInt16();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((Int16)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Int32");
+ location = (object)TestLibrary.Generator.GetInt32();
+ other = (object)TestLibrary.Generator.GetInt32();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((Int32)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Int64");
+ location = (object)(object)TestLibrary.Generator.GetInt64();
+ other = (object)TestLibrary.Generator.GetInt64();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((Int64)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Single");
+ location = (object)(object)TestLibrary.Generator.GetSingle();
+ other = (object)TestLibrary.Generator.GetSingle();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((Single)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: object == Double");
+ location = (object)(object)TestLibrary.Generator.GetDouble();
+ other = (object)TestLibrary.Generator.GetDouble();
+
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (object)((Double)location+1),
+ other
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == string");
+ location = TestLibrary.Generator.GetString(false, c_MIN_STRING_LEN, c_MAX_STRING_LEN);
+ retVal = ExchangeObjects(
+ false,
+ location,
+ (string)location+TestLibrary.Generator.GetChar(),
+ (object)TestLibrary.Generator.GetDouble()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == char");
+ location = TestLibrary.Generator.GetChar();
+ object comparand;
+ do
+ {
+ comparand = TestLibrary.Generator.GetChar();
+ }
+ while(comparand == location);
+ retVal = ExchangeObjects(
+ false,
+ location,
+ comparand,
+ (object)TestLibrary.Generator.GetChar()
+ ) && retVal;
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ public bool ExchangeObjects(bool exchange, object location, object comparand, object value)
+ {
+ bool retVal = true;
+ object oldLocation;
+ object originalLocation = location;
+
+ if (!exchange && comparand == location)
+ {
+ TestLibrary.TestFramework.LogError("003", "Comparand and location are equal unexpectadly!!!!");
+ retVal = false;
+ }
+ if (exchange && comparand != location)
+ {
+ TestLibrary.TestFramework.LogError("004", "Comparand and location are not equal unexpectadly!!!!");
+ retVal = false;
+ }
+
+ // this is the only significant difference between this test
+ // and InterlockedCompareExchange7.cs - here we use the
+ // object overload directly.
+ oldLocation = Interlocked.CompareExchange(ref location, value, comparand);
+
+ // if exchange=true, then the exchange was supposed to take place.
+ // as a result, assuming value did not equal comparand initially,
+ // and location did equal comparand initially, then we should
+ // expect the following:
+ // oldLoc holds locations old value,oldLocation == comparand, because oldLocation equals what
+ // location equaled before the exchange, and that
+ // equaled comparand
+ // location == value, because the exchange took place
+
+ if (exchange)
+ {
+ if (!Object.ReferenceEquals(location,value))
+ {
+ TestLibrary.TestFramework.LogError("005", "Interlocked.CompareExchange() did not do the exchange correctly: Expected location(" + location + ") to equal value(" + value + ")");
+ retVal = false;
+ }
+ if (!Object.ReferenceEquals(oldLocation,originalLocation))
+ {
+ TestLibrary.TestFramework.LogError("006", "Interlocked.CompareExchange() did not return the expected value: Expected oldLocation(" + oldLocation + ") to equal originalLocation(" + originalLocation + ")");
+ retVal = false;
+ }
+ }
+ // if exchange!=true, then the exchange was supposed to NOT take place.
+ // expect the following:
+ // location == originalLocation, because the exchange did not happen
+ // oldLocation == originalLocation, because the exchange did not happen
+ else
+ {
+ if (!Object.ReferenceEquals(location,originalLocation))
+ {
+ TestLibrary.TestFramework.LogError("007", "Interlocked.CompareExchange() should not change the location: Expected location(" + location + ") to equal originalLocation(" + originalLocation + ")");
+ retVal = false;
+ }
+ if (!Object.ReferenceEquals(oldLocation,originalLocation))
+ {
+ TestLibrary.TestFramework.LogError("008", "Interlocked.CompareExchange() did not return the expected value: Expected oldLocation(" + oldLocation + ") to equal originalLocation(" + originalLocation + ")");
+ retVal = false;
+ }
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/TryEnterFailureDDBugs124485.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.csproj
index a2d262da9e..0835b7be0b 100644
--- a/tests/src/baseservices/threading/readerwriterlockslim/TryEnterFailureDDBugs124485.csproj
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange2.csproj
@@ -13,9 +13,6 @@
<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>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
@@ -30,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<!-- Add Compile Object Here -->
- <Compile Include="tryenterfailureddbugs124485.cs" />
+ <Compile Include="CompareExchange2.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -40,7 +37,10 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.cs
new file mode 100644
index 0000000000..5b8fb96f26
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.cs
@@ -0,0 +1,167 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// Tests that CompareExchange(Double, Double, Double)
+// actually switches values when location = comparand and
+// does not when it does not
+public class InterlockedCompareExchange3
+{
+ private const int c_NUM_LOOPS = 100;
+
+ public static int Main()
+ {
+ InterlockedCompareExchange3 test = new InterlockedCompareExchange3();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedCompareExchange3");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+
+ return retVal;
+ }
+
+ // This test iterates 100 times. Each time it gets two
+ // Doubles, value and location. It stores location in comparand, so
+ // they will be equal on comparison. It then uses
+ // Interlocked.CompareExchange to compare location with comparand.
+ // Since they are equal, it must exchange: location is replaced by
+ // value, and the original value in location is returned to oldLocation.
+ // Then it checks that location now equals value, and that oldLocation
+ // equals comparand. If either of these are not true, retVal gets set to
+ // false, and ultimately it returns false. since location is never null,
+ // it should not throw an exception, so doing so causes the test
+ // to fail.
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Double location;
+ Double value;
+ Double comparand;
+ Double oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Double Interlocked.CompareExchange(Double&,Double,Double) where comparand is equal");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetDouble();
+ location = TestLibrary.Generator.GetDouble();
+ comparand = location;
+
+ oldLocation = Interlocked.CompareExchange(ref location, value, comparand);
+ // At this point, we should be able to make
+ // the following assertion:
+ // location = value
+ // oldLocation = comparand
+
+ if (!location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("001", "Interlocked.CompareExchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (!oldLocation.Equals(comparand))
+ {
+ TestLibrary.TestFramework.LogError("002", "Interlocked.CompareExchange() did not return the expected value: Expected(" + comparand + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // since location is not null, any exception
+ // causes test failure.
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ // This test iterates 100 times. Each time it gets two
+ // Doubles, value and location. It then gets a value for comparand, such
+ // that it is NOT EQUAL to location. It then uses
+ // Interlocked.CompareExchange to compare location with comparand.
+ // Since they are not equal, it does not exchange.
+ // since location is never null,
+ // it should not throw an exception, so doing so causes the test
+ // to fail.
+ public bool PosTest2()
+ {
+ bool retVal = true;
+ Double location;
+ Double value;
+ Double comparand;
+ Double oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: Double Interlocked.CompareExchange(Double&,Double,Double) where comparand are not equal");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetDouble();
+ location = TestLibrary.Generator.GetDouble();
+ comparand = value;
+ while(comparand.Equals(location))
+ {
+ comparand = TestLibrary.Generator.GetDouble();
+ }
+
+ oldLocation = Interlocked.CompareExchange(ref location, value, comparand);
+ // At this point, we should be able to make
+ // the following assertions:
+ // location != value
+ // location != comparand
+ // location = oldLocation
+ // oldLocation != comparand
+
+ if (location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("004", "Interlocked.CompareExchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (oldLocation.Equals(comparand))
+ {
+ TestLibrary.TestFramework.LogError("005", "Interlocked.CompareExchange() did not return the expected value: Expected(" + location + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // since location is not null, any exception
+ // causes test failure.
+ TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/SingleReleaseWriteDDBug71632.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.csproj
index f70117f419..f5430e63fb 100644
--- a/tests/src/baseservices/threading/readerwriterlockslim/SingleReleaseWriteDDBug71632.csproj
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange3.csproj
@@ -13,9 +13,6 @@
<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>1</CLRTestPriority>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
@@ -30,7 +27,7 @@
</ItemGroup>
<ItemGroup>
<!-- Add Compile Object Here -->
- <Compile Include="singlereleasewriteddbug71632.cs" />
+ <Compile Include="CompareExchange3.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -40,7 +37,10 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.cs
new file mode 100644
index 0000000000..a777b6fba9
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.cs
@@ -0,0 +1,168 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// Tests that CompareExchange(Single, Single, Single)
+// a.k.a., CompareExchange(float, float, float)
+// actually switches values when location = comparand and
+// does not when it does not
+public class InterlockedCompareExchange4
+{
+ private const int c_NUM_LOOPS = 100;
+
+ public static int Main()
+ {
+ InterlockedCompareExchange4 test = new InterlockedCompareExchange4();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedCompareExchange4");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+
+ return retVal;
+ }
+
+ // This test iterates 100 times. Each time it gets two
+ // Singles, value and location. It stores location in comparand, so
+ // they will be equal on comparison. It then uses
+ // Interlocked.CompareExchange to compare location with comparand.
+ // Since they are equal, it must exchange: location is replaced by
+ // value, and the original value in location is returned to oldLocation.
+ // Then it checks that location now equals value, and that oldLocation
+ // equals comparand. If either of these are not true, retVal gets set to
+ // false, and ultimately it returns false. since location is never null,
+ // it should not throw an exception, so doing so causes the test
+ // to fail.
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Single location;
+ Single value;
+ Single comparand;
+ Single oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Single Interlocked.CompareExchange(Single&,Single,Single) where comparand is equal");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetSingle();
+ location = TestLibrary.Generator.GetSingle();
+ comparand = location;
+
+ oldLocation = Interlocked.CompareExchange(ref location, value, comparand);
+ // At this point, we should be able to make
+ // the following assertion:
+ // location = value
+ // oldLocation = comparand
+
+ if (!location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("001", "Interlocked.CompareExchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (!oldLocation.Equals(comparand))
+ {
+ TestLibrary.TestFramework.LogError("002", "Interlocked.CompareExchange() did not return the expected value: Expected(" + comparand + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // since location is not null, any exception
+ // causes test failure.
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ // This test iterates 100 times. Each time it gets two
+ // Singles, value and location. It then gets a value for comparand, such
+ // that it is NOT EQUAL to location. It then uses
+ // Interlocked.CompareExchange to compare location with comparand.
+ // Since they are not equal, it does not exchange.
+ // since location is never null,
+ // it should not throw an exception, so doing so causes the test
+ // to fail.
+ public bool PosTest2()
+ {
+ bool retVal = true;
+ Single location;
+ Single value;
+ Single comparand;
+ Single oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: Single Interlocked.CompareExchange(Single&,Single,Single) where comparand are not equal");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetSingle();
+ location = TestLibrary.Generator.GetSingle();
+ comparand = value;
+ while(comparand.Equals(location))
+ {
+ comparand = TestLibrary.Generator.GetSingle();
+ }
+
+ oldLocation = Interlocked.CompareExchange(ref location, value, comparand);
+ // At this point, we should be able to make
+ // the following assertions:
+ // location != value
+ // location != comparand
+ // location = oldLocation
+ // oldLocation != comparand
+
+ if (location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("004", "Interlocked.CompareExchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (oldLocation.Equals(comparand))
+ {
+ TestLibrary.TestFramework.LogError("005", "Interlocked.CompareExchange() did not return the expected value: Expected(" + comparand + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // since location is not null, any exception
+ // causes test failure.
+ TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.csproj
new file mode 100644
index 0000000000..168b71d86c
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange4.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CompareExchange4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/compareexchange/compareexchange5_cti.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs
new file mode 100644
index 0000000000..f703ab948b
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs
@@ -0,0 +1,252 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+/// <summary>
+/// System.Threading.Interlocked.CompareExchange(ref object,object,object)
+/// </summary>
+
+// Tests that CompareExchange(object, object, object)
+// plays nicely with another thread accessing shared state directly
+// Also includes a test for when location = comparand = null (should
+// switch).
+public class InterlockedCompareExchange5
+{
+ public static object globalValue;
+ public Thread threadA;
+ public Thread threadB;
+ public object state;
+ public myClass obMyClass;
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+ retVal = PosTest3() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: The object is a string");
+
+ try
+ {
+ // Spin up two new threads
+ threadA = new Thread(new ThreadStart(TestComChange));
+ threadB = new Thread(new ThreadStart(changeGlobal));
+ // Start Thread A
+ // Thread A runs TestComChange
+ threadA.Start();
+ // Block spawning thread until Thread A completes
+ threadA.Join();
+ // Once Thread A completes, block spawning thread
+ // until Thread B completes as well
+ threadB.Join();
+ // now, the final values of
+ // globalValue and state should be "changedValue"
+ if (globalValue.ToString() != "changedValue" && state != (object)("changedValue"))
+ {
+ TestLibrary.TestFramework.LogError("001", "The method did not works, the result is" + globalValue + " " + state);
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest2()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: The object is a custom class");
+
+ obMyClass = new myClass(123456789);
+ try
+ {
+ // Spin up two new threads
+ threadA = new Thread(new ThreadStart(TestComChange2));
+ threadB = new Thread(new ThreadStart(changeGlobal2));
+ // Start Thread A
+ // Thread A runs TestComChange2
+ threadA.Start();
+ // Block spawning thread until Thread A completes
+ threadA.Join();
+ // Once Thread A completes, block spawning thread
+ // until Thread B completes as well
+ threadB.Join();
+ // now, the final values of
+ // globalValue and state should NOT be -100
+ if (((myClass)globalValue).a != -100 && ((myClass)state).a != -100)
+ {
+ TestLibrary.TestFramework.LogError("003", "The method did not works, the result is" + globalValue + " " + state);
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest3()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest3: The first argument is a null reference");
+
+ try
+ {
+ // a non-null object
+ object value = new myClass(-100);
+ // a null object
+ object comparand = null;
+ // a null initial state
+ globalValue = null;
+ // globalValue is null, so it should switch
+ // and return null
+ // this is a major difference with
+ // InterlockedCompareExchange8.cs --
+ // here we use the object overload
+ state = Interlocked.CompareExchange(ref globalValue, value, comparand);
+ // globalValue should equal value now
+ if (globalValue != value)
+ {
+ TestLibrary.TestFramework.LogError("005", "The method did not works, the result is" + globalValue + " " + state);
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+ #endregion
+ #region Negative Test Cases
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ InterlockedCompareExchange5 test = new InterlockedCompareExchange5();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedCompareExchange5");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+ public void TestComChange()
+ {
+ // set a value
+ object value = "changedValue";
+ // set a different value
+ object comparand = "comparand";
+ int i = 0;
+ // loop 20 times
+ while (i < 20)
+ {
+ // first ten times, we just skip this
+ // then on the tenth time, fire Thread B,
+ // setting globalValue to "Comparand"
+ if (i == 10)
+ {
+ threadB.Start();
+ }
+ // first ten iterations, globalValue does not
+ // equal comparand, so it keeps returning
+ // the contents of globalValue without
+ // poking value into it
+ // after ten, Thread B kicks in, and
+ // it matches, subsequently, globalValue
+ // gets set to "changedValue"
+ // this is a major difference with
+ // InterlockedCompareExchange8.cs --
+ // here we use the object overload
+ state = Interlocked.CompareExchange(ref globalValue, value, comparand);
+ i++;
+ Thread.Sleep(10);
+ }
+ }
+ public void changeGlobal()
+ {
+ // set when B runs
+ globalValue = "comparand";
+ }
+
+ public void TestComChange2()
+ {
+ // set a value
+ object value = new myClass(-100);
+ // set a different value
+ object comparand = obMyClass;
+ int i = 0;
+ // loop 20 times
+ while (i < 20)
+ {
+ // first ten times, we just skip this
+ // then on the tenth time, fire Thread B,
+ // setting globalValue to obMyClass
+ if (i == 10)
+ {
+ threadB.Start();
+ }
+ // first ten iterations, globalValue does not
+ // equal comparand, so it keeps returning
+ // the contents of globalValue without
+ // poking value into it
+ // after ten, Thread B kicks in, and
+ // it matches, subsequently, globalValue
+ // gets set to point to where value does
+ // this is a major difference with
+ // InterlockedCompareExchange8.cs --
+ // here we use the object overload
+ state = Interlocked.CompareExchange(ref globalValue, value, comparand);
+ i++;
+ Thread.Sleep(10);
+ }
+ }
+ public void changeGlobal2()
+ {
+ globalValue = obMyClass;
+ }
+}
+public class myClass
+{
+ public int a;
+ public myClass(int value)
+ {
+ a = value;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.csproj
new file mode 100644
index 0000000000..d1c103462d
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CompareExchange5_cti.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/compareexchange/compareexchangedouble.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.cs
new file mode 100644
index 0000000000..02fffd9862
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.cs
@@ -0,0 +1,120 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Globalization;
+
+namespace CompareExchangeDouble
+{
+ class CompareExchangeDouble
+ {
+ static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: CompareExchangeDouble " +
+ "/loops:<int> /addVal:<double>");
+ return -1;
+ }
+
+ // Get the args
+ int loops=100;
+ double valueToAdd = 1E+100;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/loops:"))
+ {
+ loops = Convert.ToInt32(args[i].Substring(7));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/addval:"))
+ {
+ CultureInfo myCultureInfo = new CultureInfo("en-US");
+ valueToAdd = Double.Parse(args[i].Substring(8), myCultureInfo);
+ continue;
+ }
+ }
+
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe(loops,valueToAdd);
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+ double expected = 0.0D;
+ for(int i=0;i<threads.Length*loops;i++)
+ expected = (double)(expected + valueToAdd);
+ if(tsi.Total == expected)
+ rValue = 100;
+ Console.WriteLine("Expected: "+expected);
+ Console.WriteLine("Actual : "+tsi.Total);
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private double totalValue = 0D;
+ private int numberOfIterations;
+ private double valueToAdd;
+ public ThreadSafe(): this(100,1E+100) { }
+ public ThreadSafe(int loops, double addend)
+ {
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ valueToAdd = addend;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorker()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ AddToTotal(valueToAdd);
+ }
+
+ public double Expected
+ {
+ get
+ {
+ return (numberOfIterations * valueToAdd);
+ }
+ }
+
+ public double Total
+ {
+ get { return totalValue; }
+ }
+
+ private double AddToTotal(double addend)
+ {
+ double initialValue, computedValue;
+ do
+ {
+ initialValue = totalValue;
+ computedValue = (double)(initialValue + addend);
+ }
+ while (initialValue != Interlocked.CompareExchange(
+ ref totalValue, computedValue, initialValue));
+ return computedValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.csproj
new file mode 100644
index 0000000000..796f8c48fa
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangedouble.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/loops:100 /addVal:1.79769313486232E+304</CLRTestExecutionArguments>
+ </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="CompareExchangeDouble.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchangefloat.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.cs
new file mode 100644
index 0000000000..9ffe170ec2
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.cs
@@ -0,0 +1,98 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace Exchange
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int loops = 100;
+ int rValue = 0;
+ if(args.Length == 1)
+ loops = Int32.Parse(args[0]);
+ float valuetoadd = 10.12345F;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe(100,valuetoadd);
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+ float expected = 0.0F;
+ for(int i=0;i<threads.Length*loops;i++)
+ expected = (float)(expected + valuetoadd);
+ if(tsi.Total == expected)
+ rValue = 100;
+ Console.WriteLine("Expected: "+expected);
+ Console.WriteLine("Actual : "+tsi.Total);
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private float totalValue = 0F;
+ private int numberOfIterations;
+ private float valueToAdd;
+ public ThreadSafe(): this(100,10.12345F) { }
+ public ThreadSafe(int loops, float addend)
+ {
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ valueToAdd = addend;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorker()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ AddToTotal(valueToAdd);
+
+ }
+ public float Expected
+ {
+ get
+ {
+ return (numberOfIterations * valueToAdd);
+ }
+ }
+ public float Total
+ {
+ get { return totalValue; }
+ }
+ private float AddToTotal(float addend)
+ {
+ float initialValue, computedValue;
+ do
+ {
+ initialValue = totalValue;
+ computedValue = (float)(initialValue + addend);
+ } while (initialValue != Interlocked.CompareExchange(ref totalValue, computedValue, initialValue));
+ return computedValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.csproj
new file mode 100644
index 0000000000..a78362bdc6
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="CompareExchangeFloat.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchangeint.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.cs
new file mode 100644
index 0000000000..d66fd51240
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.cs
@@ -0,0 +1,91 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace Exchange
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe();
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+
+ if(tsi.Total == tsi.Expected * threads.Length)
+ rValue = 100;
+ Console.WriteLine("Test Expected {0}, but found {1}", tsi.Expected * threads.Length, tsi.Total);
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private int totalValue = 0;
+ private int numberOfIterations;
+ private int valueToAdd;
+ public ThreadSafe(): this(100,100) { }
+ public ThreadSafe(int loops, int addend)
+ {
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ valueToAdd = addend;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorker()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ AddToTotal(valueToAdd);
+
+ }
+ public int Expected
+ {
+ get
+ {
+ return (numberOfIterations * valueToAdd);
+ }
+ }
+ public int Total
+ {
+ get { return totalValue; }
+ }
+ private int AddToTotal(int addend)
+ {
+ int initialValue, computedValue;
+ do
+ {
+ initialValue = totalValue;
+ computedValue = initialValue + addend;
+ } while (initialValue != Interlocked.CompareExchange(ref totalValue, computedValue, initialValue));
+ return computedValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.csproj
new file mode 100644
index 0000000000..569b22ab78
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeint.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="CompareExchangeInt.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchangeintptr.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.cs
new file mode 100644
index 0000000000..9010b3e762
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.cs
@@ -0,0 +1,87 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Collections;
+
+namespace Exchange
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe(threads.Length);
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ChangeValue));
+ threads[i].Name = i.ToString();
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+
+ if(tsi.Success)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ private int threadCount;
+ ManualResetEvent signal;
+ private IntPtr mValue;
+ private int accessCount;
+ private static object myLock = new Object();
+
+ public ThreadSafe(int size)
+ {
+ threadCount = size;
+ mValue = IntPtr.Zero;
+ signal = new ManualResetEvent(false);
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+ public bool Success
+ {
+ get {
+ Console.WriteLine("AccessCount {0} should equal threadCount {1}", accessCount, threadCount);
+ Console.WriteLine("mValue.ToInt32 {0} should equal threadCount {1}", mValue.ToInt32(), threadCount);
+ return (accessCount == threadCount) && (mValue.ToInt32() == threadCount);
+ }
+ }
+ public void ChangeValue()
+ {
+ IntPtr initialValue, newValue;
+
+ signal.WaitOne();
+ do
+ {
+ initialValue = mValue;
+ lock (myLock)
+ {
+ newValue = new IntPtr(mValue.ToInt32() + 1);
+ }
+ } while (initialValue != Interlocked.CompareExchange(ref mValue, newValue, initialValue));
+ Interlocked.Increment(ref accessCount);
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.csproj
new file mode 100644
index 0000000000..01798b4445
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="CompareExchangeIntPtr.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchangeobject.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.cs
new file mode 100644
index 0000000000..f135e156fb
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.cs
@@ -0,0 +1,101 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Collections;
+
+namespace Exchange
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe(threads.Length);
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(tsi.ChangeValue));
+ threads[i].Name = i.ToString();
+ threads[i].Start();
+ }
+
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+
+ if(tsi.Success)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ArrayList myObjArray;
+ ArrayList postObjArray;
+ ManualResetEvent signal;
+ private Object mValue;
+ private int accessCount;
+ public ThreadSafe(int arraySize)
+ {
+ accessCount = 0;
+ mValue = null;
+ postObjArray = new ArrayList(arraySize + 1);
+ myObjArray = new ArrayList(arraySize+1);
+ for(int i=0;i<arraySize;i++)
+ myObjArray.Add(new Object());
+ signal = new ManualResetEvent(false);
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+ public bool Success
+ {
+ get
+ {
+ for (int i = 0; i < postObjArray.Count; i++)
+ for (int j = i+1; j < postObjArray.Count; j++)
+ if (postObjArray[i] == postObjArray[j])
+ {
+ Console.WriteLine("Failure!!!!");
+ Console.WriteLine("ValueOne:" + postObjArray[i]);
+ Console.WriteLine("ValueTwo:" + postObjArray[j]);
+ Console.WriteLine("Position:" + i + " " + j);
+ return false;
+ }
+ //No dups so check for proper count
+ Console.WriteLine("Expect accessCount {0} to equal postObjArray.Count {1}", accessCount, postObjArray.Count);
+ return (accessCount == (postObjArray.Count));
+ }
+ }
+ public void ChangeValue()
+ {
+ Object initialValue, newValue;
+ signal.WaitOne();
+ do
+ {
+ initialValue = mValue;
+ newValue = myObjArray[Int32.Parse(Thread.CurrentThread.Name)];
+ } while (initialValue != Interlocked.CompareExchange(ref mValue, newValue, initialValue));
+ lock (this)
+ {
+ postObjArray.Add(initialValue);
+ }
+ Interlocked.Increment(ref accessCount);
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.csproj
new file mode 100644
index 0000000000..0d395c76b8
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="CompareExchangeObject.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchanget.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.cs
new file mode 100644
index 0000000000..15c230f15a
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.cs
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Test
+{
+
+ public static int Main()
+ {
+ Console.WriteLine("Start");
+ int retVal = 100;
+ string STORAGE = "OLD";
+ string NOW = "NOW";
+ string ret = "";
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+ Console.WriteLine("Comparand:" + STORAGE);
+ Console.WriteLine("Attempting Exchange in:" + NOW);
+
+ string OLDSTORAGE = STORAGE;
+ ret = Interlocked.CompareExchange<string>(ref STORAGE,NOW,STORAGE);
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+
+ //if(ret == "" || STORAGE != NOW)
+ if(ret != OLDSTORAGE || STORAGE != NOW)
+ retVal = -1;
+
+ Console.WriteLine(100 == retVal ? "Test Passed":"Test Failed");
+
+
+ STORAGE = "OLD";
+ NOW = "NOW";
+ ret = "";
+
+ Console.WriteLine("==================================");
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+ Console.WriteLine("Comparand:" + NOW);
+ Console.WriteLine("Attempting Exchange in:" + NOW);
+
+ ret = Interlocked.CompareExchange<string>(ref STORAGE,NOW,NOW);
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+ if(ret != "OLD" || STORAGE != "OLD")
+ retVal = -1;
+
+ Console.WriteLine(100 == retVal ? "Test Passed":"Test Failed");
+ return retVal;
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.csproj
new file mode 100644
index 0000000000..6bdd3b2730
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchanget.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CompareExchangeT.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/compareexchange/compareexchangetneg.il b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangetneg.il
deleted file mode 100644
index 0acce7968c..0000000000
--- a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchangetneg.il
+++ /dev/null
@@ -1,95 +0,0 @@
-.assembly extern mscorlib
-{
- .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
- .ver 2:0:0:0
-}
-.assembly CompareExchangeTNeg{}
-
-.class Test
-{
- .method public hidebysig static int32 Main() cil managed
- {
- .entrypoint
- .custom instance void [mscorlib]System.Security.SecuritySafeCriticalAttribute::.ctor() = ( 01 00 00 00 )
- // Code size 101 (0x65)
- .maxstack 3
- .locals init (int32 V_0,
- object V_1,
- object V_2,
- class [mscorlib]System.Exception V_3,
- int32 V_4,
-//Next line was added
- object& V_5)
- IL_0000: ldc.i4.m1
- IL_0001: stloc.0
- IL_0002: ldstr "Start Test"
- IL_0007: call void [mscorlib]System.Console::WriteLine(string)
- IL_000c: nop
- .try
- {
-//Next line was changed to
- IL_000d: ldloc.s 5
-//From
-// IL_000d: ldloc.s 1
- IL_0011: ldstr "hello world"
- IL_0016: ldstr "goodbye world"
- IL_001b: call !!0 [mscorlib]System.Threading.Interlocked::CompareExchange<object>(!!0&,
- !!0,
- !!0)
- IL_0020: stloc.2
- IL_0021: nop
- IL_0022: leave.s IL_0045
-
- } // end .try
- catch [mscorlib]System.NullReferenceException
- {
- IL_0024: pop
- IL_0025: ldc.i4.s 100
- IL_0027: stloc.0
- IL_0028: nop
- IL_0029: leave.s IL_0045
-
- } // end handler
- catch [mscorlib]System.Exception
- {
- IL_002b: stloc.3
- IL_002c: ldstr "Wrong exception thrown: "
- IL_0031: ldloc.3
- IL_0032: callvirt instance string [mscorlib]System.Object::ToString()
- IL_0037: call string [mscorlib]System.String::Concat(string,
- string)
- IL_003c: call void [mscorlib]System.Console::WriteLine(string)
- IL_0041: nop
- IL_0042: nop
- IL_0043: leave.s IL_0045
-
- } // end handler
- IL_0045: nop
- IL_0046: ldc.i4.s 100
- IL_0048: ldloc.0
- IL_0049: beq.s IL_0052
-
- IL_004b: ldstr "Test Failed"
- IL_0050: br.s IL_0057
-
- IL_0052: ldstr "Test Passed"
- IL_0057: call void [mscorlib]System.Console::WriteLine(string)
- IL_005c: nop
- IL_005d: ldloc.0
- IL_005e: stloc.s V_4
- IL_0060: br.s IL_0062
-
- IL_0062: ldloc.s V_4
- IL_0064: ret
- } // end of method Test::Main
-
- .method public hidebysig specialname rtspecialname
- instance void .ctor() cil managed
- {
- // Code size 7 (0x7)
- .maxstack 8
- IL_0000: ldarg.0
- IL_0001: call instance void [mscorlib]System.Object::.ctor()
- IL_0006: ret
- } // end of method Test::.ctor
-}
diff --git a/tests/src/baseservices/threading/interlocked/ctorchk/app.config b/tests/src/baseservices/threading/interlocked/ctorchk/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/ctorchk/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.cs b/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.cs
new file mode 100644
index 0000000000..6163bd50fe
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.cs
@@ -0,0 +1,30 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Reflection;
+
+class TestMonitor
+{
+ public static int Main()
+ {
+ // This will look for any private constructor.
+ // There shouldn't be one in Whidbey.
+ ConstructorInfo[] m = typeof(Interlocked).GetConstructors(
+ BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
+ Console.WriteLine(m.Length);
+
+ if(m.Length > 0)
+ {
+ Console.WriteLine("Test FAILED!");
+ return 1;
+ }
+ else
+ {
+ Console.WriteLine("Test PASSED!");
+ return 100;
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.csproj b/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.csproj
new file mode 100644
index 0000000000..31b06207a1
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/ctorchk/ctorchk.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CtorChk.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/ctorchk/project.json b/tests/src/baseservices/threading/interlocked/ctorchk/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/ctorchk/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/decrement/app.config b/tests/src/baseservices/threading/interlocked/decrement/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/interlocked/decrement/intdec.cs b/tests/src/baseservices/threading/interlocked/decrement/intdec.cs
new file mode 100644
index 0000000000..c3b31073f3
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/intdec.cs
@@ -0,0 +1,32 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ int loops = 5000;
+ int threads = 50;
+ if (Args.Length == 2)
+ {
+ loops = Int32.Parse(Args[0]);
+ threads = Int32.Parse(Args[1]);
+ }
+ Console.WriteLine("Starting Interlocked test on {0} threads for {1} iterations.",threads,loops);
+
+ IntTest testInt = new IntTest(loops, threads);
+
+ Console.WriteLine("Check Decrement: {0}", rValue = testInt.Dec());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/decrement/intdec.csproj b/tests/src/baseservices/threading/interlocked/decrement/intdec.csproj
new file mode 100644
index 0000000000..1ddb1b1162
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/intdec.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="IntDec.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/decrement/longdec.cs b/tests/src/baseservices/threading/interlocked/decrement/longdec.cs
new file mode 100644
index 0000000000..74045ee951
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/longdec.cs
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ int loops = 5000;
+ int threads = 50;
+ if (Args.Length == 2)
+ {
+ loops = Int32.Parse(Args[0]);
+ threads = Int32.Parse(Args[1]);
+ }
+ Console.WriteLine("Starting Interlocked test on {0} threads for {1} iterations.",threads,loops);
+
+ LongTest testLong = new LongTest(loops, threads);
+
+ Console.WriteLine("Check Decrement: {0}", rValue = testLong.Dec());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/decrement/longdec.csproj b/tests/src/baseservices/threading/interlocked/decrement/longdec.csproj
new file mode 100644
index 0000000000..4bb38c4821
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/longdec.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="LongDec.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/decrement/project.json b/tests/src/baseservices/threading/interlocked/decrement/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/decrement/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs
new file mode 100644
index 0000000000..fb682e093b
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs
@@ -0,0 +1,165 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections;
+using System.Threading;
+
+/// <summary>
+/// System.Threading.Interlocked.Exchange(System.Double@,System.Double)
+/// </summary>
+
+
+// This test makes sure that Exchange(Double, Double)
+// plays nicely with other threads accessing shared state directly.
+// The test spawns a bunch of threads, then each thread tries to
+// grab the mutex (set location=1), decrement a global resource count,
+// then release the mutex (set location=0). While location=0, the
+// thread will be able to set it to 1 and enter the mutex to consume
+// the resource, but if it is 1, the thread will be denied entry.
+// At the end, the test checks that:
+// the sum of all entries + denials = total potential resources
+// total potential resources = resources unconsumed + entries
+public class InterlockedExchange1
+{
+ private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn
+ private const int c_WAITTHREADSCOMPLETE = 3000; // how long main thread should sleep
+ private static int resource = 10; // resources to be consumed
+ private static double location = 0; // mutex being managed thru Exchange
+ private static int entry = 0; // threads granted entry to the mutex
+ private static int deny = 0; // threads denied entry to the mutex
+
+ public static int Main(string[] args)
+ {
+ InterlockedExchange1 exchange1 = new InterlockedExchange1();
+ TestLibrary.TestFramework.BeginTestCase("Testing System.Threading.Interlocked.Exchange(System.Double@,System.Double)...");
+
+ if (exchange1.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Verify multiple threads share the same resource by using Interlocked.Exchange method...");
+
+ try
+ {
+ // create an array of many threads
+ Thread[] threads = new Thread[c_THREADARRAT_SIZE];
+ Random rand = new Random();
+
+ // for each thread
+ for (int i = 0; i < threads.Length; i++)
+ {
+ // each thread uses ConsumeResource
+ threads[i] = new Thread(new ThreadStart(ConsumeResource));
+ // and has a name
+ threads[i].Name = String.Format("Thread{0}",i+1);
+ // put the spawning thread to sleep for a random period of time
+ Thread.Sleep(rand.Next(1,100));
+ // then start the spawned thread working
+ threads[i].Start();
+ }
+
+ // after all threads are spawned, put the spawining thread
+ // to sleep for long enough that the spawned threads have
+ // time to complete
+ Thread.Sleep(c_WAITTHREADSCOMPLETE);
+
+ // entries + denials should equal original value of resource (10)
+ if (entry + deny == 10)
+ {
+ // if any resources remain unconsumed, then those plus number
+ // of successful entries should equal the original value of
+ // resource (10)
+ if (resource > 0 && resource + entry != 10)
+ {
+ TestLibrary.TestFramework.LogError("001","The number of resources consumed is wrong!");
+ retVal = false;
+ }
+ }
+ else
+ {
+ TestLibrary.TestFramework.LogError("002","The total number is wrong!");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003","Unexpected exception occurs: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ private static void ConsumeResource()
+ {
+ // This is effectively a hand-coded mutex.
+ // The thread exchanges the value 1 with the value
+ // already at location (initially 0). So first time, it should
+ // set location=1 and return 0. When it gets back the 0, it knows
+ // it holds the mutex. So the thread 'consumes' a
+ // resource and records an 'entry', after which it sets location
+ // back to 0, effectively releasing the mutex.
+ // Any thread hitting the first Exchange while location=1 will
+ // be returned the 1, and thus not enter the mutex - it will
+ // just record a 'denial' and not 'consume' a resource.
+ // After all is said and done, denials+entries should equal total
+ // initial resources.
+
+ // obtain the mutex by putting a 1 there and getting back a 0)
+ if (Interlocked.Exchange(ref location, 1) == 0) // corrected, was !=0
+ {
+ // this thread has the mutex
+ if (resource > 0)
+ {
+ // consume a resource
+ resource--;
+ TestLibrary.TestFramework.LogInformation(String.Format("The resource is reduced, the remainder is {0}",resource));
+ }
+ else
+ {
+ // no more resources to consume - this really should never happen
+ TestLibrary.TestFramework.LogInformation("The resource is empty!");
+ }
+
+ // release the mutex (put a 0 back in location)
+ Interlocked.Exchange(ref location,0);
+ // increment the entry count -
+ Interlocked.Increment(ref entry); // corrected, was entry++;
+ // which is not thread safe;
+ }
+ else
+ {
+ // the thread could not enter the mutex because another
+ // thread has set the location to 1
+ TestLibrary.TestFramework.LogInformation("This is not available!");
+ // increment the denial count, no resource is consumed
+ Interlocked.Increment(ref deny); // corrected, was deny++;
+ // which is not thread safe;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.csproj
new file mode 100644
index 0000000000..de83597a6a
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange1_cti.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchange2.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange2.cs
new file mode 100644
index 0000000000..a4ba8ff836
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange2.cs
@@ -0,0 +1,150 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// Tests that Exchange(object, object) works on variety
+// of casted types: It just casts a bunch of different types to
+// object, then makes sure Exchange works on those objects.
+public class InterlockedExchange2
+{
+ private const int c_NUM_LOOPS = 100;
+ private const int c_MIN_STRING_LEN = 5;
+ private const int c_MAX_STRING_LEN = 128;
+
+ public static int Main()
+ {
+ InterlockedExchange2 test = new InterlockedExchange2();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedExchange2");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object Interlocked.Exchange(objct&,object)");
+
+ try
+ {
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Byte");
+ retVal = ExchangeObjects(
+ (object)TestLibrary.Generator.GetByte(),
+ (object)TestLibrary.Generator.GetByte()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Byte[]");
+ byte[] bArr1 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ byte[] bArr2 = new Byte[5 + (TestLibrary.Generator.GetInt32() % 1024)];
+ TestLibrary.Generator.GetBytes(bArr1);
+ TestLibrary.Generator.GetBytes(bArr2);
+ retVal = ExchangeObjects(
+ (object)bArr1,
+ (object)bArr2
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int16");
+ retVal = ExchangeObjects(
+ (object)TestLibrary.Generator.GetInt16(),
+ (object)TestLibrary.Generator.GetInt16()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int32");
+ retVal = ExchangeObjects(
+ (object)TestLibrary.Generator.GetInt32(),
+ (object)TestLibrary.Generator.GetInt32()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Int64");
+ retVal = ExchangeObjects(
+ (object)(object)TestLibrary.Generator.GetInt64(),
+ (object)TestLibrary.Generator.GetInt64()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Single");
+ retVal = ExchangeObjects(
+ (object)(object)TestLibrary.Generator.GetSingle(),
+ (object)TestLibrary.Generator.GetSingle()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == Double");
+ retVal = ExchangeObjects(
+ (object)TestLibrary.Generator.GetDouble(),
+ (object)TestLibrary.Generator.GetDouble()
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == string");
+ retVal = ExchangeObjects(
+ TestLibrary.Generator.GetString(false, c_MIN_STRING_LEN, c_MAX_STRING_LEN),
+ (object)TestLibrary.Generator.GetString(false, c_MIN_STRING_LEN, c_MAX_STRING_LEN)
+ ) && retVal;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: object == char");
+ retVal = ExchangeObjects(
+ TestLibrary.Generator.GetChar(),
+ TestLibrary.Generator.GetChar()
+ ) && retVal;
+
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ public bool ExchangeObjects(object location, object value)
+ {
+ bool retVal = true;
+ object oldLocation;
+ object prevLocation;
+
+ prevLocation = location;
+
+ // this is the main change from InterlockedExchange2.cs
+ // here we use the object overload
+ oldLocation = Interlocked.Exchange(ref location, value);
+
+ if (!location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("003", "Interlocked.Exchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (!oldLocation.Equals(prevLocation))
+ {
+ TestLibrary.TestFramework.LogError("004", "Interlocked.Exchange() did not return the expected value: Expected(" + prevLocation + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange2.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange2.csproj
new file mode 100644
index 0000000000..f7862d719f
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange2.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchange3.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange3.cs
new file mode 100644
index 0000000000..ed5ea017f3
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange3.cs
@@ -0,0 +1,86 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// Tests that Exchange(Double, Double)
+// actually switches values
+public class InterlockedExchange3
+{
+ private const int c_NUM_LOOPS = 100;
+
+ public static int Main()
+ {
+ InterlockedExchange3 test = new InterlockedExchange3();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedExchange3");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Double location;
+ Double value;
+ Double prevLocation;
+ Double oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Double Interlocked.Exchange(Double&,Double)");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetDouble();
+ location = TestLibrary.Generator.GetDouble();
+ prevLocation = location;
+
+ oldLocation = Interlocked.Exchange(ref location, value);
+
+ if (!location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("001", "Interlocked.Exchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (!oldLocation.Equals(prevLocation))
+ {
+ TestLibrary.TestFramework.LogError("002", "Interlocked.Exchange() did not return the expected value: Expected(" + prevLocation + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange3.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange3.csproj
new file mode 100644
index 0000000000..33feaa3da2
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange3.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchange4.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange4.cs
new file mode 100644
index 0000000000..85cc51dc09
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange4.cs
@@ -0,0 +1,86 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// Tests that Exchange(Single, Single)
+// a.k.a., CompareExchange(float, float)
+// actually switches values
+public class InterlockedExchange4
+{
+ private const int c_NUM_LOOPS = 100;
+
+ public static int Main()
+ {
+ InterlockedExchange4 test = new InterlockedExchange4();
+
+ TestLibrary.TestFramework.BeginTestCase("InterlockedExchange4");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Single location;
+ Single value;
+ Single prevLocation;
+ Single oldLocation;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Single Interlocked.Exchange(Single&,Single)");
+
+ try
+ {
+ for (int i=0; i<c_NUM_LOOPS; i++)
+ {
+ value = TestLibrary.Generator.GetSingle();
+ location = TestLibrary.Generator.GetSingle();
+ prevLocation = location;
+
+ oldLocation = Interlocked.Exchange(ref location, value);
+
+ if (!location.Equals(value))
+ {
+ TestLibrary.TestFramework.LogError("001", "Interlocked.Exchange() did not do the exchange correctly: Expected(" + value + ") Actual(" + location + ")");
+ retVal = false;
+ }
+
+ if (!oldLocation.Equals(prevLocation))
+ {
+ TestLibrary.TestFramework.LogError("002", "Interlocked.Exchange() did not return the expected value: Expected(" + prevLocation + ") Actual(" + oldLocation + ")");
+ retVal = false;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange4.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange4.csproj
new file mode 100644
index 0000000000..2c7bc4a3ec
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange4.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchange4_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs
new file mode 100644
index 0000000000..ba38b07ad2
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs
@@ -0,0 +1,165 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections;
+using System.Threading;
+
+/// <summary>
+/// System.Threading.Interlocked.Exchange(System.Single@,System.Single)
+/// </summary>
+
+
+// This test makes sure that Exchange(Single, Single)
+// plays nicely with other threads accessing shared state directly.
+// The test spawns a bunch of threads, then each thread tries to
+// grab the mutex (set location=1), decrement a global resource count,
+// then release the mutex (set location=0). While location=0, the
+// thread will be able to set it to 1 and enter the mutex to consume
+// the resource, but if it is 1, the thread will be denied entry.
+// At the end, the test checks that:
+// the sum of all entries + denials = total potential resources
+// total potential resources = resources unconsumed + entries
+public class InterlockedExchange4
+{
+ private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn
+ private const int c_WAITTHREADSCOMPLETE = 2000; // how long main thread should sleep
+ private static int resource = 10; // resources to be consumed
+ private static Int64 location = 0; // mutex being managed thru Exchange
+ private static int entry = 0; // threads granted entry to the mutex
+ private static int deny = 0; // threads denied entry to the mutex
+
+ public static int Main(string[] args)
+ {
+ InterlockedExchange4 exchange4 = new InterlockedExchange4();
+ TestLibrary.TestFramework.BeginTestCase("Testing System.Threading.Interlocked.Exchange(System.Single@,System.Single)...");
+
+ if (exchange4.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Verify multiple threads share the same resource by using Interlocked.Exchange method...");
+
+ try
+ {
+ // create an array of many threads
+ Thread[] threads = new Thread[c_THREADARRAT_SIZE];
+ Random rand = new Random();
+
+ // for each thread
+ for (int i = 0; i < threads.Length; i++)
+ {
+ // each thread uses ConsumeResource
+ threads[i] = new Thread(new ThreadStart(ConsumeResource));
+ // and has a name
+ threads[i].Name = String.Format("Thread{0}", i + 1);
+ // put the spawning thread to sleep for a random period of time
+ Thread.Sleep(rand.Next(1, 100));
+ // then start the spawned thread working
+ threads[i].Start();
+ }
+
+ // after all threads are spawned, put the spawining thread
+ // to sleep for long enough that the spawned threads have
+ // time to complete
+ Thread.Sleep(c_WAITTHREADSCOMPLETE);
+
+ // entries + denials should equal original value of resource (10)
+ if (entry + deny == 10)
+ {
+ // if any resources remain unconsumed, then those plus number
+ // of successful entries should equal the original value of
+ // resource (10)
+ if (resource > 0 && resource + entry != 10)
+ {
+ TestLibrary.TestFramework.LogError("001", "The number of resource is consumed is wrong!");
+ retVal = false;
+ }
+ }
+ else
+ {
+ TestLibrary.TestFramework.LogError("002", "The total number is wrong!");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception occurs: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ private static void ConsumeResource()
+ {
+ // This is effectively a hand-coded mutex.
+ // The thread exchanges the value 1 with the value
+ // already at location (initially 0). So first time, it should
+ // set location=1 and return 0. When it gets back the 0, it knows
+ // it holds the mutex. So the thread 'consumes' a
+ // resource and records an 'entry', after which it sets location
+ // back to 0, effectively releasing the mutex.
+ // Any thread hitting the first Exchange while location=1 will
+ // be returned the 1, and thus not enter the mutex - it will
+ // just record a 'denial' and not 'consume' a resource.
+ // After all is said and done, denials+entries should equal total
+ // original resources.
+
+ // obtain the mutex by putting a 1 there and getting back a 0)
+ if (Interlocked.Exchange(ref location, 1) == 0) // corrected, was !=0
+ {
+ // this thread has the mutex
+ if (resource > 0)
+ {
+ // consume a resource
+ resource--;
+ TestLibrary.TestFramework.LogInformation(String.Format("The resource is reduced,the rest number is {0}", resource));
+ }
+ else
+ {
+ // no more resources to consume - this really should never happen
+ TestLibrary.TestFramework.LogInformation("The resource is empty!");
+ }
+
+ // release the mutex (put a 0 back in location)
+ Interlocked.Exchange(ref location, 0);
+ // increment the entry count -
+ Interlocked.Increment(ref entry); // corrected, was entry++;
+ // which is not thread safe;
+ }
+ else
+ {
+ // the thread could not enter the mutex because another
+ // thread has set the location to 1
+ TestLibrary.TestFramework.LogInformation("This is not available!");
+ // increment the denial count, no resource is consumed
+ Interlocked.Increment(ref deny); // corrected, was deny++;
+ // which is not thread safe;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.csproj
new file mode 100644
index 0000000000..2ddaf2e162
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange4_cti.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchange5_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs
new file mode 100644
index 0000000000..af0da2a532
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs
@@ -0,0 +1,165 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections;
+using System.Threading;
+
+/// <summary>
+/// System.Threading.Interlocked.Exchange(System.Object@,System.Object)
+/// </summary>
+
+
+// This test makes sure that Exchange(object, object)
+// plays nicely with other threads accessing shared state directly.
+// The test spawns a bunch of threads, then each thread tries to
+// grab the mutex (set location=1), decrement a global resource count,
+// then release the mutex (set location=0). While location=0, the
+// thread will be able to set it to 1 and enter the mutex to consume
+// the resource, but if it is 1, the thread will be denied entry.
+// At the end, the test checks that:
+// the sum of all entries + denials = total potential resources
+// total potential resources = resources unconsumed + entries
+public class InterlockedExchange5
+{
+ private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn
+ private const int c_WAITTHREADSCOMPLETE = 2000; // how long main thread should sleep
+ private static int resource = 10; // resources to be consumed
+ private static Object location = 0; // mutex being managed thru Exchange
+ private static int entry = 0; // threads granted entry to the mutex
+ private static int deny = 0; // threads denied entry to the mutex
+
+ public static int Main(string[] args)
+ {
+ InterlockedExchange5 exchange5 = new InterlockedExchange5();
+ TestLibrary.TestFramework.BeginTestCase("Testing System.Threading.Interlocked.Exchange(System.Object@,System.Object)...");
+
+ if (exchange5.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Verify multiple threads share the same resource by using Interlocked.Exchange method...");
+
+ try
+ {
+ // create an array of many threads
+ Thread[] threads = new Thread[c_THREADARRAT_SIZE];
+ Random rand = new Random();
+
+ // for each thread
+ for (int i = 0; i < threads.Length; i++)
+ {
+ // each thread uses ConsumeResource
+ threads[i] = new Thread(new ThreadStart(ConsumeResource));
+ // and has a name
+ threads[i].Name = String.Format("Thread{0}", i + 1);
+ // put this (the spawning) thread to sleep for a random period of time
+ Thread.Sleep(rand.Next(1, 100));
+ // then start the spawned thread working
+ threads[i].Start();
+ }
+
+ // after all threads are spawned, put the spawining thread
+ // to sleep for long enough that the spawned threads have
+ // time to complete
+ Thread.Sleep(c_WAITTHREADSCOMPLETE);
+
+ // entries + denials should equal original value of resource (10)
+ if (entry + deny == 10)
+ {
+ // if any resources remain unconsumed, then those plus number
+ // of successful entries should equal the original value of
+ // resource (10)
+ if (resource > 0 && resource + entry != 10)
+ {
+ TestLibrary.TestFramework.LogError("001", "The number of resource is consumed is wrong!");
+ retVal = false;
+ }
+ }
+ else
+ {
+ TestLibrary.TestFramework.LogError("002", "The total number is wrong!");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception occurs: " + e);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+
+ private static void ConsumeResource()
+ {
+ // This is effectively a hand-coded mutex.
+ // The thread exchanges the value 1 with the value
+ // already at location (initially 0). So first time, it should
+ // set location=1 and return 0. Then the thread 'consumes' a
+ // resource and records an 'entry', after which it sets location
+ // back to 0. Any thread hitting the Exchange while loc=1 will see
+ // this and not enter the mutex - it will just record a 'denial'.
+ // After all is said and done, denials+entries should equal total
+ // resources consumed.
+ // note that since location is actually an object, Exchange is going
+ // to return an object which must be converted to Int32
+ // note that here we use the object overload of Interlocked.Exchange
+ if (Convert.ToInt32(Interlocked.Exchange(ref location, 1)) == 0) // corrected, was !=0
+ {
+ // this thread has the mutex
+ if (resource > 0)
+ {
+ // consume a resource
+ resource--;
+ TestLibrary.TestFramework.LogInformation(String.Format("The resource is reduced, the remainder is {0}", resource));
+ }
+ else
+ {
+ // no more resources to consume - this really should never happen
+ TestLibrary.TestFramework.LogInformation("The resource is empty!");
+ }
+
+ // release the mutex
+ // note that here we use the object overload
+ // of Exchange
+ Interlocked.Exchange(ref location, 0);
+ // increment the entry count -
+ Interlocked.Increment(ref entry); // corrected, was entry++;
+ // which is not thread safe
+ }
+ else
+ {
+ // the thread could not enter the mutex because another
+ // thread has set the location to 1
+ TestLibrary.TestFramework.LogInformation("This is not available!");
+ // increment the denial count, no resource is consumed
+ Interlocked.Increment(ref deny); // corrected, was deny++;
+ // which is not thread safe
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.csproj
new file mode 100644
index 0000000000..e12223d9d2
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Exchange5_cti.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/interlocked/exchange/exchangedouble.cs b/tests/src/baseservices/threading/interlocked/exchange/exchangedouble.cs
new file mode 100644
index 0000000000..385f549eb3
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangedouble.cs
@@ -0,0 +1,99 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace Exchange
+{
+ class ExchangeDouble
+ {
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe();
+ for (int i = 0; i < threads.Length - 1; i++)
+ {
+ if (i % 2 == 0)
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
+ else
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
+ threads[i].Start();
+ }
+ threads[threads.Length - 1] = new Thread(new ThreadStart(tsi.ThreadChecker));
+ threads[threads.Length - 1].Start();
+ tsi.Signal();
+
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (tsi.Pass)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private double totalValue = Double.MinValue;
+ private int numberOfIterations;
+ private double newValueA = 0.0D;
+ private double newValueB = Double.MinValue;
+ private bool success;
+ public ThreadSafe(): this(10000) { }
+ public ThreadSafe(int loops)
+ {
+ success = true;
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorkerA()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueA);
+ }
+
+ public void ThreadWorkerB()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueB);
+ }
+
+ public void ThreadChecker()
+ {
+ double tmpVal;
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ {
+ tmpVal = totalValue;
+ if (tmpVal != newValueB && tmpVal != newValueA)
+ {
+ Console.WriteLine(tmpVal + "," +
+ newValueB + "," + newValueA);
+ success = false;
+ }
+ Thread.Sleep(0);
+ }
+ }
+
+ public bool Pass
+ {
+ get
+ {
+ return (success);
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchangedouble.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchangedouble.csproj
new file mode 100644
index 0000000000..29651b43a8
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangedouble.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ExchangeDouble.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/exchange/exchangefloat.cs b/tests/src/baseservices/threading/interlocked/exchange/exchangefloat.cs
new file mode 100644
index 0000000000..0811db9469
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangefloat.cs
@@ -0,0 +1,107 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace Exchange
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class Class1
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe();
+ for (int i = 0; i < threads.Length - 1; i++)
+ {
+ if (i % 2 == 0)
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
+ else
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
+ threads[i].Start();
+ }
+ threads[threads.Length - 1] = new Thread(new ThreadStart(tsi.ThreadChecker));
+ threads[threads.Length - 1].Start();
+ tsi.Signal();
+
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (tsi.Pass)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private float totalValue = Single.MinValue;
+ private int numberOfIterations;
+ private float newValueA = 0.0F;
+ private float newValueB = Single.MinValue;
+ private bool success;
+ public ThreadSafe(): this(10000) { }
+ public ThreadSafe(int loops)
+ {
+ success = true;
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorkerA()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueA);
+
+ }
+ public void ThreadWorkerB()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueB);
+
+ }
+ public void ThreadChecker()
+ {
+ float tmpVal;
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ {
+ tmpVal = totalValue;
+ if (tmpVal != newValueB && tmpVal != newValueA)
+ {
+
+ Console.WriteLine(tmpVal + "," + newValueB + "," + newValueA);
+ success = false;
+ }
+ Thread.Sleep(0);
+ }
+
+ }
+
+ public bool Pass
+ {
+ get
+ {
+ return (success);
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchangefloat.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchangefloat.csproj
new file mode 100644
index 0000000000..b2c3ff20da
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangefloat.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ExchangeFloat.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/exchange/exchangeobject.cs b/tests/src/baseservices/threading/interlocked/exchange/exchangeobject.cs
new file mode 100644
index 0000000000..09fa32a46f
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangeobject.cs
@@ -0,0 +1,107 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InteropTests
+{
+ /// <summary>
+ /// Summary description for Class1.
+ /// </summary>
+ class ExchangeObject
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe();
+ for (int i = 0; i < threads.Length - 1; i++)
+ {
+ if (i % 2 == 0)
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
+ else
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
+ threads[i].Start();
+ }
+ threads[threads.Length - 1] = new Thread(new ThreadStart(tsi.ThreadChecker));
+ threads[threads.Length - 1].Start();
+ tsi.Signal();
+
+ for (int i = 0; i < threads.Length; i++)
+ threads[i].Join();
+
+ if (tsi.Pass)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private Object totalValue = null;
+ private int numberOfIterations;
+ private Object newValueA = new Object();
+ private Object newValueB = new Object();
+ private bool success;
+ public ThreadSafe(): this(10000) { }
+ public ThreadSafe(int loops)
+ {
+ totalValue = newValueA;
+ success = true;
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorkerA()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueB);
+
+ }
+ public void ThreadWorkerB()
+ {
+ signal.WaitOne();
+ for (int i = 0; i < numberOfIterations; i++)
+ Interlocked.Exchange(ref totalValue, newValueB);
+
+ }
+ public void ThreadChecker()
+ {
+ signal.WaitOne();
+ Object tmpVal;
+ for (int i = 0; i < numberOfIterations; i++)
+ {
+ tmpVal = totalValue;
+ if (tmpVal != newValueB && tmpVal != newValueA)
+ {
+ Console.WriteLine(tmpVal + "," + newValueB + "," + newValueA);
+ success = false;
+ }
+ Thread.Sleep(0);
+ }
+
+ }
+
+ public bool Pass
+ {
+ get
+ {
+ return (success);
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchangeobject.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchangeobject.csproj
new file mode 100644
index 0000000000..d90f451aac
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchangeobject.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ExchangeObject.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/exchange/exchanget.cs b/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs
new file mode 100644
index 0000000000..6e54966049
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchanget.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Test
+{
+
+ public static int Main()
+ {
+ Console.WriteLine("Start");
+ int retVal = 100;
+ string STORAGE = "OLD";
+ string NOW = "NOW";
+ string ret = "";
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+
+ Console.WriteLine("Echanging in:" + NOW);
+
+ string OLDSTORAGE = STORAGE;
+ ret = Interlocked.Exchange<string>(ref STORAGE,NOW);
+
+ Console.WriteLine("ref loc: " + STORAGE);
+ Console.WriteLine("Return: " + ret);
+
+ //if(ret == "" || STORAGE != NOW)
+ if(ret != OLDSTORAGE || STORAGE != NOW)
+ retVal = -1;
+
+ if (retVal == 100)
+ Console.WriteLine("Test passed");
+ else
+ Console.WriteLine("Test failed");
+
+ return retVal;
+
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchanget.csproj b/tests/src/baseservices/threading/interlocked/exchange/exchanget.csproj
new file mode 100644
index 0000000000..0d47012aeb
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/exchange/exchanget.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ExchangeT.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/increment/app.config b/tests/src/baseservices/threading/interlocked/increment/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/interlocked/increment/intinc.cs b/tests/src/baseservices/threading/interlocked/increment/intinc.cs
new file mode 100644
index 0000000000..0d484bd32e
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/intinc.cs
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ int loops = 5000;
+ int threads = 50;
+ if (Args.Length == 2)
+ {
+ loops = Int32.Parse(Args[0]);
+ threads = Int32.Parse(Args[1]);
+ }
+ Console.WriteLine("Starting Interlocked test on {0} threads for {1} iterations.",threads,loops);
+
+ IntTest testInt = new IntTest(loops, threads);
+
+ Console.WriteLine("Check Increment: {0}", rValue = testInt.Inc());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/increment/intinc.csproj b/tests/src/baseservices/threading/interlocked/increment/intinc.csproj
new file mode 100644
index 0000000000..b15bb0f6ea
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/intinc.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="IntInc.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/increment/longinc.cs b/tests/src/baseservices/threading/interlocked/increment/longinc.cs
new file mode 100644
index 0000000000..74045ee951
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/longinc.cs
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedTest
+{
+ class InterlockTest
+ {
+ public static int Main(string[] Args)
+ {
+ int rValue;
+ int loops = 5000;
+ int threads = 50;
+ if (Args.Length == 2)
+ {
+ loops = Int32.Parse(Args[0]);
+ threads = Int32.Parse(Args[1]);
+ }
+ Console.WriteLine("Starting Interlocked test on {0} threads for {1} iterations.",threads,loops);
+
+ LongTest testLong = new LongTest(loops, threads);
+
+ Console.WriteLine("Check Decrement: {0}", rValue = testLong.Dec());
+ Console.WriteLine("Test {0}", 100 == rValue ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/increment/longinc.csproj b/tests/src/baseservices/threading/interlocked/increment/longinc.csproj
new file mode 100644
index 0000000000..ab74fb3986
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/longinc.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="..\common\InterlockedHelper_CoreCLR.cs" />
+ <Compile Include="LongInc.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/increment/project.json b/tests/src/baseservices/threading/interlocked/increment/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/increment/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/read/app.config b/tests/src/baseservices/threading/interlocked/read/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/interlocked/read/interlockedread.cs b/tests/src/baseservices/threading/interlocked/read/interlockedread.cs
new file mode 100644
index 0000000000..547a4b77af
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/interlockedread.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class InterlockedRead
+{
+ ManualResetEvent mre;
+ long lCurr;
+ static int success;
+ const int expected = 5;
+
+ public InterlockedRead()
+ {
+ mre = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ InterlockedRead ir = new InterlockedRead();
+ ir.TestOne(Int64.MaxValue);
+ ir.TestOne(Int64.MinValue);
+ ir.TestOne(0);
+ ir.TestOne(Int32.MaxValue);
+ ir.TestOne(Int32.MinValue);
+ Console.WriteLine(success == expected ? "Test Passed" : "Test Failed");
+ return (success == expected) ? 100 : -1;
+ }
+
+ public void TestOne(long iValue)
+ {
+ bool bRet = true;
+ lCurr = iValue;
+ if(iValue != Interlocked.Read(ref lCurr))
+ bRet = false;
+ if(bRet)
+ success++;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/read/interlockedread.csproj b/tests/src/baseservices/threading/interlocked/read/interlockedread.csproj
new file mode 100644
index 0000000000..9945bf8262
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/interlockedread.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="InterlockedRead.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/interlocked/read/project.json b/tests/src/baseservices/threading/interlocked/read/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/interlocked/read/readthreads.cs b/tests/src/baseservices/threading/interlocked/read/readthreads.cs
new file mode 100644
index 0000000000..ad839dbc20
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/readthreads.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+namespace InterlockedRead
+{
+ class Read
+ {
+ static int Main(string[] args)
+ {
+ int rValue = 0;
+ Thread[] threads = new Thread[100];
+ ThreadSafe tsi = new ThreadSafe();
+ for (int i = 0; i < threads.Length-1; i++)
+ {
+ if(i%2==0)
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
+ else
+ threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
+ threads[i].Start();
+ }
+ threads[threads.Length-1] = new Thread(new ThreadStart(tsi.ThreadChecker));
+ threads[threads.Length-1].Start();
+ tsi.Signal();
+
+ for(int i=0;i<threads.Length;i++)
+ threads[i].Join();
+
+ if(tsi.Pass)
+ rValue = 100;
+ Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
+ return rValue;
+ }
+ }
+
+ public class ThreadSafe
+ {
+ ManualResetEvent signal;
+ private long totalValue = Int64.MinValue;
+ private int numberOfIterations;
+ private long newValueA = 0;
+ private long newValueB = Int64.MinValue;
+ private bool success;
+ public ThreadSafe(): this(10000) { }
+ public ThreadSafe(int loops)
+ {
+ success = true;
+ signal = new ManualResetEvent(false);
+ numberOfIterations = loops;
+ }
+
+ public void Signal()
+ {
+ signal.Set();
+ }
+
+ public void ThreadWorkerA()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ Interlocked.Exchange(ref totalValue, newValueA);
+
+ }
+ public void ThreadWorkerB()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ Interlocked.Exchange(ref totalValue, newValueB);
+ }
+
+ public void ThreadChecker()
+ {
+ signal.WaitOne();
+ for(int i=0;i<numberOfIterations;i++)
+ {
+ long l = Interlocked.Read(ref totalValue);
+ if(l != newValueB && l != newValueA)
+ {
+ Console.WriteLine(l + "," +
+ newValueB + "," + newValueA);
+ success = false;
+ }
+ }
+ }
+
+ public bool Pass
+ {
+ get
+ {
+ return (success);
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/interlocked/read/readthreads.csproj b/tests/src/baseservices/threading/interlocked/read/readthreads.csproj
new file mode 100644
index 0000000000..4d89f94498
--- /dev/null
+++ b/tests/src/baseservices/threading/interlocked/read/readthreads.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ReadThreads.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/monitor/ctorchk/app.config b/tests/src/baseservices/threading/monitor/ctorchk/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/ctorchk/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.cs b/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.cs
new file mode 100644
index 0000000000..f6e9674ff9
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.cs
@@ -0,0 +1,30 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Reflection;
+
+class TestMonitor
+{
+ public static int Main()
+ {
+ // This will look for any private constructor.
+ // There shouldn't be one in Whidbey.
+ ConstructorInfo[] m = typeof(Monitor).GetConstructors(
+ BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
+ Console.WriteLine(m.Length);
+
+ if(m.Length > 0)
+ {
+ Console.WriteLine("Test FAILED!");
+ return 1;
+ }
+ else
+ {
+ Console.WriteLine("Test PASSED!");
+ return 100;
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.csproj b/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.csproj
new file mode 100644
index 0000000000..31b06207a1
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/ctorchk/ctorchk.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CtorChk.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/monitor/ctorchk/project.json b/tests/src/baseservices/threading/monitor/ctorchk/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/ctorchk/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/monitor/enter/monitorenter.cs b/tests/src/baseservices/threading/monitor/enter/monitorenter.cs
new file mode 100644
index 0000000000..0a9fc4ab4c
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/enter/monitorenter.cs
@@ -0,0 +1,501 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Collections.Generic;
+
+// disable warnings about various Monitor members being obsolete
+#pragma warning disable 0618
+
+class MonEnterTests
+{
+ int m_failed;
+
+ /// <summary>
+ /// Not really negative tests, but testing expected failure modes
+ /// </summary>
+ void NegTests()
+ {
+ Console.WriteLine("null object tests");
+ ExpectException<ArgumentNullException>(delegate { Monitor.Enter(null); });
+ ExpectException<ArgumentNullException>(delegate { Monitor.TryEnter(null); });
+ bool tookLock = false;
+ ExpectException<ArgumentNullException>(delegate { Monitor.Enter(null, ref tookLock); });
+ Assert(!tookLock);
+ tookLock = false;
+ ExpectException<ArgumentNullException>(delegate { Monitor.TryEnter(null, 0, ref tookLock); });
+ Assert(!tookLock);
+ tookLock = false;
+ ExpectException<ArgumentNullException>(delegate { Monitor.TryEnter(null, TimeSpan.Zero, ref tookLock); });
+ Assert(!tookLock);
+ ExpectException<ArgumentNullException>(delegate { Monitor.TryEnter(null, 0); });
+ ExpectException<ArgumentNullException>(delegate { Monitor.TryEnter(null, TimeSpan.Zero); });
+
+ Console.WriteLine("tookLock == true tests");
+ object obj = new object();
+ tookLock = true;
+ ExpectException<ArgumentException>(delegate { Monitor.Enter(obj, ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ tookLock = true;
+ ExpectException<ArgumentException>(delegate { Monitor.TryEnter(obj, ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ tookLock = true;
+ ExpectException<ArgumentException>(delegate { Monitor.TryEnter(obj, 0, ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ tookLock = true;
+ ExpectException<ArgumentException>(delegate { Monitor.TryEnter(obj, TimeSpan.Zero, ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+
+ Console.WriteLine("timeout < -1");
+ tookLock = false;
+ ExpectException<ArgumentOutOfRangeException>(delegate { Monitor.TryEnter(obj, -2, ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+ tookLock = false;
+ ExpectException<ArgumentOutOfRangeException>(delegate { Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(-2), ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+ ExpectException<ArgumentOutOfRangeException>(delegate { tookLock = Monitor.TryEnter(obj, -2); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+ ExpectException<ArgumentOutOfRangeException>(delegate { tookLock = Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(-2)); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+
+ Console.WriteLine("timeout > int.Max");
+ tookLock = false;
+ ExpectException<ArgumentOutOfRangeException>(delegate { Monitor.TryEnter(obj, TimeSpan.FromMilliseconds((double)int.MaxValue + 1), ref tookLock); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+ ExpectException<ArgumentOutOfRangeException>(delegate { tookLock = Monitor.TryEnter(obj, TimeSpan.FromMilliseconds((double)int.MaxValue + 1)); });
+ AssertTookLockAndRelease(LockIsHeld.No, obj, tookLock);
+ }
+
+
+ AutoResetEvent contentionStartEvent = new AutoResetEvent(false);
+ volatile bool contentionStarted;
+ volatile bool inContention;
+ AutoResetEvent contentionDoneEvent = new AutoResetEvent(false);
+
+ // for some reason I had to add these to get this to build in the test environment
+ delegate void Action();
+ delegate void Action<T>(T arg);
+ delegate void Action<T1,T2>(T1 arg1, T2 arg2);
+
+ /// <summary>
+ /// Runs a lock acquisition scenario (passed in via <paramref name="run"/>) with contention
+ /// on the lock.
+ /// </summary>
+ /// <param name="obj">The object to lock</param>
+ /// <param name="spins">How many times to spin while holding the lock</param>
+ /// <param name="run">A lock acquisition scenario to perform under contention (will be passed
+ /// <paramref name="obj"/> as the object to be locked)</param>
+ void RunWithContention(object obj, int spins, Action<object> run)
+ {
+ ThreadPool.QueueUserWorkItem(delegate
+ {
+ contentionStartEvent.WaitOne();
+ Monitor.Enter(obj);
+ inContention = true;
+ contentionStarted = true;
+ Thread.Sleep(0); // yield
+ inContention = false;
+ Monitor.Exit(obj);
+ contentionDoneEvent.Set();
+ });
+ contentionStarted = false;
+ inContention = false;
+ Thread.Sleep(1);
+ contentionStartEvent.Set();
+ int waitCount = 0;
+ while (!contentionStarted)
+ {
+ waitCount++;
+ if (waitCount > 30000)
+ {
+ //Thread.Yield is internal in CoreClr, so change it to Thread.Sleep(0)
+ // Thread.Yield();
+ Thread.Sleep(0);
+ waitCount = 0;
+ }
+ }
+ run(obj);
+ contentionDoneEvent.WaitOne();
+ }
+
+ /// <summary>
+ /// Runs all tests under varying levels of contention
+ /// </summary>
+ void ContentionVariants()
+ {
+ Console.WriteLine("--- no contention ---");
+ SyncBlkVariants(LockIsHeld.No, delegate(object o, Action<object> ac) { ac(o); });
+
+ Console.WriteLine("--- a little contention ---");
+ SyncBlkVariants(LockIsHeld.Maybe, delegate(object o, Action<object> ac) { RunWithContention(o, 10000, ac); });
+
+ Console.WriteLine("--- lots of contention ---");
+ SyncBlkVariants(LockIsHeld.Maybe, delegate(object o, Action<object> ac) { RunWithContention(o, 1000000, ac); });
+ }
+
+ /// <summary>
+ /// Runs all tests under each SyncBlk variation
+ /// </summary>
+ /// <param name="lockIsHeld">Whether to expect that the lock is being held (experiencing
+ /// contention) while each lock attempt is performed</param>
+ /// <param name="scenario">A lock contention scenario to run under each SyncBlk scenario. Is
+ /// passed an object that may or may not have a SyncBlk, and a lock acquisition scenario to run
+ /// under that level of contention</param>
+ void SyncBlkVariants(LockIsHeld lockIsHeld, Action<object, Action<object>> scenario)
+ {
+ Console.WriteLine("Positive tests, no SyncBlk");
+ MethodVariants(lockIsHeld, delegate(Action<object> innerScenario)
+ {
+ object obj = new object();
+ scenario(obj, delegate(object o) { innerScenario(o); });
+ });
+
+ Console.WriteLine("Positive tests, with HashCode");
+ MethodVariants(lockIsHeld, delegate(Action<object> innerScenario)
+ {
+ object obj = new object();
+ obj.GetHashCode();
+ scenario(obj, delegate(object o) { innerScenario(o); });
+ });
+
+ Console.WriteLine("Positive tests, with SyncBlk");
+ MethodVariants(lockIsHeld, delegate(Action<object> innerScenario)
+ {
+ object obj = new object();
+ obj.GetHashCode();
+ Monitor.Enter(obj);
+ Monitor.Exit(obj);
+ scenario(obj, delegate(object o) { innerScenario(o); });
+ });
+ }
+
+ enum LockIsHeld { Yes, No, Maybe }
+
+ LockIsHeld Reverse(LockIsHeld lockIsHeld)
+ {
+ switch (lockIsHeld)
+ {
+ case LockIsHeld.Yes:
+ return LockIsHeld.No;
+ case LockIsHeld.No:
+ return LockIsHeld.Yes;
+ default:
+ return lockIsHeld;
+ }
+ }
+
+ /// <summary>
+ /// Runs all lock acquisition scenarios inside of an outer contention/SyncBlk scenario
+ /// </summary>
+ /// <param name="lockIsHeld">whether to expect the lock to be held when we try to acquire it</param>
+ /// <param name="scenario">The contention/SyncBlk scenario to run each acquisition scenario inside of.</param>
+ void MethodVariants(LockIsHeld lockIsHeld, Action<Action<object>> scenario)
+ {
+ bool tookLock;
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.Enter(obj, ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj);
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj, 0);
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ DateTime start = DateTime.Now;
+ tookLock = Monitor.TryEnter(obj, 10000);
+ double elapsed = (DateTime.Now - start).TotalSeconds;
+ AssertTookLockAndRelease(elapsed < 5.0 ? LockIsHeld.Yes : LockIsHeld.Maybe, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj, Timeout.Infinite);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(0));
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(10000));
+ AssertTookLockAndRelease(LockIsHeld.Maybe, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(Timeout.Infinite));
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, ref tookLock);
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, 0, ref tookLock);
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, 10000, ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Maybe, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, Timeout.Infinite, ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(0), ref tookLock);
+ AssertTookLockAndRelease(Reverse(lockIsHeld), obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(10000), ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Maybe, obj, tookLock);
+ });
+
+ scenario(delegate(object obj)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, TimeSpan.FromMilliseconds(Timeout.Infinite), ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ });
+
+ if (lockIsHeld == LockIsHeld.No)
+ {
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ Monitor.Enter(obj);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ tookLock = false;
+ Monitor.Enter(obj, ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ tookLock = false;
+ Monitor.TryEnter(obj, ref tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, tookLock);
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ for (int i = 0; i < 70; i++)
+ {
+ Monitor.Enter(obj);
+ }
+ for (int i = 0; i < 70; i++)
+ {
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ }
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ for (int i = 0; i < 70; i++)
+ {
+ tookLock = false;
+ Monitor.Enter(obj, ref tookLock);
+ Assert(tookLock);
+ }
+ for (int i = 0; i < 70; i++)
+ {
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ }
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+
+ scenario(delegate(object obj)
+ {
+ Monitor.Enter(obj);
+ for (int i = 0; i < 70; i++)
+ {
+ tookLock = false;
+ Monitor.TryEnter(obj, ref tookLock);
+ Assert(tookLock);
+ }
+ for (int i = 0; i < 70; i++)
+ {
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ }
+ AssertTookLockAndRelease(LockIsHeld.Yes, obj, true);
+ AssertTookLockAndRelease(LockIsHeld.No, obj, false);
+ });
+ }
+ }
+
+ void AssertTookLockAndRelease(LockIsHeld expected, object obj, bool tookLock)
+ {
+ Assert((expected == LockIsHeld.Yes && tookLock) ||
+ (expected == LockIsHeld.No && !tookLock) ||
+ expected == LockIsHeld.Maybe);
+
+ if (tookLock) Assert(!inContention);
+
+ bool exitFailed = false;
+ try
+ {
+ Monitor.Exit(obj);
+ }
+ catch (SynchronizationLockException)
+ {
+ exitFailed = true;
+ }
+
+ Assert(tookLock == !exitFailed);
+ }
+
+ void ExpectException<T>(Action action) where T : Exception
+ {
+ try
+ {
+ action();
+ }
+ catch (Exception e)
+ {
+ if (!(e is T))
+ {
+ FailNoStack("Unexpected exception:\n{0}", e.ToString());
+ }
+ return;
+ }
+ Fail("Expected {0}, but got no exception!", typeof(T).Name);
+ }
+
+ void Assert(bool condition, string message)
+ {
+ if (!condition)
+ Fail(message);
+ }
+
+ void Assert(bool condition)
+ {
+ Assert(condition, "Assertion failed");
+ }
+
+ void Fail(string message, bool printStack)
+ {
+ m_failed++;
+ Console.WriteLine(message);
+ }
+
+ void Fail(string format, params object[] args)
+ {
+ Fail(string.Format(format, args), true);
+ }
+
+ void Fail(string format)
+ {
+ Fail(format, true);
+ }
+
+ void FailNoStack(string format, params object[] args)
+ {
+ Fail(string.Format(format, args), false);
+ }
+
+
+ void ThreadIdPosTests()
+ {
+ Console.WriteLine("*** High thread ID tests ***");
+
+ // Create a thread with an ID > 1023 (the largest tid that can be stored in an
+ // object header)
+
+ List<Thread> threads = new List<Thread>(1024);
+ for (int i = 0; i < 1024; i++)
+ {
+ threads.Add(new Thread(delegate() { Assert(false, "this thread should never run"); }));
+ }
+ Thread highThread = new Thread(delegate()
+ {
+ Assert(Thread.CurrentThread.ManagedThreadId > 1024);
+ ContentionVariants();
+ });
+ highThread.Start();
+ highThread.Join();
+ }
+
+ int Run()
+ {
+ NegTests();
+ ContentionVariants();
+ ThreadIdPosTests();
+ return m_failed;
+ }
+
+ static int Main()
+ {
+ MonEnterTests tests = new MonEnterTests();
+ int failed = tests.Run();
+ if (0 != failed)
+ {
+ Console.WriteLine("Failed!");
+ }
+ else
+ {
+ Console.WriteLine("Success!");
+ }
+ return 100 + failed;
+ }
+}
+
diff --git a/tests/src/baseservices/threading/monitor/enter/monitorenter.csproj b/tests/src/baseservices/threading/monitor/enter/monitorenter.csproj
new file mode 100644
index 0000000000..60cd41b636
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/enter/monitorenter.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="MonitorEnter.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/monitor/enter/project.json b/tests/src/baseservices/threading/monitor/enter/project.json
index a2e84dc340..f364fe9bb1 100644
--- a/tests/src/baseservices/threading/monitor/enter/project.json
+++ b/tests/src/baseservices/threading/monitor/enter/project.json
@@ -24,6 +24,7 @@
"System.Text.Encoding": "4.0.10",
"System.Threading": "4.0.10",
"System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
"System.Xml.ReaderWriter": "4.0.11-rc2-23816",
"System.Xml.XDocument": "4.0.11-rc2-23816",
"System.Xml.XmlDocument": "4.0.1-rc2-23816",
diff --git a/tests/src/baseservices/threading/monitor/isentered/app.config b/tests/src/baseservices/threading/monitor/isentered/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/isentered/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/monitor/isentered/monitorisentered.cs b/tests/src/baseservices/threading/monitor/isentered/monitorisentered.cs
new file mode 100644
index 0000000000..153359ea74
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/isentered/monitorisentered.cs
@@ -0,0 +1,128 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#define DEBUG //make sure the Contract calls actually do something
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Diagnostics.Contracts;
+
+
+public static class MonitorIsHeldTest
+{
+ static int s_result = 100;
+
+ static int Main()
+ {
+ try
+ {
+ RunNullTest();
+ RunTest(new object(), "object without SyncBlk");
+ RunTest(CreateObjectWithSyncBlk(), "object with SyncBlk");
+
+ Console.WriteLine(s_result == 100 ? "Success!" : "FAILED!");
+ return s_result;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unhandled exception!");
+ Console.WriteLine(e);
+ return 999;
+ }
+ }
+
+ static object CreateObjectWithSyncBlk()
+ {
+ // force an object to have a SyncBlk, to exercise the IsEntered code that
+ // deals with these
+ object o = new object();
+ o.GetHashCode();
+ return o;
+ }
+
+ static void RunNullTest()
+ {
+ try
+ {
+ Monitor.IsEntered(null);
+ }
+ catch (ArgumentNullException)
+ {
+ // expected
+ return;
+ }
+
+ // no exception
+ Console.WriteLine("Monitor.IsEntered(null) did not throw ArgumentNullException");
+ s_result = 101;
+ }
+
+ static void RunTest(object obj, string caseName)
+ {
+ // lock not held by anyone
+ if (Monitor.IsEntered(obj))
+ {
+ Console.WriteLine("{0}: lock should be initially unheld, but IsEntered == true", caseName);
+ s_result = 102;
+ }
+
+ // lock held by this thread
+ lock (obj)
+ {
+ if (!Monitor.IsEntered(obj))
+ {
+ Console.WriteLine("{0}: lock should be held by this thread, but IsEntered == false", caseName);
+ s_result = 103;
+ }
+
+ // do it the way the user would
+ Contract.Assert(Monitor.IsEntered(obj));
+ }
+
+ // now it's released
+ if (Monitor.IsEntered(obj))
+ {
+ Console.WriteLine("{0}: lock should have been released, but IsEntered == true", caseName);
+ s_result = 104;
+ }
+
+ // do it the way the user would
+ Contract.Assert(!Monitor.IsEntered(obj));
+
+ // Make another thread hold the lock
+ ManualResetEventSlim lockHeldEvent = new ManualResetEventSlim();
+ ManualResetEventSlim releaseLockEvent = new ManualResetEventSlim();
+
+ Task otherThread = Task.Factory.StartNew(() =>
+ {
+ lock (obj)
+ {
+ Contract.Assert(Monitor.IsEntered(obj));
+ lockHeldEvent.Set();
+ releaseLockEvent.Wait();
+ }
+ });
+
+ lockHeldEvent.Wait();
+
+ // lock is held by other thread, so we should get "false"
+ if (Monitor.IsEntered(obj))
+ {
+ Console.WriteLine("{0}: lock should be held by other thread, but IsEntered == true", caseName);
+ s_result = 105;
+ }
+
+ releaseLockEvent.Set();
+ otherThread.Wait();
+
+ // lock is held by neither thread, so we should still get "false"
+ if (Monitor.IsEntered(obj))
+ {
+ Console.WriteLine("{0}: lock should not be held by any thread, but IsEntered == true", caseName);
+ s_result = 106;
+ }
+
+ }
+}
diff --git a/tests/src/baseservices/threading/monitor/isentered/monitorisentered.csproj b/tests/src/baseservices/threading/monitor/isentered/monitorisentered.csproj
new file mode 100644
index 0000000000..c12b1613ae
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/isentered/monitorisentered.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="MonitorIsEntered.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/monitor/isentered/project.json b/tests/src/baseservices/threading/monitor/isentered/project.json
new file mode 100644
index 0000000000..d7eaf466b8
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/isentered/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Contracts": "4.0.0",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/monitor/tryenter/app.config b/tests/src/baseservices/threading/monitor/tryenter/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/tryenter/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/monitor/tryenter/longtimeout.cs b/tests/src/baseservices/threading/monitor/tryenter/longtimeout.cs
new file mode 100644
index 0000000000..6e23ba5c3c
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/tryenter/longtimeout.cs
@@ -0,0 +1,92 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.Threading;
+
+//Repro for VSWhidbey 565042
+
+public class Repro
+{
+ public static object _monitor = new Object();
+ private ManualResetEvent _event;
+ private ManualResetEvent _event2;
+ public static int _status = 1;
+
+ public static int Main(string[] arguments)
+ {
+ return (new Repro().RunTest());
+ }
+
+ public int RunTest()
+ {
+ _event = new ManualResetEvent(false);
+ _event2 = new ManualResetEvent(false);
+
+ Thread thread1 = new Thread(this.Thread1);
+ thread1.Start();
+
+ Thread thread2 = new Thread(this.Thread2);
+ thread2.Start();
+
+ thread2.Join();
+ _event2.Set();
+
+ if (_status == 100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return _status;
+ }
+
+ private void Thread1()
+ {
+ Monitor.Enter(_monitor);
+ _event.Set();
+
+ _event2.WaitOne();
+ Monitor.Exit(_monitor);
+ }
+
+ private void Thread2()
+ {
+ Stopwatch timer = new Stopwatch();
+ _event.WaitOne();
+
+ timer.Start();
+ for (int i=10;i<=30;i=i+10)
+ {
+ bool tookLock = false;
+ Monitor.TryEnter(_monitor, TimeSpan.FromSeconds(i), ref tookLock);
+
+ if(tookLock)
+ {
+ _status = 98;
+ Console.WriteLine("TryEnter got monitor that it should not have been able to....");
+ Monitor.Exit(_monitor);
+ break;
+ }
+ else
+ {
+ timer.Stop();
+ if ((timer.Elapsed + TimeSpan.FromSeconds(1)) < TimeSpan.FromSeconds(i))
+ {
+ Console.WriteLine("TryEnter returned early in {0}, but expected {1}", timer.Elapsed, TimeSpan.FromSeconds(i));
+ _status = 99;
+ break;
+ }
+ else
+ {
+ Console.WriteLine("TryEnter returned as expected in {0}, with expected {1}", timer.Elapsed, TimeSpan.FromSeconds(i));
+ }
+ timer = Stopwatch.StartNew();
+ }
+ }
+
+ if (_status == 1)
+ _status=100;
+ }
+}
diff --git a/tests/src/baseservices/threading/monitor/tryenter/longtimeout.csproj b/tests/src/baseservices/threading/monitor/tryenter/longtimeout.csproj
new file mode 100644
index 0000000000..87b52aa106
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/tryenter/longtimeout.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="LongTimeOut.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/monitor/tryenter/project.json b/tests/src/baseservices/threading/monitor/tryenter/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/tryenter/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/monitor/wait/app.config b/tests/src/baseservices/threading/monitor/wait/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/wait/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/monitor/wait/project.json b/tests/src/baseservices/threading/monitor/wait/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/wait/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/monitor/wait/waitnull.cs b/tests/src/baseservices/threading/monitor/wait/waitnull.cs
new file mode 100644
index 0000000000..e2748257d0
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/wait/waitnull.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Test
+{
+
+ public static int Main()
+ {
+ try
+ {
+ Monitor.Wait(null, 0);
+ Console.WriteLine("Failed to throw exception on Monitor.Wait");
+ return 1;
+ }
+ catch(ArgumentNullException)
+ {
+ //Expected
+ }
+ return 100;
+ }
+}
+
diff --git a/tests/src/baseservices/threading/monitor/wait/waitnull.csproj b/tests/src/baseservices/threading/monitor/wait/waitnull.csproj
new file mode 100644
index 0000000000..34f215a3d1
--- /dev/null
+++ b/tests/src/baseservices/threading/monitor/wait/waitnull.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitNull.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/multiinstance/app.config b/tests/src/baseservices/threading/multiinstance/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/multiinstance/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/multiinstance/multiinstance.cs b/tests/src/baseservices/threading/multiinstance/multiinstance.cs
new file mode 100644
index 0000000000..0238fd821d
--- /dev/null
+++ b/tests/src/baseservices/threading/multiinstance/multiinstance.cs
@@ -0,0 +1,322 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Security;
+using System.Threading;
+using System.Collections.Generic;
+using TestLibrary;
+
+#if WINCORESYS
+[assembly: AllowPartiallyTrustedCallers]
+#endif
+
+[SecuritySafeCritical]
+public class MultiThreading
+{
+ #region ParamsDefintion
+ private struct CommandLineParams
+ {
+ public string assemblyName;
+ public string[] args;
+ public int workers;
+ }
+ #endregion Params
+
+ #region Data
+ static private CommandLineParams cmdParams;
+ static private MethodInfo methToExec;
+ static private List<int> retVals;
+ static private object myLock;
+ static private ManualResetEvent[] events;
+ #endregion Data
+
+
+ #region Utilities
+ private static void Usage()
+ {
+ Console.WriteLine("Usage: MultipleInstance.exe /workers:#### /exe:#####");
+ Console.WriteLine("/workers: run test in n threads.");
+ }
+
+ private static bool ParseArguments(string[] args, ref CommandLineParams cmdParams)
+ {
+ bool ret = true;
+ cmdParams.workers = 0;
+ try
+ {
+ int index = 0;
+ for (int i = 0; i < args.Length; i++)
+ {
+ string name = "";
+ string value = "";
+
+ if (args[i].Contains(":"))
+ {
+ name = args[i].Substring(0, args[i].IndexOf(":")).ToLower();
+ value = args[i].Substring(args[i].IndexOf(":") + 1);
+ }
+
+ if (name.StartsWith("/workers"))
+ {
+ cmdParams.workers = Convert.ToInt32(value);
+ }
+ else if (name.StartsWith("/exe"))
+ {
+ cmdParams.assemblyName = value;
+ index = i;
+ break;
+ }
+ else
+ {
+ Console.WriteLine("Invalid paramter: {0}", args[i]);
+ ret = false;
+ }
+ }
+ if (index == args.Length - 1)
+ {
+ cmdParams.args = new string[0];
+ }
+ else
+ {
+ cmdParams.args = new string[args.Length - index - 1];
+ for (int i = index + 1; i < args.Length; i++)
+ {
+ cmdParams.args[i - index - 1] = args[i];
+ }
+ }
+
+
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ ret = false;
+ }
+ return ret;
+ }
+
+ public static Byte[] ReadFileContents(String path)
+ {
+ byte[] bytes;
+ using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ // Do a blocking read
+ int index = 0;
+ long fileLength = fs.Length;
+ if (fileLength > Int32.MaxValue)
+ throw new IOException("File size greater then 2Gb");
+ int count = (int)fs.Length;
+ bytes = new byte[count];
+ while (count > 0)
+ {
+ int n = fs.Read(bytes, index, count);
+ if (n == 0)
+ throw new EndOfStreamException();
+ index += n;
+ count -= n;
+ }
+ }
+ return bytes;
+ }
+
+ private static MethodInfo GetEntryPoint(string assemblyName)
+ {
+ Assembly asm = null;
+ string asmName = "";
+
+
+ asmName = assemblyName;
+
+ try
+ {
+ asmName = assemblyName;
+ if (asmName.LastIndexOf(".") > -1)
+ {
+ asmName = asmName.Substring(0, asmName.LastIndexOf("."));
+ }
+ if (asmName.LastIndexOf(@"\") > -1)
+ {
+ asmName = asmName.Substring(asmName.LastIndexOf(@"\") + 1);
+ }
+ if (asmName.LastIndexOf(@"/") > -1)
+ {
+ asmName = asmName.Substring(asmName.LastIndexOf(@"/") + 1);
+ }
+
+ asm = Assembly.Load( new AssemblyName(asmName) );
+ }
+ catch (FileLoadException)
+ {
+ asm = null;
+ }
+ catch (FileNotFoundException)
+ {
+ asm = null;
+ }
+
+ if (null == asm)
+ {
+ MethodInfo assemload = null;
+ foreach(MethodInfo m in typeof(Assembly).GetMethods(BindingFlags.NonPublic | BindingFlags.Static))
+ {
+ ParameterInfo[] mps = m.GetParameters();
+ if (m.Name.Equals("Load") && mps.Length == 1 && mps[0].GetType() == typeof(byte[])) assemload = m;
+ }
+ if (assemload == null) {
+ throw new Exception("Failed to get Assembly.Load(int8[]) method");
+ }
+
+ asm = (Assembly)assemload.Invoke(null, new object[1] { ReadFileContents( assemblyName ) });
+ }
+
+ methToExec = asm.EntryPoint;
+
+ return methToExec;
+ }
+
+ private static void Worker()
+ {
+ if (cmdParams.workers > 1)
+ WaitHandle.WaitAny(events);
+
+ RunMain();
+ }
+
+ private static Thread NewThread()
+ {
+ Thread t = null;
+ t = new Thread(new ThreadStart(Worker));
+ return t;
+ }
+ #endregion Utilities
+
+ #region Main
+ public static int Main(string[] args)
+ {
+ if (0 == args.Length)
+ {
+ Usage();
+ return 0;
+ }
+
+ cmdParams = new CommandLineParams();
+ if (!ParseArguments(args, ref cmdParams))
+ {
+ Usage();
+ return 0;
+ }
+
+ retVals = new List<int>();
+ myLock = new object();
+
+ Run(); //run test...
+
+ int retVal = retVals[0];
+ for (int i = 0; i < retVals.Count - 1; i++)
+ {
+ if (retVals[i] != retVals[i + 1])
+ {
+ Logging.WriteLine("Failed");
+ retVal = 0xff;
+ break;
+ }
+ }
+ return retVal;
+ }
+
+ private static void Run()
+ {
+ methToExec = GetEntryPoint(cmdParams.assemblyName);
+ int threadNum = cmdParams.workers;
+ if (threadNum == 0)
+ {
+ Logging.WriteLine("Run test in the main thread");
+ RunMain();
+ }
+ else if (threadNum == 1)
+ {
+ Logging.WriteLine("Run test in a worker thread");
+ Thread t = NewThread();
+ t.Start();
+ t.Join();
+ }
+ else if (threadNum > 1)
+ {
+ Logging.WriteLine("Run test in the main thread and spawn {0} threads to run test", threadNum - 1);
+
+ events = new ManualResetEvent[1];
+ events[0] = new ManualResetEvent(false);
+
+ Thread[] threads = new Thread[threadNum - 1];
+ for (int i = 0; i < threads.Length; i++)
+ {
+ threads[i] = NewThread();
+ threads[i].Start();
+ }
+ events[0].Set();
+ RunMain();
+ foreach (Thread t in threads)
+ {
+ t.Join();
+ }
+ }
+ }
+
+
+
+
+ private static void RunMain()
+ {
+ int numMainParams = methToExec.GetParameters().Length;
+ if (numMainParams > 1)
+ {
+ throw new Exception("Main method must contain 0 or 1 arguments.");
+ }
+
+ DateTime time1 = DateTime.Now;
+ Object oExitCode = null;
+ while (true)
+ {
+ oExitCode = methToExec.Invoke(null, numMainParams == 1 ? new Object[] { cmdParams.args } : null);
+ DateTime time2 = DateTime.Now;
+ TimeSpan span = time2 - time1;
+ if (span.TotalMilliseconds > 1500)
+ break;
+ Thread.Sleep(0);
+ }
+
+
+ int iRetCode;
+ if (methToExec.ReturnParameter.ParameterType == typeof(void))
+ {
+ //iRetCode = Environment.ExitCode;
+ Console.WriteLine("WARNING: Unable to get the exit code from a void Main method");
+ iRetCode = 100;
+ }
+ else if (methToExec.ReturnParameter.ParameterType == typeof(int))
+ {
+ iRetCode = (int)oExitCode;
+ }
+ else if (methToExec.ReturnParameter.ParameterType == typeof(uint))
+ {
+ iRetCode = (int)(uint)oExitCode;
+ }
+ else
+ {
+ throw new Exception("Main method must return void, int or uint not " + methToExec.ReturnParameter.ParameterType.ToString());
+ }
+
+ lock (myLock)
+ {
+ retVals.Add(iRetCode);
+ }
+ }
+ #endregion
+}
+
+
diff --git a/tests/src/baseservices/threading/multiinstance/multiinstance.csproj b/tests/src/baseservices/threading/multiinstance/multiinstance.csproj
new file mode 100644
index 0000000000..ed6abfb039
--- /dev/null
+++ b/tests/src/baseservices/threading/multiinstance/multiinstance.csproj
@@ -0,0 +1,49 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ </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="MultiInstance.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/multiinstance/project.json b/tests/src/baseservices/threading/multiinstance/project.json
new file mode 100644
index 0000000000..f084fdaed9
--- /dev/null
+++ b/tests/src/baseservices/threading/multiinstance/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.1.0-rc2-23816",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.cs
new file mode 100644
index 0000000000..c3f68a22ce
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.cs
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private Mutex myMutex01 = new Mutex(false);
+ private Mutex myMutex02 = new Mutex(false);
+ private Mutex myMutex03 = new Mutex(false);
+ private ManualResetEvent myMRE = new ManualResetEvent(false);
+ private int iRet = -1;
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ wae.Run();
+ Console.WriteLine(wae.iRet == 100 ? "Test Passed!" : "Test Failed");
+ return wae.iRet;
+ }
+
+ private void Run()
+ {
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(
+ new WaitHandle[]{myMutex01, myMutex02, myMutex03}, 5000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(-1 == am.MutexIndex && null == am.Mutex)
+ iRet = 100;
+ }
+ }
+
+ private void AbandonTheMutex()
+ {
+ myMutex03.WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj
new file mode 100644
index 0000000000..a4072fdbc0
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="AM01WaitAllNeg.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am02waitoneneg.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.cs
new file mode 100644
index 0000000000..4dc5171717
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+ private int iRet = -1;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex(false);
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ wao.Run();
+ Console.WriteLine(100 == wao.iRet ? "Test Passed" : "Test Failed");
+ return wao.iRet;
+ }
+
+ private void Run()
+ {
+ Console.WriteLine("Test abandoned mutex is thrown using WaitOne");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne(10000);
+ Console.WriteLine("WaitOne did not throw an exception!");
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(-1 == am.MutexIndex && null == am.Mutex)
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj
new file mode 100644
index 0000000000..0fb0266fb2
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="AM02WaitOneNeg.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am04waitany.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.cs
new file mode 100644
index 0000000000..377d27d68a
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.cs
@@ -0,0 +1,113 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private int iRet = -1;
+ private ManualResetEvent mre = new ManualResetEvent(false);
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: AM04WaitAny /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ wae.Run(iSize, iPos);
+
+ Console.WriteLine(100 == wae.iRet ? "Test Passed" : "Test Failed");
+ return wae.iRet;
+ }
+
+ private void Run(int iArraySize, int iPosToAbandon)
+ {
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize, iPosToAbandon);
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ mre.WaitOne();
+ int i = -1;
+
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, -1);
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(iPosToAbandon == am.MutexIndex && wh[am.MutexIndex] == am.Mutex)
+ iRet = 50;
+
+ // We should now be in a state where this thread owns the mutex
+ am.Mutex.WaitOne();
+ am.Mutex.ReleaseMutex();
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ t.Join();
+
+ // Release a 2nd time
+ try
+ {
+ Console.WriteLine("Release again");
+ ((Mutex)wh[iPosToAbandon]).ReleaseMutex();
+ iRet += 50;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ mre.Set();
+ }
+
+ private void CreateMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i != iPos)
+ wh[i] = new AutoResetEvent(false);
+ else
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj
new file mode 100644
index 0000000000..1cd6bf8453
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:10 /pos:0</CLRTestExecutionArguments>
+ </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="AM04WaitAny.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am05waitanymutex.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.cs
new file mode 100644
index 0000000000..0f093d8b41
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.cs
@@ -0,0 +1,112 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private int iRet = -1;
+ private ManualResetEvent mre = new ManualResetEvent(false);
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: AM05WaitAny /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ wae.Run(iSize, iPos);
+
+ Console.WriteLine(100 == wae.iRet ? "Test Passed" : "Test Failed");
+ return wae.iRet;
+ }
+
+ private void Run(int iArraySize, int iPosToAbandon)
+ {
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize);
+
+ Thread t2 = new Thread(new ParameterizedThreadStart(this.AbandonElse));
+ t2.Start(iPosToAbandon);
+
+ // Let the thread work
+ Thread.Sleep(1000);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ mre.WaitOne();
+ int i = -1;
+
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, -1);
+ Console.WriteLine("No exception thrown - " + i);
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(iPosToAbandon == am.MutexIndex && wh[am.MutexIndex] == am.Mutex)
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ }
+
+ private void AbandonElse(Object o)
+ {
+ // Do a wait on all of them so it blocks WaitAny()
+ for(int i=0;i<wh.Length;i++)
+ {
+ if(i != Convert.ToInt32(o))
+ wh[i].WaitOne();
+ }
+ mre.WaitOne();
+ Thread.Sleep(5000);
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ mre.Set();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj
new file mode 100644
index 0000000000..1f4899bc78
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:63</CLRTestExecutionArguments>
+ </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="AM05WaitAnyMutex.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am06abandonall.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.cs
new file mode 100644
index 0000000000..650dcb0dd6
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.cs
@@ -0,0 +1,70 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon all mutexes in array");
+ CreateMutexArray(64);
+ myMRE = new ManualResetEvent(false);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 10000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(am.MutexIndex == 0 && am.Mutex == wh[am.MutexIndex])
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj
new file mode 100644
index 0000000000..f084b568fc
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="AM06AbandonAll.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am07abandonmultiplemutex.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.cs
new file mode 100644
index 0000000000..f4e6d4a40b
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.cs
@@ -0,0 +1,96 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private int iRet = -1;
+ private ManualResetEvent mre = new ManualResetEvent(false);
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ wae.Run();
+
+ Console.WriteLine(100 == wae.iRet ? "Test Passed" : "Test Failed");
+ return wae.iRet;
+ }
+
+ private void Run()
+ {
+ CreateMutexArray(64);
+ int[] aPos = new int[5]{6,8,10,12,14};
+ Thread t2 = new Thread(new ParameterizedThreadStart(this.AbandonElse));
+ t2.Start(aPos[0]);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(aPos);
+ mre.WaitOne();
+ int i = -1;
+ Thread.Sleep(400);
+
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, -1);
+ Console.WriteLine("No exception thrown - {0}", i);
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(aPos[0] == am.MutexIndex && wh[am.MutexIndex] == am.Mutex)
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ t.Join();
+ }
+
+ private void AbandonElse(Object o)
+ {
+ int iPos = (int)o;
+
+ // Do a wait on all Mutexes up to the 1st one
+ for(int i=0;i<iPos;i++)
+ {
+ wh[i].WaitOne();
+ Console.WriteLine("Blocking {0}", i);
+ }
+
+ mre.WaitOne();
+ Thread.Sleep(5000);
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ // This thread needs to complete before the wait
+ // otherwise the Wait will return immediately
+
+ int[] iPos = (int[])o;
+ for(int i=0;i<iPos.Length;i++)
+ {
+ wh[iPos[i]].WaitOne();
+ Console.WriteLine(iPos[i]);
+ }
+ mre.Set();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj
new file mode 100644
index 0000000000..7dee338ca5
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="AM07AbandonMultipleMutex.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/am08mixedarray.cs b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.cs
new file mode 100644
index 0000000000..b61f42c665
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.cs
@@ -0,0 +1,119 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent mre = new ManualResetEvent(false);
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex in array with other WaitHandles, signaling other mutexes");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.WaitOnAllExceptPos));
+ t.Start();
+
+ Thread t2 = new Thread(new ThreadStart(this.AbandonLastMutex));
+ t2.Start();
+
+ mre.WaitOne();
+ mre.Reset();
+ t2.Join(); // make sure the thread has exited before checking for the abandoned mutex
+
+ int i = -1;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, 5000);
+ Console.WriteLine("WaitAny did not throw AbandonedMutexExcpetion");
+ Console.WriteLine("Object at position {0} ({1}) returned", i, wh[i].GetType());
+ }
+ catch(AbandonedMutexException am)
+ {
+ Console.WriteLine("AbandonedMutexException thrown! Checking values...");
+ if(61 == am.MutexIndex)
+ {
+ if (am.Mutex == wh[am.MutexIndex])
+ iRet = 100;
+ else
+ Console.WriteLine("Expected AbandonedMutexException to == Indexed Mutex, but it does not.");
+ }
+ else
+ Console.WriteLine("Expected return of 61, but found " + am.MutexIndex);
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void WaitOnAllExceptPos()
+ {
+ Mutex m = new Mutex();
+ bool bSet = false;
+ for(int i=wh.Length-1;i>=0;i--)
+ {
+ if(wh[i].GetType() == m.GetType())
+ {
+ if(bSet)
+ {
+ wh[i].WaitOne();
+ Console.Write(i + ".");
+ }
+ bSet = true;
+ }
+ }
+ mre.Set();
+ //This Sleep keeps Thread alive to hold Mutexes
+ Thread.Sleep(15000);
+ }
+
+ private void AbandonLastMutex()
+ {
+ Mutex m = new Mutex();
+ for(int i=wh.Length-1;i>=0;i--)
+ {
+ if(wh[i].GetType() == m.GetType())
+ {
+ wh[i].WaitOne();
+ Console.WriteLine(i + "AbandonLastMutex.");
+ break;
+ }
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj
new file mode 100644
index 0000000000..a88c6564f7
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="AM08MixedArray.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/abandonedmutex/app.config b/tests/src/baseservices/threading/mutex/abandonedmutex/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/project.json b/tests/src/baseservices/threading/mutex/abandonedmutex/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/abandonedmutex/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/misc/app.config b/tests/src/baseservices/threading/mutex/misc/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/mutex/misc/mutexctor1.cs b/tests/src/baseservices/threading/mutex/misc/mutexctor1.cs
new file mode 100644
index 0000000000..e82bb26c37
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/mutexctor1.cs
@@ -0,0 +1,173 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading; // For Thread, Mutex
+
+/// <summary>
+/// Ctor(Boolean)
+/// </summary>
+///
+// Tests that you can create a mutex, that if the mutex is
+// owned that other threads cannot change shared state governed
+// by that mutex, and that if it is unowned we can pick it up
+// without blocking.
+public class MutexCtor1
+{
+ #region Public Fields
+ public const int c_DEFAULT_INT_VALUE = 0;
+
+ public volatile static int m_SharedResource = c_DEFAULT_INT_VALUE;
+ #endregion
+
+ #region Private Fields
+ private const int c_DEFAULT_SLEEP_TIME = 1000; // 1 second
+
+ private Mutex m_Mutex = null;
+ #endregion
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ // Add your scenario description here
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Construct a new Mutex instance with initiallyOwned set to true (ensure that the thread owns the mutex)");
+
+ using(m_Mutex = new Mutex(true))
+ {
+ try
+ {
+ do
+ {
+ if (null == m_Mutex)
+ {
+ TestLibrary.TestFramework.LogError("001", "Can not construct a new Mutex intance with initiallyOwned set to true.");
+ retVal = false;
+
+ break;
+ }
+
+ // Ensure initial owner of the mutex is current thread
+
+ // Create another thread to change value of m_SharedResource
+ thread = new Thread(new ThreadStart(ThreadProc));
+ thread.Start();
+
+ // Sleep 1 second to wait the thread get started
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+
+ if (m_SharedResource != c_DEFAULT_INT_VALUE)
+ {
+ TestLibrary.TestFramework.LogError("002", "Call Mutex(true) does not set current thread to be the owner of the mutex.");
+ retVal = false;
+ }
+ m_Mutex.ReleaseMutex();
+ } while (false); // do
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ // Wait until all threads are terminated
+ thread.Join();
+ }
+
+ // Reset the value of m_SharedResource for further usage
+ m_SharedResource = c_DEFAULT_INT_VALUE;
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest2()
+ {
+ bool retVal = true;
+
+ // Add your scenario description here
+ TestLibrary.TestFramework.BeginScenario("PosTest2: Construct a new Mutex instance with initiallyOwned set to false. Ensure that the thread does not own the mutex");
+
+ using (m_Mutex = new Mutex(false))
+ {
+ try
+ {
+ if (null == m_Mutex)
+ {
+ TestLibrary.TestFramework.LogError("004", "Can not construct a new Mutex intance with initiallyOwned set to false.");
+ retVal = false;
+ }
+ else
+ {
+ // this would block this thread if we owned the mutex
+ m_Mutex.WaitOne();
+ m_Mutex.ReleaseMutex();
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Reset the value of m_SharedResource for further usage
+ m_SharedResource = c_DEFAULT_INT_VALUE;
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ MutexCtor1 test = new MutexCtor1();
+
+ TestLibrary.TestFramework.BeginTestCase("MutexCtor1");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ #region Private Methods
+ private void ThreadProc()
+ {
+ m_Mutex.WaitOne();
+ m_SharedResource++;
+ m_Mutex.ReleaseMutex();
+ }
+ #endregion
+}
diff --git a/tests/src/baseservices/threading/mutex/misc/mutexctor1.csproj b/tests/src/baseservices/threading/mutex/misc/mutexctor1.csproj
new file mode 100644
index 0000000000..c616eb3ae3
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/mutexctor1.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="MutexCtor1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/mutex/misc/mutexctor2.cs b/tests/src/baseservices/threading/mutex/misc/mutexctor2.cs
new file mode 100644
index 0000000000..0dff03ec8c
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/mutexctor2.cs
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading; // For Thread, Mutex
+
+/// <summary>
+/// Ctor()
+/// </summary>
+///
+// tests the default mutex constructor creates
+// a mutex which is not owned.
+public class MutexCtor2
+{
+ #region Public Fields
+ public const int c_DEFAULT_INT_VALUE = 0;
+
+ public static int m_SharedResource = c_DEFAULT_INT_VALUE;
+ #endregion
+
+ #region Private Fields
+ private Mutex m_Mutex = null;
+ #endregion
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+
+ // Add your scenario description here
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Construct a new Mutex instance");
+
+ // create the mutex in unowned state
+ using (m_Mutex = new Mutex())
+ {
+ try
+ {
+ do
+ {
+ if (null == m_Mutex)
+ {
+ TestLibrary.TestFramework.LogError("001", "Can not construct a new Mutex intance");
+ retVal = false;
+
+ break;
+ }
+
+ // Ensure initial owner of the mutex is not the current thread
+ // This call should NOT block
+ m_Mutex.WaitOne();
+ m_Mutex.ReleaseMutex();
+
+ } while (false); // do
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Reset the value of m_SharedResource for further usage
+ m_SharedResource = c_DEFAULT_INT_VALUE;
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ MutexCtor2 test = new MutexCtor2();
+
+ TestLibrary.TestFramework.BeginTestCase("MutexCtor2");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/mutex/misc/mutexctor2.csproj b/tests/src/baseservices/threading/mutex/misc/mutexctor2.csproj
new file mode 100644
index 0000000000..9399b967d2
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/mutexctor2.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="MutexCtor2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/mutex/misc/project.json b/tests/src/baseservices/threading/mutex/misc/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/misc/waitone1.cs b/tests/src/baseservices/threading/mutex/misc/waitone1.cs
new file mode 100644
index 0000000000..40f144b66b
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/waitone1.cs
@@ -0,0 +1,217 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading; // For Thread, Mutex
+
+/// <summary>
+/// WaitOne()
+/// </summary>
+///
+// Tests that Mutex.WaitOne will block when another
+// thread holds the mutex, and then will grab the mutex
+// when it is released. Also that appropriate exceptions
+// are thrown if the other thread abandons or disposes of
+// the mutex
+public class MutexWaitOne1
+{
+ #region Private Fields
+ private const int c_DEFAULT_SLEEP_TIME = 1000; // 1 second
+
+ private Mutex m_Mutex = null;
+ #endregion
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ TestLibrary.TestFramework.LogInformation("[Negative]");
+ retVal = NegTest1() && retVal;
+ retVal = NegTest2() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: WaitOne returns true when current instance receives a signal");
+
+ try
+ {
+ do
+ {
+ m_Mutex = new Mutex();
+ thread = new Thread(new ThreadStart(SignalMutex));
+ thread.Start();
+
+ if (m_Mutex.WaitOne() != true)
+ {
+ TestLibrary.TestFramework.LogError("001", "WaitOne returns false when current instance receives a signal.");
+ retVal = false;
+
+ break;
+ }
+
+ m_Mutex.ReleaseMutex();
+ } while (false); // do
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ m_Mutex.Dispose();
+ }
+
+ return retVal;
+ }
+ #endregion
+
+ #region Negative Test Cases
+ public bool NegTest1()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest1: AbandonedMutexException should be thrown if a thread exited without releasing a mutex");
+
+ using (m_Mutex = new Mutex(false))
+ {
+ try
+ {
+ thread = new Thread(new ThreadStart(NeverReleaseMutex));
+ thread.Start();
+
+ Thread.Sleep(100);
+ m_Mutex.WaitOne();
+
+ TestLibrary.TestFramework.LogError("101", "AbandonedMutexException is not thrown if a thread exited without releasing a mutex");
+ retVal = false;
+ }
+ catch (AbandonedMutexException)
+ {
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ thread.Join();
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool NegTest2()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest2: ObjectDisposedException should be thrown if current instance has already been disposed");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(DisposeMutex));
+ thread.Start();
+
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ m_Mutex.WaitOne();
+
+ TestLibrary.TestFramework.LogError("103", "ObjectDisposedException is not thrown if current instance has already been disposed");
+ retVal = false;
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ ((IDisposable)m_Mutex).Dispose();
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ MutexWaitOne1 test = new MutexWaitOne1();
+
+ TestLibrary.TestFramework.BeginTestCase("MutexWaitOne1");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ #region Private Methods
+ private void SignalMutex()
+ {
+ m_Mutex.WaitOne();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ m_Mutex.ReleaseMutex();
+ }
+
+ private void NeverReleaseMutex()
+ {
+ m_Mutex.WaitOne();
+ // Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ }
+
+ private void DisposeMutex()
+ {
+ // Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ ((IDisposable)m_Mutex).Dispose();
+ }
+ #endregion
+}
diff --git a/tests/src/baseservices/threading/mutex/misc/waitone1.csproj b/tests/src/baseservices/threading/mutex/misc/waitone1.csproj
new file mode 100644
index 0000000000..87cd12e421
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/waitone1.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOne1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/mutex/misc/waitone2.cs b/tests/src/baseservices/threading/mutex/misc/waitone2.cs
new file mode 100644
index 0000000000..8c0a94d5a8
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/waitone2.cs
@@ -0,0 +1,573 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading; // For Thread, Mutex
+
+public class TestContextBoundObject
+{
+ public void TestMethod()
+ {
+ Thread.Sleep(MutexWaitOne2.c_LONG_SLEEP_TIME);
+ }
+}
+
+/// <summary>
+/// WaitOne(System.Int32, System.Boolean)
+/// </summary>
+///
+
+// Exercises Mutex:
+// Waits infinitely,
+// Waits a finite time,
+// Times out appropriately,
+// Throws Exceptions appropriately.
+public class MutexWaitOne2
+{
+ #region Public Constants
+ public const int c_DEFAULT_SLEEP_TIME = 1000; // 1 second
+ public const int c_LONG_SLEEP_TIME = 5000; // 5 second
+ #endregion
+
+ #region Private Fields
+ private Mutex m_Mutex = null;
+ #endregion
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+ retVal = PosTest2() && retVal;
+ retVal = PosTest3() && retVal;
+ retVal = PosTest4() && retVal;
+ retVal = PosTest5() && retVal;
+ retVal = PosTest6() && retVal;
+ retVal = PosTest7() && retVal;
+
+ TestLibrary.TestFramework.LogInformation("[Negative]");
+ retVal = NegTest1() && retVal;
+ retVal = NegTest2() && retVal;
+ retVal = NegTest3() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Wait Infinite");
+
+ try
+ {
+ do
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(SleepLongTime));
+ thread.Start();
+
+ if (m_Mutex.WaitOne(Timeout.Infinite) != true)
+ {
+ TestLibrary.TestFramework.LogError("001", "Can not wait Infinite");
+ retVal = false;
+
+ break;
+ }
+
+ m_Mutex.ReleaseMutex();
+
+ } while (false); // do
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest2()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest2: Wait some finite time");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(SignalMutex));
+ thread.Start();
+
+ m_Mutex.WaitOne(2 * c_DEFAULT_SLEEP_TIME);
+
+ m_Mutex.ReleaseMutex();
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest3()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest3: Wait some finite time will quit for timeout");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(SignalMutex));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ if (false != m_Mutex.WaitOne(c_DEFAULT_SLEEP_TIME / 10))
+ {
+ m_Mutex.ReleaseMutex();
+ TestLibrary.TestFramework.LogError("004", "WaitOne returns true when wait time out");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("005", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest4()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest4: Wait some finite time will quit for timeout when another thread is in nondefault managed context");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(CallContextBoundObjectMethod));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ if (false != m_Mutex.WaitOne(c_DEFAULT_SLEEP_TIME))
+ {
+ m_Mutex.ReleaseMutex();
+ TestLibrary.TestFramework.LogError("006", "WaitOne returns true when wait some finite time will quit for timeout when another thread is in nondefault managed context");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("007", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest5()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest5: Wait some finite time will quit for timeout when another thread is in nondefault managed context");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(CallContextBoundObjectMethod));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ if (false != m_Mutex.WaitOne(c_DEFAULT_SLEEP_TIME))
+ {
+ m_Mutex.ReleaseMutex();
+ TestLibrary.TestFramework.LogError("008", "WaitOne returns true when wait some finite time will quit for timeout when another thread is in nondefault managed context");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("009", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest6()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest6: Wait infinite time when another thread is in nondefault managed context");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(CallContextBoundObjectMethod));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ if (true != m_Mutex.WaitOne(Timeout.Infinite))
+ {
+ m_Mutex.ReleaseMutex();
+ TestLibrary.TestFramework.LogError("010", "WaitOne returns false when wait infinite time when another thread is in nondefault managed context");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("011", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool PosTest7()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest7: Wait infinite time when another thread is in nondefault managed context");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(CallContextBoundObjectMethod));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ if (true != m_Mutex.WaitOne(Timeout.Infinite))
+ {
+ m_Mutex.ReleaseMutex();
+ TestLibrary.TestFramework.LogError("012", "WaitOne returns false when wait infinite time when another thread is in nondefault managed context");
+ retVal = false;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("013", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+
+ #region Negative Test Cases
+ public bool NegTest1()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest1: AbandonedMutexException should be thrown if a thread exited without releasing a mutex");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(NeverReleaseMutex));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ m_Mutex.WaitOne(Timeout.Infinite);
+
+ // AbandonedMutexException is not thrown on Windows 98 or Windows ME
+ //if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+ //{
+ TestLibrary.TestFramework.LogError("101", "AbandonedMutexException is not thrown if a thread exited without releasing a mutex");
+ retVal = false;
+ //}
+ }
+ catch (AbandonedMutexException)
+ {
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool NegTest2()
+ {
+ bool retVal = true;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest2: ObjectDisposedException should be thrown if current instance has already been disposed");
+
+ try
+ {
+ m_Mutex = new Mutex();
+
+ thread = new Thread(new ThreadStart(DisposeMutex));
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ m_Mutex.WaitOne(Timeout.Infinite);
+
+ TestLibrary.TestFramework.LogError("103", "ObjectDisposedException is not thrown if current instance has already been disposed");
+ retVal = false;
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ thread.Join();
+ }
+
+ if (null != m_Mutex)
+ {
+ ((IDisposable)m_Mutex).Dispose();
+ }
+ }
+
+ return retVal;
+ }
+
+ public bool NegTest3()
+ {
+ bool retVal = true;
+ int testInt = 0;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest3: Check ArgumentOutOfRangeException will be thrown if millisecondsTimeout is a negative number other than -1");
+
+ try
+ {
+ testInt = TestLibrary.Generator.GetInt32();
+
+ if (testInt > 0)
+ {
+ testInt = 0 - testInt;
+ }
+
+ if (testInt == -1)
+ {
+ testInt--;
+ }
+
+ m_Mutex = new Mutex();
+ m_Mutex.WaitOne(testInt);
+
+ TestLibrary.TestFramework.LogError("105", "ArgumentOutOfRangeException is not thrown if millisecondsTimeout is a negative number other than -1");
+ TestLibrary.TestFramework.LogInformation("[LOCAL VARIABLES] testInt = " + testInt);
+ retVal = false;
+ }
+ catch (ArgumentOutOfRangeException)
+ {
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("106", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation("[LOCAL VARIABLES] testInt = " + testInt);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != m_Mutex)
+ {
+ m_Mutex.Dispose();
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ MutexWaitOne2 test = new MutexWaitOne2();
+
+ TestLibrary.TestFramework.BeginTestCase("MutexWaitOne2");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ #region Private Methods
+ private void SleepLongTime()
+ {
+ m_Mutex.WaitOne();
+ Thread.Sleep(c_LONG_SLEEP_TIME);
+ m_Mutex.ReleaseMutex();
+ }
+
+ private void SignalMutex()
+ {
+ m_Mutex.WaitOne();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ m_Mutex.ReleaseMutex();
+ }
+
+ private void NeverReleaseMutex()
+ {
+ m_Mutex.WaitOne();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ }
+
+ private void DisposeMutex()
+ {
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ ((IDisposable)m_Mutex).Dispose();
+ }
+
+ private void CallContextBoundObjectMethod()
+ {
+ m_Mutex.WaitOne();
+ TestContextBoundObject obj = new TestContextBoundObject();
+ obj.TestMethod();
+ m_Mutex.ReleaseMutex();
+ }
+ #endregion
+}
diff --git a/tests/src/baseservices/threading/mutex/misc/waitone2.csproj b/tests/src/baseservices/threading/mutex/misc/waitone2.csproj
new file mode 100644
index 0000000000..4503c8df48
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/misc/waitone2.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOne2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/mutex/openexisting/app.config b/tests/src/baseservices/threading/mutex/openexisting/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.cs
new file mode 100644
index 0000000000..d14cff6915
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Mutex mut;
+ try
+ {
+ mut = Mutex.OpenExisting(Common.GetUniqueName());
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.csproj
new file mode 100644
index 0000000000..2435b283fb
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg1.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg2.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.cs
new file mode 100644
index 0000000000..5bc9a5a4cd
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Mutex mut;
+ try
+ {
+ mut = Mutex.OpenExisting("");
+ }
+ catch (ArgumentException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.csproj
new file mode 100644
index 0000000000..d399d72004
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg2.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg3.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.cs
new file mode 100644
index 0000000000..734e0c4309
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Mutex mut;
+ try
+ {
+ mut = Mutex.OpenExisting(null);
+ }
+ catch (ArgumentNullException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.csproj
new file mode 100644
index 0000000000..cf8e8753de
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg3.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg4.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.cs
new file mode 100644
index 0000000000..2511dcf996
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Mutex mut;
+ try
+ {
+ String myMut = null;
+ mut = Mutex.OpenExisting(myMut);
+ }
+ catch (ArgumentNullException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.csproj
new file mode 100644
index 0000000000..5e0c806e7d
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg4.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg5.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs
new file mode 100644
index 0000000000..0cd7db0cb1
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a closed mutex
+ try
+ {
+ using (Mutex mut1 = new Mutex(false, sName)) {}
+ Mutex mut2 = Mutex.OpenExisting(sName);
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.csproj
new file mode 100644
index 0000000000..f41f8612b6
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg5.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg5.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg6.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.cs
new file mode 100644
index 0000000000..9979366f42
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a Mutex with the same name as a Semaphore
+ using (Semaphore sem = new Semaphore(10, 10, sName))
+ {
+ try
+ {
+ Mutex mut = Mutex.OpenExisting(sName);
+ }
+ catch(WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught exception where WaitHandleCannotBeOpenedException was expected: " +
+ e.ToString());
+ }
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.csproj
new file mode 100644
index 0000000000..443223efa1
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg6.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg6.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg7.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.cs
new file mode 100644
index 0000000000..c4846141e8
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public ManualResetEvent mre;
+ public Mutex mut;
+
+ public OpenMutexNeg()
+ {
+ mre = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a Mutex that has been abandoned
+ mut = new Mutex(false, sName);
+ Thread th = new Thread(new ParameterizedThreadStart(AbandonMutex));
+ th.Start(mut);
+ mre.WaitOne();
+ try
+ {
+ Mutex mut1 = Mutex.OpenExisting(sName);
+ mut1.WaitOne();
+ }
+ catch (AbandonedMutexException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutex(Object o)
+ {
+ ((Mutex)o).WaitOne();
+ mre.Set();
+ Thread.Sleep(1000);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.csproj
new file mode 100644
index 0000000000..f18172de62
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg7.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg7.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexneg8.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.cs
new file mode 100644
index 0000000000..ff47944833
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexNeg
+{
+ public Mutex mut;
+
+ public static int Main()
+ {
+ OpenMutexNeg omn = new OpenMutexNeg();
+ return omn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ // open a Mutex, not case specific
+ mut = new Mutex(false, "This is a Mutex that is Case Specific");
+ try
+ {
+ Mutex mut1 = Mutex.OpenExisting("This is a Mutex that is Case specific");
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.csproj
new file mode 100644
index 0000000000..cdf646e670
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexneg8.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexNeg8.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexpos1.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.cs
new file mode 100644
index 0000000000..93f53a82bc
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexPos
+{
+ Mutex mut;
+ ManualResetEvent mre;
+
+ public OpenMutexPos()
+ {
+ mre = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ OpenMutexPos omp = new OpenMutexPos();
+ return omp.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // Basic test, not owned
+ using(mut = new Mutex(false, sName))
+ {
+ Thread t = new Thread(new ThreadStart(OwnMutex));
+ t.Start();
+ mre.WaitOne();
+ try
+ {
+ Mutex mut1 = Mutex.OpenExisting(sName);
+ mut1.WaitOne();
+ mut1.ReleaseMutex();
+ iRet = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ ex.ToString());
+ }
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void OwnMutex()
+ {
+ mut.WaitOne();
+ mre.Set();
+ Thread.Sleep(3000);
+ mut.ReleaseMutex();
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.csproj
new file mode 100644
index 0000000000..154af904e8
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexPos1.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexpos2.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.cs
new file mode 100644
index 0000000000..9581bdb517
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.cs
@@ -0,0 +1,46 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexPos
+{
+ Mutex mut;
+ ManualResetEvent mre;
+
+ public OpenMutexPos()
+ {
+ mre = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ OpenMutexPos omp = new OpenMutexPos();
+ return omp.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // Basic test, owned
+ using (mut = new Mutex(true, sName))
+ {
+ try
+ {
+ Mutex mut1 = Mutex.OpenExisting(sName);
+ iRet = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ ex.ToString());
+ }
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.csproj
new file mode 100644
index 0000000000..1ea748d868
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos2.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexPos2.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexpos3.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.cs
new file mode 100644
index 0000000000..01abc0de33
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenMutexPos
+{
+ Mutex mut;
+
+ public static int Main()
+ {
+ OpenMutexPos omp = new OpenMutexPos();
+ return omp.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // Open an abandoned mutex
+ using (mut = new Mutex(false, sName))
+ {
+ Thread t = new Thread(new ThreadStart(AbandonMutex));
+ t.Start();
+ t.Join();
+ try
+ {
+ Mutex mut1 = Mutex.OpenExisting(sName);
+ iRet = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ ex.ToString());
+ }
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutex()
+ {
+ mut.WaitOne();
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.csproj
new file mode 100644
index 0000000000..551eb604e3
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexPos3.cs" />
+ <Compile Include="..\OpenMutexCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/openmutexpos4.cs b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.cs
new file mode 100644
index 0000000000..c46dc61b1b
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+/// <summary>
+/// Verifies if we CreateMutex adn then OpenMutex we don't have ownership of the mutex.
+/// </summary>
+public class Test
+{
+ const string mutexName = "MySharedMutex";
+ static ManualResetEvent manualEvent = new ManualResetEvent(false);
+ static ManualResetEvent exitEvent = new ManualResetEvent(false);
+ int success = 100;
+
+
+ public void CreateMutexThread()
+ {
+ Console.WriteLine("Inside thread which creates a mutex");
+
+ Mutex mutex = new Mutex(true, mutexName);
+
+
+ Console.WriteLine("Mutex created");
+
+ manualEvent.Set();
+ mutex.ReleaseMutex();
+
+ exitEvent.WaitOne();
+ }
+
+ public void ReuseMutexThread()
+ {
+ Console.WriteLine("Waiting to reuse mutex");
+ manualEvent.WaitOne();
+ bool exists;
+
+ Mutex mutex = new Mutex(true, mutexName, out exists);
+
+ if (exists)
+ {
+ Console.WriteLine("Error, created new mutex!");
+ success = 97;
+ }
+ else
+ {
+ mutex.WaitOne();
+ }
+
+
+ try
+ {
+ Console.WriteLine("Mutex reused {0}", exists);
+ mutex.ReleaseMutex();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unexpected exception: {0}", e);
+ success = 98;
+ }
+
+ exitEvent.Set();
+ }
+
+ int RunTest()
+ {
+ Thread t1 = new Thread(new ThreadStart(CreateMutexThread));
+ Thread t2 = new Thread(new ThreadStart(ReuseMutexThread));
+ t1.Start();
+ t2.Start();
+ t1.Join();
+ t2.Join();
+
+ if (success == 100) Console.WriteLine("Test passed"); else Console.WriteLine("Test failed");
+ return (success);
+ }
+
+ public static int Main()
+ {
+ return (new Test().RunTest());
+ }
+}
+
diff --git a/tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.csproj b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.csproj
new file mode 100644
index 0000000000..38705ff16f
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/openmutexpos4.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="OpenMutexPos4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/mutex/openexisting/project.json b/tests/src/baseservices/threading/mutex/openexisting/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openexisting/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/mutex/openmutexcommon.cs b/tests/src/baseservices/threading/mutex/openmutexcommon.cs
new file mode 100644
index 0000000000..fce7fc3044
--- /dev/null
+++ b/tests/src/baseservices/threading/mutex/openmutexcommon.cs
@@ -0,0 +1,32 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using 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 = (char)rand.Next(Char.MinValue, Char.MaxValue);
+ semNameNum += ((int)c).ToString() + ";";
+ semName += (char)rand.Next(Char.MinValue, Char.MaxValue);
+ }
+ // 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/paramthreadstart/threadstartarray.cs b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.cs
new file mode 100644
index 0000000000..30f9074b4f
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.cs
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class ThreadStartArray
+{
+ Mutex[] m;
+ AutoResetEvent are = new AutoResetEvent(false);
+
+ public static int Main()
+ {
+ // Abandon this mutex
+ Mutex[] mArr = new Mutex[64];
+ for(int i=0;i<mArr.Length;i++)
+ mArr[i] = new Mutex(false);
+
+ ThreadStartArray tsa = new ThreadStartArray();
+ return tsa.Run(mArr);
+ }
+
+ private int Run(Mutex[] mPass)
+ {
+ bool bRet = false;
+ Thread t = new Thread(new ParameterizedThreadStart(ThreadWorker));
+ t.Start(mPass);
+ are.WaitOne();
+
+ // Check to make sure the array is abandoned
+ try
+ {
+ WaitHandle.WaitAny(m, 10000);
+ }
+ catch(AbandonedMutexException)
+ {
+ bRet = true;
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + ex.ToString());
+ }
+
+ Console.WriteLine(bRet ? "Test Passed" : "Test Failed");
+ return (bRet ? 100 : -1);
+ }
+
+ private void ThreadWorker(Object o)
+ {
+ for(int i = 0;i<((Mutex[])o).Length;i++)
+ ((Mutex[])o)[i].WaitOne();
+
+ m = (Mutex[])o;
+ are.Set();
+ Thread.Sleep(1000);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj
new file mode 100644
index 0000000000..7080a6e0ba
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ThreadStartArray.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/paramthreadstart/threadstartclass.cs b/tests/src/baseservices/threading/paramthreadstart/threadstartclass.cs
new file mode 100644
index 0000000000..e3667b04b2
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartclass.cs
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Diagnostics;
+
+class ThreadStartClass
+{
+ Object oSaved = null;
+
+ public static int Main(string[] args)
+ {
+ ThreadStartClass tsc = new ThreadStartClass();
+ return tsc.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = 100;
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ Thread.Sleep(1000);
+ sw.Stop();
+
+ Thread t = new Thread(new ParameterizedThreadStart(ThreadWorker));
+ t.Start(sw);
+ t.Join();
+
+ if (sw.ElapsedMilliseconds != ((Stopwatch)oSaved).ElapsedMilliseconds)
+ {
+ Console.WriteLine("Expected ((Stopwatch)oSaved).ElapsedMilliseconds = sw.ElapsedMilliseconds=" + sw.ElapsedMilliseconds.ToString());
+ Console.WriteLine("Actual oSaved.ElapsedMilliseconds=" + ((Stopwatch)oSaved).ElapsedMilliseconds.ToString());
+ iRet = 98;
+ }
+ Console.WriteLine("Expected ((Stopwatch)oSaved).ElapsedMilliseconds to be 1000, but found " + ((Stopwatch)oSaved).ElapsedMilliseconds);
+ if (((Stopwatch)oSaved).ElapsedMilliseconds < 950)
+ {
+ Console.WriteLine("Expected ((Stopwatch)oSaved).ElapsedMilliseconds to be 1000, but found " + ((Stopwatch)oSaved).ElapsedMilliseconds);
+ iRet = 97;
+ }
+
+ Console.WriteLine(iRet==100 ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void ThreadWorker(Object o)
+ {
+ oSaved = o;
+ }
+}
diff --git a/tests/src/baseservices/threading/paramthreadstart/threadstartclass.csproj b/tests/src/baseservices/threading/paramthreadstart/threadstartclass.csproj
new file mode 100644
index 0000000000..5fedee6ff1
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartclass.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ThreadStartClass.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/paramthreadstart/threadstartstruct.cs b/tests/src/baseservices/threading/paramthreadstart/threadstartstruct.cs
new file mode 100644
index 0000000000..f6e5e54725
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartstruct.cs
@@ -0,0 +1,67 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class ThreadStartStruct
+{
+ int iRet = -1;
+
+ public struct MyStruct
+ {
+ public int myInt;
+ public string myStr;
+ public long myLong;
+ public double myDouble;
+ public Mutex myMutex;
+ }
+
+ public static int Main()
+ {
+ ThreadStartStruct tss = new ThreadStartStruct();
+ return tss.Run();
+ }
+
+ private int Run()
+ {
+ MyStruct m = new MyStruct();
+ m.myInt = Int32.MinValue;
+ m.myStr = "This is the string";
+ m.myLong = Int64.MaxValue;
+ m.myDouble = Double.MinValue;
+ m.myMutex = new Mutex(true);
+
+ Thread t = new Thread(new ParameterizedThreadStart(ThreadWorker));
+ t.Start(m);
+ // Test to see if it passing an owned mutex
+ Thread.Sleep(1000);
+ m.myMutex.ReleaseMutex();
+ t.Join();
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return (100 == iRet ? 100 : -1);
+ }
+
+ private void ThreadWorker(Object o)
+ {
+ if(Int32.MinValue == ((MyStruct)o).myInt &&
+ "This is the string" == ((MyStruct)o).myStr &&
+ Int64.MaxValue == ((MyStruct)o).myLong &&
+ Double.MinValue == ((MyStruct)o).myDouble)
+ {
+ try
+ {
+ ((MyStruct)o).myMutex.WaitOne();
+ ((MyStruct)o).myMutex.ReleaseMutex();
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/paramthreadstart/threadstartstruct.csproj b/tests/src/baseservices/threading/paramthreadstart/threadstartstruct.csproj
new file mode 100644
index 0000000000..46a548def9
--- /dev/null
+++ b/tests/src/baseservices/threading/paramthreadstart/threadstartstruct.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ThreadStartStruct.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/readerwriterlockslim/singlereleasewriteddbug71632.cs b/tests/src/baseservices/threading/readerwriterlockslim/singlereleasewriteddbug71632.cs
deleted file mode 100644
index 842e392858..0000000000
--- a/tests/src/baseservices/threading/readerwriterlockslim/singlereleasewriteddbug71632.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Threading;
-
-class C
-{
- private ReaderWriterLockSlim rwls;
- private ManualResetEvent mre;
- private ManualResetEvent mre1;
- private int threadCount = 100;
- private int oneThreadAccess;
-
- static int Main()
- {
- return (new C()).RunTest();
- }
-
- public int RunTest()
- {
- int retCode = -10;
- rwls = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
- threadCount = 0;
- oneThreadAccess = 0;
-
- retCode = DoTesting();
-
- return retCode;
- }
-
- private int DoTesting()
- {
- mre = new ManualResetEvent(false);
- mre1 = new ManualResetEvent(false);
- Thread[] threadArray = new Thread[5];
- threadArray[0] = new Thread(this.LockTaker);
- threadArray[0].Start();
- mre1.WaitOne();
- for (int i = 1; i < threadArray.Length; i++)
- {
- threadArray[i] = new Thread(this.LockCompetitor);
- threadArray[i].Start();
- }
-
- for (int i = 0; i < threadArray.Length; i++)
- {
- threadArray[i].Join();
- }
-
- mre = new ManualResetEvent(false);
- mre1 = new ManualResetEvent(false);
- threadArray[0] = new Thread(this.LockTakerWrite);
- threadArray[0].Start();
- mre1.WaitOne();
- for (int i = 1; i < threadArray.Length; i++)
- {
- threadArray[i] = new Thread(this.LockCompetitorWrite);
- threadArray[i].Start();
- }
-
- for (int i = 0; i < threadArray.Length; i++)
- {
- threadArray[i].Join();
- }
- if (threadCount == 8)
- return 100;
- else
- return threadCount;
- }
-
- void LockTaker()
- {
- rwls.EnterUpgradeableReadLock();
- Interlocked.Increment(ref oneThreadAccess);
- mre1.Set();
- mre.WaitOne();
- Thread.Sleep(1000);
- if (oneThreadAccess != 1)
- {
- Console.WriteLine("Expected original UpgradeLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 50;
- }
- Interlocked.Decrement(ref oneThreadAccess);
- if (oneThreadAccess != 0)
- {
- Console.WriteLine("Expected original UpgradeLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 60;
- }
- rwls.ExitUpgradeableReadLock();
- }
-
- void LockCompetitor()
- {
- Interlocked.Increment(ref threadCount);
- if (threadCount == 4)
- mre.Set();
- rwls.EnterUpgradeableReadLock();
- Interlocked.Increment(ref oneThreadAccess);
- Thread.Sleep(2000);
- if (oneThreadAccess != 1)
- {
- Console.WriteLine("Expected original UpgradeLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 70;
- }
- Interlocked.Decrement(ref oneThreadAccess);
- Thread.Sleep(3000);
- if (oneThreadAccess != 0)
- {
- Console.WriteLine("Expected original UpgradeLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 80;
- }
- rwls.ExitUpgradeableReadLock();
- }
-
- void LockTakerWrite()
- {
- rwls.EnterWriteLock();
- Interlocked.Increment(ref oneThreadAccess);
- mre1.Set();
- mre.WaitOne();
- Thread.Sleep(1000);
- if (oneThreadAccess != 1)
- {
- Console.WriteLine("Expected original WriteLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 50;
- }
- Interlocked.Decrement(ref oneThreadAccess);
- if (oneThreadAccess != 0)
- {
- Console.WriteLine("Expected original WriteLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 60;
- }
- rwls.ExitWriteLock();
- }
-
- void LockCompetitorWrite()
- {
- Interlocked.Increment(ref threadCount);
- if (threadCount == 8)
- mre.Set();
- rwls.EnterWriteLock();
- Interlocked.Increment(ref oneThreadAccess);
- Thread.Sleep(2000);
- if (oneThreadAccess != 1)
- {
- Console.WriteLine("Expected original WriteLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 70;
- }
- Interlocked.Decrement(ref oneThreadAccess);
- Thread.Sleep(3000);
- if (oneThreadAccess != 0)
- {
- Console.WriteLine("Expected original WriteLock to have the lock, but a second thread appears to have modified oneThreadAccess");
- threadCount = 80;
- }
- rwls.ExitWriteLock();
- }
-} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/tryenterfailureddbugs124485.cs b/tests/src/baseservices/threading/readerwriterlockslim/tryenterfailureddbugs124485.cs
deleted file mode 100644
index ad5480c4a3..0000000000
--- a/tests/src/baseservices/threading/readerwriterlockslim/tryenterfailureddbugs124485.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Threading;
-
-class Program
-{
- private ReaderWriterLockSlim rwls = new ReaderWriterLockSlim();
-
- public int RunTest()
- {
- bool lockTaken = false;
- int retCode = 25;
- try
- {
- lockTaken = false;
- Console.WriteLine("Attempting rwls.TryEnterUpgradeableReadLock(-2647); on unowned lock");
- lockTaken = rwls.TryEnterUpgradeableReadLock(-2647);
- retCode = -100;
- Console.WriteLine("Expected exception but aquired lock. Failing test.");
- }
- catch (ArgumentException ae)
- {
- retCode = retCode + 25;
- Console.WriteLine("As expected: Caught ArgumentException\n{0}", ae.Message);
- }
- finally
- {
- if (lockTaken)
- {
- rwls.ExitUpgradeableReadLock();
- }
- }
-
- try
- {
- lockTaken = false;
- Console.WriteLine();
- Console.WriteLine("Attempting rwls.TryEnterReadLock(-2647); on unowned lock");
- lockTaken = rwls.TryEnterReadLock(-2647);
- retCode = -110;
- Console.WriteLine("Expected exception but aquired lock. Failing test.");
- }
- catch (ArgumentException ae)
- {
- retCode = retCode + 25;
- Console.WriteLine("As expected: Caught ArgumentException\n{0}", ae.Message);
- }
- finally
- {
- if (lockTaken)
- {
- rwls.ExitReadLock();
- }
- }
-
- try
- {
- lockTaken = false;
- Console.WriteLine();
- Console.WriteLine("Attempting rwls.TryEnterWriteLock(-2647); on unowned lock");
- lockTaken = rwls.TryEnterWriteLock(-2647);
- retCode = -120;
- Console.WriteLine("Expected exception but aquired lock. Failing test.");
- }
- catch (ArgumentException ae)
- {
- retCode = retCode + 25;
- Console.WriteLine("As expected: Caught ArgumentException\n{0}", ae.Message);
- }
- finally
- {
- if (lockTaken)
- {
- rwls.ExitWriteLock();
- }
- }
-
- return retCode;
- }
-
- static int Main()
- {
- return (new Program()).RunTest();
- }
-} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/readerwriterlockslim/upgrader.cs b/tests/src/baseservices/threading/readerwriterlockslim/upgrader.cs
deleted file mode 100644
index 05543089d2..0000000000
--- a/tests/src/baseservices/threading/readerwriterlockslim/upgrader.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-using System;
-using System.Threading;
-
-class Upgrader
-{
- private static ReaderWriterLockSlim rwls = new ReaderWriterLockSlim();
- private const int readerCount = 10;
- private static CountdownEvent ev = new CountdownEvent(readerCount);
-
- /// <summary>
- /// This is the thread body that will try to enter read/write/upgrade
- /// lock.
- /// </summary>
- /// <param name="threadIndex"></param>
- /// <param name="lockAction">0: try enter read lock; 1: try enter write lock; other value: try enter upgrade lock</param>
- public static void ThreadMethod(object parameters)
- {
- object[] parameterArray = (object[]) parameters;
- int threadIndex = (int)parameterArray[0];
- int lockAction = (int)parameterArray[1];
-
- if (lockAction == 0)
- Upgrader.rwls.EnterReadLock();
- else if (lockAction == 1)
- Upgrader.rwls.EnterWriteLock();
- else
- Upgrader.rwls.EnterUpgradeableReadLock();
-
- Upgrader.ev.Signal();
- Console.WriteLine(" @Thread {0} Signal ", threadIndex);
- Thread.CurrentThread.Join();
- }
-
- public static int RunTest()
- {
- int retCode = 0;
-
- try
- {
- Upgrader.rwls.EnterUpgradeableReadLock();
- Console.WriteLine(" Main thread EnterUpgradeableReadLock !");
-
- for (int i = 0; i < readerCount; i++)
- {
- Thread t = new Thread(new ParameterizedThreadStart(Upgrader.ThreadMethod));
- object[] parameters = new object[] { i, 0 };
- // The thread MUST be set to background thread otherwise it will be dead forever
- t.IsBackground = true;
- t.Start(parameters);
- Console.WriteLine(" @Thread {0} start ", i);
- }
-
- ev.Wait();
- Console.WriteLine(" ev.wait ");
- if (rwls.TryEnterWriteLock(5 * 1000))
- {
- Console.WriteLine(" Wrong: @Main thread enter Write Lock! ");
- retCode = 90;
- }
- else
- {
- Console.WriteLine(" @Main thread cannot enter Write Lock! ");
- retCode = 100;
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Wrong: Unexpected exception happened!");
- Console.WriteLine(e.ToString());
- retCode = 80;
- }
- return retCode;
- }
-
- static int Main()
- {
- int retCode = Upgrader.RunTest();
- if (retCode == 100)
- Console.WriteLine(" Test Passed! ");
- else
- Console.WriteLine(" Test Failed! ");
- return retCode;
- }
-} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/13662/13662-a.cs b/tests/src/baseservices/threading/regressions/13662/13662-a.cs
new file mode 100644
index 0000000000..c3f5d0fd87
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/13662-a.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+
+public class Test {
+
+ public static int Main(){
+
+ int rValue = 100;
+ Timer[] tArray = new Timer[1000];
+ int val = 0;
+ while(val < 10){
+ Interlocked.Increment(ref val);
+ Console.WriteLine("Loop {0}",val);
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+ return rValue;
+ }
+
+ public static void TFunc(Object o)
+ {
+ Thread.Sleep(1);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/13662/13662-a.csproj b/tests/src/baseservices/threading/regressions/13662/13662-a.csproj
new file mode 100644
index 0000000000..060d106e7b
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/13662-a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="13662-a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/13662/13662-b.cs b/tests/src/baseservices/threading/regressions/13662/13662-b.cs
new file mode 100644
index 0000000000..1e7a4d9936
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/13662-b.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+
+public class Test {
+
+ public static int Main(){
+
+ int rValue = 100;
+ Timer[] tArray = new Timer[1000];
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+
+ return rValue;
+ }
+
+ public static void TFunc(Object o)
+ {
+ Thread.Sleep(1);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/13662/13662-b.csproj b/tests/src/baseservices/threading/regressions/13662/13662-b.csproj
new file mode 100644
index 0000000000..cb48cb6969
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/13662-b.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="13662-b.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/13662/13662-simple.csproj b/tests/src/baseservices/threading/regressions/13662/13662-simple.csproj
new file mode 100644
index 0000000000..1180566fbf
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/13662-simple.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="simple.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/13662/app.config b/tests/src/baseservices/threading/regressions/13662/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/13662/project.json b/tests/src/baseservices/threading/regressions/13662/project.json
new file mode 100644
index 0000000000..83df7e0bca
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.Timer": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/13662/simple.cs b/tests/src/baseservices/threading/regressions/13662/simple.cs
new file mode 100644
index 0000000000..230c63951f
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/13662/simple.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+
+public class Test {
+
+ public static int Main(){
+
+ int rValue = 100;
+ Timer[] tArray = new Timer[100];
+ int val = 0;
+ while(val < 10){
+ Interlocked.Increment(ref val);
+ Console.WriteLine("Loop {0}",val);
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,1000000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+ return rValue;
+ }
+
+ public static void TFunc(Object o)
+ {
+ Thread.Sleep(1);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/269336/app.config b/tests/src/baseservices/threading/regressions/269336/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/269336/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs b/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs
new file mode 100644
index 0000000000..60185dc496
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs
@@ -0,0 +1,37 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class ObjMonHelper {
+ const string FailMsg = @"Monitor.Enter appears to have mistaken a hash code in an object header for
+a valid lock owned by the current thread.";
+
+ public static int Main() {
+ var ok = true;
+ var arr = new object[1024*1024];
+
+ // Call GetHashCode to populate the object header with its hash
+ for (var i = 0; i < arr.Length; i++) {
+ arr[i] = new object();
+ arr[i].GetHashCode();
+ }
+
+ // Attempt to lock and unlock each object. If the bug is present, the object will appear
+ // to be locked by the current thread and Monitor.Enter will incorrectly take a fast path.
+ // Monitor.Exit will then correctly take the slow path, find that the object is not locked,
+ // and throw.
+ try {
+ for (var i = 0; i < arr.Length; i++)
+ lock (arr[i])
+ GC.KeepAlive(arr[i]);
+ } catch (SynchronizationLockException) {
+ ok = false;
+ }
+
+ Console.WriteLine(ok ? "Test passed" : FailMsg);
+ return ok ? 100 : -1;
+ }
+}
diff --git a/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj b/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj
new file mode 100644
index 0000000000..f9f3c00609
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="ObjMonHelper.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/269336/project.json b/tests/src/baseservices/threading/regressions/269336/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/269336/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/30032/30032.cs b/tests/src/baseservices/threading/regressions/30032/30032.cs
new file mode 100644
index 0000000000..caf979e6b8
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/30032/30032.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+
+public class Test {
+
+ public static int Main(){
+
+ int rValue = 100;
+ Timer[] tArray = new Timer[100];
+ int val = 0;
+ while(val < 10){
+ try{
+ Interlocked.Increment(ref val);
+ Console.WriteLine("Loop {0}",val);
+ for(int i = 0;i<tArray.Length;i++)
+ tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000000);
+
+ Thread.Sleep(1000);
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ }
+ catch(Exception e){
+ Console.WriteLine(e.ToString());
+ rValue = -1;
+ }
+ }
+ Console.WriteLine("Test {0}",100 == rValue ? "Passed":"Failed");
+ return rValue;
+ }
+
+ public static void TFunc(Object o)
+ {
+ Thread.Sleep(1);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/30032/30032.csproj b/tests/src/baseservices/threading/regressions/30032/30032.csproj
new file mode 100644
index 0000000000..a5ea30006d
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/30032/30032.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="30032.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/30032/app.config b/tests/src/baseservices/threading/regressions/30032/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/30032/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/30032/project.json b/tests/src/baseservices/threading/regressions/30032/project.json
new file mode 100644
index 0000000000..83df7e0bca
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/30032/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.Timer": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/beta1/347011.cs b/tests/src/baseservices/threading/regressions/beta1/347011.cs
new file mode 100644
index 0000000000..fa0377b6aa
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta1/347011.cs
@@ -0,0 +1,35 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class TimerTest
+{
+ public static void Target(Object foo){}
+
+ public static int Main()
+ {
+ int retVal = 0;
+ Timer timer = new Timer(new TimerCallback(Target),new Object(), 1000,1000);
+ timer.Dispose();
+ try
+ {
+ timer.Change(5000,5000);
+ retVal = -5;
+ }
+ catch(ObjectDisposedException)
+ {
+ Console.WriteLine("Caught Expected exception");
+ retVal = 100;
+ }
+ catch(Exception ex)
+ {
+ Console.WriteLine("Unexpected exception: " + ex.ToString());
+ retVal = -1;
+ }
+ Console.WriteLine(100 == retVal ? "Test Passed":"Test Failed");
+ return retVal;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/beta1/347011.csproj b/tests/src/baseservices/threading/regressions/beta1/347011.csproj
new file mode 100644
index 0000000000..ec0f62e4e9
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta1/347011.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>240</CLRTestExecutionArguments>
+ </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="347011.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/beta1/app.config b/tests/src/baseservices/threading/regressions/beta1/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta1/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/beta1/project.json b/tests/src/baseservices/threading/regressions/beta1/project.json
new file mode 100644
index 0000000000..83df7e0bca
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta1/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.Timer": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/beta2/437017.cs b/tests/src/baseservices/threading/regressions/beta2/437017.cs
new file mode 100644
index 0000000000..284a5ae8df
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/437017.cs
@@ -0,0 +1,125 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class Test
+{
+ static bool _fTestFailed = false;
+ static bool _fTestDone = false;
+ static ManualResetEvent _mre;
+ static AutoResetEvent _are = new AutoResetEvent(false);
+
+ public static int Main(string[] args)
+ {
+ Thread th = new Thread(new ThreadStart(Thread2));
+ th.Start();
+ Thread th2 = new Thread(new ThreadStart(Thread3));
+ th2.Start();
+ System.Diagnostics.Stopwatch myTimer = new System.Diagnostics.Stopwatch();
+ myTimer.Start();
+
+ int i = 0;
+ while (!_fTestFailed && myTimer.Elapsed.Minutes < 5 && i < 25000)
+ {
+ i++;
+ ManualResetEvent mre = new ManualResetEvent(false);
+ _mre = new ManualResetEvent(false);
+ RegisteredWaitHandle rwh = ThreadPool.RegisterWaitForSingleObject(mre, new WaitOrTimerCallback(callback), null, -1, false);
+ _are.Set();
+
+ bool bUnregisterSucceeded = false; //Used to improve speed of the test when Unregister has failed
+ try
+ {
+ rwh.Unregister(_mre);
+ bUnregisterSucceeded = true;
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+
+ if (bUnregisterSucceeded)
+ {
+ try
+ {
+ if (_mre.WaitOne(0))
+ {
+ Console.Write("@");
+ }
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+ }
+
+ if (i % 100 == 0) Console.WriteLine(i);
+ }
+ _fTestDone = true;
+ _are.Set();
+ th.Join();
+ th2.Join();
+
+ if (!_fTestFailed)
+ {
+ Console.WriteLine("Test Passed");
+ return 100;
+ }
+
+ Console.WriteLine("Test Failed");
+ return 101;
+
+ }
+
+ static void callback(object state, bool fTimedOut)
+ {
+ Console.Write("!");
+ _fTestFailed = true;
+ }
+
+ public static void Thread3()
+ {
+ while (true & !_fTestDone)
+ {
+ _are.WaitOne();
+ _mre.Dispose();
+ }
+ }
+
+ public static void Thread2()
+ {
+ while (true & !_fTestDone)
+ {
+ Console.Write("#");
+ AutoResetEvent are;
+ using (are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+
+ using (are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+
+ using(are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/src/baseservices/threading/regressions/beta2/437017.csproj b/tests/src/baseservices/threading/regressions/beta2/437017.csproj
new file mode 100644
index 0000000000..62491893c7
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/437017.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="437017.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/beta2/437044.cs b/tests/src/baseservices/threading/regressions/beta2/437044.cs
new file mode 100644
index 0000000000..9da799fc90
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/437044.cs
@@ -0,0 +1,119 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class Test
+{
+ static bool _fTestFailed = false;
+ static bool _fTestDone = false;
+ static ManualResetEvent _mre;
+ static AutoResetEvent _are = new AutoResetEvent(false);
+
+ public static int Main(string[] args)
+ {
+ Thread th = new Thread(new ThreadStart(Thread2));
+ th.Start();
+ Thread th2 = new Thread(new ThreadStart(Thread3));
+ th2.Start();
+
+ for (int i = 0; i < 20000 && !_fTestFailed; i++)
+ {
+ _mre = new ManualResetEvent(false);
+ Timer t = new Timer(new TimerCallback(callback), null, 1000000, Timeout.Infinite);
+ _are.Set();
+
+ bool bDisposeSucceeded = false; //Used to improve speed of the test when Dispose has failed
+ try
+ {
+ t.Dispose();
+ bDisposeSucceeded = true;
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+
+ if (bDisposeSucceeded)
+ {
+ try
+ {
+ if (_mre.WaitOne(0))
+ {
+ Console.Write("@");
+ }
+ }
+ catch (ObjectDisposedException)
+ {
+ }
+ }
+ }
+ _fTestDone = true;
+ _are.Set();
+ th.Join();
+ th2.Join();
+
+ if (!_fTestFailed)
+ {
+ Console.WriteLine("Test Passed");
+ return 100;
+ }
+
+ Console.WriteLine("Test Failed");
+ return 101;
+
+ }
+
+ static void callback(object state)
+ {
+ Console.Write("!");
+ _fTestFailed = true;
+ }
+
+ public static void Thread3()
+ {
+ while (true & !_fTestDone)
+ {
+ _are.WaitOne();
+ _mre.Dispose();
+ }
+ }
+
+ public static void Thread2()
+ {
+ while (true & !_fTestDone)
+ {
+ Console.Write("#");
+ AutoResetEvent are;
+
+ using(are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+
+ using(are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+
+ using(are = new AutoResetEvent(false))
+ {
+ if (are.WaitOne(0))
+ {
+ Console.WriteLine("ARE Signaled!");
+ _fTestFailed = true;
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/src/baseservices/threading/regressions/beta2/437044.csproj b/tests/src/baseservices/threading/regressions/beta2/437044.csproj
new file mode 100644
index 0000000000..f0004b6951
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/437044.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="437044.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/beta2/app.config b/tests/src/baseservices/threading/regressions/beta2/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/beta2/project.json b/tests/src/baseservices/threading/regressions/beta2/project.json
new file mode 100644
index 0000000000..fbeed16724
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/beta2/project.json
@@ -0,0 +1,37 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Threading.Timer": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/app.config b/tests/src/baseservices/threading/regressions/devdiv489437/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/devdiv489437/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/project.json b/tests/src/baseservices/threading/regressions/devdiv489437/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/devdiv489437/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs
new file mode 100644
index 0000000000..8b3754f704
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+/*
+ * Issue description:
+ If a SemaphoreSlim.WaitAsync call is cancelled just after Release has
+ caused it to start to complete, we end up decrementing the semaphore's
+ count *and* cancelling the task. The caller does not know the count has
+ been decremented, because the call appears to fail. This leads to
+ deadlock later, because the caller has no reason to believe it should
+ release the erroneously-acquired count.
+
+Change description:
+ If the operation has already begun completing successfully, do not
+ cancel the associated Task.
+*/
+
+class Test
+{
+ static int Main(string[] args)
+ {
+ SemaphoreSlim s = new SemaphoreSlim(initialCount: 1);
+
+ var cts = new CancellationTokenSource();
+ s.Wait();
+ var t = s.WaitAsync(cts.Token);
+ s.Release();
+ cts.Cancel();
+
+
+ if (t.Status != TaskStatus.Canceled && s.CurrentCount == 0)
+ {
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("FAIL");
+ Console.WriteLine("Expected task status to not be Canceled and s.CurrentCount == 0");
+ Console.WriteLine("Actual: Task: " + t.Status + "; CurrentCount: " + s.CurrentCount);
+ return 101;
+ }
+
+
+ }
+}
+
diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj
new file mode 100644
index 0000000000..3067a13bc0
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="test489437.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/threadex.cs b/tests/src/baseservices/threading/regressions/threadex.cs
new file mode 100644
index 0000000000..f57a094be7
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/threadex.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Threading;
+using System.Reflection;
+
+public class ThreadEx
+{
+ public static void Abort(Thread thread)
+ {
+ MethodInfo abort = null;
+ foreach(MethodInfo m in thread.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance))
+ {
+ if (m.Name.Equals("AbortInternal") && m.GetParameters().Length == 0) abort = m;
+ }
+ if (abort == null)
+ {
+ throw new Exception("Failed to get Thread.Abort method");
+ }
+ abort.Invoke(thread, new object[0]);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs
new file mode 100644
index 0000000000..6a053a1301
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+public class Stop {
+
+ public static int Main(String[] args) {
+
+ Stop tm = new Stop();
+ try
+ {
+
+ ThreadPool.QueueUserWorkItem(new WaitCallback(tm.RunTest));
+ Thread.Sleep(3000);
+ }
+ catch
+ {
+ return -1;
+ }
+ return 100;
+ }
+ public void RunTest(object foo)
+ {
+ try{
+ throw new Exception();
+ }
+ catch
+ {}
+ }
+}
diff --git a/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj
new file mode 100644
index 0000000000..6d9a458176
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="200176.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/regressions/whidbey_m3/app.config b/tests/src/baseservices/threading/regressions/whidbey_m3/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/whidbey_m3/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/regressions/whidbey_m3/project.json b/tests/src/baseservices/threading/regressions/whidbey_m3/project.json
new file mode 100644
index 0000000000..5aea493104
--- /dev/null
+++ b/tests/src/baseservices/threading/regressions/whidbey_m3/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/app.config b/tests/src/baseservices/threading/semaphore/ctoropen/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/project.json b/tests/src/baseservices/threading/semaphore/ctoropen/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.cs
new file mode 100644
index 0000000000..cd13936ada
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.cs
@@ -0,0 +1,69 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length != 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtor1 /iCount:<int> /mCount:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1;
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount);
+ }
+
+ private int Run(int iCount, int mCount)
+ {
+ // Testing basic scenario
+ int iRet = -1;
+ Semaphore sem = null;
+ try
+ {
+ using (sem = new Semaphore(iCount, mCount))
+ {
+ int iPrev = 0, count = iCount;
+ // Do a wait one if we can
+ if (iCount > 0)
+ {
+ sem.WaitOne();
+ count--;
+ }
+ iPrev = sem.Release();
+
+ if (iPrev == count)
+ iRet = 100;
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("FAIL: CtorTest1(" + iCount + "," + mCount + ") - Unexpected exception thrown: " + ex.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.csproj
new file mode 100644
index 0000000000..92a10c5a0b
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:2147483647 /mCount:2147483647</CLRTestExecutionArguments>
+ </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="SemaphoreCtor1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorector2.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.cs
new file mode 100644
index 0000000000..060c9f8de5
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.cs
@@ -0,0 +1,99 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtor2 /iCount:<int> /mCount:<int> " +
+ "[/semName:<string>] [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int iCount, int mCount, string semName, int iRandom)
+ {
+ // Testing basic string scenario
+ int iRet = -1, count = iCount;
+ Semaphore sem1 = null, sem2 = null;
+ if (iRandom > 0)
+ semName = Common.GenerateUnicodeString(iRandom);
+ try
+ {
+ using (sem1 = new Semaphore(iCount, mCount, semName))
+ {
+ using (sem2 = (semName != null && semName != string.Empty) ? Semaphore.OpenExisting(semName) : sem1)
+ {
+ if (iCount > 0)
+ {
+ sem2.WaitOne();
+ count--;
+ }
+
+ int iPrev = sem2.Release();
+
+ if (iPrev == count)
+ iRet = 100;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + ex.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.csproj
new file mode 100644
index 0000000000..bd935a08dc
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector2.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:0 /mCount:1 /semName:MySemaphoreName</CLRTestExecutionArguments>
+ </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="SemaphoreCtor2.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorector3.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.cs
new file mode 100644
index 0000000000..52144bc138
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.cs
@@ -0,0 +1,128 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtor3 /iCount:<int> /mCount:<int> " +
+ "[/semName:<string>] [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int iCount, int mCount, string semName, int iRandom)
+ {
+ // Testing overlap of long strings
+ int iRet = -1;
+ Semaphore sem1 = null, sem2 = null, sem3 = null,
+ sem4 = null, sem6 = null;
+ if (iRandom > 0)
+ {
+ //TestFramework.GlobalData intl = new TestFramework.GlobalData();
+ //semName = intl.GetString(iRandom, iRandom).Replace(@"\", "");
+ Console.WriteLine("WARNING: No random name generation is ocurring");
+ }
+ string semNewName = semName.Remove(semName.Length - 2, 1);
+ try
+ {
+ // Create slightly different names
+ using (sem1 = new Semaphore(iCount, mCount, semName))
+ {
+ sem2 = new Semaphore(iCount, mCount, semNewName);
+ // Make sure we can open it
+ using(sem3 = Semaphore.OpenExisting(semName))
+ {
+ sem4 = Semaphore.OpenExisting(semNewName);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + ex.ToString());
+ Console.WriteLine("Test Failed");
+ return iRet;
+ }
+
+ // Make sure you can't open it
+ try
+ {
+ Semaphore sem5 = Semaphore.OpenExisting(semName);
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ // This is expected
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ Console.WriteLine("Test Failed");
+ return iRet;
+ }
+
+ // Make sure you can still open the other one
+ sem6 = Semaphore.OpenExisting(semNewName);
+ // Do a wait and release
+ sem6.WaitOne();
+ sem6.Release();
+ iRet = 100;
+
+ //Add a subsequent use of sem2 to avoid system event be GCed.
+ GC.KeepAlive(sem2);
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.csproj
new file mode 100644
index 0000000000..5b2838924c
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:10 /mCount:10 /semname:abcdefghijklmnopqrstuvwxyz</CLRTestExecutionArguments>
+ </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="SemaphoreCtor3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorector4.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.cs
new file mode 100644
index 0000000000..fff49e49ef
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtor4 /iCount:<int> /mCount:<int> " +
+ "[/semName:<string>] [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int iCount, int mCount, string semName, int iRandom)
+ {
+ // Testing createdNew
+ bool createdNew;
+ int iRet = -1, count = iCount;
+ Semaphore sem = null;
+ if (iRandom > 0)
+ semName = Common.GenerateUnicodeString(iRandom);
+ try
+ {
+ using(sem = new Semaphore(iCount, mCount, semName, out createdNew))
+ {
+ if (iCount > 0)
+ {
+ sem.WaitOne();
+ count--;
+ }
+
+ int iPrev = sem.Release();
+ if (iPrev == count && createdNew)
+ iRet = 100;
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + ex.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.csproj
new file mode 100644
index 0000000000..77149e8a8b
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector4.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:3 /mCount:5 /iRandom:260</CLRTestExecutionArguments>
+ </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="SemaphoreCtor4.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorector5.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.cs
new file mode 100644
index 0000000000..27bfb5c5b7
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.cs
@@ -0,0 +1,108 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtor4 /iCount:<int> /mCount:<int> " +
+ "[/semName:<string>] [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int iCount, int mCount, string semName, int iRandom)
+ {
+ // Testing createdNew
+ bool createdNew, createdNew2;
+ bool bResult = true;
+ int iRet = -1, count = iCount;
+ Semaphore sem1 = null, sem2 = null;
+ if (iRandom > 0)
+ semName = Common.GenerateUnicodeString(iRandom);
+ try
+ {
+ // Open one, createdNew = true
+ using (sem1 = new Semaphore(iCount, mCount, semName, out createdNew))
+ {
+ if (!createdNew)
+ bResult = false;
+ // Open another, createdNew = false
+ using (sem2 = new Semaphore(iCount, mCount, semName, out createdNew2))
+ {
+ if (createdNew2)
+ bResult = false;
+
+ if (iCount > 0)
+ {
+ sem2.WaitOne();
+ count--;
+ }
+
+ int iPrev = sem2.Release();
+ if (bResult && iPrev == count)
+ iRet = 100;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + ex.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.csproj
new file mode 100644
index 0000000000..3e8388b26f
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorector5.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:2147483647 /mCount:2147483647 /iRandom:220</CLRTestExecutionArguments>
+ </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="SemaphoreCtor5.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorectorneg1.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.cs
new file mode 100644
index 0000000000..f9386e1813
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.cs
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length != 2)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtorNeg1 /iCount:<int> /mCount:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1;
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount);
+ }
+
+ private int Run(int initCount, int maxCount)
+ {
+ int iRet = -1;
+ Semaphore sem = null;
+ try
+ {
+ using (sem = new Semaphore(initCount, maxCount))
+ {
+ Console.WriteLine("Semaphore was created!");
+ }
+ }
+ catch(ArgumentException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ // other exceptions are not valid
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.csproj
new file mode 100644
index 0000000000..ee0afa25da
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:-2147483647 /mCount:2147483647</CLRTestExecutionArguments>
+ </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="SemaphoreCtorNeg1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorectorneg2.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.cs
new file mode 100644
index 0000000000..f99c8769b6
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.cs
@@ -0,0 +1,93 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 3)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtorNeg2 /iCount:<int> /mCount:<int> " +
+ "/semName:<string> [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int initalValue, int maxValue, string semName, int iRandom)
+ {
+ int iRet = -1;
+ Semaphore sem = null;
+ if (iRandom > 0)
+ semName = Common.GenerateUnicodeString(iRandom);
+ try
+ {
+ using (sem = new Semaphore(initalValue, maxValue, semName))
+ {
+ Console.WriteLine("Semaphore was created!");
+ }
+ }
+ catch(ArgumentException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.csproj
new file mode 100644
index 0000000000..3d0de00beb
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg2.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:-1 /mCount:3 /semName:" "</CLRTestExecutionArguments>
+ </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="SemaphoreCtorNeg2.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphorectorneg3.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.cs
new file mode 100644
index 0000000000..724853c552
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.cs
@@ -0,0 +1,103 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class CtorTest
+{
+ public static int Main(string[] args)
+ {
+ // Check args
+ if (args.Length < 3)
+ {
+ Console.WriteLine("USAGE: SemaphoreCtorNeg3 /iCount:<int> /mCount:<int> " +
+ "[/semName:<string>] [/iRandom:<int>]");
+ return -1;
+ }
+
+ // Get the args
+ int iCount = -1, mCount = -1, iRandom = -1;
+ string semName = "DefaultString";
+
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i].ToLower().StartsWith("/icount:"))
+ {
+ iCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/mcount:"))
+ {
+ mCount = Convert.ToInt32(args[i].Substring(8));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/irandom:"))
+ {
+ iRandom = Convert.ToInt32(args[i].Substring(9));
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/semname:"))
+ {
+ semName = args[i].Substring(9);
+ if (semName.ToLower() == "null")
+ semName = null;
+ continue;
+ }
+
+ if (args[i].ToLower().StartsWith("/unisemname:"))
+ {
+ semName = string.Empty;
+ // Convert to unicode
+ string[] s = args[i].Substring(12).Split(';');
+ foreach (string str in s)
+ semName += Convert.ToChar(Convert.ToInt32(str));
+ continue;
+ }
+ }
+ CtorTest ct = new CtorTest();
+ return ct.Run(iCount, mCount, semName, iRandom);
+ }
+
+ private int Run(int initalValue, int maxValue, string semName,
+ int iRandom)
+ {
+ int iRet = -1;
+ Semaphore sem = null;
+ if (iRandom > 0)
+ {
+ //TestFramework.GlobalData intl = new TestFramework.GlobalData();
+ //semName = intl.GetString(iRandom, iRandom).Replace(@"\", "");
+ Console.WriteLine("WARNING: Random name generation is disabled");
+ }
+ bool bRet=true;
+ try
+ {
+ using (sem = new Semaphore(initalValue, maxValue, semName, out bRet))
+ {
+ if(bRet)
+ Console.WriteLine("Semaphore was created!");
+ }
+ }
+ catch(ArgumentException)
+ {
+ // Expected
+ if(bRet)
+ iRet = 100;
+ else
+ Console.WriteLine("Returned FALSE");
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.csproj
new file mode 100644
index 0000000000..778ea97af0
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphorectorneg3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/iCount:-2147483647 /mCount:-2147483647 /semName:null</CLRTestExecutionArguments>
+ </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="SemaphoreCtorNeg3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg1.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.cs
new file mode 100644
index 0000000000..d6bbb165a4
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Semaphore sem;
+ try
+ {
+ sem = Semaphore.OpenExisting(Common.GetUniqueName());
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.csproj
new file mode 100644
index 0000000000..44c362b239
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg1.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg2.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.cs
new file mode 100644
index 0000000000..a5ea955c49
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.cs
@@ -0,0 +1,40 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Semaphore sem;
+ try
+ {
+ using (sem = Semaphore.OpenExisting(""))
+ {
+ }
+ }
+ catch (ArgumentException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.csproj
new file mode 100644
index 0000000000..026767dc6e
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg2.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg3.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.cs
new file mode 100644
index 0000000000..6194222068
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.cs
@@ -0,0 +1,38 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Semaphore sem;
+ try
+ {
+ sem = Semaphore.OpenExisting(null);
+ }
+ catch (ArgumentNullException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.csproj
new file mode 100644
index 0000000000..d3869905ed
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg3.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg4.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.cs
new file mode 100644
index 0000000000..45f5db5ca9
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Semaphore sem;
+ try
+ {
+ String mySem = null;
+ sem = Semaphore.OpenExisting(mySem);
+ }
+ catch (ArgumentNullException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.csproj
new file mode 100644
index 0000000000..926a5a30c7
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg4.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg5.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.cs
new file mode 100644
index 0000000000..998c26179b
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a closed semaphore
+ try
+ {
+ using (Semaphore sem1 = new Semaphore(10, 10, sName))
+ {
+ }
+ Semaphore sem2 = Semaphore.OpenExisting(sName);
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.csproj
new file mode 100644
index 0000000000..4ffb5dd858
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg5.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg5.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg6.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.cs
new file mode 100644
index 0000000000..282c5c43d2
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.cs
@@ -0,0 +1,42 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a semaphore with the same name as a mutex
+ Mutex mu = new Mutex(false, sName);
+ try
+ {
+ using (Semaphore sem = Semaphore.OpenExisting(sName))
+ {
+ }
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.csproj
new file mode 100644
index 0000000000..45ded3c8f9
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg6.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg6.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/ctoropen/semaphoreopenneg7.cs b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.cs
new file mode 100644
index 0000000000..ff36723e14
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.cs
@@ -0,0 +1,43 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class OpenSemaphoreNeg
+{
+ public static int Main()
+ {
+ OpenSemaphoreNeg osn = new OpenSemaphoreNeg();
+ return osn.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ string sName = Common.GetUniqueName();
+ // open a semaphore with the same name as a mutex
+ EventWaitHandle ewh = new EventWaitHandle(false,
+ EventResetMode.AutoReset, sName);
+ try
+ {
+ using(Semaphore sem = Semaphore.OpenExisting(sName))
+ {
+ }
+ }
+ catch (WaitHandleCannotBeOpenedException)
+ {
+ //Expected
+ iRet = 100;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Caught unexpected exception: " +
+ e.ToString());
+ }
+
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.csproj b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.csproj
new file mode 100644
index 0000000000..9bd067c486
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/ctoropen/semaphoreopenneg7.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemaphoreOpenNeg7.cs" />
+ <Compile Include="..\SemaphoreCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/semaphorecommon.cs b/tests/src/baseservices/threading/semaphore/semaphorecommon.cs
new file mode 100644
index 0000000000..11f23caddb
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/semaphorecommon.cs
@@ -0,0 +1,36 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using 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/semaphore/unit/app.config b/tests/src/baseservices/threading/semaphore/unit/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/semaphore/unit/project.json b/tests/src/baseservices/threading/semaphore/unit/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/semaphore/unit/semdemo.cs b/tests/src/baseservices/threading/semaphore/unit/semdemo.cs
new file mode 100644
index 0000000000..9dc502f0f1
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/semdemo.cs
@@ -0,0 +1,88 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+
+using System;
+using System.Threading;
+
+class Test
+{
+ private Semaphore sem = null;
+ private const int numIterations = 1;
+ private const int numThreads = 10;
+ private int m_success;
+
+ static int Main()
+ {
+ Test t = new Test();
+ t.RunTest();
+ return t.CheckRet();
+
+ }
+
+ private void RunTest()
+ {
+ Semaphore s = new Semaphore(3,3);
+ sem = s;
+
+ Thread[] threads =new Thread[numThreads];
+
+ // Create the threads that will use the protected resource.
+ for(int i = 0; i < numThreads; i++)
+ {
+ threads[i] = new Thread(new ThreadStart(this.MyThreadProc));
+ threads[i].Name = String.Format("Thread{0}", i + 1);
+ threads[i].Start();
+ }
+
+ // The main thread exits, but the application continues to
+ // run until all foreground threads have exited.
+
+ for(int i =0; i< numThreads; i++) {
+ threads[i].Join();
+ }
+ }
+
+ private void MyThreadProc()
+ {
+ for(int i = 0; i < numIterations; i++)
+ {
+ UseResource();
+ }
+ }
+
+ private int CheckRet()
+ {
+ Console.WriteLine(m_success == numThreads ? "Test Passed":"Test Failed");
+ return (m_success == numThreads ? 100:-1);
+ }
+
+ private void Success()
+ {
+ Interlocked.Increment(ref m_success);
+ }
+
+ // This method represents a resource that must be synchronized
+ // so that only one thread at a time can enter.
+ private void UseResource()
+ {
+ // Wait until it is safe to enter.
+ sem.WaitOne();
+
+ Console.WriteLine("{0} has entered the protected area",
+ Thread.CurrentThread.Name);
+
+ // Place code to access non-reentrant resources here.
+
+ // Simulate some work.
+ Thread.Sleep(500);
+ Success();
+ Console.WriteLine("{0} is leaving the protected area\r\n",
+ Thread.CurrentThread.Name);
+
+ // Release the Mutex.
+ sem.Release();
+
+ }
+}
diff --git a/tests/src/baseservices/threading/semaphore/unit/semdemo.csproj b/tests/src/baseservices/threading/semaphore/unit/semdemo.csproj
new file mode 100644
index 0000000000..1e981bf0e8
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/semdemo.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemDemo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/semaphore/unit/semtest.cs b/tests/src/baseservices/threading/semaphore/unit/semtest.cs
new file mode 100644
index 0000000000..599f864927
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/semtest.cs
@@ -0,0 +1,190 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+
+using System;
+using System.Threading;
+
+class TestSemaphore
+{
+ const int intialCount = 10;
+ const int maximumCount = 10;
+
+ int successes;
+ int failures;
+ int expected;
+
+ public TestSemaphore()
+ {
+ successes = 0;
+ failures = 0;
+ expected = 8;
+ }
+
+ static int Main()
+ {
+ TestSemaphore myTest = new TestSemaphore();
+ myTest.NegativeTest();
+
+ myTest.FuncTest1();
+ myTest.FuncTest2();
+
+ myTest.FuncTest3();
+
+ return (myTest.CheckSuccess());
+ }
+
+ private int CheckSuccess()
+ {
+ if(successes == expected && failures == 0)
+ return 100;
+ return -1;
+ }
+
+ private void Failure(string message)
+ {
+ Console.WriteLine(message);
+ failures++;
+ }
+ private void Success()
+ {
+ successes++;
+ }
+
+ public void NegativeTest() {
+ try {
+ new Semaphore(-1, 0);
+ Failure("new Semaphore(-1, 0) Expected Exception is not thrown");
+ }
+ catch(ArgumentOutOfRangeException) {
+ Success();
+ }
+ catch {
+ Failure("UnExpected Exception thrown");
+ }
+
+ try {
+ new Semaphore(0, -1);
+ Failure("new Semaphore(0, -1) Expected Exception is not thrown");
+ }
+ catch(ArgumentOutOfRangeException) {
+ Success();
+ }
+ catch {
+ Failure("UnExpected Exception thrown");
+ }
+
+ try {
+ new Semaphore(1, 0);
+ Failure("new Semaphore(1, 0) Expected Exception is not thrown");
+ }
+ catch(ArgumentException) {
+ Success();
+ }
+ catch {
+ Failure("UnExpected Exception thrown");
+ }
+
+ }
+
+ public void FuncTest1() {
+ using (Semaphore sem = new Semaphore(intialCount, maximumCount))
+ {
+ sem.WaitOne();
+ int previousCount = sem.Release();
+ Console.WriteLine("Previous Count is {0}", previousCount);
+ if(previousCount != intialCount -1) {
+ Failure("Previous Count is not correct");
+ }
+ else
+ Success();
+
+ try {
+ sem.Release();
+ Failure("Expected Exception is not thrown");
+ }
+ catch(SemaphoreFullException) {
+ Success();
+ }
+ }
+
+ }
+
+ public void FuncTest2() {
+ using (Semaphore sem2 = new Semaphore(intialCount, maximumCount, "Semaphore_TESTSEM"))
+ {
+ bool createdNew;
+ using (Semaphore sem3 = new Semaphore(intialCount, maximumCount, "Semaphore_TESTSEM", out createdNew))
+ {
+ if( createdNew ) {
+ Failure("Error: we are not expecting a new semaphore here");
+ }
+ else
+ Success();
+ }
+
+ using (Semaphore sem4 = Semaphore.OpenExisting("Semaphore_TESTSEM"))
+ {
+ sem4.WaitOne();
+ sem4.WaitOne();
+ int previousCount = sem4.Release(2);
+ Console.WriteLine("Previous Count is {0}", previousCount);
+ if(previousCount != intialCount -2) {
+ Failure("Previous Count is not correct");
+ }
+ else
+ Success();
+ }
+ }
+ }
+
+ public void FuncTest3() {
+
+ Thread t = new Thread(new ThreadStart(Create));
+ Thread t2 = new Thread(new ThreadStart(Open));
+ __flag = false;
+ t.Start();
+ t2.Start();
+ t.Join();
+ t2.Join();
+
+
+ }
+ public bool __flag;
+
+ public void Create()
+ {
+ using (Semaphore sem = new Semaphore(intialCount, maximumCount, "Semaphore_TESTSEMOPEN"))
+ {
+ __flag = true;
+ while(__flag)
+ Thread.Sleep(0);
+ }
+ }
+
+ public void Open()
+ {
+ Semaphore sem4;
+ try{
+ while(!__flag)
+ Thread.Sleep(0);
+ using (sem4 = Semaphore.OpenExisting("Semaphore_TESTSEMOPEN"))
+ {
+ __flag = false;
+ Console.WriteLine("Opened on new thread");
+ Success();
+ sem4.WaitOne();
+ sem4.WaitOne();
+ }
+ }
+ catch(Exception e)
+ {
+ Failure(e.ToString());
+ }
+ finally
+ {
+ __flag = false;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/semaphore/unit/semtest.csproj b/tests/src/baseservices/threading/semaphore/unit/semtest.csproj
new file mode 100644
index 0000000000..48305ce6f1
--- /dev/null
+++ b/tests/src/baseservices/threading/semaphore/unit/semtest.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="SemTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/app.config b/tests/src/baseservices/threading/threadpool/bindhandle/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.cs
new file mode 100644
index 0000000000..b0fe11adc9
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.cs
@@ -0,0 +1,63 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+/// <summary>
+/// Verifies passing an invalid handle (not overlapped) to BindHandle works as expected
+/// </summary>
+class BindHandle1
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandle1().RunTest());
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ public static extern IntPtr CreateFile(String FileName, uint Access, uint Share, int Atts, uint Dispo, uint Flags, int Template);
+
+
+ int RunTest()
+ {
+ try
+ {
+ try
+ {
+ using (SafeFileHandle sfh = new SafeFileHandle(CreateFile("test.txt", 0x40000000, 0, 0, 2, 0x40000000, 0), true))
+ {
+ if (ThreadPool.BindHandle(sfh))
+ {
+ Console.WriteLine("BindHandle call succeeded");
+ }
+ else
+ {
+ Console.WriteLine("Unexpected: BindHandle call failed");
+ return (98);
+ }
+
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Unexpected exception: {0}", ex);
+ return (98);
+ }
+ }
+ finally
+ {
+ if (File.Exists("test.txt"))
+ {
+ File.Delete("test.txt");
+ }
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.csproj
new file mode 100644
index 0000000000..fcaaf5f0a3
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandle1.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandle1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandleinvalid.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.cs
new file mode 100644
index 0000000000..a388d6c671
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using Microsoft.Win32.SafeHandles;
+
+class BindHandleInvalid
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandleInvalid().RunTest());
+ }
+
+ int RunTest()
+ {
+ SafeFileHandle sfh = new SafeFileHandle(IntPtr.Zero, false);
+
+ try
+ {
+ ThreadPool.BindHandle(sfh);
+ }
+ catch (Exception ex)
+ {
+ if (ex.ToString().IndexOf("0x80070006") != -1) // E_HANDLE, we can't access hresult
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ else
+ {
+ Console.WriteLine("Got wrong error: {0}", ex);
+ }
+ }
+ Console.WriteLine("Didn't get argument null exception");
+ return (99);
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.csproj
new file mode 100644
index 0000000000..d17f9301bd
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleInvalid.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandleinvalid3.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.cs
new file mode 100644
index 0000000000..519c843523
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.cs
@@ -0,0 +1,62 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+/// <summary>
+/// Verifies passing an invalid handle (not overlapped) to BindHandle works as expected
+/// </summary>
+class BindHandleInvalid3
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandleInvalid3().RunTest());
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ public static extern IntPtr CreateFile(String FileName, uint Access, uint Share, int Atts, uint Dispo, uint Flags, int Template);
+
+
+ int RunTest()
+ {
+ try
+ {
+ try
+ {
+ using (SafeFileHandle sfh = new SafeFileHandle(CreateFile("test.txt", 0x40000000, 0, 0, 2, 0x80, 0), true))
+ {
+
+ ThreadPool.BindHandle(sfh);
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.ToString().IndexOf("0x80070057") != -1) // E_INVALIDARG, the handle isn't overlapped
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ else
+ {
+ Console.WriteLine("Got wrong error: {0}", ex);
+ }
+ }
+ }
+ finally
+ {
+ if (File.Exists("test.txt"))
+ {
+ File.Delete("test.txt");
+ }
+ }
+ Console.WriteLine("Didn't get argument null exception");
+ return (99);
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.csproj
new file mode 100644
index 0000000000..2671dbb365
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid3.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleInvalid3.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandleinvalid4.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.cs
new file mode 100644
index 0000000000..ebfde369f5
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.cs
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+/// <summary>
+/// Verifies passing an invalid handle (not overlapped) to BindHandle works as expected
+/// </summary>
+class BindHandleInvalid3
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandleInvalid3().RunTest());
+ }
+
+ int RunTest()
+ {
+ try
+ {
+ try
+ {
+ using (FileStream fs1 = new FileStream("test.txt", FileMode.Create))
+ {
+ ThreadPool.BindHandle(fs1.SafeFileHandle);
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.ToString().IndexOf("0x80070057") != -1) // E_INVALIDARG, the handle isn't overlapped
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ else
+ {
+ Console.WriteLine("Got wrong error: {0}", ex);
+ }
+ }
+ }
+ finally
+ {
+ if (File.Exists("test.txt"))
+ {
+ File.Delete("test.txt");
+ }
+ }
+ Console.WriteLine("Didn't get argument null exception");
+ return (99);
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.csproj
new file mode 100644
index 0000000000..e3f04342e1
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid4.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleInvalid4.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandleinvalid5.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.cs
new file mode 100644
index 0000000000..64f55a1750
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.cs
@@ -0,0 +1,63 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+/// <summary>
+/// Verifies passing an invalid handle (not overlapped) to BindHandle works as expected
+/// </summary>
+class BindHandleInvalid3
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandleInvalid3().RunTest());
+ }
+
+ int RunTest()
+ {
+ try
+ {
+ try
+ {
+ using (FileStream fs1 = new FileStream("test.txt",
+ FileMode.Create,
+ FileAccess.ReadWrite,
+ FileShare.ReadWrite,
+ 0x10000,
+ true))
+ {
+
+ ThreadPool.BindHandle(fs1.SafeFileHandle);
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.ToString().IndexOf("0x80070057") != -1) // E_INVALIDARG, we've already bound the handle.
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ else
+ {
+ Console.WriteLine("Got wrong error: {0}", ex);
+ }
+ }
+ }
+ finally
+ {
+ if (File.Exists("test.txt"))
+ {
+ File.Delete("test.txt");
+ }
+ }
+ Console.WriteLine("Didn't get argument null exception");
+ return (99);
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.csproj
new file mode 100644
index 0000000000..78914cf051
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid5.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleInvalid5.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandleinvalid6.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.cs
new file mode 100644
index 0000000000..7700cc28c1
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.cs
@@ -0,0 +1,78 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.IO;
+using System.Runtime.InteropServices;
+using Microsoft.Win32.SafeHandles;
+
+/// <summary>
+/// Verifies passing an invalid handle (not overlapped) to BindHandle works as expected
+/// </summary>
+class BindHandle1
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandle1().RunTest());
+ }
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+ public static extern IntPtr CreateFile(String FileName, uint Access, uint Share, int Atts, uint Dispo, uint Flags, int Template);
+
+ int RunTest()
+ {
+ try
+ {
+ try
+ {
+ using (SafeFileHandle sfh = new SafeFileHandle(CreateFile("test.txt", 0x40000000, 0, 0, 2, 0x40000000, 0), true))
+ {
+
+ try
+ {
+ if (ThreadPool.BindHandle(sfh))
+ {
+ Console.WriteLine("BindHandle call succeeded");
+ }
+ else
+ {
+ Console.WriteLine("Unexpected: BindHandle call failed");
+ return (98);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unexpected exception on 1st call: {0}", e);
+ return (92);
+ }
+
+ ThreadPool.BindHandle(sfh);
+ }
+ }
+ catch (Exception ex)
+ {
+ if (ex.ToString().IndexOf("0x80070057") != -1) // E_INVALIDARG, we've already bound the handle.
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ else
+ {
+ Console.WriteLine("Got wrong error: {0}", ex);
+ }
+ }
+ }
+ finally
+ {
+ if (File.Exists("test.txt"))
+ {
+ File.Delete("test.txt");
+ }
+ }
+ return (99);
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.csproj
new file mode 100644
index 0000000000..4df9d661d9
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandleinvalid6.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleInvalid6.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/bindhandlenull.cs b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.cs
new file mode 100644
index 0000000000..3eaee3d126
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.cs
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class BindHandleNull
+{
+ public static int Main(string[] args)
+ {
+ return (new BindHandleNull().RunTest());
+ }
+
+ int RunTest()
+ {
+ try
+ {
+ ThreadPool.BindHandle(null);
+ }
+ catch (ArgumentNullException)
+ {
+ Console.WriteLine("Test passed");
+ return (100);
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected: {0}", e);
+ return (98);
+ }
+ return (97);
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.csproj b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.csproj
new file mode 100644
index 0000000000..fad59546d0
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/bindhandlenull.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="BindHandleNull.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/bindhandle/project.json b/tests/src/baseservices/threading/threadpool/bindhandle/project.json
new file mode 100644
index 0000000000..5aea493104
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/bindhandle/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/ctorchk/app.config b/tests/src/baseservices/threading/threadpool/ctorchk/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/ctorchk/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.cs b/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.cs
new file mode 100644
index 0000000000..957fe73470
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.cs
@@ -0,0 +1,30 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using System.Reflection;
+
+class TestMonitor
+{
+ public static int Main()
+ {
+ // This will look for any private constructor.
+ // There shouldn't be one in Whidbey.
+ ConstructorInfo[] m = typeof(ThreadPool).GetConstructors(
+ BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public );
+ Console.WriteLine(m.Length);
+
+ if(m.Length > 0)
+ {
+ Console.WriteLine("Test FAILED!");
+ return 1;
+ }
+ else
+ {
+ Console.WriteLine("Test PASSED!");
+ return 100;
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.csproj b/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.csproj
new file mode 100644
index 0000000000..31b06207a1
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/ctorchk/ctorchk.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="CtorChk.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/ctorchk/project.json b/tests/src/baseservices/threading/threadpool/ctorchk/project.json
new file mode 100644
index 0000000000..5aea493104
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/ctorchk/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/unregister/app.config b/tests/src/baseservices/threading/threadpool/unregister/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/threadpool/unregister/project.json b/tests/src/baseservices/threading/threadpool/unregister/project.json
new file mode 100644
index 0000000000..5aea493104
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/project.json
@@ -0,0 +1,36 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/threadpool/unregister/regression_749068.cs b/tests/src/baseservices/threading/threadpool/unregister/regression_749068.cs
new file mode 100644
index 0000000000..4f9deaab3b
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/regression_749068.cs
@@ -0,0 +1,137 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Threading;
+
+/************************
+ * Regression test for bug Bug 749068:WatsonCrash: coreclr.dll!Thread::DoAppropriateWaitWorker -- APPLICATION_HANG_BlockedOn_EventHandle c0000194
+ *
+ * Should be run with complus_GCStress=3
+ *
+ * During GC, no IO completion threads are created. So if there was no IO completion thread to begin with,
+ * there will be no threads monitoring the event which signals to schedule the corresponding callback,
+ * this blocks whatever code, which is waiting for the callback to finish or unregister it, indefinitely
+ *
+ ************************/
+namespace Prog
+{
+ class Callback
+ {
+ ManualResetEvent sessionNotification;
+ RegisteredWaitHandle sessionRegisteredWait;
+ public Callback()
+ {
+ this.sessionRegisteredWait = null;
+ this.sessionNotification = null;
+ }
+ public void ServiceCallbackOnPositionAvailable(Object state, bool timedOut)
+ {
+
+ if (this.sessionRegisteredWait == null)
+ {
+ this.sessionNotification.Reset();
+ this.sessionRegisteredWait.Unregister(null);
+
+ this.sessionRegisteredWait =
+ ThreadPool.RegisterWaitForSingleObject(this.sessionNotification,
+ ServiceCallbackOnPositionAvailable,
+ this, /* object state */
+ -1, /* INFINITE */
+ true /* ExecuteOnlyOnce */);
+
+ }
+ Console.WriteLine("callback running");
+
+ }
+ public void call()
+ {
+ if (this.sessionNotification != null)
+ this.sessionNotification.Set();
+ }
+ public void register()
+ {
+
+
+ this.sessionNotification = new ManualResetEvent(false);
+
+ this.sessionRegisteredWait = ThreadPool.RegisterWaitForSingleObject(
+ this.sessionNotification,
+ ServiceCallbackOnPositionAvailable,
+ this, /* object state */
+ -1, /* INFINITE */
+ true /* ExecuteOnlyOnce */);
+
+
+ }
+ public bool unregister()
+ {
+ ManualResetEvent callbackThreadComplete = new ManualResetEvent(false);
+ int timeToWait = 5000; //milliseconds
+ System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
+ sw.Start();
+ if (this.sessionRegisteredWait != null)
+ {
+ if (this.sessionRegisteredWait.Unregister(callbackThreadComplete))
+ {
+ Console.WriteLine("waiting on succesful unregister");
+ callbackThreadComplete.WaitOne(timeToWait);
+ }
+ }
+ this.sessionRegisteredWait = null;
+
+ long elapsed = sw.ElapsedMilliseconds;
+ Console.WriteLine("Elapsed: {0} millisec", elapsed);
+ if (elapsed >= timeToWait)
+ {
+ Console.WriteLine("Error. Callback was not signaled");
+ return false;
+ }
+ else
+ {
+ Console.WriteLine("Success");
+ return true;
+ }
+
+
+
+
+ }
+
+
+ }
+
+
+ class Program
+ {
+
+ static int Main(string[] args)
+ {
+ Callback obj = new Callback();
+
+ Console.WriteLine("start");
+ obj.register();
+
+ obj.call();
+ bool success = obj.unregister();
+
+ Console.WriteLine("end");
+ if (success)
+ {
+ Console.WriteLine("test passed");
+ return 100;
+ }
+ else
+ {
+ Console.WriteLine("test failed");
+ return 2;
+ }
+
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/threadpool/unregister/regression_749068.csproj b/tests/src/baseservices/threading/threadpool/unregister/regression_749068.csproj
new file mode 100644
index 0000000000..903dc771bb
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/regression_749068.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Regression_749068.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/unregister/unregister01.cs b/tests/src/baseservices/threading/threadpool/unregister/unregister01.cs
new file mode 100644
index 0000000000..ad70603379
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/unregister01.cs
@@ -0,0 +1,64 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#region Using directives
+
+
+
+using System;
+
+using System.Collections.Generic;
+
+using System.Text;
+
+using System.Threading;
+
+
+
+#endregion
+
+
+
+namespace UnregisterWaitNativeBug
+{
+ class Program
+ {
+ public int ret = 0;
+ RegisteredWaitHandle[] regWait;
+ static int Main(string[] args)
+ {
+ Program p = new Program();
+ p.Run();
+ Console.WriteLine(100 == p.ret ? "Test Passed" : "Test Failed");
+ return p.ret;
+ }
+ public void Run()
+ {
+ int size = 100;
+ AutoResetEvent[] are = new AutoResetEvent[size];
+ regWait = new RegisteredWaitHandle[size];
+
+ for (int i = 0; i < size; i++)
+ {
+ are[i] = new AutoResetEvent(false);
+ regWait[i] = ThreadPool.RegisterWaitForSingleObject((WaitHandle)are[i], new WaitOrTimerCallback(TheCallBack), are[i], -1, false);
+ }
+
+ for (int i = 0; i < size; i++)
+ {
+ are[i].Set();
+ }
+ Thread.Sleep(1000);
+ for (int i = 0; i < size; i++)
+ {
+ regWait[i].Unregister(are[i]);
+ }
+ }
+ public void TheCallBack(object foo, bool state)
+ {
+ Interlocked.Increment(ref ret);
+ }
+ }
+}
+
diff --git a/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj b/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj
new file mode 100644
index 0000000000..ef700c1fa1
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Unregister01.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadpool/unregister/unregister03.cs b/tests/src/baseservices/threading/threadpool/unregister/unregister03.cs
new file mode 100644
index 0000000000..6454964f69
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/unregister03.cs
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#region Using directives
+
+
+
+using System;
+
+using System.Collections.Generic;
+
+using System.Text;
+
+using System.Threading;
+
+
+
+#endregion
+
+
+
+namespace UnregisterWaitNativeBug
+{
+ class Program
+ {
+ public int ret = 0;
+ RegisteredWaitHandle[] regWait;
+ static int Main(string[] args)
+ {
+ Program p = new Program();
+ p.Run();
+ Console.WriteLine(100 == p.ret ? "Test Passed" : "Test Failed");
+ return p.ret;
+ }
+ public void Run()
+ {
+ int size = 100;
+ AutoResetEvent[] are = new AutoResetEvent[size];
+ regWait = new RegisteredWaitHandle[size];
+
+ for (int i = 0; i < size; i++)
+ {
+ are[i] = new AutoResetEvent(false);
+ regWait[i] = ThreadPool.RegisterWaitForSingleObject((WaitHandle)are[i], new WaitOrTimerCallback(TheCallBack), are[i], -1, false);
+ }
+
+ for (int i = 0; i < size; i++)
+ {
+ are[i].Set();
+ are[i] = null;
+ }
+ Thread.Sleep(1000);
+ for (int i = 0; i < size; i++)
+ {
+ regWait[i].Unregister(are[i]);
+ }
+ }
+ public void TheCallBack(object foo, bool state)
+ {
+ Interlocked.Increment(ref ret);
+ }
+ }
+}
+
diff --git a/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj b/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj
new file mode 100644
index 0000000000..48ccc8d32d
--- /dev/null
+++ b/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="Unregister03.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/threadstatic/project.json b/tests/src/baseservices/threading/threadstatic/project.json
index a2e84dc340..f364fe9bb1 100644
--- a/tests/src/baseservices/threading/threadstatic/project.json
+++ b/tests/src/baseservices/threading/threadstatic/project.json
@@ -24,6 +24,7 @@
"System.Text.Encoding": "4.0.10",
"System.Threading": "4.0.10",
"System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Threading.ThreadPool": "4.0.10-rc2-23816",
"System.Xml.ReaderWriter": "4.0.11-rc2-23816",
"System.Xml.XDocument": "4.0.11-rc2-23816",
"System.Xml.XmlDocument": "4.0.1-rc2-23816",
diff --git a/tests/src/baseservices/threading/threadstatic/threadstatic07.cs b/tests/src/baseservices/threading/threadstatic/threadstatic07.cs
new file mode 100644
index 0000000000..600c6f6df4
--- /dev/null
+++ b/tests/src/baseservices/threading/threadstatic/threadstatic07.cs
@@ -0,0 +1,221 @@
+//Test is checking the ReserveSlot function
+// If someone screws up the function we will end up
+// setting values in the wrong slots and the totals will be wrong
+
+using System;
+using System.IO;
+using System.Threading;
+
+// Test Description:
+// Just basic heavy reading and writing from ThreadStatic members in normal threads and threadpools threads as well.
+// Ported from desktop test: BaseServices\Regression\V1\Threads\ThreadStatic\threadstatic1.cs
+
+public class Sensor
+{
+ [ThreadStatic]
+ static int A = 1;
+ [ThreadStatic]
+ static int B = 2;
+ [ThreadStatic]
+ static int C = 3;
+ [ThreadStatic]
+ static int D = 4;
+ [ThreadStatic]
+ static DateTime T = DateTime.Now;
+ [ThreadStatic]
+ static String S = "John Stockton";
+
+ static volatile int AA = -1;
+ static volatile int BB = -2;
+ static volatile int CC = -3;
+ static volatile int DD = -4;
+ static DateTime TT = DateTime.Now;
+ static String SS = "Karl Malone";
+ static volatile int Result = 100;
+
+ [ThreadStatic]
+ static int AAA = 5;
+ [ThreadStatic]
+ static int BBB = 6;
+ [ThreadStatic]
+ static int CCC = 7;
+ [ThreadStatic]
+ static int DDD = 8;
+ [ThreadStatic]
+ static DateTime TTT = DateTime.Now;
+ [ThreadStatic]
+ static String SSS = "Olden Polynice";
+
+ public static int Main(string[] args)
+ {
+ Console.WriteLine("Hello NBA Fans!!");
+ Console.WriteLine("ThreadStatic test 2: Various reading and writing of Threadstatic variables.");
+ Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+
+ ValueMess1();
+
+ StartThread();
+ if (Result != 100)
+ {
+ Console.WriteLine("Test Failed.");
+ }
+ else
+ {
+ Console.WriteLine("Test Succeeded.");
+ }
+
+ return Result;
+ }
+
+ public static void StartThread()
+ {
+ Thread SimulationThread;
+ Thread SimulationThread2;
+ Thread SimulationThread3;
+ Thread SimulationThread4;
+ Thread SimulationThread5;
+ Thread SimulationThread6;
+
+ ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFunc2), null);
+ ValueMess2();
+
+ ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFunc2), null);
+
+ ValueMess2();
+ SimulationThread = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread.Start();
+
+ ValueMess2();
+ SimulationThread2 = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread2.Start();
+
+ ValueMess2();
+ SimulationThread3 = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread3.Start();
+
+ ValueMess2();
+ SimulationThread4 = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread4.Start();
+
+ ValueMess2();
+ SimulationThread5 = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread5.Start();
+
+ ValueMess2();
+ SimulationThread6 = new Thread(new ThreadStart(ThreadFunc));
+ SimulationThread6.Start();
+ Thread.Sleep(500);
+ SimulationThread6.Join();
+
+ ValueMess1();
+ Console.WriteLine("Main A: {0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("Main AA: {0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+ Console.WriteLine("Main AAA: {0}, {1}, {2}, {3}, {4}, {5}", AAA, BBB, CCC, DDD, TTT, SSS);
+ int Y = Thread.CurrentThread.GetHashCode();
+ int X = (A ^ Y) | (B ^ Y) | (C ^ Y) |(D ^ Y)| (AAA ^ Y) | (BBB ^ Y) | (CCC ^ Y) |(DDD ^ Y);
+ Console.WriteLine("X: {0}, {1}", X, S);
+
+ if (X != 0)
+ {
+ Console.WriteLine("Something went wrong in thread: {0}", S);
+ Result = 700 + Y;
+ }
+ }
+
+ public static void ThreadFunc()
+ {
+ Console.WriteLine("ThreadStarted.. {0}", Thread.CurrentThread.GetHashCode().ToString());
+ Console.WriteLine("A: {0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("AA: {0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+ Console.WriteLine("AAA: {0}, {1}, {2}, {3}, {4}, {5}", AAA, BBB, CCC, DDD, TTT, SSS);
+
+ ValueMess1();
+
+ Console.WriteLine("A: {0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("AA: {0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+ Console.WriteLine("AAA: {0}, {1}, {2}, {3}, {4}, {5}", AAA, BBB, CCC, DDD, TTT, SSS);
+
+ int Y = Thread.CurrentThread.GetHashCode();
+ int X = (A ^ Y) | (B ^ Y) | (C ^ Y) |(D ^ Y)| (AAA ^ Y) | (BBB ^ Y) | (CCC ^ Y) |(DDD ^ Y);
+ Console.WriteLine("X: {0}, {1}", X, S);
+
+ if (X != 0)
+ {
+ Console.WriteLine("Something went wrong in thread: {0}", S);
+ Result = 700 + Y;
+ }
+ }
+
+ public static void ThreadFunc2(Object O)
+ {
+ Console.WriteLine("Threadpool Started.. {0}", Thread.CurrentThread.GetHashCode().ToString());
+ Console.WriteLine("TP A: {0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("TP AA: {0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+ Console.WriteLine("TP AAA: {0}, {1}, {2}, {3}, {4}, {5}", AAA, BBB, CCC, DDD, TTT, SSS);
+
+ ValueMess1();
+
+ Console.WriteLine("TP A: {0}, {1}, {2}, {3}, {4}, {5}", A, B, C, D, T, S);
+ Console.WriteLine("TP AA: {0}, {1}, {2}, {3}, {4}, {5}", AA, BB, CC, DD, TT, SS);
+ Console.WriteLine("TP AAA: {0}, {1}, {2}, {3}, {4}, {5}", AAA, BBB, CCC, DDD, TTT, SSS);
+
+ int Y = Thread.CurrentThread.GetHashCode();
+ int X = (A ^ Y) | (B ^ Y) | (C ^ Y) |(D ^ Y)| (AAA ^ Y) | (BBB ^ Y) | (CCC ^ Y) |(DDD ^ Y);
+ Console.WriteLine("X: {0}, {1}", X, S);
+
+ if (X != 0)
+ {
+ Console.WriteLine("Something went wrong in thread: {0}", S);
+ Result = 700 + Y;
+ }
+ }
+
+ public static void ValueMess1()
+ {
+ A = Thread.CurrentThread.GetHashCode();
+ B = Thread.CurrentThread.GetHashCode();
+ C = Thread.CurrentThread.GetHashCode();
+ D = Thread.CurrentThread.GetHashCode();
+ T = DateTime.Now;
+ S = Thread.CurrentThread.GetHashCode().ToString();
+
+ AA = Thread.CurrentThread.GetHashCode();
+ BB = Thread.CurrentThread.GetHashCode();
+ CC = Thread.CurrentThread.GetHashCode();
+ DD = Thread.CurrentThread.GetHashCode();
+ TT = DateTime.Now;
+ SS = Thread.CurrentThread.GetHashCode().ToString();
+
+ AAA = Thread.CurrentThread.GetHashCode();
+ BBB = Thread.CurrentThread.GetHashCode();
+ CCC = Thread.CurrentThread.GetHashCode();
+ DDD = Thread.CurrentThread.GetHashCode();
+ TTT = DateTime.Now;
+ SSS = Thread.CurrentThread.GetHashCode().ToString();
+ }
+
+ public static void ValueMess2()
+ {
+ A = -Thread.CurrentThread.GetHashCode();
+ B = -Thread.CurrentThread.GetHashCode();
+ C = -Thread.CurrentThread.GetHashCode();
+ D = -Thread.CurrentThread.GetHashCode();
+ T = DateTime.Now;
+ S = Thread.CurrentThread.GetHashCode().ToString();
+
+ AA = -Thread.CurrentThread.GetHashCode();
+ BB = -Thread.CurrentThread.GetHashCode();
+ CC = -Thread.CurrentThread.GetHashCode();
+ DD = -Thread.CurrentThread.GetHashCode();
+ TT = DateTime.Now;
+ SS = Thread.CurrentThread.GetHashCode().ToString();
+
+ AAA = -Thread.CurrentThread.GetHashCode();
+ BBB = -Thread.CurrentThread.GetHashCode();
+ CCC = -Thread.CurrentThread.GetHashCode();
+ DDD = -Thread.CurrentThread.GetHashCode();
+ TTT = DateTime.Now;
+ SSS = Thread.CurrentThread.GetHashCode().ToString();
+ }
+}
diff --git a/tests/src/baseservices/threading/threadstatic/threadstatic07.csproj b/tests/src/baseservices/threading/threadstatic/threadstatic07.csproj
new file mode 100644
index 0000000000..a0c5be57bb
--- /dev/null
+++ b/tests/src/baseservices/threading/threadstatic/threadstatic07.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="threadstatic07.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/misc/app.config b/tests/src/baseservices/threading/waithandle/misc/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/waithandle/misc/project.json b/tests/src/baseservices/threading/waithandle/misc/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.cs b/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.cs
new file mode 100644
index 0000000000..c6dda93a8b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.cs
@@ -0,0 +1,100 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+/// <summary>
+/// System.IDisposable.Dispose
+/// </summary>
+
+// Tests disposing of a WaitHandle-derived type
+// via the IDisposable interface.
+// This test is ok for Desktop, but
+// SL does not support Mutex
+public class WaitHandleDispose2
+{
+ #region Public Constants
+ public const int c_DEFAULT_WAIT_TIME = 1000; // 1 second
+ #endregion
+
+#region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ public bool PosTest1()
+ {
+ bool retVal = false;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: Call Dispose");
+
+ try
+ {
+ // Mutex derives from WaitHandle,
+ // and normally you don't create a WaitHandle
+ WaitHandle handle = new Mutex();
+
+ // used to do a cast to IDisposable, but
+ // now WaitHandle implements the IDisposable
+ // interface directly
+ IDisposable disposable = handle as IDisposable;
+ disposable.Dispose();
+
+ // Dispose
+ //handle.Dispose();
+
+ // Do a waitone on the handle, should immediately throw
+ // ObjectDisposedException
+ handle.WaitOne(c_DEFAULT_WAIT_TIME);
+
+ // if we get here, it wasn't disposed of, error
+ TestLibrary.TestFramework.LogError("001", "handle.Dispose() did not dispose of the handle");
+ retVal = false;
+ }
+ catch (ObjectDisposedException)
+ {
+ // swallow it, this is where we wanted to go
+ retVal = true;
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ [System.Security.SecurityCritical]
+ public static int Main()
+ {
+ WaitHandleDispose2 test = new WaitHandleDispose2();
+
+ TestLibrary.TestFramework.BeginTestCase("WaitHandleDispose2");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.csproj b/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.csproj
new file mode 100644
index 0000000000..37e29deb19
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/waithandledispose2.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitHandleDispose2.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/waithandle/misc/waithandlewaitone1.cs b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.cs
new file mode 100644
index 0000000000..c8815fff85
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.cs
@@ -0,0 +1,292 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+/// <summary>
+/// WaitOne
+/// </summary>
+
+// Verifies that WaitOne can acquire a
+// mutex, that calling it while the mutex is held will
+// cause a thread to block, that if the mutex is
+// never released then WaitOne throws an
+// AbandonedMutexException, and that calling it on a
+// disposed-of mutex throws ObjectDisposedException
+// this test works for Orcas and Client, but Mutex
+// is not supported for Silverlight.
+public class WaitHandleWaitOne1
+{
+ #region Private Fields
+ private const int c_DEFAULT_SLEEP_TIME = 5000; // 1 second
+
+ private WaitHandle m_Handle = null;
+ #endregion
+
+ #region Public Methods
+ public bool RunTests()
+ {
+ bool retVal = true;
+
+ TestLibrary.TestFramework.LogInformation("[Positive]");
+ retVal = PosTest1() && retVal;
+
+ TestLibrary.TestFramework.LogInformation("[Negative]");
+ retVal = NegTest1() && retVal;
+ retVal = NegTest2() && retVal;
+
+ return retVal;
+ }
+
+ #region Positive Test Cases
+ // this one tests that a WaitOne will wait on a Mutex
+ // and then grab it when it is free
+ public bool PosTest1()
+ {
+ bool retVal = false;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("PosTest1: WaitOne returns true when current instance receives a signal");
+
+ // m_Handle is of type WaitHandle
+ // Mutex is a subclass of WaitHandle
+ using(m_Handle = new Mutex())
+ {
+ try
+ {
+ // Spin up a thread. SignalMutex grabs
+ // the Mutex, then goes to sleep for 5 seconds. It
+ // only releases the mutex after sleeping for those
+ // 5 seconds
+ thread = new Thread(new ThreadStart(SignalMutex));
+ // Start it
+ thread.Start();
+ // Then put this calling thread to sleep
+ // for one second so that it doesn't beat the spawned
+ // thread to the mutex
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ // Now, the spawned thread should already
+ // have the mutex and be sleeping on it for several
+ // seconds. try to grab the mutex now. We should
+ // simply block until the other thread releases it,
+ // then we should get it.
+ // Net result, we should get true back from WaitOne
+ if (m_Handle.WaitOne() != true)
+ {
+ TestLibrary.TestFramework.LogError("001", "WaitOne returns false when current instance receives a signal.");
+ retVal = false;
+
+ }
+ else
+ {
+ // got the mutex ok
+ retVal = true;
+ }
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ // Wait for the thread to terminate
+ if (null != thread)
+ {
+ // Wait on that thread
+ thread.Join();
+ }
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+
+ #region Negative Test Cases
+ // this one just tests that a WaitOne will receive
+ // a AbandonedMutexException
+ public bool NegTest1()
+ {
+ bool retVal = false;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest1: AbandonedMutexException should be thrown if a thread exited without releasing a mutex");
+
+ // m_Handle is of type WaitHandle
+ // Mutex is a subclass of WaitHandle
+ using(m_Handle = new Mutex())
+ {
+ try
+ {
+ // Spin up a thread. SignalMutex grabs
+ // the Mutex, then goes to sleep for 5 seconds.
+ thread = new Thread(new ThreadStart(NeverReleaseMutex));
+ // Start it
+ thread.Start();
+ // Then put this calling thread to sleep
+ // for just over one second so that it doesn't beat
+ // the spawned thread to the mutex
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 3); // To avoid race
+ // Now, the spawned thread should already
+ // have the mutex and be sleeping on it forever.
+ // try to grab the mutex now. We should simply block until
+ // the other thread releases it, which is never. When that
+ // thread returns from its method, an AbandonedMutexException
+ // should be thrown instead
+ m_Handle.WaitOne();
+
+ // We should not get here
+ TestLibrary.TestFramework.LogError("101", "AbandonedMutexException is not thrown if a thread exited without releasing a mutex");
+ retVal = false;
+ }
+ catch (AbandonedMutexException)
+ {
+ // Swallow it, this is where we want
+ // the test to go
+ retVal = true;
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ // The spawned thread is still running.
+ // Join on it until it is done
+ thread.Join();
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ // this one just tests that WaitOne will receive an
+ // ObjectDisposedException if the Mutex is disposed of
+ // by the spawned thread while WaitOne is waiting on it
+ public bool NegTest2()
+ {
+ bool retVal = false;
+ Thread thread = null;
+
+ TestLibrary.TestFramework.BeginScenario("NegTest2: ObjectDisposedException should be thrown if current instance has already been disposed");
+
+ try
+ {
+ // m_Handle is of type WaitHandle
+ // Mutex is a subclass of WaitHandle
+ m_Handle = new Mutex();
+
+ // Spin up a thread. DisposeMutex
+ // simply tries to dispose of the mutex.
+ thread = new Thread(new ThreadStart(DisposeMutex));
+ // Start it
+ thread.Start();
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME / 5); // To avoid race
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ // Now, the spawned thread should have
+ // had plenty of time to dispose of the mutex
+ // Calling WaitOne at this point should result
+ // in an ObjectDisposedException being thrown
+ m_Handle.WaitOne();
+
+ // We should not get here
+ TestLibrary.TestFramework.LogError("103", "ObjectDisposedException is not thrown if current instance has already been disposed");
+ retVal = false;
+ }
+ catch (ObjectDisposedException)
+ {
+ // Swallow it, this is where we want
+ // the test to go
+ retVal = true;
+ }
+ catch (Exception e)
+ {
+ TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
+ TestLibrary.TestFramework.LogInformation(e.StackTrace);
+ retVal = false;
+ }
+ finally
+ {
+ if (null != thread)
+ {
+ // Wait for the spawned thread to finish
+ // cleaning up
+ thread.Join();
+ }
+
+ if (null != m_Handle)
+ {
+ // spawned thread was unable to dispose of it
+ ((IDisposable)m_Handle).Dispose();
+ }
+ }
+
+ return retVal;
+ }
+ #endregion
+ #endregion
+
+ public static int Main()
+ {
+ WaitHandleWaitOne1 test = new WaitHandleWaitOne1();
+
+ TestLibrary.TestFramework.BeginTestCase("WaitHandleWaitOne1");
+
+ if (test.RunTests())
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("PASS");
+ return 100;
+ }
+ else
+ {
+ TestLibrary.TestFramework.EndTestCase();
+ TestLibrary.TestFramework.LogInformation("FAIL");
+ return 0;
+ }
+ }
+
+ #region Private Methods
+ private void SignalMutex()
+ {
+ // Request ownership of the mutex.
+ // You can use the WaitHandle.WaitOne
+ // method to request ownership of a mutex. Block
+ // until m_Handle receives a signal
+ m_Handle.WaitOne();
+ // Put this thread to sleep
+ // for 5 seconds
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ // Then release the mutex
+ (m_Handle as Mutex).ReleaseMutex();
+ }
+
+ private void NeverReleaseMutex()
+ {
+ // Request ownership of the mutex.
+ // You can use the WaitHandle.WaitOne
+ // method to request ownership of a mutex. Block
+ // until m_Handle receives a signal
+ m_Handle.WaitOne();
+ // Put this thread to sleep
+ // for 5 seconds
+ Thread.Sleep(c_DEFAULT_SLEEP_TIME);
+ // And we never release
+ // the mutex
+ }
+
+ private void DisposeMutex()
+ {
+ ((IDisposable)m_Handle).Dispose();
+ }
+ #endregion
+}
diff --git a/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj
new file mode 100644
index 0000000000..3fad3f285a
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitHandleWaitOne1.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="project.json" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="$(SourceDir)\Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj">
+ <Project>{8ffe99c0-22f8-4462-b839-970eac1b3472}</Project>
+ <Name>coreclr</Name>
+ </ProjectReference>
+ </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/waithandle/waitall/app.config b/tests/src/baseservices/threading/waithandle/waitall/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/waithandle/waitall/emptyarray.cs b/tests/src/baseservices/threading/waithandle/waitall/emptyarray.cs
new file mode 100644
index 0000000000..47f6bdfa85
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/emptyarray.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+//Regression for DevDiv Bugs 1142
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ WaitHandle[] waitHandles = {};
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAll");
+ WaitHandle.WaitAll(waitHandles, 5000);
+ Console.WriteLine("After WaitAll");
+ }
+ catch (ArgumentException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAll threw unexpected Exception.");
+ Console.WriteLine("WaitAll: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/nullarray.cs b/tests/src/baseservices/threading/waithandle/waitall/nullarray.cs
new file mode 100644
index 0000000000..cdc17e4a23
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/nullarray.cs
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+//Regression for DevDiv Bugs 1142
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ // Console.WriteLine(Thread.CurrentThread.GetApartmentState());
+
+ // Not supported (CoreCLR GitHub issue #2999)
+ // AppDomain.CurrentDomain.UnhandledException += Unhandled;
+
+ WaitHandle[] waitHandles = null;
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAll");
+ WaitHandle.WaitAll(waitHandles, 5000);//, false);
+ Console.WriteLine("After WaitAll");
+ }
+ catch (ArgumentNullException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAll threw unexpected Exception.");
+ Console.WriteLine("WaitAll: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+
+ // private static void Unhandled(object sender, UnhandledExceptionEventArgs args)
+ // {
+ // Exception e = (Exception) args.ExceptionObject;
+ // Console.WriteLine("Unhandled reports: {0}", e);
+ // }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.cs b/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.cs
new file mode 100644
index 0000000000..61b1e9e9f2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ WaitHandle[] waitHandles = { new Mutex(), new Mutex(), null, new Mutex() };
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAll");
+ WaitHandle.WaitAll(waitHandles, 5000);
+ Console.WriteLine("After WaitAll");
+ }
+ catch (ArgumentNullException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAll threw unexpected Exception.");
+ Console.WriteLine("WaitAll: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.csproj b/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.csproj
new file mode 100644
index 0000000000..5b0c222d09
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/nullarraymember.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="NullArrayMember.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/project.json b/tests/src/baseservices/threading/waithandle/waitall/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallemptyarray.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallemptyarray.csproj
new file mode 100644
index 0000000000..5b318a87f3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallemptyarray.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="EmptyArray.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex1.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.cs
new file mode 100644
index 0000000000..2adb4efefe
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.cs
@@ -0,0 +1,60 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "not signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(
+ new WaitHandle[]{myMutex,
+ new ManualResetEvent(false)}, 5000);
+ // Expected timeout and NOT throw exception
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj
new file mode 100644
index 0000000000..99e1caebfb
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx1.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex10.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.cs
new file mode 100644
index 0000000000..32a61f4fe0
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.cs
@@ -0,0 +1,103 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx10 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait, signaling others - " +
+ iNumElements + ", " + iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 10000);
+ Console.WriteLine("AbandonedMutexException was not thrown!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ else
+ ((ManualResetEvent)w).Set();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj
new file mode 100644
index 0000000000..d78c75a6cd
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:63</CLRTestExecutionArguments>
+ </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="WaitAllEx10.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex10a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.cs
new file mode 100644
index 0000000000..98f98261a4
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.cs
@@ -0,0 +1,103 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx10 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait, signaling others - " +
+ iNumElements + ", " + iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("AbandonedMutexException was not thrown!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ else
+ ((ManualResetEvent)w).Set();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex();
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj
new file mode 100644
index 0000000000..e6746a5b44
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:0</CLRTestExecutionArguments>
+ </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="WaitAllEx10a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex11.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex11.cs
new file mode 100644
index 0000000000..cb2f8d72ca
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex11.cs
@@ -0,0 +1,70 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon before a wait");
+ CreateMutexArray(64);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 10000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWait()
+ {
+ wh[63].WaitOne();
+ myMRE.Set();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex11.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex11.csproj
new file mode 100644
index 0000000000..3f42f07b01
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex11.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx11.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex11a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex11a.cs
new file mode 100644
index 0000000000..d98e0265d0
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex11a.cs
@@ -0,0 +1,70 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon before a wait");
+ CreateMutexArray(64);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWait()
+ {
+ wh[63].WaitOne();
+ myMRE.Set();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex11a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex11a.csproj
new file mode 100644
index 0000000000..ec0e2f4237
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex11a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx11a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex1a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.cs
new file mode 100644
index 0000000000..3c63d0bb51
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.cs
@@ -0,0 +1,60 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "not signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(
+ new WaitHandle[]{myMutex,
+ new ManualResetEvent(false)}, 5000);
+ // Expected timeout and NOT throw exception
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj
new file mode 100644
index 0000000000..d4c1fefeeb
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx1a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex2.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.cs
new file mode 100644
index 0000000000..0970739515
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.cs
@@ -0,0 +1,66 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "and signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonAndSet));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(
+ new WaitHandle[]{myMutex, myMRE}, 5000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAndSet()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Signaling the Event
+ myMRE.Set();
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj
new file mode 100644
index 0000000000..a9de93471e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx2.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex2a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.cs
new file mode 100644
index 0000000000..fdddeb7811
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.cs
@@ -0,0 +1,66 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "and signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonAndSet));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(
+ new WaitHandle[]{myMutex, myMRE});
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAndSet()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Signaling the Event
+ myMRE.Set();
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj
new file mode 100644
index 0000000000..49423c2b79
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx2a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex3.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.cs
new file mode 100644
index 0000000000..da2678f7e3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning more than one mutex mix " +
+ "with other WaitHandles, signaling other elements");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 10000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ AutoResetEvent are = new AutoResetEvent(false);
+
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == myMRE.GetType())
+ ((ManualResetEvent)w).Set();
+ if(w.GetType() == are.GetType())
+ ((AutoResetEvent)w).Set();
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 2:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj
new file mode 100644
index 0000000000..d43c1ca872
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx3.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex3a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.cs
new file mode 100644
index 0000000000..acd4753e6b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning more than one mutex mix " +
+ "with other WaitHandles, signaling other elements");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ AutoResetEvent are = new AutoResetEvent(false);
+
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == myMRE.GetType())
+ ((ManualResetEvent)w).Set();
+ if(w.GetType() == are.GetType())
+ ((AutoResetEvent)w).Set();
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 2:
+ wh[i] = new Mutex();
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj
new file mode 100644
index 0000000000..1de92aefab
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx3a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex4.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.cs
new file mode 100644
index 0000000000..666b1cefa3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.cs
@@ -0,0 +1,87 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex " +
+ "in array with other WaitHandles");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOne));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and no exception thrown
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOne()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ break;
+ }
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 2:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj
new file mode 100644
index 0000000000..1775b1c7eb
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx4.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex4a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.cs
new file mode 100644
index 0000000000..5b98e4476e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.cs
@@ -0,0 +1,87 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex " +
+ "in array with other WaitHandles");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOne));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and no exception thrown
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOne()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ break;
+ }
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(true);
+ break;
+ case 2:
+ wh[i] = new Mutex();
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj
new file mode 100644
index 0000000000..d6c514b0ac
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx4a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex5.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.cs
new file mode 100644
index 0000000000..e3232cc73d
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex in array " +
+ "with other WaitHandles, signaling other mutexes");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOneAndRelease));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and no exception thrown
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOneAndRelease()
+ {
+ Mutex m = new Mutex();
+ bool bSet = false;
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ myMRE.Set();
+ if(bSet)
+ ((Mutex)w).ReleaseMutex();
+ bSet = true;
+ }
+ }
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 2:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj
new file mode 100644
index 0000000000..a887e0f20e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx5.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex5a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.cs
new file mode 100644
index 0000000000..a59ebbb2ce
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.cs
@@ -0,0 +1,89 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex in array " +
+ "with other WaitHandles, signaling other mutexes");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOneAndRelease));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and no exception thrown
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOneAndRelease()
+ {
+ Mutex m = new Mutex();
+ bool bSet = false;
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ myMRE.Set();
+ if(bSet)
+ ((Mutex)w).ReleaseMutex();
+ bSet = true;
+ }
+ }
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%4)
+ {
+ case 0:
+ wh[i] = new AutoResetEvent(true);
+ break;
+ case 1:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 2:
+ wh[i] = new Mutex();
+ break;
+ case 3:
+ wh[i] = new Semaphore(5,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj
new file mode 100644
index 0000000000..de80ba4863
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx5a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex6.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.cs
new file mode 100644
index 0000000000..450e101e16
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx6 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iArraySize, int iPosToAbandon)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize);
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 5000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj
new file mode 100644
index 0000000000..70d5e634fe
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:2 /pos:0</CLRTestExecutionArguments>
+ </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="WaitAllEx6.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex6a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.cs
new file mode 100644
index 0000000000..a5573ad712
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.cs
@@ -0,0 +1,94 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx6a /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iArraySize, int iPosToAbandon)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize);
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj
new file mode 100644
index 0000000000..de3702b20a
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:30</CLRTestExecutionArguments>
+ </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="WaitAllEx6a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex7.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.cs
new file mode 100644
index 0000000000..8e216d9a3b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon all mutexes in array");
+ CreateMutexArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(wh, 5000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ AutoResetEvent are = new AutoResetEvent(false);
+
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj
new file mode 100644
index 0000000000..8bfe2016b3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx7.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex7a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.cs
new file mode 100644
index 0000000000..69bcd965d1
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon all mutexes in array");
+ CreateMutexArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ bool bRet = false;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ AutoResetEvent are = new AutoResetEvent(false);
+
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj
new file mode 100644
index 0000000000..9600f13ccf
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx7a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex8.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.cs
new file mode 100644
index 0000000000..2d796e61bf
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon same named mutex");
+ // Create array with the same name
+ string sName = Common.GetUniqueName();
+ wh = new Mutex[2];
+ wh[0] = new Mutex(false, sName);
+ wh[1] = new Mutex(false, sName);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(0);
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 10000);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(ArgumentException)
+ {
+ // bug #237497 - ArgumentException is thrown instead of
+ // an AbandonedMutexException.
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj
new file mode 100644
index 0000000000..a39a4ea747
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx8.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex8a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.cs
new file mode 100644
index 0000000000..99b5234d9f
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ private WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ private WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon same named mutex");
+ // Create array with the same name
+ string sName = Common.GetUniqueName();
+ wh = new Mutex[2];
+ wh[0] = new Mutex(false, sName);
+ wh[1] = new Mutex(false, sName);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(0);
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh);
+ Console.WriteLine("WaitAll did not throw an " +
+ "exception, bRet = " + bRet);
+ }
+ catch(ArgumentException)
+ {
+ // bug #237497 - ArgumentException is thrown instead of
+ // an AbandonedMutexException.
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj
new file mode 100644
index 0000000000..0f15fe0cef
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAllEx8a.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex9.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.cs
new file mode 100644
index 0000000000..f8ea18511f
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.cs
@@ -0,0 +1,100 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx9 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait - " + iNumElements + ", " +
+ iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and pass
+ if(bRet)
+ Console.WriteLine("No exception thrown!");
+ else
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj
new file mode 100644
index 0000000000..9e71a34068
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:63</CLRTestExecutionArguments>
+ </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="WaitAllEx9.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallex9a.cs b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.cs
new file mode 100644
index 0000000000..37b2484656
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.cs
@@ -0,0 +1,100 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAllEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAllEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAllEx9a /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAllEx wae = new WaitAllEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait - " + iNumElements + ", " +
+ iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ bool bRet = WaitHandle.WaitAll(wh, 5000);
+ // Expected timeout and pass
+ if(bRet)
+ Console.WriteLine("No exception thrown!");
+ else
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex();
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj
new file mode 100644
index 0000000000..f834ecbb39
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:0</CLRTestExecutionArguments>
+ </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="WaitAllEx9a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitall/waitallnullarray.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallnullarray.csproj
new file mode 100644
index 0000000000..c2547433e7
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitall/waitallnullarray.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="NullArray.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/app.config b/tests/src/baseservices/threading/waithandle/waitany/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/waithandle/waitany/emptyarray.cs b/tests/src/baseservices/threading/waithandle/waitany/emptyarray.cs
new file mode 100644
index 0000000000..ef15894d79
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/emptyarray.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+//Regression for DevDiv Bugs 1142
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ WaitHandle[] waitHandles = {};
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAny");
+ WaitHandle.WaitAny(waitHandles, 5000);
+ Console.WriteLine("After WaitAny");
+ }
+ catch (ArgumentException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAny threw unexpected Exception.");
+ Console.WriteLine("WaitAny: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/nullarray.cs b/tests/src/baseservices/threading/waithandle/waitany/nullarray.cs
new file mode 100644
index 0000000000..7d4cb18d5a
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/nullarray.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+//Regression for DevDiv Bugs 1142
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ WaitHandle[] waitHandles = null;
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAny");
+ WaitHandle.WaitAny(waitHandles, 5000);
+ Console.WriteLine("After WaitAny");
+ }
+ catch (ArgumentNullException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAny threw unexpected Exception.");
+ Console.WriteLine("WaitAny: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/nullarraymember.cs b/tests/src/baseservices/threading/waithandle/waitany/nullarraymember.cs
new file mode 100644
index 0000000000..8b24b45942
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/nullarraymember.cs
@@ -0,0 +1,41 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class Duplicates
+{
+ static int Main()
+ {
+ int retCode = 99;
+
+ WaitHandle[] waitHandles = { new Mutex(), new Mutex(), null, new Mutex() };
+
+ // Can't catch exception in v2.0. Should be fixed in Post-Orcas. VSWhidbey 543816
+ try
+ {
+ Console.WriteLine("Before WaitAny");
+ WaitHandle.WaitAny(waitHandles, 5000);
+ Console.WriteLine("After WaitAny");
+ }
+ catch (ArgumentNullException)
+ {
+ retCode = 100;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("WaitAny threw unexpected Exception.");
+ Console.WriteLine("WaitAny: {0}", ex);
+ retCode = 98;
+ }
+
+ if (retCode ==100)
+ Console.WriteLine("Test Passed");
+ else
+ Console.WriteLine("Test Failed");
+
+ return retCode;
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/nullarraymemberwaitany.csproj b/tests/src/baseservices/threading/waithandle/waitany/nullarraymemberwaitany.csproj
new file mode 100644
index 0000000000..5b0c222d09
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/nullarraymemberwaitany.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="NullArrayMember.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/project.json b/tests/src/baseservices/threading/waithandle/waitany/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyemptyarray.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyemptyarray.csproj
new file mode 100644
index 0000000000..5b318a87f3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyemptyarray.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="EmptyArray.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex1.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs
new file mode 100644
index 0000000000..b55f8a0fde
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "not signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(
+ new WaitHandle[]{myMutex,
+ new ManualResetEvent(false)}, 10000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj
new file mode 100644
index 0000000000..8ce3bfe4e2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx1.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex10.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs
new file mode 100644
index 0000000000..bb13264d4c
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx10 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait, signaling others - " +
+ iNumElements + ", " + iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 10000);
+ iRet = 100;
+ }
+ catch(AbandonedMutexException)
+ {
+ // Should never throw
+ Console.WriteLine("AbandonedMutexException thrown and " +
+ "shouldn't have");
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ else
+ ((ManualResetEvent)w).Set();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj
new file mode 100644
index 0000000000..a02ea10cd5
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:2 /pos:1</CLRTestExecutionArguments>
+ </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="WaitAnyEx10.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex10a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs
new file mode 100644
index 0000000000..b92f81985e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs
@@ -0,0 +1,104 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx10a /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait, signaling others - " +
+ iNumElements + ", " + iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ iRet = 100;
+ }
+ catch(AbandonedMutexException)
+ {
+ // Should never throw
+ Console.WriteLine("AbandonedMutexException thrown and " +
+ "shouldn't have");
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ else
+ ((ManualResetEvent)w).Set();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex();
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj
new file mode 100644
index 0000000000..6657bb6751
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:2 /pos:1</CLRTestExecutionArguments>
+ </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="WaitAnyEx10a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex1a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.cs
new file mode 100644
index 0000000000..4638d32d72
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.cs
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "not signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(
+ new WaitHandle[]{myMutex,
+ new ManualResetEvent(false)});
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj
new file mode 100644
index 0000000000..f8672b6009
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx1a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex2.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2.cs
new file mode 100644
index 0000000000..aa27c0eea1
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2.cs
@@ -0,0 +1,68 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test
+
+class WaitAnyEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ }
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "and signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonAndSet));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(
+ new WaitHandle[]{myMutex, myMRE}, 5000);
+ Console.WriteLine("WaitAny did not throw AbandonedMutexException");
+ }
+ catch(AbandonedMutexException)
+ {
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ finally
+ {
+ myMRE.Reset();
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAndSet()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Signaling the Event
+ myMRE.Set();
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex2.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2.csproj
new file mode 100644
index 0000000000..f908c9c704
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx2.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex2a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.cs
new file mode 100644
index 0000000000..bbd2b018c6
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.cs
@@ -0,0 +1,68 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test
+
+class WaitAnyEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ myMutex = new Mutex();
+ }
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Testing Mutex and non-Mutex, " +
+ "and signaling the other element");
+ Thread t = new Thread(new ThreadStart(this.AbandonAndSet));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(
+ new WaitHandle[]{myMutex, myMRE});
+ Console.WriteLine("WaitAny did not throw AbandonedMutexException");
+ }
+ catch(AbandonedMutexException)
+ {
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ finally
+ {
+ myMRE.Reset();
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAndSet()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ Console.WriteLine("Holding the Mutex");
+ // Signaling the Event
+ myMRE.Set();
+ // Not calling ReleaseMutex() so the Mutex becomes abandoned
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.csproj
new file mode 100644
index 0000000000..4c7826da22
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex2a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx2a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex3.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs
new file mode 100644
index 0000000000..e1160c5e73
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs
@@ -0,0 +1,81 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning more than one mutex " +
+ "mix with other WaitHandles");
+ CreateArray(64);
+ myMRE = new ManualResetEvent(false);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 10000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj
new file mode 100644
index 0000000000..4800d70ded
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx3.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex3a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs
new file mode 100644
index 0000000000..f79cfa5cbf
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs
@@ -0,0 +1,81 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning more than one mutex " +
+ "mix with other WaitHandles");
+ CreateArray(64);
+ myMRE = new ManualResetEvent(false);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex();
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj
new file mode 100644
index 0000000000..d945945e54
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx3a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex4.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4.cs
new file mode 100644
index 0000000000..a67aa329c6
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex " +
+ "in array with other WaitHandles");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOne));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 5000);
+ Console.WriteLine("WaitAny did not throw an exception");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOne()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ break;
+ }
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex4.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4.csproj
new file mode 100644
index 0000000000..8fc46b2467
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx4.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex4a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.cs
new file mode 100644
index 0000000000..e3e45567e2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.cs
@@ -0,0 +1,76 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex " +
+ "in array with other WaitHandles");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOne));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw an exception");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOne()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ break;
+ }
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex();
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.csproj
new file mode 100644
index 0000000000..41864ccad3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex4a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx4a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex5.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs
new file mode 100644
index 0000000000..cdd75e5f19
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex in array " +
+ "with other WaitHandles, signaling other mutexes");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOneAndRelease));
+ t.Start();
+ t.Join();
+ int i = -1;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, 5000);
+ Console.WriteLine("WaitAny did not throw AbandonedMutexExcpetion");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOneAndRelease()
+ {
+ Mutex m = new Mutex();
+ bool bSet = false;
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ if(bSet)
+ ((Mutex)w).ReleaseMutex();
+ bSet = true;
+ }
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.csproj
new file mode 100644
index 0000000000..1b86000fa2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx5.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex5a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs
new file mode 100644
index 0000000000..16c4e50e61
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs
@@ -0,0 +1,85 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandoning only one Mutex in array " +
+ "with other WaitHandles, signaling other mutexes");
+ CreateArray(64);
+ Thread t = new Thread(new ThreadStart(this.AbandonOneAndRelease));
+ t.Start();
+ t.Join();
+ int i = -1;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw AbandonedMutexExcpetion");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonOneAndRelease()
+ {
+ Mutex m = new Mutex();
+ bool bSet = false;
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ {
+ w.WaitOne();
+ if(bSet)
+ ((Mutex)w).ReleaseMutex();
+ bSet = true;
+ }
+ }
+ }
+
+ private void CreateArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ switch(i%3)
+ {
+ case 0:
+ wh[i] = new ManualResetEvent(false);
+ break;
+ case 1:
+ wh[i] = new Mutex();
+ break;
+ case 2:
+ wh[i] = new Semaphore(0,5);
+ break;
+ }
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.csproj
new file mode 100644
index 0000000000..63db1823a0
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx5a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex6.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs
new file mode 100644
index 0000000000..0f5b58658b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx6 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iArraySize, int iPosToAbandon)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize);
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ t.Join();
+ int i = -1;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh, 5000);
+ if(0 == iPosToAbandon)
+ Console.WriteLine("WaitAny didn't return an " +
+ "AbandonedMutexException");
+ else
+ // Expected to pass
+ iRet = 100;
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected if pos is first
+ if(0 == iPosToAbandon)
+ iRet = 100;
+ else
+ Console.WriteLine("WaitAny threw AbandonedMutexException " +
+ "and shouldn't have!");
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.csproj
new file mode 100644
index 0000000000..f909482138
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:2 /pos:1</CLRTestExecutionArguments>
+ </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="WaitAnyEx6.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex6a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.cs
new file mode 100644
index 0000000000..89fde02a9e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.cs
@@ -0,0 +1,97 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx6a /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iArraySize, int iPosToAbandon)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon a particular mutex - " + iArraySize + ", " +
+ iPosToAbandon);
+ CreateMutexArray(iArraySize);
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(iPosToAbandon);
+ t.Join();
+ int i = -1;
+ try
+ {
+ Console.WriteLine("Waiting...");
+ i = WaitHandle.WaitAny(wh);
+ if(0 == iPosToAbandon)
+ Console.WriteLine("WaitAny didn't return an " +
+ "AbandonedMutexException");
+ else
+ // Expected to pass
+ iRet = 100;
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected if pos is first
+ if(iPosToAbandon == 0)
+ iRet = 100;
+ else
+ Console.WriteLine("WaitAny threw AbandonedMutexException " +
+ "and shouldn't have!");
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.csproj
new file mode 100644
index 0000000000..f1d52c20a8
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:30</CLRTestExecutionArguments>
+ </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="WaitAnyEx6a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex7.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs
new file mode 100644
index 0000000000..cc3108d0f2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs
@@ -0,0 +1,69 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon all mutexes in array");
+ CreateMutexArray(64);
+ myMRE = new ManualResetEvent(false);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 10000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj
new file mode 100644
index 0000000000..bcff9ffc43
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx7.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex7a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs
new file mode 100644
index 0000000000..903b83c372
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs
@@ -0,0 +1,69 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ private ManualResetEvent myMRE;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon all mutexes in array");
+ CreateMutexArray(64);
+ myMRE = new ManualResetEvent(false);
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexes));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexes()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateMutexArray(int numElements)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ wh[i] = new Mutex();
+ }
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj
new file mode 100644
index 0000000000..6fdb1a4644
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx7a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex8.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs
new file mode 100644
index 0000000000..358ae5162b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon same named mutex");
+ // Create array with the same name
+ wh = new Mutex[2];
+ string sName = Common.GetUniqueName();
+ wh[0] = new Mutex(false, sName);
+ wh[1] = new Mutex(false, sName);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(0);
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 5000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.csproj
new file mode 100644
index 0000000000..cd0fc97f50
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx8.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex8a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.cs
new file mode 100644
index 0000000000..53f3fdaf53
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This is a non-9x test.
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+
+ public static int Main()
+ {
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon same named mutex");
+ // Create array with the same name
+ wh = new Mutex[2];
+ string sName = Common.GetUniqueName();
+ wh[0] = new Mutex(false, sName);
+ wh[1] = new Mutex(false, sName);
+
+ Thread t = new Thread(new
+ ParameterizedThreadStart(this.AbandonMutexPos));
+ t.Start(0);
+ t.Join();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexPos(Object o)
+ {
+ wh[Convert.ToInt32(o)].WaitOne();
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.csproj
new file mode 100644
index 0000000000..3f4e73744a
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitAnyEx8a.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex9.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs
new file mode 100644
index 0000000000..76b3006829
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs
@@ -0,0 +1,102 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx9 /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait - " + iNumElements + ", " +
+ iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh, 10000);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex(false, Common.GetUniqueName());
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj
new file mode 100644
index 0000000000..59f4188d86
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj
@@ -0,0 +1,44 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:2 /pos:1</CLRTestExecutionArguments>
+ </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="WaitAnyEx9.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanyex9a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs
new file mode 100644
index 0000000000..1c5817f9e0
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs
@@ -0,0 +1,102 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitAnyEx
+{
+ WaitHandle[] wh;
+ ManualResetEvent myMRE;
+
+ public WaitAnyEx()
+ {
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main(string[] args)
+ {
+ // Check number of args
+ if(args.Length != 2)
+ {
+ Console.WriteLine("USAGE: WaitAnyEx9a /size:<int> /pos:<int>");
+ return -1;
+ }
+
+ // Get the args
+ int iPos=-1, iSize = -1;;
+
+ for(int i=0;i<args.Length;i++)
+ {
+ if(args[i].ToLower().StartsWith("/size:"))
+ {
+ iSize = Convert.ToInt32(args[i].Substring(6));
+ continue;
+ }
+
+ if(args[i].ToLower().StartsWith("/pos:"))
+ {
+ iPos = Convert.ToInt32(args[i].Substring(5));
+ }
+ }
+
+ WaitAnyEx wae = new WaitAnyEx();
+ return wae.Run(iSize, iPos);
+ }
+
+ private int Run(int iNumElements, int iPos)
+ {
+ int iRet = -1;
+ Console.WriteLine("Abandon during a wait - " + iNumElements + ", " +
+ iPos);
+ CreateOneMutexArray(iNumElements, iPos);
+
+ Thread t = new Thread(new ThreadStart(this.AbandonAllMutexesWait));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Waiting...");
+ int i = WaitHandle.WaitAny(wh);
+ Console.WriteLine("WaitAny did not throw an " +
+ "exception, i = " + i);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " +
+ e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonAllMutexesWait()
+ {
+ Mutex m = new Mutex();
+ foreach(WaitHandle w in wh)
+ {
+ if(w.GetType() == m.GetType())
+ w.WaitOne();
+ }
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+
+ private void CreateOneMutexArray(int numElements, int iPos)
+ {
+ wh = new WaitHandle[numElements];
+ for(int i=0;i<numElements;i++)
+ {
+ if(i == iPos)
+ wh[i] = new Mutex();
+ else
+ wh[i] = new ManualResetEvent(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj
new file mode 100644
index 0000000000..6f3c58829f
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</CLRTestPriority>
+ <CLRTestExecutionArguments>/size:64 /pos:30</CLRTestExecutionArguments>
+ </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="WaitAnyEx9a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitany/waitanynullarray.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanynullarray.csproj
new file mode 100644
index 0000000000..c2547433e7
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitany/waitanynullarray.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="NullArray.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waithandlecommon.cs b/tests/src/baseservices/threading/waithandle/waithandlecommon.cs
new file mode 100644
index 0000000000..469e3a4a1f
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waithandlecommon.cs
@@ -0,0 +1,16 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class Common
+{
+ 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/waithandle/waitone/app.config b/tests/src/baseservices/threading/waithandle/waitone/app.config
new file mode 100644
index 0000000000..c51f616257
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/app.config
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Globalization" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/tests/src/baseservices/threading/waithandle/waitone/project.json b/tests/src/baseservices/threading/waithandle/waitone/project.json
new file mode 100644
index 0000000000..21a7fa4381
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/project.json
@@ -0,0 +1,35 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc2-23816",
+ "System.Collections.Specialized": "4.0.1-rc2-23816",
+ "System.ComponentModel": "4.0.1-rc2-23816",
+ "System.Console": "4.0.0-rc2-23816",
+ "System.Diagnostics.Process": "4.1.0-rc2-23816",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.0",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.0.1-rc2-23816",
+ "System.Linq.Queryable": "4.0.1-rc2-23816",
+ "System.Reflection": "4.0.10",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc2-23816",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc2-23816",
+ "System.Runtime.Loader": "4.0.0-rc2-23816",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Threading.Thread": "4.0.0-rc2-23816",
+ "System.Xml.ReaderWriter": "4.0.11-rc2-23816",
+ "System.Xml.XDocument": "4.0.11-rc2-23816",
+ "System.Xml.XmlDocument": "4.0.1-rc2-23816",
+ "System.Xml.XmlSerializer": "4.0.11-rc2-23816"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ }
+} \ No newline at end of file
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.cs
new file mode 100644
index 0000000000..b463ee5269
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.cs
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test abandoned mutex is thrown using WaitOne");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne(10000);
+ Console.WriteLine("WaitOne did not throw an exception!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj
new file mode 100644
index 0000000000..592ca92090
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx1.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex1a.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.cs
new file mode 100644
index 0000000000..b076ec6d8b
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.cs
@@ -0,0 +1,58 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test abandoned mutex is thrown using WaitOne");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne();
+ Console.WriteLine("WaitOne did not throw an exception!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.csproj
new file mode 100644
index 0000000000..9a13cedaad
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx1a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex2.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.cs
new file mode 100644
index 0000000000..889e1541ca
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test AbandonedMutexException is " +
+ "thrown when abandoned with a WaitAll");
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWaitAll));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne(10000);
+ Console.WriteLine("WaitOne did not throw an exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWaitAll()
+ {
+ Console.WriteLine("Abandoning Mutex");
+ WaitHandle.WaitAll(new WaitHandle[]{myMutex, new Mutex()});
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj
new file mode 100644
index 0000000000..6948c7dbea
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx2.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex2a.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.cs
new file mode 100644
index 0000000000..4fa2ddb9ca
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test AbandonedMutexException is " +
+ "thrown when abandoned with a WaitAll");
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWaitAll));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne();
+ Console.WriteLine("WaitOne did not throw an exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWaitAll()
+ {
+ Console.WriteLine("Abandoning Mutex");
+ WaitHandle.WaitAll(new WaitHandle[]{myMutex, new Mutex()});
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.csproj
new file mode 100644
index 0000000000..8ad36d92d3
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx2a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex3.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.cs
new file mode 100644
index 0000000000..85bd139354
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test AbandonedMutexException is " +
+ "thrown when abandoned with a WaitAny");
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWaitAny));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne(10000);
+ Console.WriteLine("WaitOne did not throw an exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWaitAny()
+ {
+ Console.WriteLine("Abandoning Mutex");
+ WaitHandle.WaitAny(new WaitHandle[]{new ManualResetEvent(false), myMutex});
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj
new file mode 100644
index 0000000000..36c63a1d21
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx3.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex3a.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.cs
new file mode 100644
index 0000000000..cefbda2670
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+ private ManualResetEvent myMRE;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex();
+ myMRE = new ManualResetEvent(false);
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test AbandonedMutexException is " +
+ "thrown when abandoned with a WaitAny");
+ Thread t = new Thread(new ThreadStart(this.AbandonMutexWaitAny));
+ t.Start();
+ myMRE.WaitOne();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne();
+ Console.WriteLine("WaitOne did not throw an exception, bRet = " + bRet);
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonMutexWaitAny()
+ {
+ Console.WriteLine("Abandoning Mutex");
+ WaitHandle.WaitAny(new WaitHandle[]{new ManualResetEvent(false), myMutex});
+ myMRE.Set();
+ Thread.Sleep(1000);
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.csproj
new file mode 100644
index 0000000000..a9a1ec3ee2
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx3a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex4.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4.cs
new file mode 100644
index 0000000000..0e79432f42
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4.cs
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This test is for non-9x platforms. 9x does not throw an AbandonedMutexException
+// when it is not actively waiting.
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex(false, Common.GetUniqueName());
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test abandoned mutex is thrown using WaitOne");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne(10000);
+ Console.WriteLine("WaitOne did not throw an exception!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex4.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4.csproj
new file mode 100644
index 0000000000..93202d398e
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4.csproj
@@ -0,0 +1,43 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx4.cs" />
+ <Compile Include="..\WaitHandleCommon.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/waithandle/waitone/waitoneex4a.cs b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.cs
new file mode 100644
index 0000000000..a9ec241706
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.cs
@@ -0,0 +1,57 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+
+// This test is for non-9x platforms. 9x does not throw an AbandonedMutexException
+// when it is not actively waiting.
+
+class WaitOneEx
+{
+ private Mutex myMutex;
+
+ public WaitOneEx()
+ {
+ myMutex = new Mutex();
+ }
+
+ public static int Main()
+ {
+ WaitOneEx wao = new WaitOneEx();
+ return wao.Run();
+ }
+
+ private int Run()
+ {
+ int iRet = -1;
+ Console.WriteLine("Test abandoned mutex is thrown using WaitOne");
+ Thread t = new Thread(new ThreadStart(this.AbandonTheMutex));
+ t.Start();
+ t.Join();
+ try
+ {
+ Console.WriteLine("Wait on an abandoned mutex");
+ bool bRet = myMutex.WaitOne();
+ Console.WriteLine("WaitOne did not throw an exception!");
+ }
+ catch(AbandonedMutexException)
+ {
+ // Expected
+ iRet = 100;
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Unexpected exception thrown: " + e.ToString());
+ }
+ Console.WriteLine(100 == iRet ? "Test Passed" : "Test Failed");
+ return iRet;
+ }
+
+ private void AbandonTheMutex()
+ {
+ Console.WriteLine("Acquire the Mutex");
+ myMutex.WaitOne();
+ }
+}
diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.csproj
new file mode 100644
index 0000000000..e7cdf3f846
--- /dev/null
+++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex4a.csproj
@@ -0,0 +1,42 @@
+<?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>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</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>
+ <CLRTestPriority>1</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="WaitOneEx4a.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <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/testsFailingOutsideWindows.txt b/tests/testsFailingOutsideWindows.txt
index 43d7189fb9..039c7841f2 100644
--- a/tests/testsFailingOutsideWindows.txt
+++ b/tests/testsFailingOutsideWindows.txt
@@ -1,4 +1,3 @@
-baseservices/exceptions/simple/HardwareEH/HardwareEH.sh
baseservices/exceptions/unittests/EHPatternTests/EHPatternTests.sh
baseservices/threading/paramthreadstart/ThreadStartString_1/ThreadStartString_1.sh
CoreMangLib/cti/system/multicastdelegate/MulticastDelegateCtor/MulticastDelegateCtor.sh
diff --git a/tests/testsUnsupportedOutsideWindows.txt b/tests/testsUnsupportedOutsideWindows.txt
index 3831f860c2..74e32dbd68 100644
--- a/tests/testsUnsupportedOutsideWindows.txt
+++ b/tests/testsUnsupportedOutsideWindows.txt
@@ -1,6 +1,119 @@
baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged/UnmanagedToManaged.sh
baseservices/exceptions/regressions/Dev11/147911/test147911/test147911.sh
baseservices/threading/commitstackonlyasneeded/DefaultStackCommit/DefaultStackCommit.sh
+baseservices/threading/interlocked/compareexchange/compareexchangetneg/compareexchangetneg.sh
+baseservices/threading/monitor/pulse/monitorpulse02/monitorpulse02.sh
+baseservices/threading/monitor/tryenter/negativetestharness/negativetestharness.sh
+baseservices/threading/mutex/abandonedmutex/am04waitany/am04waitany.sh
+baseservices/threading/mutex/abandonedmutex/am05waitanymutex/am05waitanymutex.sh
+baseservices/threading/mutex/abandonedmutex/am06abandonall/am06abandonall.sh
+baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex/am07abandonmultiplemutex.sh
+baseservices/threading/mutex/abandonedmutex/am08mixedarray/am08mixedarray.sh
+baseservices/threading/mutex/abandonedmutex/am09threadabort/am09threadabort.sh
+baseservices/threading/mutex/openexisting/openmutexneg1/openmutexneg1.sh
+baseservices/threading/mutex/openexisting/openmutexneg2/openmutexneg2.sh
+baseservices/threading/mutex/openexisting/openmutexneg3/openmutexneg3.sh
+baseservices/threading/mutex/openexisting/openmutexneg4/openmutexneg4.sh
+baseservices/threading/mutex/openexisting/openmutexneg5/openmutexneg5.sh
+baseservices/threading/mutex/openexisting/openmutexneg6/openmutexneg6.sh
+baseservices/threading/mutex/openexisting/openmutexneg7/openmutexneg7.sh
+baseservices/threading/mutex/openexisting/openmutexneg8/openmutexneg8.sh
+baseservices/threading/mutex/openexisting/openmutexpos1/openmutexpos1.sh
+baseservices/threading/mutex/openexisting/openmutexpos2/openmutexpos2.sh
+baseservices/threading/mutex/openexisting/openmutexpos3/openmutexpos3.sh
+baseservices/threading/mutex/openexisting/openmutexpos4/openmutexpos4.sh
+baseservices/threading/readerwriterlockslim/ensurelockordering/ensurelockordering.sh
+baseservices/threading/regressions/135972/oswaitinlock/oswaitinlock.sh
+baseservices/threading/regressions/135972/oswaitinsleep/oswaitinsleep.sh
+baseservices/threading/regressions/beta1/322338/322338.sh
+baseservices/threading/regressions/beta2/417296_abort/417296_abort.sh
+baseservices/threading/regressions/m2/91848/91848.sh
+baseservices/threading/regressions/m2/tastaticconst/tastaticconst.sh
+baseservices/threading/regressions/whidbey_m3/105019/105019.sh
+baseservices/threading/semaphore/ctoropen/semaphorector2/semaphorector2.sh
+baseservices/threading/semaphore/ctoropen/semaphorector3/semaphorector3.sh
+baseservices/threading/semaphore/ctoropen/semaphorector4/semaphorector4.sh
+baseservices/threading/semaphore/ctoropen/semaphorector5/semaphorector5.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg1/semaphoreopenneg1.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg2/semaphoreopenneg2.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg3/semaphoreopenneg3.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg4/semaphoreopenneg4.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg5/semaphoreopenneg5.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg6/semaphoreopenneg6.sh
+baseservices/threading/semaphore/ctoropen/semaphoreopenneg7/semaphoreopenneg7.sh
+baseservices/threading/semaphore/unit/semtest/semtest.sh
+baseservices/threading/threadabort/exceptioninfinally/argumentexception/argumentexception.sh
+baseservices/threading/threadabort/exceptioninfinally/dividebyzero/dividebyzero.sh
+baseservices/threading/threadabort/exceptioninfinally/nullrefexception/nullrefexception.sh
+baseservices/threading/threadabort/rudeposnonhosted/rudenonhostedone/rudenonhostedone.sh
+baseservices/threading/threadabort/rudeposnonhosted/rudenonhostedthree/rudenonhostedthree.sh
+baseservices/threading/threadabort/rudeposnonhosted/rudenonhostedtwo/rudenonhostedtwo.sh
+baseservices/threading/threadabort/rudethreadpool/rudeabortrepeat/rudeabortrepeat.sh
+baseservices/threading/threadabort/tasuite/ta001a/ta001a.sh
+baseservices/threading/threadabort/tasuite/ta001b/ta001b.sh
+baseservices/threading/threadabort/tasuite/ta002a/ta002a.sh
+baseservices/threading/threadabort/tasuite/ta002b/ta002b.sh
+baseservices/threading/threadabort/tasuite/ta003a/ta003a.sh
+baseservices/threading/threadabort/tasuite/ta003b/ta003b.sh
+baseservices/threading/threadabort/tasuite/ta004a/ta004a.sh
+baseservices/threading/threadabort/tasuite/ta004b/ta004b.sh
+baseservices/threading/threadabort/tasuite/ta005a/ta005a.sh
+baseservices/threading/threadabort/tasuite/ta005b/ta005b.sh
+baseservices/threading/threadabort/tasuite/ta006a/ta006a.sh
+baseservices/threading/threadabort/tasuite/ta007a/ta007a.sh
+baseservices/threading/threadabort/tasuite/ta007b/ta007b.sh
+baseservices/threading/threadabort/tasuite/ta008a/ta008a.sh
+baseservices/threading/threadabort/tasuite/ta009a/ta009a.sh
+baseservices/threading/threadabort/tasuite/ta010a/ta010a.sh
+baseservices/threading/threadabort/tasuite/ta011a/ta011a.sh
+baseservices/threading/threadabort/tasuite/ta012a/ta012a.sh
+baseservices/threading/threadabort/tasuite/ta012b/ta012b.sh
+baseservices/threading/threadabort/tasuite/ta013a/ta013a.sh
+baseservices/threading/threadabort/tasuite/ta014a/ta014a.sh
+baseservices/threading/threadabort/tasuite/ta015a/ta015a.sh
+baseservices/threading/threadabort/tasuite/ta016a/ta016a.sh
+baseservices/threading/threadabort/tasuite/ta017a/ta017a.sh
+baseservices/threading/threadabort/tasuite/ta017b/ta017b.sh
+baseservices/threading/threadabort/tasuite/ta018a/ta018a.sh
+baseservices/threading/threadabort/tasuite/ta019a/ta019a.sh
+baseservices/threading/threadabort/tasuite/ta020a/ta020a.sh
+baseservices/threading/threadabort/tasuite/threadabort/threadabort.sh
+baseservices/threading/threadabort/tasuite/threadstarttwice/threadstarttwice.sh
+baseservices/threading/threadpool/bindhandle/bindhandle1/bindhandle1.sh
+baseservices/threading/threadpool/bindhandle/bindhandleinvalid/bindhandleinvalid.sh
+baseservices/threading/threadpool/bindhandle/bindhandleinvalid3/bindhandleinvalid3.sh
+baseservices/threading/threadpool/bindhandle/bindhandleinvalid4/bindhandleinvalid4.sh
+baseservices/threading/threadpool/bindhandle/bindhandleinvalid5/bindhandleinvalid5.sh
+baseservices/threading/threadpool/bindhandle/bindhandleinvalid6/bindhandleinvalid6.sh
+baseservices/threading/volatile/atomictest/atomictest.sh
+baseservices/threading/waithandle/abandonedmutexscenarios/threadabort/threadabort.sh
+baseservices/threading/waithandle/waitall/waitallex1/waitallex1.sh
+baseservices/threading/waithandle/waitall/waitallex10/waitallex10.sh
+baseservices/threading/waithandle/waitall/waitallex11/waitallex11.sh
+baseservices/threading/waithandle/waitall/waitallex2/waitallex2.sh
+baseservices/threading/waithandle/waitall/waitallex3/waitallex3.sh
+baseservices/threading/waithandle/waitall/waitallex4/waitallex4.sh
+baseservices/threading/waithandle/waitall/waitallex5/waitallex5.sh
+baseservices/threading/waithandle/waitall/waitallex6/waitallex6.sh
+baseservices/threading/waithandle/waitall/waitallex7/waitallex7.sh
+baseservices/threading/waithandle/waitall/waitallex8/waitallex8.sh
+baseservices/threading/waithandle/waitall/waitallex8a/waitallex8a.sh
+baseservices/threading/waithandle/waitall/waitallex9/waitallex9.sh
+baseservices/threading/waithandle/waitany/waitanyex1/waitanyex1.sh
+baseservices/threading/waithandle/waitany/waitanyex10/waitanyex10.sh
+baseservices/threading/waithandle/waitany/waitanyex2/waitanyex2.sh
+baseservices/threading/waithandle/waitany/waitanyex3/waitanyex3.sh
+baseservices/threading/waithandle/waitany/waitanyex4/waitanyex4.sh
+baseservices/threading/waithandle/waitany/waitanyex5/waitanyex5.sh
+baseservices/threading/waithandle/waitany/waitanyex6/waitanyex6.sh
+baseservices/threading/waithandle/waitany/waitanyex7/waitanyex7.sh
+baseservices/threading/waithandle/waitany/waitanyex8/waitanyex8.sh
+baseservices/threading/waithandle/waitany/waitanyex8a/waitanyex8a.sh
+baseservices/threading/waithandle/waitany/waitanyex9/waitanyex9.sh
+baseservices/threading/waithandle/waitone/waitoneex1/waitoneex1.sh
+baseservices/threading/waithandle/waitone/waitoneex2/waitoneex2.sh
+baseservices/threading/waithandle/waitone/waitoneex3/waitoneex3.sh
+baseservices/threading/waithandle/waitone/waitoneex4/waitoneex4.sh
CoreMangLib/cti/system/byte/ByteToString3/ByteToString3.sh
CoreMangLib/cti/system/convert/ConvertToInt32_4/ConvertToInt32_4.sh
CoreMangLib/cti/system/datetime/DateTimeParseExact1/DateTimeParseExact1.sh
@@ -9,10 +122,10 @@ CoreMangLib/cti/system/datetime/DateTimeParseExact3/DateTimeParseExact3.sh
CoreMangLib/cti/system/decimal/DecimalToInt32/DecimalToInt32.sh
CoreMangLib/cti/system/double/DoubleToString3/DoubleToString3.sh
CoreMangLib/cti/system/double/DoubleToString4/DoubleToString4.sh
-CoreMangLib/cti/system/int64/Int64ToString3/Int64ToString3.sh
CoreMangLib/cti/system/int/Int32ToString3/Int32ToString3.sh
-CoreMangLib/cti/system/string/StringCompare15/StringCompare15.sh
+CoreMangLib/cti/system/int64/Int64ToString3/Int64ToString3.sh
CoreMangLib/cti/system/string/StringCompare1/StringCompare1.sh
+CoreMangLib/cti/system/string/StringCompare15/StringCompare15.sh
CoreMangLib/cti/system/string/StringCompare2/StringCompare2.sh
CoreMangLib/cti/system/uint16/UInt16ToString3/UInt16ToString3.sh
CoreMangLib/cti/system/uint16/UInt16ToString4/UInt16ToString4.sh
@@ -20,27 +133,85 @@ CoreMangLib/cti/system/uint32/UInt32ToString2/UInt32ToString2.sh
CoreMangLib/system/collections/generic/hashset/Regression_Dev10_609271/Regression_Dev10_609271.sh
CoreMangLib/system/collections/generic/hashset/Regression_Dev10_624201/Regression_Dev10_624201.sh
Interop/NativeCallable/NativeCallableTest/NativeCallableTest.sh
-JIT/Directed/IL/PInvokeTail/PInvokeTail/PInvokeTail.sh
-JIT/Directed/IL/PInvokeTail/TailWinApi/TailWinApi.sh
-JIT/Directed/UnrollLoop/loop2_cs_d/loop2_cs_d.sh
-JIT/Directed/UnrollLoop/loop2_cs_do/loop2_cs_do.sh
-JIT/Directed/UnrollLoop/loop2_cs_r/loop2_cs_r.sh
-JIT/Directed/UnrollLoop/loop2_cs_ro/loop2_cs_ro.sh
+JIT/Directed/coverage/oldtests/callipinvoke/callipinvoke.sh
JIT/Directed/coverage/oldtests/Desktop/callipinvoke_il_d/callipinvoke_il_d.sh
JIT/Directed/coverage/oldtests/Desktop/callipinvoke_il_r/callipinvoke_il_r.sh
-JIT/Directed/coverage/oldtests/callipinvoke/callipinvoke.sh
+JIT/Directed/IL/PInvokeTail/PInvokeTail/PInvokeTail.sh
+JIT/Directed/IL/PInvokeTail/TailWinApi/TailWinApi.sh
JIT/Directed/pinvoke/calli_excep/calli_excep.sh
JIT/Directed/pinvoke/jump/jump.sh
JIT/Directed/pinvoke/sin/sin.sh
JIT/Directed/pinvoke/sysinfo_cs/sysinfo_cs.sh
JIT/Directed/pinvoke/sysinfo_il/sysinfo_il.sh
JIT/Directed/pinvoke/tail/tail.sh
+JIT/Directed/UnrollLoop/loop2_cs_d/loop2_cs_d.sh
+JIT/Directed/UnrollLoop/loop2_cs_do/loop2_cs_do.sh
+JIT/Directed/UnrollLoop/loop2_cs_r/loop2_cs_r.sh
+JIT/Directed/UnrollLoop/loop2_cs_ro/loop2_cs_ro.sh
JIT/Generics/Fields/getclassfrommethodparam/getclassfrommethodparam.sh
JIT/Generics/pinvoke/instance01/instance01.sh
JIT/Generics/pinvoke/instance02/instance02.sh
JIT/Generics/pinvoke/instance03/instance03.sh
JIT/Generics/pinvoke/static01/static01.sh
JIT/Generics/pinvoke/static02/static02.sh
+JIT/jit64/gc/misc/funclet/funclet.sh
+JIT/jit64/mcc/interop/mcc_i00/mcc_i00.sh
+JIT/jit64/mcc/interop/mcc_i01/mcc_i01.sh
+JIT/jit64/mcc/interop/mcc_i02/mcc_i02.sh
+JIT/jit64/mcc/interop/mcc_i03/mcc_i03.sh
+JIT/jit64/mcc/interop/mcc_i04/mcc_i04.sh
+JIT/jit64/mcc/interop/mcc_i05/mcc_i05.sh
+JIT/jit64/mcc/interop/mcc_i06/mcc_i06.sh
+JIT/jit64/mcc/interop/mcc_i07/mcc_i07.sh
+JIT/jit64/mcc/interop/mcc_i10/mcc_i10.sh
+JIT/jit64/mcc/interop/mcc_i11/mcc_i11.sh
+JIT/jit64/mcc/interop/mcc_i12/mcc_i12.sh
+JIT/jit64/mcc/interop/mcc_i13/mcc_i13.sh
+JIT/jit64/mcc/interop/mcc_i14/mcc_i14.sh
+JIT/jit64/mcc/interop/mcc_i15/mcc_i15.sh
+JIT/jit64/mcc/interop/mcc_i16/mcc_i16.sh
+JIT/jit64/mcc/interop/mcc_i17/mcc_i17.sh
+JIT/jit64/mcc/interop/mcc_i30/mcc_i30.sh
+JIT/jit64/mcc/interop/mcc_i31/mcc_i31.sh
+JIT/jit64/mcc/interop/mcc_i32/mcc_i32.sh
+JIT/jit64/mcc/interop/mcc_i33/mcc_i33.sh
+JIT/jit64/mcc/interop/mcc_i34/mcc_i34.sh
+JIT/jit64/mcc/interop/mcc_i35/mcc_i35.sh
+JIT/jit64/mcc/interop/mcc_i36/mcc_i36.sh
+JIT/jit64/mcc/interop/mcc_i37/mcc_i37.sh
+JIT/jit64/mcc/interop/mcc_i50/mcc_i50.sh
+JIT/jit64/mcc/interop/mcc_i51/mcc_i51.sh
+JIT/jit64/mcc/interop/mcc_i52/mcc_i52.sh
+JIT/jit64/mcc/interop/mcc_i53/mcc_i53.sh
+JIT/jit64/mcc/interop/mcc_i54/mcc_i54.sh
+JIT/jit64/mcc/interop/mcc_i55/mcc_i55.sh
+JIT/jit64/mcc/interop/mcc_i56/mcc_i56.sh
+JIT/jit64/mcc/interop/mcc_i57/mcc_i57.sh
+JIT/jit64/mcc/interop/mcc_i60/mcc_i60.sh
+JIT/jit64/mcc/interop/mcc_i61/mcc_i61.sh
+JIT/jit64/mcc/interop/mcc_i62/mcc_i62.sh
+JIT/jit64/mcc/interop/mcc_i63/mcc_i63.sh
+JIT/jit64/mcc/interop/mcc_i64/mcc_i64.sh
+JIT/jit64/mcc/interop/mcc_i65/mcc_i65.sh
+JIT/jit64/mcc/interop/mcc_i66/mcc_i66.sh
+JIT/jit64/mcc/interop/mcc_i67/mcc_i67.sh
+JIT/jit64/mcc/interop/mcc_i70/mcc_i70.sh
+JIT/jit64/mcc/interop/mcc_i71/mcc_i71.sh
+JIT/jit64/mcc/interop/mcc_i72/mcc_i72.sh
+JIT/jit64/mcc/interop/mcc_i73/mcc_i73.sh
+JIT/jit64/mcc/interop/mcc_i74/mcc_i74.sh
+JIT/jit64/mcc/interop/mcc_i75/mcc_i75.sh
+JIT/jit64/mcc/interop/mcc_i76/mcc_i76.sh
+JIT/jit64/mcc/interop/mcc_i77/mcc_i77.sh
+JIT/jit64/mcc/interop/mcc_i80/mcc_i80.sh
+JIT/jit64/mcc/interop/mcc_i81/mcc_i81.sh
+JIT/jit64/mcc/interop/mcc_i82/mcc_i82.sh
+JIT/jit64/mcc/interop/mcc_i83/mcc_i83.sh
+JIT/jit64/mcc/interop/mcc_i84/mcc_i84.sh
+JIT/jit64/mcc/interop/mcc_i85/mcc_i85.sh
+JIT/jit64/mcc/interop/mcc_i86/mcc_i86.sh
+JIT/jit64/mcc/interop/mcc_i87/mcc_i87.sh
+JIT/jit64/regress/vsw/286991/test/test.sh
JIT/Methodical/Arrays/misc/_il_dbgarrres/_il_dbgarrres.sh
JIT/Methodical/Arrays/misc/_il_relarrres/_il_relarrres.sh
JIT/Methodical/cctor/xassem/xprecise3_cs_d/xprecise3_cs_d.sh
@@ -121,74 +292,16 @@ JIT/Methodical/explicit/coverage/seq_short_1_d/seq_short_1_d.sh
JIT/Methodical/explicit/coverage/seq_short_1_r/seq_short_1_r.sh
JIT/Methodical/explicit/coverage/seq_val_1_d/seq_val_1_d.sh
JIT/Methodical/explicit/coverage/seq_val_1_r/seq_val_1_r.sh
+JIT/opt/Inline/tests/security/security.sh
+JIT/opt/Inline/tests/xmodb/xmodb.sh
+JIT/Regression/clr-x64-JIT/v2.1/b173569/b173569/b173569.sh
+JIT/Regression/clr-x64-JIT/v4.0/devdiv374539/DevDiv_374539/DevDiv_374539.sh
JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b32374/b32374/b32374.sh
+JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b79250/b79250/b79250.sh
JIT/Regression/CLR-x86-JIT/V1.2-M01/b07493/b07493/b07493.sh
JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b427411/Desktop/b427411/b427411.sh
JIT/Regression/VS-ia64-JIT/V1.2-M01/b15632/b15632/b15632.sh
JIT/Regression/VS-ia64-JIT/V2.0-RTM/b286991/b286991/b286991.sh
-JIT/Regression/clr-x64-JIT/v2.1/b173569/b173569/b173569.sh
-JIT/Regression/clr-x64-JIT/v4.0/devdiv374539/DevDiv_374539/DevDiv_374539.sh
-JIT/jit64/gc/misc/funclet/funclet.sh
-JIT/jit64/mcc/interop/mcc_i00/mcc_i00.sh
-JIT/jit64/mcc/interop/mcc_i01/mcc_i01.sh
-JIT/jit64/mcc/interop/mcc_i02/mcc_i02.sh
-JIT/jit64/mcc/interop/mcc_i03/mcc_i03.sh
-JIT/jit64/mcc/interop/mcc_i04/mcc_i04.sh
-JIT/jit64/mcc/interop/mcc_i05/mcc_i05.sh
-JIT/jit64/mcc/interop/mcc_i06/mcc_i06.sh
-JIT/jit64/mcc/interop/mcc_i07/mcc_i07.sh
-JIT/jit64/mcc/interop/mcc_i10/mcc_i10.sh
-JIT/jit64/mcc/interop/mcc_i11/mcc_i11.sh
-JIT/jit64/mcc/interop/mcc_i12/mcc_i12.sh
-JIT/jit64/mcc/interop/mcc_i13/mcc_i13.sh
-JIT/jit64/mcc/interop/mcc_i14/mcc_i14.sh
-JIT/jit64/mcc/interop/mcc_i15/mcc_i15.sh
-JIT/jit64/mcc/interop/mcc_i16/mcc_i16.sh
-JIT/jit64/mcc/interop/mcc_i17/mcc_i17.sh
-JIT/jit64/mcc/interop/mcc_i30/mcc_i30.sh
-JIT/jit64/mcc/interop/mcc_i31/mcc_i31.sh
-JIT/jit64/mcc/interop/mcc_i32/mcc_i32.sh
-JIT/jit64/mcc/interop/mcc_i33/mcc_i33.sh
-JIT/jit64/mcc/interop/mcc_i34/mcc_i34.sh
-JIT/jit64/mcc/interop/mcc_i35/mcc_i35.sh
-JIT/jit64/mcc/interop/mcc_i36/mcc_i36.sh
-JIT/jit64/mcc/interop/mcc_i37/mcc_i37.sh
-JIT/jit64/mcc/interop/mcc_i50/mcc_i50.sh
-JIT/jit64/mcc/interop/mcc_i51/mcc_i51.sh
-JIT/jit64/mcc/interop/mcc_i52/mcc_i52.sh
-JIT/jit64/mcc/interop/mcc_i53/mcc_i53.sh
-JIT/jit64/mcc/interop/mcc_i54/mcc_i54.sh
-JIT/jit64/mcc/interop/mcc_i55/mcc_i55.sh
-JIT/jit64/mcc/interop/mcc_i56/mcc_i56.sh
-JIT/jit64/mcc/interop/mcc_i57/mcc_i57.sh
-JIT/jit64/mcc/interop/mcc_i60/mcc_i60.sh
-JIT/jit64/mcc/interop/mcc_i61/mcc_i61.sh
-JIT/jit64/mcc/interop/mcc_i62/mcc_i62.sh
-JIT/jit64/mcc/interop/mcc_i63/mcc_i63.sh
-JIT/jit64/mcc/interop/mcc_i64/mcc_i64.sh
-JIT/jit64/mcc/interop/mcc_i65/mcc_i65.sh
-JIT/jit64/mcc/interop/mcc_i66/mcc_i66.sh
-JIT/jit64/mcc/interop/mcc_i67/mcc_i67.sh
-JIT/jit64/mcc/interop/mcc_i70/mcc_i70.sh
-JIT/jit64/mcc/interop/mcc_i71/mcc_i71.sh
-JIT/jit64/mcc/interop/mcc_i72/mcc_i72.sh
-JIT/jit64/mcc/interop/mcc_i73/mcc_i73.sh
-JIT/jit64/mcc/interop/mcc_i74/mcc_i74.sh
-JIT/jit64/mcc/interop/mcc_i75/mcc_i75.sh
-JIT/jit64/mcc/interop/mcc_i76/mcc_i76.sh
-JIT/jit64/mcc/interop/mcc_i77/mcc_i77.sh
-JIT/jit64/mcc/interop/mcc_i80/mcc_i80.sh
-JIT/jit64/mcc/interop/mcc_i81/mcc_i81.sh
-JIT/jit64/mcc/interop/mcc_i82/mcc_i82.sh
-JIT/jit64/mcc/interop/mcc_i83/mcc_i83.sh
-JIT/jit64/mcc/interop/mcc_i84/mcc_i84.sh
-JIT/jit64/mcc/interop/mcc_i85/mcc_i85.sh
-JIT/jit64/mcc/interop/mcc_i86/mcc_i86.sh
-JIT/jit64/mcc/interop/mcc_i87/mcc_i87.sh
-JIT/jit64/regress/vsw/286991/test/test.sh
-JIT/opt/Inline/tests/security/security.sh
-JIT/opt/Inline/tests/xmodb/xmodb.sh
-JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b79250/b79250/b79250.sh
managed/Compilation/Compilation/Compilation.sh
Regressions/coreclr/0584/Test584/Test584.sh
GC/Regressions/v2.0-beta2/437657/437657/437657.sh
diff --git a/tests/x86_legacy_backend_issues.targets b/tests/x86_legacy_backend_issues.targets
index 66c083a734..99bcd6b485 100644
--- a/tests/x86_legacy_backend_issues.targets
+++ b/tests/x86_legacy_backend_issues.targets
@@ -615,5 +615,11 @@
<ExcludeList Include="$(XunitTestBinBase)\GC\Scenarios\muldimjagary\muldimjagary\*">
<Issue>3392</Issue>
</ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\baseservices\threading\waithandle\waitall\waitallex8\*">
+ <Issue>3832</Issue>
+ </ExcludeList>
+ <ExcludeList Include="$(XunitTestBinBase)\baseservices\threading\waithandle\waitall\waitallex8a\*">
+ <Issue>3832</Issue>
+ </ExcludeList>
</ItemGroup>
</Project>