Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
9cb9c84a3e58bd2712f47e85a4c926a0c2bd947e

View File

@@ -28,13 +28,34 @@ fi
# Remove the test executable from the arg list so it isn't passed to test execution
shift
testExtRepo=$( dirname ${CoreRT_TestRoot} )/tests_downloaded/CoreCLR/
nativeArtifactRepo=${testExtRepo}native/
dirSuffix=$(dirname ${PWD#$testExtRepo})/
nativeDir=${nativeArtifactRepo}tests/src/${dirSuffix}
# In OSX we copy the native component to the directory where the exectuable resides.
# However, in Linux dlopen doesn't seem to look for current directory to resolve the dynamic library.
# So instead we point LD_LIBRARY_PATH to the directory where the native component is.
if [ -e ${nativeDir} ]; then
if [ "${CoreRT_BuildOS}" == "OSX" ]; then
echo "Copying native component from :"${nativeDir}
cp ${nativeDir}*.dylib native/ 2>/dev/null
fi
if [ "${CoreRT_BuildOS}" == "Linux" ]; then
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${nativeDir}
export LD_LIBRARY_PATH
fi
fi
if [[ ! -f native/${TestFileName} ]]; then
echo "ERROR: Native binary not found. Unable to run test."
exit -1
fi
native/${TestFileName} "$@"
pushd native/
./${TestFileName} "$@"
testScriptExitCode=$?
popd
if [[ $CoreRT_EnableCoreDumps == 1 ]]; then
# Handle any core files generated when running the test.

View File

@@ -0,0 +1 @@
https://ci.dot.net/job/dotnet_coreclr/job/master/job/debug_ubuntu/1667/artifact/bin/obj/Linux.x64.Debug/tests/*zip*/tests.zip

View File

@@ -0,0 +1 @@
https://ci.dot.net/job/dotnet_coreclr/job/master/job/debug_osx10.12/653/artifact/bin/obj/OSX.x64.Debug/tests/*zip*/tests.zip

View File

@@ -0,0 +1 @@
https://ci.dot.net/job/dotnet_coreclr/job/master/job/debug_windows_nt_prtest/4/artifact/bin/tests/tests.zip

View File

@@ -0,0 +1,54 @@
<!--
Running all 7000 Pri-0 CoreCLR tests would take forever. Exclude down to a set that provides
broad coverage and an expected reasonable run time (< 30 minutes)
-->
<Project DefaultTargets = "GetListOfTestCmds"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemGroup Condition="'$(XunitTestBinBase)' != ''">
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyCharArray\CopyCharArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyDoubleArray\CopyDoubleArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt16Array\CopyInt16Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt32Array\CopyInt32Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt64Array\CopyInt64Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyIntPtrArray\CopyIntPtrArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopySingleArray\CopySingleArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\PrimitiveMarshalling\EnumMarshalling\EnumTest\EnumTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\FuncPtrAsDelegateParam\FuncPtrAsDelegateParam\FuncPtrAsDelegateParam.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\FunctionPointer\FunctionPtrTest\FunctionPtrTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\GetExceptionForHR\GetExceptionForHR\GetExceptionForHR.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\GetNativeVariantForObject\GetNativeVariantForObject\GetNativeVariantForObject.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\GetObjectForNativeVariant\GetObjectForNativeVariant\GetObjectForNativeVariant.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\GetObjectsForNativeVariants\GetObjectsForNativeVariants\GetObjectsForNativeVariants.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\IUnknown\IUnknownTest\IUnknownTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\StringMarshalling\LPSTR\LPSTRTest\LPSTRTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\StringMarshalling\LPTSTR\LPTSTRTest\LPTSTRTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\ArrayMarshalling\ByValArray\MarshalArrayByValTest\MarshalArrayByValTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\ArrayMarshalling\BoolArray\MarshalBoolArrayTest\MarshalBoolArrayTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Miscellaneous\MarshalClassTests\MarshalClassTests.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\StructMarshalling\PInvoke\MarshalStructAsLayoutExp\MarshalStructAsLayoutExp.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\StructMarshalling\PInvoke\MarshalStructAsLayoutSeq\MarshalStructAsLayoutSeq.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\MarshalStructure\MarshalStructure\MarshalStructure.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\NativeCallable\NativeCallableTest\NativeCallableTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\OffsetOf\OffsetOf\OffsetOf.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\PrimitiveMarshalling\UIntPtr\PInvokeUIntPtrTest\PInvokeUIntPtrTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\ReadWrite\ReadWriteByte\ReadWriteByte.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\ReadWrite\ReadWriteInt16\ReadWriteInt16.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\ReadWrite\ReadWriteInt32\ReadWriteInt32.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\ReadWrite\ReadWriteInt64\ReadWriteInt64.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\ReadWrite\ReadWriteIntPtr\ReadWriteIntPtr.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\RefCharArray\RefCharArrayTest\RefCharArrayTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\RefInt\RefIntTest\RefIntTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\SimpleStruct\SimpleStruct\SimpleStruct.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\SizeConst\SizeConstTest\SizeConstTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\String\StringMarshalingTest\StringMarshalingTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\UnsafeAddrOfPinnedArrayElement\UnsafeAddrOfPinnedArrayElement\UnsafeAddrOfPinnedArrayElement.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\StringMarshalling\UTF8\UTF8Test\UTF8Test.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Miscellaneous\AutoLayoutStructure\AutoLayoutStructure.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\BestFitMapping\BestFitMapping\BestFitMapping.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\PrimitiveMarshalling\Bool\BoolTest\BoolTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\ICastable\Castable\Castable.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyByteArray\CopyByteArray.cmd" />
</ItemGroup>
</Project>

43
external/corert/tests/Interop.unix.txt vendored Normal file
View File

@@ -0,0 +1,43 @@
Interop/MarshalAPI/Copy/CopyInt16Array/CopyInt16Array.sh
Interop/MarshalAPI/Copy/CopyInt32Array/CopyInt32Array.sh
Interop/MarshalAPI/Copy/CopyInt64Array/CopyInt64Array.sh
Interop/MarshalAPI/Copy/CopyIntPtrArray/CopyIntPtrArray.sh
Interop/MarshalAPI/Copy/CopySingleArray/CopySingleArray.sh
Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest/EnumTest.sh
Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.sh
Interop/MarshalAPI/FunctionPointer/FunctionPtrTest/FunctionPtrTest.sh
Interop/MarshalAPI/GetExceptionForHR/GetExceptionForHR/GetExceptionForHR.sh
Interop/MarshalAPI/GetNativeVariantForObject/GetNativeVariantForObject/GetNativeVariantForObject.sh
Interop/MarshalAPI/GetObjectForNativeVariant/GetObjectForNativeVariant/GetObjectForNativeVariant.sh
Interop/MarshalAPI/GetObjectsForNativeVariants/GetObjectsForNativeVariants/GetObjectsForNativeVariants.sh
Interop/MarshalAPI/IUnknown/IUnknownTest/IUnknownTest.sh
Interop/StringMarshalling/LPSTR/LPSTRTest/LPSTRTest.sh
Interop/StringMarshalling/LPTSTR/LPTSTRTest/LPTSTRTest.sh
Interop/ArrayMarshalling/ByValArray/MarshalArrayByValTest/MarshalArrayByValTest.sh
Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayTest/MarshalBoolArrayTest.sh
Interop/MarshalAPI/Miscellaneous/MarshalClassTests/MarshalClassTests.sh
Interop/StructMarshalling/PInvoke/MarshalStructAsLayoutExp/MarshalStructAsLayoutExp.sh
Interop/StructMarshalling/PInvoke/MarshalStructAsLayoutSeq/MarshalStructAsLayoutSeq.sh
Interop/MarshalAPI/MarshalStructure/MarshalStructure/MarshalStructure.sh
Interop/NativeCallable/NativeCallableTest/NativeCallableTest.sh
Interop/MarshalAPI/OffsetOf/OffsetOf/OffsetOf.sh
Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest/PInvokeUIntPtrTest.sh
Interop/MarshalAPI/ReadWrite/ReadWriteByte/ReadWriteByte.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt16/ReadWriteInt16.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt32/ReadWriteInt32.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt64/ReadWriteInt64.sh
Interop/MarshalAPI/ReadWrite/ReadWriteIntPtr/ReadWriteIntPtr.sh
Interop/RefCharArray/RefCharArrayTest/RefCharArrayTest.sh
Interop/RefInt/RefIntTest/RefIntTest.sh
Interop/SimpleStruct/SimpleStruct/SimpleStruct.sh
Interop/SizeConst/SizeConstTest/SizeConstTest.sh
Interop/MarshalAPI/String/StringMarshalingTest/StringMarshalingTest.sh
Interop/MarshalAPI/UnsafeAddrOfPinnedArrayElement/UnsafeAddrOfPinnedArrayElement/UnsafeAddrOfPinnedArrayElement.sh
Interop/StringMarshalling/UTF8/UTF8Test/UTF8Test.sh
Interop/MarshalAPI/Miscellaneous/AutoLayoutStructure/AutoLayoutStructure.sh
Interop/BestFitMapping/BestFitMapping/BestFitMapping.sh
Interop/PrimitiveMarshalling/Bool/BoolTest/BoolTest.sh
Interop/ICastable/Castable/Castable.sh
Interop/MarshalAPI/Copy/CopyByteArray/CopyByteArray.sh
Interop/MarshalAPI/Copy/CopyCharArray/CopyCharArray.sh
Interop/MarshalAPI/Copy/CopyDoubleArray/CopyDoubleArray.sh

View File

@@ -4,7 +4,7 @@
broad coverage and an expected reasonable run time (< 30 minutes)
-->
<Project DefaultTargets = "GetListOfTestCmds"
<Project DefaultTargets = "GetListOfTestCmds"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<ItemGroup Condition="'$(XunitTestBinBase)' != ''">
<IncludeList Include="$(XunitTestBinBase)\GC\Features\PartialCompaction\eco1\eco1.cmd" />
@@ -33,10 +33,10 @@
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyCharArray\CopyCharArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyDoubleArray\CopyDoubleArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt16Array\CopyInt16Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt32Array\CopyInt32Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyInt64Array\CopyInt64Array.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopyIntPtrArray\CopyIntPtrArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\MarshalAPI\Copy\CopySingleArray\CopySingleArray.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\ArrayMarshalling\BoolArray\MarshalBoolArrayTest\MarshalBoolArrayTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\PrimitiveMarshalling\Bool\BoolTest\BoolTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\SizeConst\SizeConstTest\SizeConstTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\Interop\PrimitiveMarshalling\UIntPtr\PInvokeUIntPtrTest\PInvokeUIntPtrTest.cmd" />
<IncludeList Include="$(XunitTestBinBase)\JIT\CodeGenBringUpTests\addref\addref.cmd" />
<IncludeList Include="$(XunitTestBinBase)\JIT\CodeGenBringUpTests\And1\And1.cmd" />
<IncludeList Include="$(XunitTestBinBase)\JIT\CodeGenBringUpTests\AndRef\AndRef.cmd" />

View File

@@ -192,4 +192,29 @@ JIT/CodeGenBringUpTests/UModConst/UModConst.sh
JIT/Directed/FaultHandlers/Nesting/Nesting/Nesting.sh
Loader/classloader/TypeInitialization/CctorsWithSideEffects/CctorThrowStaticField/CctorThrowStaticField.sh
JIT/jit64/localloc/eh/eh01_dynamic/eh01_dynamic.sh
JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976/DevDiv_142976.sh
JIT/Regression/JitBlue/DevDiv_142976/DevDiv_142976/DevDiv_142976.sh
Interop/MarshalAPI/Copy/CopyByteArray/CopyByteArray.sh
Interop/MarshalAPI/Copy/CopyCharArray/CopyCharArray.sh
Interop/MarshalAPI/Copy/CopyDoubleArray/CopyDoubleArray.sh
Interop/MarshalAPI/Copy/CopyInt16Array/CopyInt16Array.sh
Interop/MarshalAPI/Copy/CopyInt32Array/CopyInt32Array.sh
Interop/MarshalAPI/Copy/CopyInt64Array/CopyInt64Array.sh
Interop/MarshalAPI/Copy/CopyIntPtrArray/CopyIntPtrArray.sh
Interop/MarshalAPI/Copy/CopySingleArray/CopySingleArray.sh
Interop/PrimitiveMarshalling/EnumMarshalling/EnumTest/EnumTest.sh
Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam/FuncPtrAsDelegateParam.sh
Interop/MarshalAPI/FunctionPointer/FunctionPtrTest/FunctionPtrTest.sh
Interop/MarshalAPI/GetObjectsForNativeVariants/GetObjectsForNativeVariants/GetObjectsForNativeVariants.sh
Interop/StringMarshalling/LPSTR/LPSTRTest/LPSTRTest.sh
Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayTest/MarshalBoolArrayTest.sh
Interop/PrimitiveMarshalling/UIntPtr/PInvokeUIntPtrTest/PInvokeUIntPtrTest.sh
Interop/MarshalAPI/ReadWrite/ReadWriteByte/ReadWriteByte.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt16/ReadWriteInt16.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt32/ReadWriteInt32.sh
Interop/MarshalAPI/ReadWrite/ReadWriteInt64/ReadWriteInt64.sh
Interop/MarshalAPI/ReadWrite/ReadWriteIntPtr/ReadWriteIntPtr.sh
Interop/RefCharArray/RefCharArrayTest/RefCharArrayTest.sh
Interop/RefInt/RefIntTest/RefIntTest.sh
Interop/SizeConst/SizeConstTest/SizeConstTest.sh
Interop/MarshalAPI/UnsafeAddrOfPinnedArrayElement/UnsafeAddrOfPinnedArrayElement/UnsafeAddrOfPinnedArrayElement.sh
Interop/PrimitiveMarshalling/Bool/BoolTest/BoolTest.sh

View File

@@ -14,6 +14,10 @@ set CoreRT_CoreCLRTargetsFile=
set CoreRT_TestLogFileName=testresults.xml
set CoreRT_TestName=*
:: Default to highest Visual Studio version available
set CoreRT_VSVersion=vs2015
if defined VS150COMNTOOLS set CoreRT_VSVersion=vs2017
:ArgLoop
if "%1" == "" goto :ArgsDone
if /i "%1" == "/?" goto :Usage
@@ -21,6 +25,9 @@ if /i "%1" == "x64" (set CoreRT_BuildArch=x64&&shift&goto ArgLoop)
if /i "%1" == "x86" (set CoreRT_BuildArch=x86&&shift&goto ArgLoop)
if /i "%1" == "arm" (set CoreRT_BuildArch=arm&&shift&goto ArgLoop)
if /i "%1" == "vs2017" (set CoreRT_VSVersion=vs2017&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set CoreRT_VSVersion=vs2015&shift&goto Arg_Loop)
if /i "%1" == "debug" (set CoreRT_BuildType=Debug&shift&goto ArgLoop)
if /i "%1" == "release" (set CoreRT_BuildType=Release&shift&goto ArgLoop)
if /i "%1" == "/coreclr" (
@@ -39,6 +46,7 @@ if /i "%1" == "/coreclr" (
if /i "!SelectedTests!" == "Top200" set CoreRT_CoreCLRTargetsFile=%CoreRT_TestRoot%\Top200.CoreCLR.issues.targets&&goto :ExtRepoTestsOk
if /i "!SelectedTests!" == "KnownGood" set CoreRT_CoreCLRTargetsFile=%CoreRT_TestRoot%\CoreCLR.issues.targets&&goto :ExtRepoTestsOk
if /i "!SelectedTests!" == "Interop" set CoreRT_CoreCLRTargetsFile=%CoreRT_TestRoot%\Interop.CoreCLR.issues.targets&&goto :ExtRepoTestsOk
echo Invalid test selection specified: !SelectedTests!
goto :Usage
@@ -71,6 +79,7 @@ echo.
echo --- CoreCLR Subset ---
echo Top200 : Runs broad coverage / CI validation (~200 tests).
echo KnownGood : Runs tests known to pass on CoreRT (~6000 tests).
echo Interop : Runs only the interop tests (~43 tests).
echo All : Runs all tests. There will be many failures (~7000 tests).
exit /b 2
@@ -101,7 +110,12 @@ if NOT "%CoreRT_MultiFileConfiguration%" == "" (
set __LogDir=%CoreRT_TestRoot%\..\bin\Logs\%__BuildStr%\tests
call "!VS140COMNTOOLS!\..\..\VC\vcvarsall.bat" %CoreRT_BuildArch%
:: VS2017 changed the location of vcvarsall.bat.
if /i "%__VSVersion%" == "vs2017" (
call "!VS150COMNTOOLS!\..\..\VC\Auxiliary\Build\vcvarsall.bat" %CoreRT_BuildArch%
) else (
call "!VS140COMNTOOLS!\..\..\VC\vcvarsall.bat" %CoreRT_BuildArch%
)
if "%CoreRT_RunCoreCLRTests%"=="true" goto :TestExtRepo
@@ -113,30 +127,31 @@ if /i "%__BuildType%"=="Debug" (
echo. > %__CoreRTTestBinDir%\testResults.tmp
rem Hacky filtering to prevent shared generics and unshared generics from mixing
set __Filter=
if /i "%CoreRT_MultiFileConfiguration%" == "MultiModule" (
set __Filter=^^^| findstr /V Generics
)
set /a __CppTotalTests=0
set /a __CppPassedTests=0
set /a __JitTotalTests=0
set /a __JitPassedTests=0
for /f "delims=" %%a in ('cmd /c dir /s /aD /b %CoreRT_TestRoot%\src\%CoreRT_TestName% %__Filter%') do (
for /f "delims=" %%a in ('dir /s /aD /b %CoreRT_TestRoot%\src\%CoreRT_TestName%') do (
set __SourceFolder=%%a
set __SourceFileName=%%~na
set __RelativePath=!__SourceFolder:%CoreRT_TestRoot%=!
set __SourceFileProj=
if exist "!__SourceFolder!\!__SourceFileName!.csproj" (
set __SourceFileProj=!__SourceFolder!\!__SourceFileName!.csproj
)
if exist "!__SourceFolder!\!__SourceFileName!.ilproj" (
set __SourceFileProj=!__SourceFolder!\!__SourceFileName!.ilproj
)
if NOT "!__SourceFileProj!" == "" (
if /i not "%CoreRT_TestCompileMode%" == "cpp" (
set __Mode=Jit
call :CompileFile !__SourceFolder! !__SourceFileName! %__LogDir%\!__RelativePath!
call :CompileFile !__SourceFolder! !__SourceFileName! !__SourceFileProj! %__LogDir%\!__RelativePath!
set /a __JitTotalTests=!__JitTotalTests!+1
)
if /i not "%CoreRT_TestCompileMode%" == "ryujit" (
if not exist "!__SourceFolder!\no_cpp" (
set __Mode=Cpp
call :CompileFile !__SourceFolder! !__SourceFileName! %__LogDir%\!__RelativePath!
call :CompileFile !__SourceFolder! !__SourceFileName! !__SourceFileProj! %__LogDir%\!__RelativePath!
set /a __CppTotalTests=!__CppTotalTests!+1
)
)
@@ -193,7 +208,8 @@ goto :eof
echo.
set __SourceFolder=%~1
set __SourceFileName=%~2
set __CompileLogPath=%~3
set __SourceFileProj=%~3
set __CompileLogPath=%~4
echo Compiling directory !__SourceFolder! !__Mode!
echo.
@@ -217,9 +233,9 @@ goto :eof
)
)
echo msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFile!.csproj
echo msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFileProj!
echo.
msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFile!.csproj
msbuild /m /ConsoleLoggerParameters:ForceNoAlign "/p:IlcPath=%CoreRT_ToolchainDir%" "/p:Configuration=%CoreRT_BuildType%" "/p:Platform=%CoreRT_BuildArch%" "/p:RepoLocalBuild=true" "/p:FrameworkLibPath=%~dp0..\bin\Product\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\lib" "/p:FrameworkObjPath=%~dp0..\bin\obj\%CoreRT_BuildOS%.%CoreRT_BuildArch%.%CoreRT_BuildType%\Framework" !extraArgs! !__SourceFileProj!
endlocal
set __SavedErrorLevel=%ErrorLevel%
@@ -267,7 +283,7 @@ goto :eof
if exist "%CoreRT_TestExtRepo%" rmdir /S /Q "%CoreRT_TestExtRepo%"
mkdir "%CoreRT_TestExtRepo%"
set /p TESTS_REMOTE_URL=< "%~dp0..\CoreCLRTestsURL.txt"
set /p TESTS_REMOTE_URL=< "%~dp0\CoreCLRTestsURL.txt"
set TESTS_LOCAL_ZIP=%CoreRT_TestExtRepo%\tests.zip
set INIT_TESTS_LOG=%~dp0..\init-tests.log
echo Restoring tests (this may take a few minutes)..

View File

@@ -14,6 +14,7 @@ usage()
echo " --- CoreCLR Subset ---"
echo " top200 : Runs broad coverage / CI validation (~200 tests)."
echo " knowngood : Runs tests known to pass on CoreRT (~6000 tests)."
echo " interop : Runs only the interop tests (~43 tests)."
echo " all : Runs all tests. There will be many failures (~7000 tests)."
exit 1
}
@@ -80,34 +81,50 @@ run_test_dir()
return $?
}
download_and_unzip_tests_artifacts()
{
url=$1
location=$2
semaphore=$3
if [ ! -e ${semaphore} ]; then
if [ -d ${location} ]; then
rm -r ${location}
fi
mkdir -p ${location}
local_zip=${location}/tests.zip
curl --retry 10 --retry-delay 5 -sSL -o ${local_zip} ${url}
unzip -q ${local_zip} -d ${location}
echo "CoreCLR tests artifacts restored from ${url}" >> ${semaphore}
fi
}
restore_coreclr_tests()
{
CoreRT_Test_Download_Semaphore=${CoreRT_TestExtRepo}/init-tests.completed
CoreRT_NativeArtifact_Download_Semaphore=${CoreRT_TestExtRepo}/init-native-artifact.completed
if [ -e ${CoreRT_Test_Download_Semaphore} ]; then
if [ -e ${CoreRT_Test_Download_Semaphore} ] && [ -e ${CoreRT_NativeArtifact_Download_Semaphore} ]; then
echo "Tests are already initialized."
return 0
fi
TESTS_REMOTE_URL=$(<${CoreRT_TestRoot}/CoreCLRTestsURL.txt)
NATIVE_REMOTE_URL=$(<${CoreRT_TestRoot}/CoreCLRTestsNativeArtifacts_${CoreRT_BuildOS}.txt)
CoreRT_NativeArtifactRepo=${CoreRT_TestExtRepo}/native
if [ -d ${CoreRT_TestExtRepo} ]; then
rm -r ${CoreRT_TestExtRepo}
fi
mkdir -p ${CoreRT_TestExtRepo}
echo "Restoring tests (this may take a few minutes).."
TESTS_REMOTE_URL=$(<${CoreRT_TestRoot}/../CoreCLRTestsURL.txt)
TESTS_LOCAL_ZIP=${CoreRT_TestExtRepo}/tests.zip
curl --retry 10 --retry-delay 5 -sSL -o ${TESTS_LOCAL_ZIP} ${TESTS_REMOTE_URL}
download_and_unzip_tests_artifacts ${TESTS_REMOTE_URL} ${CoreRT_TestExtRepo} ${CoreRT_Test_Download_Semaphore}
unzip -q ${TESTS_LOCAL_ZIP} -d ${CoreRT_TestExtRepo}
echo "CoreCLR tests restored from ${TESTS_REMOTE_URL}" >> ${CoreRT_Test_Download_Semaphore}
echo "Restoring native test artifacts..."
download_and_unzip_tests_artifacts ${NATIVE_REMOTE_URL} ${CoreRT_NativeArtifactRepo} ${CoreRT_NativeArtifact_Download_Semaphore}
}
run_coreclr_tests()
{
if [ -z ${CoreRT_TestExtRepo} ]; then
CoreRT_TestExtRepo=${CoreRT_TestRoot}/../tests_downloaded/CoreCLR
CoreRT_TestExtRepo=$( dirname ${CoreRT_TestRoot} )/tests_downloaded/CoreCLR
fi
restore_coreclr_tests
@@ -127,6 +144,8 @@ run_coreclr_tests()
CoreRT_TestSelectionArg=
if [ "$SelectedTests" = "top200" ]; then
CoreRT_TestSelectionArg="--playlist=${CoreRT_TestRoot}/Top200.unix.txt"
elif [ "$SelectedTests" = "interop" ]; then
CoreRT_TestSelectionArg="--playlist=${CoreRT_TestRoot}/Interop.unix.txt"
elif [ "$SelectedTests" = "knowngood" ]; then
# Todo: Build the list of tests that pass
CoreRT_TestSelectionArg=
@@ -206,7 +225,7 @@ while [ "$1" != "" ]; do
if [ -z ${SelectedTests} ]; then
SelectedTests=top200
elif [ "${SelectedTests}" != "all" ] && [ "${SelectedTests}" != "top200" ] && [ "${SelectedTests}" != "knowngood" ]; then
elif [ "${SelectedTests}" != "all" ] && [ "${SelectedTests}" != "top200" ] && [ "${SelectedTests}" != "knowngood" ] && [ "${SelectedTests}" != "interop" ]; then
echo "Error: Invalid CoreCLR test selection."
exit -1
fi

View File

@@ -26,14 +26,10 @@ class Program
if (ThreadTest.Run() != Pass)
return Fail;
return Pass;
}
if (TimerTest.Run() != Pass)
return Fail;
public static bool IsRunnningOnWindows()
{
// Note: Environment.OSVersion is not yet available.
// This is a temporary hack that allows to skip Task related tests on Unix.
return System.IO.Path.DirectorySeparatorChar == '\\';
return Pass;
}
}
@@ -163,12 +159,6 @@ class ThreadStaticsTestWithTasks
public static void Run()
{
if (!Program.IsRunnningOnWindows())
{
// Tasks are not supported on Unix yet
return;
}
Task[] tasks = new Task[TotalTaskCount];
for (int i = 0; i < tasks.Length; ++i)
{
@@ -340,12 +330,6 @@ class ThreadTest
private static void TestIsBackgroundProperty()
{
if (!Program.IsRunnningOnWindows())
{
// This test uses tasks which are not supported on Unix yet
return;
}
// Thread created using Thread.Start
var t_event = new AutoResetEvent(false);
var t = new Thread(() => t_event.WaitOne());
@@ -576,3 +560,73 @@ class ThreadTest
}
}
}
class TimerTest
{
private static AutoResetEvent s_event;
private static Timer s_timer;
private static volatile int s_periodicTimerCount;
public static int Run()
{
s_event = new AutoResetEvent(false);
s_timer = new Timer(TimerCallback, null, 200, Timeout.Infinite);
bool timerFired = s_event.WaitOne(TimeSpan.FromSeconds(5));
if (!timerFired)
{
Console.WriteLine("The timer test failed: timer has not fired.");
return Program.Fail;
}
// Change the timer to a very long value
s_event.Reset();
s_timer.Change(3000000, Timeout.Infinite);
timerFired = s_event.WaitOne(500);
if (timerFired)
{
Console.WriteLine("The timer test failed: timer fired earlier than expected.");
return Program.Fail;
}
// Try change existing timer to a small value and make sure it fires
s_event.Reset();
s_timer.Change(200, Timeout.Infinite);
timerFired = s_event.WaitOne(TimeSpan.FromSeconds(5));
if (!timerFired)
{
Console.WriteLine("The timer test failed: failed to change the existing timer.");
return Program.Fail;
}
// Test a periodic timer
s_periodicTimerCount = 0;
s_event.Reset();
s_timer = new Timer(PeriodicTimerCallback, null, 200, 20);
while (s_periodicTimerCount < 3)
{
timerFired = s_event.WaitOne(TimeSpan.FromSeconds(5));
if (!timerFired)
{
Console.WriteLine("The timer test failed: the periodic timer has not fired.");
return Program.Fail;
}
}
// Stop the periodic timer
s_timer.Change(Timeout.Infinite, Timeout.Infinite);
return Program.Pass;
}
private static void TimerCallback(object state)
{
s_event.Set();
}
private static void PeriodicTimerCallback(object state)
{
Interlocked.Increment(ref s_periodicTimerCount);
s_event.Set();
}
}

View File

@@ -20,6 +20,8 @@ public class BringUpTest
static BringUpTest g = null;
static int finallyCounter = 0;
public static int Main()
{
if (string.Empty.Length > 0)
@@ -102,6 +104,27 @@ public class BringUpTest
counter++;
}
// test interaction of filters and finally clauses with GC
try
{
ThrowExcThroughMethodsWithFinalizers1("Main");
}
catch (Exception e) when (FilterWithGC() && counter++ > 0)
{
Console.WriteLine(e.Message);
if (e.Message != "ThrowExcThroughMethodsWithFinalizers2")
{
Console.WriteLine("Unexpected exception message!");
return Fail;
}
if (finallyCounter != 2)
{
Console.WriteLine("Finalizers didn't execute!");
return Fail;
}
counter++;
}
try
{
try
@@ -121,7 +144,7 @@ public class BringUpTest
counter++;
}
if (counter != 8)
if (counter != 10)
{
Console.WriteLine("Unexpected counter value");
return Fail;
@@ -129,4 +152,52 @@ public class BringUpTest
return Pass;
}
static void CreateSomeGarbage()
{
for (int i = 0; i < 100; i++)
{
string s = new string('.', 100);
}
}
static void ThrowExcThroughMethodsWithFinalizers1(string caller)
{
CreateSomeGarbage();
string s = caller + " + ThrowExcThroughMethodsWithFinalizers1";
CreateSomeGarbage();
try
{
ThrowExcThroughMethodsWithFinalizers2(s);
}
finally
{
Console.WriteLine("Executing finally in {0}", s);
finallyCounter++;
}
}
static void ThrowExcThroughMethodsWithFinalizers2(string caller)
{
CreateSomeGarbage();
string s = caller + " + ThrowExcThroughMethodsWithFinalizers2";
CreateSomeGarbage();
try
{
throw new Exception("ThrowExcThroughMethodsWithFinalizers2");
}
finally
{
Console.WriteLine("Executing finally in {0}", s);
finallyCounter++;
}
}
static bool FilterWithGC()
{
CreateSomeGarbage();
GC.Collect();
CreateSomeGarbage();
return true;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,4 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<IlcArg Include="--usesharedgenerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="*.cs" />
</ItemGroup>

View File

@@ -36,12 +36,36 @@ namespace PInvokeTests
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiString(string str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiStringOut(out string str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiStringRef(ref string str);
[DllImport("*", EntryPoint = "VerifyAnsiStringRef", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiStringInRef([In]ref string str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern int VerifyUnicodeString(string str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern int VerifyUnicodeStringOut(out string str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern int VerifyUnicodeStringRef(ref string str);
[DllImport("*", EntryPoint = "VerifyUnicodeStringRef", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern int VerifyUnicodeStringInRef([In]ref string str);
[DllImport("*", CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiStringArray([In, MarshalAs(UnmanagedType.LPArray)]string[] str);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern bool VerifyAnsiCharArrayIn(char[] a);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern bool VerifyAnsiCharArrayOut([Out]char[] a);
[DllImport("*", CharSet = CharSet.Ansi)]
private static extern void ToUpper([In, Out, MarshalAs(UnmanagedType.LPArray)]string[] str);
@@ -49,8 +73,23 @@ namespace PInvokeTests
private static extern bool VerifySizeParamIndex(
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out byte[] arrByte, out byte arrSize);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = "VerifyUnicodeStringBuilder")]
private static extern int VerifyUnicodeStringBuilder(StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = "VerifyUnicodeStringBuilder")]
private static extern int VerifyUnicodeStringBuilderIn([In]StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern int VerifyStringBuilder(StringBuilder sb);
private static extern int VerifyUnicodeStringBuilderOut([Out]StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "VerifyAnsiStringBuilder")]
private static extern int VerifyAnsiStringBuilder(StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "VerifyAnsiStringBuilder")]
private static extern int VerifyAnsiStringBuilderIn([In]StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
private static extern int VerifyAnsiStringBuilderOut([Out]StringBuilder sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
public static extern bool SafeHandleTest(SafeMemoryHandle sh1, Int64 sh1Value);
@@ -70,6 +109,12 @@ namespace PInvokeTests
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool ReversePInvoke_String(Delegate_String del);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern Delegate_String GetDelegate();
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool Callback(ref Delegate_String d);
delegate void Delegate_Unused();
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern unsafe int* ReversePInvoke_Unused(Delegate_Unused del);
@@ -77,6 +122,9 @@ namespace PInvokeTests
[DllImport("*", CallingConvention = CallingConvention.StdCall, EntryPoint = "StructTest")]
static extern bool StructTest_Auto(AutoStruct ss);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool StructTest_Sequential2(NesterOfSequentialStruct.SequentialStruct ss);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool StructTest(SequentialStruct ss);
@@ -92,6 +140,47 @@ namespace PInvokeTests
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool StructTest_Nested(NestedStruct ns);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool StructTest_Array(SequentialStruct []ns, int length);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
static extern bool IsNULL(char[] a);
[DllImport("*", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
static extern bool IsNULL(String sb);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool IsNULL(Foo[] foo);
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool IsNULL(SequentialStruct[] foo);
[StructLayout(LayoutKind.Sequential, CharSet= CharSet.Ansi, Pack = 4)]
public unsafe struct InlineArrayStruct
{
public int f0;
public int f1;
public int f2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public short[] inlineArray;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
public string inlineString;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 4)]
public unsafe struct InlineUnicodeStruct
{
public int f0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
public string inlineString;
}
[DllImport("*", CallingConvention = CallingConvention.StdCall)]
static extern bool InlineArrayTest(ref InlineArrayStruct ias, ref InlineUnicodeStruct ius);
public static int Main(string[] args)
{
TestBlittableType();
@@ -167,7 +256,10 @@ namespace PInvokeTests
Console.WriteLine("Testing marshalling blittable struct arrays");
Foo[] arr_foo = new Foo[ArraySize];
Foo[] arr_foo = null;
ThrowIfNotEquals(true, IsNULL(arr_foo), "Blittable array null check failed");
arr_foo = new Foo[ArraySize];
for (int i = 0; i < ArraySize; i++)
{
arr_foo[i].a = i;
@@ -175,6 +267,16 @@ namespace PInvokeTests
}
ThrowIfNotEquals(0, CheckIncremental_Foo(arr_foo, ArraySize), "Array marshalling failed");
char[] a = "Hello World".ToCharArray();
ThrowIfNotEquals(true, VerifyAnsiCharArrayIn(a), "Ansi Char Array In failed");
char[] b = new char[12];
ThrowIfNotEquals(true, VerifyAnsiCharArrayOut(b), "Ansi Char Array Out failed");
ThrowIfNotEquals("Hello World!", new String(b), "Ansi Char Array Out failed2");
char[] c = null;
ThrowIfNotEquals(true, IsNULL(c), "AnsiChar Array null check failed");
}
private static void TestByRef()
@@ -200,15 +302,66 @@ namespace PInvokeTests
Console.WriteLine("Testing marshalling string");
ThrowIfNotEquals(1, VerifyAnsiString("Hello World"), "Ansi String marshalling failed.");
ThrowIfNotEquals(1, VerifyUnicodeString("Hello World"), "Unicode String marshalling failed.");
string s;
ThrowIfNotEquals(1, VerifyAnsiStringOut(out s), "Out Ansi String marshalling failed");
ThrowIfNotEquals("Hello World", s, "Out Ansi String marshalling failed");
VerifyAnsiStringInRef(ref s);
ThrowIfNotEquals("Hello World", s, "In Ref ansi String marshalling failed");
VerifyAnsiStringRef(ref s);
ThrowIfNotEquals("Hello World!", s, "Ref ansi String marshalling failed");
ThrowIfNotEquals(1, VerifyUnicodeStringOut(out s), "Out Unicode String marshalling failed");
ThrowIfNotEquals("Hello World", s, "Out Unicode String marshalling failed");
VerifyUnicodeStringInRef(ref s);
ThrowIfNotEquals("Hello World", s, "In Ref Unicode String marshalling failed");
VerifyUnicodeStringRef(ref s);
ThrowIfNotEquals("Hello World!", s, "Ref Unicode String marshalling failed");
string ss = null;
ThrowIfNotEquals(true, IsNULL(ss), "Ansi String null check failed");
}
private static void TestStringBuilder()
{
Console.WriteLine("Testing marshalling string builder");
StringBuilder sb = new StringBuilder(16);
VerifyStringBuilder(sb);
bool result = (sb.ToString() == "Hello World");
ThrowIfNotEquals(true, result, "Unicode String builder marshalling failed.");
StringBuilder sb = new StringBuilder("Hello World");
ThrowIfNotEquals(1, VerifyUnicodeStringBuilder(sb), "Unicode StringBuilder marshalling failed");
ThrowIfNotEquals("HELLO WORLD", sb.ToString(), "Unicode StringBuilder marshalling failed.");
StringBuilder sb1 = null;
// for null stringbuilder it should return -1
ThrowIfNotEquals(-1, VerifyUnicodeStringBuilder(sb1), "Null unicode StringBuilder marshalling failed");
StringBuilder sb2 = new StringBuilder("Hello World");
ThrowIfNotEquals(1, VerifyUnicodeStringBuilderIn(sb2), "In unicode StringBuilder marshalling failed");
// Only [In] should change stringbuilder value
ThrowIfNotEquals("Hello World", sb2.ToString(), "In unicode StringBuilder marshalling failed");
StringBuilder sb3 = new StringBuilder();
ThrowIfNotEquals(1, VerifyUnicodeStringBuilderOut(sb3), "Out Unicode string marshalling failed");
ThrowIfNotEquals("Hello World", sb3.ToString(), "Out Unicode StringBuilder marshalling failed");
StringBuilder sb4 = new StringBuilder("Hello World");
ThrowIfNotEquals(1, VerifyAnsiStringBuilder(sb4), "Ansi StringBuilder marshalling failed");
ThrowIfNotEquals("HELLO WORLD", sb4.ToString(), "Ansi StringBuilder marshalling failed.");
StringBuilder sb5 = null;
// for null stringbuilder it should return -1
ThrowIfNotEquals(-1, VerifyAnsiStringBuilder(sb5), "Null Ansi StringBuilder marshalling failed");
StringBuilder sb6 = new StringBuilder("Hello World");
ThrowIfNotEquals(1, VerifyAnsiStringBuilderIn(sb6), "In unicode StringBuilder marshalling failed");
// Only [In] should change stringbuilder value
ThrowIfNotEquals("Hello World", sb6.ToString(), "In unicode StringBuilder marshalling failed");
StringBuilder sb7 = new StringBuilder();
ThrowIfNotEquals(1, VerifyAnsiStringBuilderOut(sb7), "Out Ansi string marshalling failed");
ThrowIfNotEquals("Hello World!", sb7.ToString(), "Out Ansi StringBuilder marshalling failed");
}
@@ -298,6 +451,13 @@ namespace PInvokeTests
Delegate_Int closed = new Delegate_Int((new ClosedDelegateCLass()).Sum);
ThrowIfNotEquals(true, ReversePInvoke_Int(closed), "Closed Delegate marshalling failed.");
Delegate_String ret = GetDelegate();
ThrowIfNotEquals(true, ret("Hello World!"), "Delegate as P/Invoke return failed");
Delegate_String d = new Delegate_String(new ClosedDelegateCLass().GetString);
ThrowIfNotEquals(true, Callback(ref d), "Delegate IN marshalling failed");
ThrowIfNotEquals(true, d("Hello World!"), "Delegate OUT marshalling failed");
Delegate_String ds = new Delegate_String((new ClosedDelegateCLass()).GetString);
ThrowIfNotEquals(true, ReversePInvoke_String(ds), "Delegate marshalling failed.");
}
@@ -326,6 +486,18 @@ namespace PInvokeTests
public String f3;
}
// A second struct with the same name but nested. Regression test against native types being mangled into
// the compiler-generated type and losing fully qualified type name information.
class NesterOfSequentialStruct
{
[StructLayout(LayoutKind.Sequential)]
public struct SequentialStruct
{
public float f1;
public int f2;
}
}
[StructLayout(LayoutKind.Explicit)]
public struct ExplicitStruct
{
@@ -366,6 +538,12 @@ namespace PInvokeTests
StructTest_ByOut(out ss2);
ThrowIfNotEquals(true, ss2.f0 == 1 && ss2.f1 == 1.0 && ss2.f2 == 1.0 && ss2.f3.Equals("0123456"), "Struct marshalling scenario3 failed.");
NesterOfSequentialStruct.SequentialStruct ss3 = new NesterOfSequentialStruct.SequentialStruct();
ss3.f1 = 10.0f;
ss3.f2 = 123;
ThrowIfNotEquals(true, StructTest_Sequential2(ss3), "Struct marshalling scenario1 failed.");
ExplicitStruct es = new ExplicitStruct();
es.f1 = 100;
es.f2 = 100.0f;
@@ -377,9 +555,50 @@ namespace PInvokeTests
ns.f2 = es;
ThrowIfNotEquals(true, StructTest_Nested(ns), "Struct marshalling scenario5 failed.");
// RhpThrowEx is not implemented in CPPCodeGen
SequentialStruct[] ssa = null;
ThrowIfNotEquals(true, IsNULL(ssa), "Non-blittable array null check failed");
ssa = new SequentialStruct[3];
for (int i = 0; i < 3; i++)
{
ssa[i].f1 = 0;
ssa[i].f1 = i;
ssa[i].f2 = i*i;
ssa[i].f3 = i.LowLevelToString();
}
ThrowIfNotEquals(true, StructTest_Array(ssa, ssa.Length), "Array of struct marshalling failed");
InlineArrayStruct ias = new InlineArrayStruct();
ias.inlineArray = new short[128];
for (short i = 0; i < 128; i++)
{
ias.inlineArray[i] = i;
}
ias.inlineString = "Hello";
InlineUnicodeStruct ius = new InlineUnicodeStruct();
ius.inlineString = "Hello World";
#if !CODEGEN_CPP
bool pass = false;
ThrowIfNotEquals(true, InlineArrayTest(ref ias, ref ius), "inline array marshalling failed");
bool pass = true;
for (short i = 0; i < 128; i++)
{
if (ias.inlineArray[i] != i + 1)
{
pass = false;
}
}
ThrowIfNotEquals(true, pass, "inline array marshalling failed");
ThrowIfNotEquals("Hello World", ias.inlineString, "Inline ByValTStr Ansi marshalling failed");
ThrowIfNotEquals("Hello World", ius.inlineString, "Inline ByValTStr Unicode marshalling failed");
// RhpThrowEx is not implemented in CPPCodeGen
pass = false;
AutoStruct autoStruct = new AutoStruct();
try
{
@@ -421,4 +640,35 @@ namespace PInvokeTests
}
} //end of SafeMemoryHandle class
public static class LowLevelExtensions
{
// Int32.ToString() calls into glob/loc garbage that hits CppCodegen limitations
public static string LowLevelToString(this int i)
{
char[] digits = new char[11];
int numDigits = 0;
if (i == int.MinValue)
return "-2147483648";
bool negative = i < 0;
if (negative)
i = -i;
do
{
digits[numDigits] = (char)('0' + (i % 10));
numDigits++;
i /= 10;
}
while (i != 0);
if (negative)
{
digits[numDigits] = '-';
numDigits++;
}
Array.Reverse(digits);
return new string(digits, digits.Length - numDigits, numDigits);
}
}
}

View File

@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef Windows_NT
#include <windows.h>
#define DLL_EXPORT extern "C" __declspec(dllexport)
@@ -17,6 +18,29 @@
#define __stdcall
#endif
#if (_MSC_VER >= 1400) // Check MSC version
#pragma warning(push)
#pragma warning(disable: 4996) // Disable deprecation
#endif
void* MemAlloc(long bytes)
{
#ifdef Windows_NT
return (unsigned char *)CoTaskMemAlloc(bytes);
#else
return (unsigned char *)malloc(bytes);
#endif
}
void MemFree(void *p)
{
#ifdef Windows_NT
CoTaskMemFree(p);
#else
free(p);
#endif
}
DLL_EXPORT int __stdcall Square(int intValue)
{
return intValue * intValue;
@@ -94,18 +118,24 @@ DLL_EXPORT bool __stdcall GetNextChar(short *value)
int CompareAnsiString(const char *val, const char * expected)
{
if (val == NULL)
return strcmp(val, expected) == 0 ? 1 : 0;
}
int CompareUnicodeString(const unsigned short *val, const unsigned short *expected)
{
if (val == NULL && expected == NULL)
return 1;
if (val == NULL || expected == NULL)
return 0;
const char *p = expected;
const char *q = val;
const unsigned short *p = val;
const unsigned short *q = expected;
while (*p && *q && *p == *q)
{
p++;
q++;
}
return *p == 0 && *q == 0;
}
@@ -117,6 +147,45 @@ DLL_EXPORT int __stdcall VerifyAnsiString(char *val)
return CompareAnsiString(val, "Hello World");
}
void CopyAnsiString(char *dst, char *src)
{
if (src == NULL || dst == NULL)
return;
char *p = dst, *q = src;
while (*q)
{
*p++ = *q++;
}
*p = '\0';
}
DLL_EXPORT int __stdcall VerifyAnsiStringOut(char **val)
{
if (val == NULL)
return 0;
*val = (char*)MemAlloc(sizeof(char) * 12);
CopyAnsiString(*val, "Hello World");
return 1;
}
DLL_EXPORT int __stdcall VerifyAnsiStringRef(char **val)
{
if (val == NULL)
return 0;
if (!CompareAnsiString(*val, "Hello World"))
{
MemFree(*val);
return 0;
}
*val = (char*)MemAlloc(sizeof(char) * 13);
CopyAnsiString(*val, "Hello World!");
return 1;
}
DLL_EXPORT int __stdcall VerifyAnsiStringArray(char **val)
{
if (val == NULL || *val == NULL)
@@ -155,25 +224,52 @@ DLL_EXPORT int __stdcall VerifyUnicodeString(unsigned short *val)
return 0;
unsigned short expected[] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0};
unsigned short *p = expected;
unsigned short *q = val;
while (*p && *q && *p == *q)
{
p++;
q++;
}
return *p == 0 && *q == 0;
return CompareUnicodeString(val, expected);
}
DLL_EXPORT int __stdcall VerifyUnicodeStringOut(unsigned short **val)
{
if (val == NULL)
return 0;
unsigned short *p = (unsigned short *)MemAlloc(sizeof(unsigned short) * 12);
unsigned short expected[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0 };
for (int i = 0; i < 12; i++)
p[i] = expected[i];
*val = p;
return 1;
}
DLL_EXPORT int __stdcall VerifyUnicodeStringRef(unsigned short **val)
{
if (val == NULL)
return 0;
unsigned short expected[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0};
unsigned short *p = expected;
unsigned short *q = *val;
if (!CompareUnicodeString(p, q))
return 0;
MemFree(*val);
p = (unsigned short*)MemAlloc(sizeof(unsigned short) * 13);
int i;
for (i = 0; i < 11; i++)
p[i] = expected[i];
p[i++] = '!';
p[i] = '\0';
*val = p;
return 1;
}
DLL_EXPORT bool __stdcall VerifySizeParamIndex(unsigned char ** arrByte, unsigned char *arrSize)
{
*arrSize = 10;
#ifdef Windows_NT
*arrByte = (unsigned char *)CoTaskMemAlloc(sizeof(unsigned char) * (*arrSize));
#else
*arrByte = (unsigned char *)malloc(sizeof(unsigned char) * (*arrSize));
#endif
*arrByte = (unsigned char *)MemAlloc(sizeof(unsigned char) * (*arrSize));
if (*arrByte == NULL)
return false;
@@ -228,22 +324,98 @@ DLL_EXPORT bool __stdcall ReversePInvoke_Int(int(__stdcall *fnPtr) (int, int, in
return fnPtr(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) == 55;
}
DLL_EXPORT bool __stdcall ReversePInvoke_String(bool(__stdcall *fnPtr) (char *))
typedef bool(__stdcall *StringFuncPtr) (char *);
DLL_EXPORT bool __stdcall ReversePInvoke_String(StringFuncPtr fnPtr)
{
char str[] = "Hello World";
return fnPtr(str);
}
DLL_EXPORT void __stdcall VerifyStringBuilder(unsigned short *val)
bool CheckString(char *str)
{
char str[] = "Hello World";
int i;
for (i = 0; str[i] != '\0'; i++)
val[i] = (unsigned short)str[i];
val[i] = 0;
return CompareAnsiString(str, "Hello World!") == 1;
}
DLL_EXPORT StringFuncPtr __stdcall GetDelegate()
{
return CheckString;
}
DLL_EXPORT bool __stdcall Callback(StringFuncPtr *fnPtr)
{
char str[] = "Hello World";
if ((*fnPtr)(str) == false)
return false;
*fnPtr = CheckString;
return true;
}
// returns
// -1 if val is null
// 1 if val is "Hello World"
// 0 otherwise
DLL_EXPORT int __stdcall VerifyUnicodeStringBuilder(unsigned short *val)
{
if (val == NULL)
return -1;
if (!VerifyUnicodeString(val))
return 0;
for (int i = 0; val[i] != '\0'; i++)
{
if ((char)val[i] >= 'a' && (char)val[i] <= 'z')
{
val[i] += 'A' - 'a';
}
}
return 1;
}
DLL_EXPORT int __stdcall VerifyUnicodeStringBuilderOut(unsigned short *val)
{
if (val == NULL)
return 0;
unsigned short src[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', 0 };
for (int i = 0; i < 12; i++)
val[i] = src[i];
return 1;
}
DLL_EXPORT int __stdcall VerifyAnsiStringBuilderOut(char *val)
{
if (val == NULL)
return 0;
CopyAnsiString(val, "Hello World!");
return 1;
}
// returns
// -1 if val is null
// 1 if val is "Hello World"
// 0 otherwise
DLL_EXPORT int __stdcall VerifyAnsiStringBuilder(char *val)
{
if (val == NULL)
return -1;
if (!VerifyAnsiString(val))
return 0;
for (int i = 0; val[i] != '\0'; i++)
{
if (val[i] >= 'a' && val[i] <= 'z')
{
val[i] += 'A' - 'a';
}
}
return 1;
}
DLL_EXPORT int* __stdcall ReversePInvoke_Unused(void(__stdcall *fnPtr) (void))
{
return 0;
@@ -257,6 +429,12 @@ struct NativeSequentialStruct
char *str;
};
struct NativeSequentialStruct2
{
float a;
int b;
};
DLL_EXPORT bool __stdcall StructTest(NativeSequentialStruct nss)
{
if (nss.s != 100)
@@ -275,6 +453,17 @@ DLL_EXPORT bool __stdcall StructTest(NativeSequentialStruct nss)
return true;
}
DLL_EXPORT bool __stdcall StructTest_Sequential2(NativeSequentialStruct2 nss)
{
if (nss.a != 10.0)
return false;
if (nss.b != 123)
return false;
return true;
}
DLL_EXPORT void __stdcall StructTest_ByRef(NativeSequentialStruct *nss)
{
nss->a++;
@@ -296,11 +485,7 @@ DLL_EXPORT void __stdcall StructTest_ByOut(NativeSequentialStruct *nss)
int arrSize = 7;
char *p;
#ifdef Windows_NT
p = (char *)CoTaskMemAlloc(sizeof(char) * arrSize);
#else
p = (char *)malloc(sizeof(char) * arrSize);
#endif
p = (char *)MemAlloc(sizeof(char) * arrSize);
for (int i = 0; i < arrSize; i++)
{
@@ -310,6 +495,69 @@ DLL_EXPORT void __stdcall StructTest_ByOut(NativeSequentialStruct *nss)
nss->str = p;
}
DLL_EXPORT bool __stdcall StructTest_Array(NativeSequentialStruct *nss, int length)
{
if (nss == NULL)
return false;
char expected[16];
for (int i = 0; i < 3; i++)
{
if (nss[i].s != 0)
return false;
if (nss[i].a != i)
return false;
if (nss[i].b != i*i)
return false;
sprintf(expected, "%d", i);
if (CompareAnsiString(expected, nss[i].str) == 0)
return false;
}
return true;
}
typedef struct {
int a;
int b;
int c;
short inlineArray[128];
char inlineString[11];
} inlineStruct;
typedef struct {
int a;
unsigned short inlineString[11];
} inlineUnicodeStruct;
DLL_EXPORT bool __stdcall InlineArrayTest(inlineStruct* p, inlineUnicodeStruct *q)
{
for (short i = 0; i < 128; i++)
{
if (p->inlineArray[i] != i)
return false;
p->inlineArray[i] = i + 1;
}
if (CompareAnsiString(p->inlineString, "Hello") != 1)
return false;
if (!VerifyUnicodeString(q->inlineString))
return false;
q->inlineString[5] = p->inlineString[5] = ' ';
q->inlineString[6] = p->inlineString[6] = 'W';
q->inlineString[7] = p->inlineString[7] = 'o';
q->inlineString[8] = p->inlineString[8] = 'r';
q->inlineString[9] = p->inlineString[9] = 'l';
q->inlineString[10] = p->inlineString[10] = 'd';
return true;
}
struct NativeExplicitStruct
{
@@ -349,3 +597,25 @@ DLL_EXPORT bool __stdcall StructTest_Nested(NativeNestedStruct nns)
return StructTest_Explicit(nns.nes);
}
DLL_EXPORT bool __stdcall VerifyAnsiCharArrayIn(char *a)
{
return CompareAnsiString(a, "Hello World") == 1;
}
DLL_EXPORT bool __stdcall VerifyAnsiCharArrayOut(char *a)
{
if (a == NULL)
return false;
CopyAnsiString(a, "Hello World!");
return true;
}
DLL_EXPORT bool __stdcall IsNULL(void *a)
{
return a == NULL;
}
#if (_MSC_VER >= 1400) // Check MSC version
#pragma warning(pop) // Renable previous depreciations
#endif

View File

@@ -0,0 +1,12 @@
@echo off
setlocal
"%1\%2"
set ErrorCode=%ERRORLEVEL%
IF "%ErrorCode%"=="100" (
echo %~n0: pass
EXIT /b 0
) ELSE (
echo %~n0: fail - %ErrorCode%
EXIT /b 1
)
endlocal

View File

@@ -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.Runtime.InteropServices;
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
class PreInitializedAttribute: Attribute
{
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
class InitDataBlobAttribute: Attribute
{
public InitDataBlobAttribute(Type type, string fieldName)
{
}
}
}
class Details
{
private static IntPtr PreInitializedField_DataBlob = IntPtr.Zero;
}
public class PreInitDataTest
{
static int[] StaticIntArrayField = new int[] { 5, 6, 7, 8 };
[System.Runtime.CompilerServices.PreInitialized]
[System.Runtime.CompilerServices.InitDataBlob(typeof(Details), "PreInitializedField_DataBlob")]
static int[] PreInitializedField = new int[] { 1, 2, 3, 4 };
static string StaticStringField = "ABCDE";
const int Pass = 100;
const int Fail = -1;
public static int Main(string[] args)
{
int result = Pass;
if (!TestPreInitData())
{
Console.WriteLine("Failed");
result = Fail;
}
// Make sure PreInitializedField works with other statics
if (!TestOtherStatics())
{
Console.WriteLine("Failed");
result = Fail;
}
return result;
}
static bool TestPreInitData()
{
Console.WriteLine("Testing preinitialized array...");
for (int i = 0; i < PreInitializedField.Length; ++i)
{
if (PreInitializedField[i] != i + 1)
return false;
}
return true;
}
static bool TestOtherStatics()
{
Console.WriteLine("Testing other statics work well with preinitialized data in the same type...");
for (int i = 0; i < StaticIntArrayField.Length; ++i)
{
if (StaticIntArrayField[i] != i + 5)
return false;
}
if (StaticStringField != "ABCDE")
return false;
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More