diff options
author | Swaroop Sridhar <Swaroop.Sridhar@microsoft.com> | 2017-03-15 10:40:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-15 10:40:25 -0700 |
commit | 7f8ba1a8bd20ce2330b8d733f1e51959470fdd8f (patch) | |
tree | 8f77f36f03d578eca85282b443c292025453bcf3 /tests | |
parent | 44df0f37ce9e4e4ea63718ba0b4e74d53970037a (diff) | |
download | coreclr-7f8ba1a8bd20ce2330b8d733f1e51959470fdd8f.tar.gz coreclr-7f8ba1a8bd20ce2330b8d733f1e51959470fdd8f.tar.bz2 coreclr-7f8ba1a8bd20ce2330b8d733f1e51959470fdd8f.zip |
Add support for testing via ILLINK
Add support for testing via ILLINK
This commit has the following changes:
1) Setup the testing infrastructure to run the CoreCLR tests after linking through ILLinker
`runtest.cmd /link <path-to-illink.exe>`
2) The linker is taken as an argument for runtest.cmd, typically the corebuild of
https://github.com/mono/linker
3) Tests are run by linking the test binaries and all libraries except `System.Private.Corelib.dll`
4) For tests that use reflection, setup Reflection roots in source directories as `<test>.reflect.xml`
Diffstat (limited to 'tests')
19 files changed, 159 insertions, 31 deletions
diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 9d54289912..89e2571da5 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -80,6 +80,8 @@ if /i "%1" == "jitdisasm" (set __JitDisasm=1&shift&goto Arg_Loop) if /i "%1" == "GenerateLayoutOnly" (set __GenerateLayoutOnly=1&shift&goto Arg_Loop) if /i "%1" == "PerfTests" (set __PerfTests=true&shift&goto Arg_Loop) if /i "%1" == "runcrossgentests" (set RunCrossGen=true&shift&goto Arg_Loop) +if /i "%1" == "link" (set DoLink=true&set ILLINK=%2&shift&shift&goto Arg_Loop) + REM change it to COMPlus_GCStress when we stop using xunit harness if /i "%1" == "gcstresslevel" (set __GCSTRESSLEVEL=%2&set __TestTimeout=1800000&shift&shift&goto Arg_Loop) @@ -399,6 +401,7 @@ echo TestEnv- Optional parameter - this will run a custom script to set custom t echo VSVersion- Optional parameter - VS2015 or VS2017 ^(default: VS2017^) echo AgainstPackages - Optional parameter - this indicates that we are running tests that were built against packages echo GenerateLayoutOnly - If specified will not run the tests and will only create the Runtime Dependency Layout +echo link "ILlink" - Runs the tests after linking via ILlink echo RunCrossgenTests - Runs ReadytoRun tests echo jitstress n - Runs the tests with COMPlus_JitStress=n echo jitstressregs n - Runs the tests with COMPlus_JitStressRegs=n diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index 5de78b42f6..fa6d4580f9 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -33,17 +33,21 @@ WARNING: When setting properties based on their current state (for example: <!-- https://github.com/dotnet/coreclr/issues/2481. Delete /raweh to ildasm once it is resolved.--> <IlasmRoundTripBatchScript Condition="'$(IlasmRoundTrip)'=='true'"> <![CDATA[ -ECHO %CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName) -%CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName) -IF NOT "!ERRORLEVEL!"=="0" ( - ECHO EXECUTION OF ILDASM - FAILED !ERRORLEVEL! - Exit /b 1 -) -ECHO %CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName) -%CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName) -IF NOT "!ERRORLEVEL!"=="0" ( - ECHO EXECUTION OF ILASM - FAILED !ERRORLEVEL! - Exit /b 1 +REM Disable Ilasm round-tripping for Linker tests. +REM Todo: Ilasm round-trip on linked binaries. +IF NOT DEFINED DoLink ( + ECHO %CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName) + %CORE_ROOT%\ildasm.exe /raweh /out=$(DisassemblyName) $(InputAssemblyName) + IF NOT "!ERRORLEVEL!"=="0" ( + ECHO EXECUTION OF ILDASM - FAILED !ERRORLEVEL! + Exit /b 1 + ) + ECHO %CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName) + %CORE_ROOT%\ilasm.exe /output=$(TargetAssemblyName) $(_IlasmSwitches) $(DisassemblyName) + IF NOT "!ERRORLEVEL!"=="0" ( + ECHO EXECUTION OF ILASM - FAILED !ERRORLEVEL! + Exit /b 1 + ) ) ]]> </IlasmRoundTripBatchScript> @@ -203,7 +207,72 @@ Exit /b 0 </BatchCLRTestExecutionScriptArgument> </ItemGroup> - <PropertyGroup> + <PropertyGroup> + <ReflectionRootsXml>$(MSBuildProjectName).reflect.xml</ReflectionRootsXml> + <BatchLinkerTestLaunchCmds><![CDATA[ +REM Linker commands + +set LinkBin=__Link +set Assemblies=-a System.Private.CoreLib + +IF defined DoLink ( + IF NOT EXIST !ILLINK! ( + ECHO ILLink [%ILLINK%] Not Found + Exit /b 1 + ) + + REM Clean up old Linked binaries, if any + IF EXIST %LinkBin% rmdir /s /q %LinkBin% + + REM Remove Native images, since the goal is to run from Linked binaries + del /q /f *.ni.* 2> nul + + REM Use hints for reflection roots, if provided in $(ReflectionRootsXml) + IF EXIST $(ReflectionRootsXml) set ReflectionRoots=-x $(ReflectionRootsXml) + + REM Include all .exe files in this directory as entry points (some tests had multiple .exe file modules) + FOR /F "delims=" %%E IN ('dir /b *.exe *.dll') DO SET Assemblies=!Assemblies! -a %%~nE + + REM Run dotnet-linker + REM Run the Linker such that all assemblies except System.Private.Corlib.dll are linked + REM Debug symbol generation needs some fixes, and is currently omitted. + REM Once this is fixed, add -b true option. + ECHO %ILLINK% -out %LinkBin% -d %CORE_ROOT% -c link -l none -t !Assemblies! !ReflectionRoots! + %ILLINK% -out %LinkBin% -d %CORE_ROOT% -c link -l none -t !Assemblies! !ReflectionRoots! + IF NOT "!ERRORLEVEL!"=="0" ( + ECHO EXECUTION OF %DOTNETLINK% - FAILED !ERRORLEVEL! + IF EXIST %LinkBin% rmdir /s /q %LinkBin% + Exit /b 1 + ) + + REM Copy CORECLR native binaries to %LinkBin%, so that we can run the test based on that directory + copy %CORE_ROOT%\clrjit.dll %LinkBin% > nul 2> nul + copy %CORE_ROOT%\coreclr.dll %LinkBin% > nul 2> nul + copy %CORE_ROOT%\mscorrc.dll %LinkBin% > nul 2> nul + copy %CORE_ROOT%\CoreRun.exe %LinkBin% > nul 2> nul + + REM Copy some files that may be arguments + copy *.txt %LinkBin% > nul 2> nul + + set ExePath=%LinkBin%\$(InputAssemblyName) + set CORE_ROOT=%~dp0%LinkBin% +) +]]> + </BatchLinkerTestLaunchCmds> + <BatchLinkerTestCleanupCmds> + <![CDATA[ +REM Clean up the LinkBin directories after test execution. +REM Otherwise, RunTests may run out of disk space. + +if defined DoLink ( + if not defined KeepLinkedBinaries ( + IF EXIST %LinkBin% rmdir /s /q %LinkBin% + ) +) +]]> + </BatchLinkerTestCleanupCmds> + </PropertyGroup> + <PropertyGroup> <_CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"%CORE_ROOT%\corerun.exe"</_CLRTestRunFile> <BatchCLRTestLaunchCmds><![CDATA[ IF NOT "%CLRCustomTestLauncher%"=="" ( @@ -213,21 +282,28 @@ IF NOT "%CLRCustomTestLauncher%"=="" ( ) ]]></BatchCLRTestLaunchCmds> <BatchCLRTestLaunchCmds Condition=" '$(IlasmRoundTrip)'=='true' "><![CDATA[ -$(BatchCLRTestLaunchCmds) -ECHO %LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args% -%LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args% - -IF NOT "!ERRORLEVEL!"=="%CLRTestExpectedExitCode%" ( - ECHO END EXECUTION OF IL{D}ASM BINARY - FAILED !ERRORLEVEL! vs %CLRTestExpectedExitCode% - ECHO FAILED - Exit /b 1 + $(BatchCLRTestLaunchCmds) +IF NOT DEFINED DoLink ( + ECHO %LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args% + %LAUNCHER% $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args% + + IF NOT "!ERRORLEVEL!"=="%CLRTestExpectedExitCode%" ( + ECHO END EXECUTION OF IL{D}ASM BINARY - FAILED !ERRORLEVEL! vs %CLRTestExpectedExitCode% + ECHO FAILED + Exit /b 1 + ) ) ]]></BatchCLRTestLaunchCmds> - <BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"><![CDATA[ + <BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"> + <![CDATA[ +set ExePath=$(InputAssemblyName) +$(BatchLinkerTestLaunchCmds) $(BatchCLRTestLaunchCmds) -ECHO %LAUNCHER% $(InputAssemblyName) %CLRTestExecutionArguments% -%LAUNCHER% $(InputAssemblyName) %CLRTestExecutionArguments% + +ECHO %LAUNCHER% %ExePath% %CLRTestExecutionArguments% +%LAUNCHER% %ExePath% %CLRTestExecutionArguments% set CLRTestExitCode=!ERRORLEVEL! +$(BatchLinkerTestCleanupCmds) ]]></BatchCLRTestLaunchCmds> <BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'RunOnly'"><![CDATA[ diff --git a/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.csproj b/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.csproj index bc95b076ed..7f6443785f 100644 --- a/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.csproj +++ b/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> diff --git a/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.reflect.xml b/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.reflect.xml new file mode 100644 index 0000000000..c7c5a30b6f --- /dev/null +++ b/tests/src/CoreMangLib/system/delegate/miscellaneous/ClosedStatic.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="ClosedStatic"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/GC/Scenarios/ReflectObj/reflectobj.csproj b/tests/src/GC/Scenarios/ReflectObj/reflectobj.csproj index 9890c835e7..c2a22b8738 100644 --- a/tests/src/GC/Scenarios/ReflectObj/reflectobj.csproj +++ b/tests/src/GC/Scenarios/ReflectObj/reflectobj.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> diff --git a/tests/src/GC/Scenarios/ReflectObj/reflectobj.reflect.xml b/tests/src/GC/Scenarios/ReflectObj/reflectobj.reflect.xml new file mode 100644 index 0000000000..27541391fc --- /dev/null +++ b/tests/src/GC/Scenarios/ReflectObj/reflectobj.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="reflectobj"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.ilproj b/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.ilproj index fc143e2d08..78baf3b33c 100644 --- a/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.ilproj +++ b/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.ilproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> diff --git a/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.reflect.xml b/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.reflect.xml new file mode 100644 index 0000000000..9b45130938 --- /dev/null +++ b/tests/src/JIT/Regression/Dev11/External/dev11_13748/ReflectOnField.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="reflectOnField"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override1.ilproj b/tests/src/Loader/classloader/MethodImpl/self_override1.ilproj index a383c04d74..f3b5392b79 100644 --- a/tests/src/Loader/classloader/MethodImpl/self_override1.ilproj +++ b/tests/src/Loader/classloader/MethodImpl/self_override1.ilproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <AssemblyName>self_override1</AssemblyName> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override1.reflect.xml b/tests/src/Loader/classloader/MethodImpl/self_override1.reflect.xml new file mode 100644 index 0000000000..4d01f1aebc --- /dev/null +++ b/tests/src/Loader/classloader/MethodImpl/self_override1.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="self_override1"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override2.ilproj b/tests/src/Loader/classloader/MethodImpl/self_override2.ilproj index 32c420ba11..fbd9b908ac 100644 --- a/tests/src/Loader/classloader/MethodImpl/self_override2.ilproj +++ b/tests/src/Loader/classloader/MethodImpl/self_override2.ilproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <AssemblyName>self_override2</AssemblyName> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override2.reflect.xml b/tests/src/Loader/classloader/MethodImpl/self_override2.reflect.xml new file mode 100644 index 0000000000..90d85f5ae5 --- /dev/null +++ b/tests/src/Loader/classloader/MethodImpl/self_override2.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="self_override2"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override3.ilproj b/tests/src/Loader/classloader/MethodImpl/self_override3.ilproj index c1b9eececc..82a9be358e 100644 --- a/tests/src/Loader/classloader/MethodImpl/self_override3.ilproj +++ b/tests/src/Loader/classloader/MethodImpl/self_override3.ilproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <AssemblyName>self_override3</AssemblyName> diff --git a/tests/src/Loader/classloader/MethodImpl/self_override3.reflect.xml b/tests/src/Loader/classloader/MethodImpl/self_override3.reflect.xml new file mode 100644 index 0000000000..0836d93b38 --- /dev/null +++ b/tests/src/Loader/classloader/MethodImpl/self_override3.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="self_override3"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.csproj b/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.csproj index 64b24ce071..be180bbd96 100644 --- a/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.csproj +++ b/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <AssemblyName>TestObjectGetTypeVirtual</AssemblyName> diff --git a/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.reflect.xml b/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.reflect.xml new file mode 100644 index 0000000000..b052d520c6 --- /dev/null +++ b/tests/src/Loader/classloader/regressions/14610/TestObjectGetTypeVirtual.reflect.xml @@ -0,0 +1,5 @@ +<linker> + <assembly fullname="TestObjectGetTypeVirtual"> + <type fullname="*" required="true" /> + </assembly> +</linker> diff --git a/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.csproj b/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.csproj index 893005c41d..8231c2a5f9 100644 --- a/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.csproj +++ b/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="12.0" DefaultTargets="Build;CopyReflectionRoots" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <AssemblyName>dev11_95728</AssemblyName> diff --git a/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.reflect.xml b/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.reflect.xml new file mode 100644 index 0000000000..b74972aca1 --- /dev/null +++ b/tests/src/Loader/classloader/regressions/dev11_95728/dev11_95728.reflect.xml @@ -0,0 +1,9 @@ +<linker> + <assembly fullname="dev11_95728"> + <type fullname="*" required="true" /> + </assembly> + <assembly fullname="System.Linq.Expressions"> + <!-- - Called by System.Linq.Expressions.Expression:CreateLambda --> + <type fullname="System.Linq.Expressions.Expression`1" required="true" /> + </assembly> +</linker> diff --git a/tests/src/dir.targets b/tests/src/dir.targets index 2cc051d74a..5c2b077842 100644 --- a/tests/src/dir.targets +++ b/tests/src/dir.targets @@ -184,4 +184,9 @@ </Target> + <Target Name="CopyReflectionRoots"> + <Copy SourceFiles="$(AssemblyName).reflect.xml" + DestinationFolder="$(OutputPath)" + Condition="Exists('$(AssemblyName).reflect.xml')"/> + </Target> </Project> |