This enables ilasm round-trip testing for Windows.
In order to test il{d}asm on xPlatforms, I injected ilasm round trip before executing the test.
This means this step is a part of the runtest not the buildtest -- unlike runtest, currently buildtest is only on Windows.
1. Test batch file is extended to run ildasm followed by ilasm.
2. BuildTest has now an optional flag "ilasmroundtrip" to enable the round-trip tests. Note under this flag, we run both the original binary and the round-trip binary respectively.
3. Test timeout is increased since the round-trip is part of runtime.
4. Did some clean-up on CLRTest.Execute.Batch.targets
5. Bail out the round-trip tests that are built against mscorlib instead of .Net Core.
6. Added /raweh to ildasm due to https://github.com/dotnet/coreclr/issues/2481
7. ilasmroundtrip.targets (~10 tests) are added to enable them by default in a regular test run.
Tested with enabling the entire tests (>5K tests) with 'ilasmroundtrip' on, which should be on in a daily or weekly stress mode.
if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
if /i "%1" == "crossgen" (set _crossgen=true&shift&goto Arg_Loop)
+if /i "%1" == "ilasmroundtrip" (set _ilasmroundtrip=true&shift&goto Arg_Loop)
if /i "%1" == "priority" (set _priorityvalue=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "verbose" (set _verbosity=detailed&shift&goto Arg_Loop)
:ArgsDone
if defined _crossgen echo Building tests with CrossGen enabled.&set _buildParameters=%_buildParameters% /p:CrossGen=true
+if defined _ilasmroundtrip echo Building tests with IlasmRoundTrip enabled.&set _buildParameters=%_buildParameters% /p:IlasmRoundTrip=true
if defined _priorityvalue echo Building Test Priority %_priorityvalue%&set _buildParameters=%_buildParameters% /p:CLRTestPriorityToBuild=%_priorityvalue%
if defined _verbosity echo Enabling verbose file logging
if not defined _verbosity set _verbosity=normal
echo VSVersion - optional argument to use VS2013 or VS2015 (default VS2015)
echo CrossGen - Enables the tests to run crossgen on the test executables before executing them.
echo Priority (N) where N is a number greater than zero that signifies the set of tests that will be built and consequently run.
+echo IlasmRoundTrip - Enables ilasm round trip build and run of the tests before executing them.
echo Verbose - Enables detailed file logging for the msbuild tasks.
exit /b 1
</PropertyGroup>
</Target>
+ <Target
+ Name="GetIlasmRoundTripBatchScript"
+ Returns="$(IlasmRoundTripBatchScript)">
+ <PropertyGroup>
+ <InputAssemblyName Condition="'$(CLRTestKind)' == 'RunOnly'">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))</InputAssemblyName>
+ <InputAssemblyName Condition="'$(CLRTestKind)' == 'BuildAndRun'">$(MSBuildProjectName).exe</InputAssemblyName>
+ <DisassemblyName>$(MSBuildProjectName).dasm.il</DisassemblyName>
+ <TargetAssemblyName>$(MSBuildProjectName).asm.exe</TargetAssemblyName>
+
+ <!-- If a test is built against mscorlib instead of dotnet Core, permission attributes can be embedded, which CoreCLR does not support. -->
+ <IlasmRoundTrip Condition="'$(ReferenceLocalMscorlib)'!=''">false</IlasmRoundTrip>
+
+ <!-- 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
+)
+ ]]>
+ </IlasmRoundTripBatchScript>
+ </PropertyGroup>
+ </Target>
+
<!-- This is here because of this bug: http://blogs.msdn.com/b/msbuild/archive/2006/01/03/508629.aspx-->
<Target Name="FetchExternalProperties">
<!--Call GetExecuteShFullPath to get ToRunProject cmd file Path -->
<Target Name="GenerateBatchExecutionScript"
Inputs="$(MSBuildProjectFullPath)"
Outputs="$(OutputPath)\$(MSBuildProjectName).cmd"
- DependsOnTargets="FetchExternalProperties;GetCrossgenBatchScript">
+ DependsOnTargets="FetchExternalProperties;GetCrossgenBatchScript;GetIlasmRoundTripBatchScript">
<Message Text="Project depends on $(_CLRTestToRunFileFullPath)." Condition="'$(_CLRTestNeedsProjectToRun)' == 'True'" />
<BatchCLRTestExecutionScriptArgument Include="coreroot">
<HasParam>true</HasParam>
- <ParamName>envScriptFullPath</ParamName>
+ <ParamName>CoreRootFullPath</ParamName>
<Command><![CDATA[
set CORE_ROOT=%2
]]></Command>
</ItemGroup>
<PropertyGroup>
- <_CLRTestExeFile Condition="'$(_CLRTestNeedsProjectToRun)' == 'true'">$(_CLRTestToRunFileFullPath)</_CLRTestExeFile>
- <_CLRTestExeFile Condition="'$(_CLRTestNeedsProjectToRun)' == 'false'">$(MSBuildProjectName).exe</_CLRTestExeFile>
- <_CLRTestExeFile Condition="'$(CLRTestIsHosted)'=='true' And '$(_CLRTestNeedsProjectToRun)'=='true'">$([MSBuild]::MakeRelative($(OutputPath), $(_CLRTestToRunFileFullPath)))</_CLRTestExeFile>
- <_CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"%CORE_ROOT%\corerun.exe" "$(_CLRTestExeFile)"</_CLRTestRunFile>
- <_CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='false'">"$(_CLRTestExeFile)"</_CLRTestRunFile>
+ <_CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"%CORE_ROOT%\corerun.exe"</_CLRTestRunFile>
+ <BatchCLRTestLaunchCmds Condition=" '$(IlasmRoundTrip)'=='true' "><![CDATA[
+ECHO $(_CLRTestRunFile) $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args%
+$(_CLRTestRunFile) $(TargetAssemblyName) %CLRTestExecutionArguments% %Host_Args%
- <BatchCLRTestLaunchCmds Condition=" '$(BatchCLRTestLaunchCmds)'=='' "><![CDATA[
-IF NOT "%CLRCustomTestLauncher%"=="" (
- goto :CustomLauncher
-) ELSE (
- goto :DefaultLauncher
+IF NOT "!ERRORLEVEL!"=="%CLRTestExpectedExitCode%" (
+ ECHO END EXECUTION OF IL{D}ASM BINARY - FAILED !ERRORLEVEL! vs %CLRTestExpectedExitCode%
+ ECHO FAILED
+ Exit /b 1
)
-
-:CustomLauncher
- call %CLRCustomTestLauncher% %~dp0 $(_CLRTestExeFile) %CLRTestExecutionArguments% %Host_Args%
- set CLRTestExitCode=%ERRORLEVEL%
- goto :EndLauncher
-
-:DefaultLauncher
- ECHO $(_CLRTestRunFile) %CLRTestExecutionArguments% %Host_Args%
- %_DebuggerFullPath% $(_CLRTestRunFile) %CLRTestExecutionArguments% %Host_Args%
- set CLRTestExitCode=%ERRORLEVEL%
-
-:EndLauncher
-
]]></BatchCLRTestLaunchCmds>
- </PropertyGroup>
+ <BatchCLRTestLaunchCmds><![CDATA[
+$(BatchCLRTestLaunchCmds)
+ECHO %_DebuggerFullPath% $(_CLRTestRunFile) $(InputAssemblyName) %CLRTestExecutionArguments% %Host_Args%
+%_DebuggerFullPath% $(_CLRTestRunFile) $(InputAssemblyName) %CLRTestExecutionArguments% %Host_Args%
+set CLRTestExitCode=!ERRORLEVEL!
+ ]]></BatchCLRTestLaunchCmds>
+ </PropertyGroup>
<PropertyGroup>
<BatchEnvironmentVariables>
@(CLRTestBatchEnvironmentVariable -> '%(Identity)', '%0d%0a')
<_CLRTestExecutionScriptText>
<![CDATA[
@ECHO OFF
-setlocal
+setlocal ENABLEDELAYEDEXPANSION
pushd %~dp0
$(BatchCLRTestArgPrep)
$(BatchCLRTestExitCodePrep)
REM CrossGen Script (when /p:CrossGen=true)
$(CrossgenBatchScript)
+REM IlasmRoundTrip Script
+$(IlasmRoundTripBatchScript)
+
REM Precommands
$(CLRTestBatchPreCommands)
REM Launch
<_OutputTypeArgument Condition="'$(OutputType)' == 'Library'">/DLL</_OutputTypeArgument>
<_OutputTypeArgument Condition="'$(OutputType)' == 'Exe'">/EXE</_OutputTypeArgument>
<_IlasmSwitches>/QUIET /NOLOGO</_IlasmSwitches>
- <_IlasmSwitches Condition="'$(KeyOriginatorFile)' != ''">$(_IlasmSwitches) /KEY=$(KeyOriginatorFile)</_IlasmSwitches>
<_IlasmSwitches Condition="'$(FoldIdenticalMethods)' == 'True'">$(_IlasmSwitches) /FOLD</_IlasmSwitches>
<_IlasmSwitches Condition="'$(SizeOfStackReserve)' != ''">$(_IlasmSwitches) /STACK=$(SizeOfStackReserve)</_IlasmSwitches>
<_IlasmSwitches Condition="'$(DebugType)' == 'Full'">$(_IlasmSwitches) /DEBUG</_IlasmSwitches>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <IlasmRoundTrip>true</IlasmRoundTrip>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">