1 @if not defined _echo @echo off
2 setlocal EnableDelayedExpansion EnableExtensions
4 :: Define a prefix for most output progress messages that come from this script. That makes
5 :: it easier to see where these are coming from. Note that there is a trailing space here.
6 set "__MsgPrefix=RUNTEST: "
8 set __ThisScriptDir="%~dp0"
10 if /I not "%PROCESSOR_ARCHITECTURE%"=="arm64" (
11 if /I not "%PROCESSOR_ARCHITECTURE%"=="arm" (
12 call "%__ThisScriptDir%"\..\setup_vs_tools.cmd
13 if NOT '%ERRORLEVEL%' == '0' exit /b 1
15 if defined VS150COMNTOOLS (
16 set __VSVersion=vs2017
18 set __VSVersion=vs2015
23 :: Set the default arguments
26 set __BuildOS=Windows_NT
28 set "__ProjectDir=%~dp0"
29 :: remove trailing slash
30 if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
31 set "__ProjectFilesDir=%__ProjectDir%"
32 set "__RootBinDir=%__ProjectDir%\..\bin"
33 set "__LogsDir=%__RootBinDir%\Logs"
36 set __msbuildExtraArgs=
38 set __GCSimulatorTests=
39 set __AgainstPackages=
47 set __CoreFXTestsRunAllAvailable=
48 set __SkipGenerateLayout=
49 set __BuildXUnitWrappers=
50 set __PrintLastResultsOnly=
53 if "%1" == "" goto ArgsDone
55 if /i "%1" == "/?" goto Usage
56 if /i "%1" == "-?" goto Usage
57 if /i "%1" == "/h" goto Usage
58 if /i "%1" == "-h" goto Usage
59 if /i "%1" == "/help" goto Usage
60 if /i "%1" == "-help" goto Usage
62 if /i "%1" == "x64" (set __BuildArch=x64&shift&goto Arg_Loop)
63 if /i "%1" == "x86" (set __BuildArch=x86&shift&goto Arg_Loop)
64 if /i "%1" == "arm" (set __BuildArch=arm&shift&goto Arg_Loop)
65 if /i "%1" == "arm64" (set __BuildArch=arm64&shift&goto Arg_Loop)
67 if /i "%1" == "debug" (set __BuildType=Debug&shift&goto Arg_Loop)
68 if /i "%1" == "release" (set __BuildType=Release&shift&goto Arg_Loop)
69 if /i "%1" == "checked" (set __BuildType=Checked&shift&goto Arg_Loop)
71 if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
72 if /i "%1" == "vs2017" (set __VSVersion=%1&shift&goto Arg_Loop)
74 if /i "%1" == "TestEnv" (set __TestEnv=%2&shift&shift&goto Arg_Loop)
75 if /i "%1" == "AgainstPackages" (set __AgainstPackages=1&shift&goto Arg_Loop)
76 if /i "%1" == "sequential" (set __Sequential=1&shift&goto Arg_Loop)
77 if /i "%1" == "crossgen" (set __DoCrossgen=1&shift&goto Arg_Loop)
78 if /i "%1" == "crossgenaltjit" (set __DoCrossgen=1&set __CrossgenAltJit=%2&shift&shift&goto Arg_Loop)
79 if /i "%1" == "longgc" (set __LongGCTests=1&shift&goto Arg_Loop)
80 if /i "%1" == "gcsimulator" (set __GCSimulatorTests=1&shift&goto Arg_Loop)
81 if /i "%1" == "jitstress" (set COMPlus_JitStress=%2&shift&shift&goto Arg_Loop)
82 if /i "%1" == "jitstressregs" (set COMPlus_JitStressRegs=%2&shift&shift&goto Arg_Loop)
83 if /i "%1" == "jitminopts" (set COMPlus_JITMinOpts=1&shift&goto Arg_Loop)
84 if /i "%1" == "jitforcerelocs" (set COMPlus_ForceRelocs=1&shift&goto Arg_Loop)
85 if /i "%1" == "jitdisasm" (set __JitDisasm=1&shift&goto Arg_Loop)
86 if /i "%1" == "ilasmroundtrip" (set __IlasmRoundTrip=1&shift&goto Arg_Loop)
87 if /i "%1" == "GenerateLayoutOnly" (set __GenerateLayoutOnly=1&shift&goto Arg_Loop)
88 if /i "%1" == "skipgeneratelayout" (set __SkipGenerateLayout=1&shift&goto Arg_Loop)
89 if /i "%1" == "buildxunitwrappers" (set __BuildXunitWrappers=1&shift&goto Arg_Loop)
90 if /i "%1" == "printlastresultsonly" (set __PrintLastResultsOnly=1&shift&goto Arg_Loop)
91 if /i "%1" == "PerfTests" (set __PerfTests=true&shift&goto Arg_Loop)
92 if /i "%1" == "CoreFXTests" (set __CoreFXTests=true&shift&goto Arg_Loop)
93 if /i "%1" == "CoreFXTestsAll" (set __CoreFXTests=true&set __CoreFXTestsRunAllAvailable=true&shift&goto Arg_Loop)
94 if /i "%1" == "CoreFXTestList" (set __CoreFXTests=true&set __CoreFXTestList=%2&shift&shift&goto Arg_Loop)
95 if /i "%1" == "runcrossgentests" (set RunCrossGen=true&shift&goto Arg_Loop)
96 if /i "%1" == "link" (set DoLink=true&set ILLINK=%2&shift&shift&goto Arg_Loop)
97 REM tieredcompilation is on by default now, but setting this environment variable is harmless and I didn't want to break any automation that might be using it just yet
98 if /i "%1" == "tieredcompilation" (set COMPLUS_TieredCompilation=1&shift&goto Arg_Loop)
99 if /i "%1" == "gcname" (set COMPlus_GCName=%2&shift&shift&goto Arg_Loop)
100 if /i "%1" == "timeout" (set __TestTimeout=%2&shift&shift&goto Arg_Loop)
101 if /i "%1" == "altjitarch" (set __AltJitArch=%2&shift&shift&goto Arg_Loop)
103 REM change it to COMPlus_GCStress when we stop using xunit harness
104 if /i "%1" == "gcstresslevel" (set COMPlus_GCStress=%2&set __TestTimeout=1800000&shift&shift&goto Arg_Loop)
105 if /i "%1" == "collectdumps" (set __CollectDumps=true&shift&goto Arg_Loop)
107 if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs
108 :: All the rest of the args will be collected and passed directly to msbuild.
111 if "%1"=="" goto ArgsDone
112 set __msbuildExtraArgs=%__msbuildExtraArgs% %1
113 goto CollectMsbuildArgs
117 echo %__MsgPrefix%CORE_ROOT is initially set to: "%CORE_ROOT%"
121 :: Done with argument processing. Check argument values for validity.
123 if defined __TestEnv (if not exist %__TestEnv% echo %__MsgPrefix%Error: Test Environment script %__TestEnv% not found && exit /b 1)
124 if "%__PerfTests%"=="true" (if defined __GenerateLayoutOnly echo %__MsgPrefix%Error: Don't specify both "PerfTests" and "GenerateLayoutOnly" && exit /b 1)
125 if "%__CoreFXTests%"=="true" (if defined __GenerateLayoutOnly echo %__MsgPrefix%Error: Don't specify both "CoreFXTests" and "GenerateLayoutOnly" && exit /b 1)
127 if defined __CoreFXTestList (
128 if not exist "%__CoreFXTestList%" (
129 echo %__MsgPrefix%Error: Couldn't find CoreFX Test List "%__CoreFXTestList%".
134 :: Set the remaining variables based upon the determined configuration
135 set __MSBuildBuildArch=%__BuildArch%
137 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
138 set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
140 :: Default global test environment variables
141 :: REVIEW: are these ever expected to be defined on entry to this script? Why? By whom?
142 :: REVIEW: XunitTestReportDirBase is not used in this script. Who needs to have it set?
143 if not defined XunitTestBinBase set XunitTestBinBase=%__TestWorkingDir%
144 if not defined XunitTestReportDirBase set XunitTestReportDirBase=%XunitTestBinBase%\Reports\
146 REM At this point in the script there will be a divergence in how the tests are run.
147 REM For official builds we will continue to run tests using the un-unified scripting
148 REM which relies on msbuild and calls runtest.proj directly. For all other scenarios
149 REM runtest.py will handle setup and will then call runtest.proj
151 if defined __AgainstPackages goto SetupMSBuildAndCallRuntestProj
152 if "%__CoreFXTests%"=="true" goto SetupMSBuildAndCallRuntestProj
153 if "%__PerfTests%"=="true" goto SetupMSBuildAndCallRuntestProj
154 if defined __GenerateLayoutOnly goto SetupMSBuildAndCallRuntestProj
156 REM We are not running in the official build scenario, call runtest.py
158 set __RuntestPyArgs=-arch %__BuildArch% -build_type %__BuildType%
161 set __RuntestPyArgs=%__RuntestPyArgs% --il_link
164 if defined __LongGCTests (
165 set __RuntestPyArgs=%__RuntestPyArgs% --long_gc
168 if defined __GCSimulatorTests (
169 set __RuntestPyArgs=%__RuntestPyArgs% --gcsimulator
172 if defined __JitDisasm (
173 set __RuntestPyArgs=%__RuntestPyArgs% --jitdisasm
176 if defined __IlasmRoundTrip (
177 set __RuntestPyArgs=%__RuntestPyArgs% --ilasmroundtrip
180 if defined __TestEnv (
181 set __RuntestPyArgs=%__RuntestPyArgs% -test_env %__TestEnv%
184 if defined __Sequential (
185 set __RuntestPyArgs=%__RuntestPyArgs% --sequential
188 if not defined __SkipGenerateLayout (
189 set __RuntestPyArgs=%__RuntestPyArgs% --generate_layout
192 if defined __GenerateLayoutOnly (
193 set __RuntestPyArgs=%__RuntestPyArgs% --generate_layout_only
196 if defined __BuildXUnitWrappers (
197 set __RuntestPyArgs=%__RuntestPyArgs% --build_xunit_test_wrappers
200 if defined RunCrossGen (
201 set __RuntestPyArgs=%__RuntestPyArgs% --run_crossgen_tests
204 if defined __DoCrossgen (
205 set __RuntestPyArgs=%__RuntestPyArgs% --precompile_core_root
208 if defined __PrintLastResultsOnly (
209 set __RuntestPyArgs=%__RuntestPyArgs% --analyze_results_only
212 if defined __AltJitArch (
213 set __RuntestPyArgs=%__RuntestPyArgs% -altjit_arch %__AltJitArch%
216 REM __ProjectDir is poorly named, it is actually <projectDir>/tests
217 set NEXTCMD=python "%__ProjectDir%\runtest.py" %__RuntestPyArgs%
223 :SetupMSBuildAndCallRuntestProj
225 :: Set up msbuild and tools environment. Check if msbuild and VS exist.
228 if /i "%__VSVersion%" == "vs2017" (
229 set "__VSToolsRoot=%VS150COMNTOOLS%"
230 set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
232 set _msbuildexe="%VS150COMNTOOLS%\..\..\MSBuild\15.0\Bin\MSBuild.exe"
233 ) else if /i "%__VSVersion%" == "vs2015" (
234 set "__VSToolsRoot=%VS140COMNTOOLS%"
235 set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
237 set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
238 if not exist !_msbuildexe! set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
241 :: Does VS really exist?
242 if not exist "%__VSToolsRoot%\..\IDE\devenv.exe" goto NoVS
243 if not exist "%__VCToolsRoot%\vcvarsall.bat" goto NoVS
244 if not exist "%__VSToolsRoot%\VsDevCmd.bat" goto NoVS
246 :: Does MSBuild really exist?
247 if not exist %_msbuildexe% (
248 echo %__MsgPrefix%Error: Could not find MSBuild.exe. Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
252 if not defined VSINSTALLDIR (
253 echo %__MsgPrefix%Error: runtest.cmd should be run from a Visual Studio Command Prompt. Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
257 :: Note: We've disabled node reuse because it causes file locking issues.
258 :: The issue is that we extend the build with our own targets which
259 :: means that that rebuilding cannot successfully delete the task
261 set __msbuildCommonArgs=/nologo /nodeReuse:false %__msbuildExtraArgs% /p:Platform=%__MSBuildBuildArch%
263 if not defined __Sequential (
264 set __msbuildCommonArgs=%__msbuildCommonArgs% /maxcpucount
266 set __msbuildCommonArgs=%__msbuildCommonArgs% /p:ParallelRun=false
269 if defined __AgainstPackages (
270 set __msbuildCommonArgs=%__msbuildCommonArgs% /p:BuildTestsAgainstPackages=true
274 set __msbuildCommonArgs=%__msbuildCommonArgs% /p:RunTestsViaIllink=true
277 if not exist %__LogsDir% md %__LogsDir%
279 REM These log files are created automatically by the test run process. Q: what do they depend on being set?
280 set __TestRunHtmlLog=%__LogsDir%\TestRun_%__BuildOS%__%__BuildArch%__%__BuildType%.html
281 set __TestRunXmlLog=%__LogsDir%\TestRun_%__BuildOS%__%__BuildArch%__%__BuildType%.xml
283 REM Prepare the Test Drop
285 if not defined __GenerateLayoutOnly (
286 echo %__MsgPrefix%Removing 'ni' files and 'lock' folders from %__TestWorkingDir%
287 REM Cleans any NI from the last run
288 powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force"
289 REM Cleans up any lock folder used for synchronization from last run
290 powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse"
293 if defined CORE_ROOT goto SkipCoreRootSetup
295 set "CORE_ROOT=%XunitTestBinBase%\Tests\Core_Root"
296 echo %__MsgPrefix%Using Default CORE_ROOT as %CORE_ROOT%
297 echo %__MsgPrefix%Copying Built binaries from %__BinDir% to %CORE_ROOT%
298 if exist "%CORE_ROOT%" rd /s /q "%CORE_ROOT%"
300 xcopy "%__BinDir%" "%CORE_ROOT%"
304 if not exist %CORE_ROOT%\coreclr.dll (
305 echo %__MsgPrefix%Error: Ensure you have done a successful build of the Product and %CORE_ROOT% contains runtime binaries.
309 if "%__CoreFXTests%"=="true" goto RunCoreFXTests
311 if "%__PerfTests%"=="true" goto RunPerfTests
313 REM =========================================================================================
315 REM === Run normal (non-perf) tests
317 REM =========================================================================================
319 call :SetTestEnvironment
321 call :ResolveDependencies
322 if errorlevel 1 exit /b 1
324 if defined __DoCrossgen (
325 echo %__MsgPrefix%Running crossgen on framework assemblies
329 REM Delete the unecessary mscorlib.ni file.
330 if exist %CORE_ROOT%\mscorlib.ni.dll del %CORE_ROOT%\mscorlib.ni.dll
332 if defined __GenerateLayoutOnly (
333 echo %__MsgPrefix%Done generating layout.
337 ::Check if the test Binaries are built
338 if not exist %XunitTestBinBase% (
339 echo %__MsgPrefix%Error: Ensure the Test Binaries are built and are present at %XunitTestBinBase%.
340 echo %__MsgPrefix%Run "buildtest.cmd %__BuildArch% %__BuildType%" to build the tests first.
344 if "%__CollectDumps%"=="true" (
346 set "__DumplingHelperPath=%__ProjectDir%\..\Tools\DumplingHelper.py"
347 python "!__DumplingHelperPath!" install_dumpling
349 :: Create the crash dump folder if necessary
350 set "__CrashDumpFolder=%tmp%\CoreCLRTestCrashDumps"
351 if not exist "!__CrashDumpFolder!" (
352 mkdir "!__CrashDumpFolder!"
355 :: Grab the current time before execution begins. This will be used to determine which crash dumps
357 for /f "delims=" %%a in ('python !__DumplingHelperPath! get_timestamp') do @set __StartTime=%%a
360 echo %__MsgPrefix%CORE_ROOT that will be used is: %CORE_ROOT%
361 echo %__MsgPrefix%Starting test run at %TIME%
363 set __BuildLogRootName=TestRunResults
364 call :msbuild "%__ProjectFilesDir%\runtest.proj" /p:Runtests=true /clp:showcommandline
365 set __errorlevel=%errorlevel%
367 if "%__CollectDumps%"=="true" (
368 python "%__DumplingHelperPath%" collect_dump %errorlevel% "%__CrashDumpFolder%" %__StartTime% "CoreCLR_Tests"
371 if %__errorlevel% GEQ 1 (
372 echo %__MsgPrefix%Test Run failed. Refer to the following:
373 echo Html report: %__TestRunHtmlLog%
379 REM =========================================================================================
381 REM === Run perf tests
383 REM =========================================================================================
386 echo %__MsgPrefix%CORE_ROOT that will be used is: %CORE_ROOT%
387 echo %__MsgPrefix%Starting test run at %TIME%
389 set __BuildLogRootName=PerfTestRunResults
390 echo %__MsgPrefix%Running perf tests
391 call :msbuild "%__ProjectFilesDir%\runtest.proj" /t:RunPerfTests /clp:showcommandline
394 echo %__MsgPrefix%Test Run failed. Refer to the following:
395 echo Html report: %__TestRunHtmlLog%
400 REM =========================================================================================
402 REM === Run CoreFX tests
404 REM =========================================================================================
408 set _CoreFXTestHost=%XunitTestBinBase%\testhost
409 set __ToolsDir=%__ProjectDir%\..\Tools
410 set "DotNetCli=%__ToolsDir%\dotnetcli\dotnet.exe"
412 set _RootCoreFXTestPath=%__TestWorkingDir%\CoreFX
413 set _CoreFXTestUtilitiesOutputPath=%_RootCoreFXTestPath%\CoreFXTestUtilities
414 set _CoreFXTestBinariesPath=%_RootCoreFXTestPath%\tests_downloaded
415 set _CoreFXLogsDir=%__LogsDir%\CoreFX\%__BuildOS%.%__BuildArch%.%__BuildType%
416 if not exist "%_CoreFXLogsDir%" (mkdir "%_CoreFXLogsDir%")
418 set _CoreFXTestSetupUtilityName=CoreFX.TestUtils.TestFileSetup
419 set _CoreFXTestSetupUtility=%__ProjectFilesDir%\src\Common\CoreFX\TestFileSetup\%_CoreFXTestSetupUtilityName%.csproj
421 call :ResolveDependencies
422 if errorlevel 1 exit /b 1
424 if defined __GenerateTestHostOnly (
428 if not exist %_CoreFXTestHost%\dotnet.exe (
429 echo %__MsgPrefix%CoreFX test host not found, please run runtest.cmd again
433 set /p _CoreFXTestRemoteURL=< "%__ProjectFilesDir%\CoreFX\CoreFXTestListURL.txt"
434 if not defined __CoreFXTestList ( set __CoreFXTestList=%__ProjectFilesDir%\CoreFX\CoreFX.issues.json )
436 set _CoreFXTestExecutable=xunit.console.netcore.exe
437 set _CoreFXTestExecutableArgs= --notrait category=nonnetcoreapptests --notrait category=nonwindowstests --notrait category=failing --notrait category=IgnoreForCI --notrait category=OuterLoop --notrait Benchmark=true
439 REM Set the log file name to something Jenkins can understand
440 set _CoreFX_TestLogFileName=testResults.xml
441 set _CoreFX_TestRunScriptName=CoreCLR_RunTest.cmd
442 if "%__CoreFXTestsRunAllAvailable%" == "true" (
443 set _CoreFX_RunCommand=--runAllTests
445 set _CoreFX_RunCommand=--runSpecifiedTests
448 echo %__MsgPrefix%Downloading and Running CoreFX Test Binaries
449 set NEXTCMD=call "%DotNetCli%" "%_CoreFXTestUtilitiesOutputPath%\%_CoreFXTestSetupUtilityName%.dll" --clean --outputDirectory "%_CoreFXTestBinariesPath%" --testListJsonPath "%__CoreFXTestList%" --testUrl "!_CoreFXTestRemoteURL!" %_CoreFX_RunCommand% --dotnetPath "%_CoreFXTestHost%\dotnet.exe" --executable %_CoreFXTestExecutable% --log %_CoreFXLogsDir% %_CoreFXTestExecutableArgs%
453 echo %__MsgPrefix%CoreFX tests finished with failures. Refer to the following:
454 echo %_CoreFXLogsDir%
460 REM =========================================================================================
462 REM === All tests complete!
464 REM =========================================================================================
468 echo %__MsgPrefix%Test run successful. Finished at %TIME%. Refer to the log files for details:
469 echo %__TestRunHtmlLog%
470 echo %__TestRunXmlLog%
473 REM =========================================================================================
475 REM === Compile the managed assemblies in Core_ROOT before running the tests
477 REM =========================================================================================
481 if defined __JitDisasm goto :jitdisasm
483 REM Skip mscorlib since it is already precompiled.
484 if /I "%3" == "mscorlib.dll" exit /b 0
485 if /I "%3" == "mscorlib.ni.dll" exit /b 0
487 "%1\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" "%2" >nul 2>nul
488 set /a __exitCode = %errorlevel%
489 if "%__exitCode%" == "-2146230517" (
490 echo %2 is not a managed assembly.
494 if %__exitCode% neq 0 (
495 echo Unable to precompile %2
499 echo %__MsgPrefix%Successfully precompiled %2
504 if /I "%3" == "mscorlib.ni.dll" exit /b 0
506 echo "%1\corerun" "%1\jit-dasm.dll" --crossgen %1\crossgen.exe --platform %CORE_ROOT% --output %__TestWorkingDir%\dasm "%2"
507 "%1\corerun" "%1\jit-dasm.dll" --crossgen %1\crossgen.exe --platform %CORE_ROOT% --output %__TestWorkingDir%\dasm "%2"
508 set /a __exitCode = %errorlevel%
510 if "%__exitCode%" == "-2146230517" (
511 echo %2 is not a managed assembly.
515 if %__exitCode% neq 0 (
516 echo Unable to precompile %2
520 echo %__MsgPrefix%Successfully precompiled and generated dasm for %2
526 if defined __CrossgenAltJit (
527 REM Set altjit flags for the crossgen run. Note that this entire crossgen section is within a setlocal/endlocal scope,
528 REM so we don't need to save or unset these afterwards.
529 echo %__MsgPrefix%Setting altjit environment variables for %__CrossgenAltJit%.
531 set COMPlus_AltJitNgen=*
532 set COMPlus_AltJitName=%__CrossgenAltJit%
533 set COMPlus_AltJitAssertOnNYI=1
534 set COMPlus_NoGuiOnAssert=1
535 set COMPlus_ContinueOnAssert=0
538 for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%CORE_ROOT%" "%%F" %%~nF%%~xF
542 REM =========================================================================================
544 REM === Subroutine to invoke msbuild.
546 REM === All arguments are passed to msbuild. The first argument should be the .proj file to invoke.
548 REM === On entry, environment variable __BuildLogRootName must be set to a file name prefix for the generated log files.
549 REM === All the "standard" environment variables that aren't expected to change per invocation must also be set,
550 REM === like __msbuildCommonArgs.
552 REM === The build log files will be overwritten, not appended to.
554 REM =========================================================================================
558 echo %__MsgPrefix%Invoking msbuild
560 set "__BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
561 set "__BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
562 set "__BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
564 set __msbuildLogArgs=^
565 /fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%";Append ^
566 /fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
567 /fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
568 /consoleloggerparameters:Summary ^
571 set __msbuildArgs=%* %__msbuildCommonArgs% %__msbuildLogArgs%
573 @REM The next line will overwrite the existing log file, if any.
574 echo %__MsgPrefix%%_msbuildexe% %__msbuildArgs%
575 echo Invoking: %_msbuildexe% %__msbuildArgs% > "%__BuildLog%"
577 %_msbuildexe% %__msbuildArgs%
579 echo %__MsgPrefix%Error: msbuild failed. Refer to the log files for details:
588 REM =========================================================================================
590 REM === Set various environment variables, based on arguments to this script, before invoking the tests.
592 REM =========================================================================================
596 :: Long GC tests take about 10 minutes per test on average, so
597 :: they often bump up against the default 10 minute timeout.
598 :: 20 minutes is more than enough time for a test to complete successfully.
599 if defined __LongGCTests (
600 echo %__MsgPrefix%Running Long GC tests, extending timeout to 20 minutes
601 set __TestTimeout=1200000
602 set RunningLongGCTests=1
605 :: GCSimulator tests can take up to an hour to complete. They are run twice a week in the
606 :: CI, so it's fine if they take a long time.
607 if defined __GCSimulatorTests (
608 echo %__MsgPrefix%Running GCSimulator tests, extending timeout to one hour
609 set __TestTimeout=3600000
610 set RunningGCSimulatorTests=1
613 if defined __JitDisasm (
614 if defined __DoCrossgen (
615 echo %__MsgPrefix%Running jit disasm on framework and test assemblies
617 if not defined __DoCrossgen (
618 echo %__MsgPrefix%Running jit disasm on test assemblies only
620 set RunningJitDisasm=1
623 if defined __IlasmRoundTrip (
624 echo %__MsgPrefix%Running Ilasm round trip
625 set RunningIlasmRoundTrip=1
630 REM =========================================================================================
632 REM === Generate the "layout" directory in CORE_ROOT; download dependencies.
634 REM =========================================================================================
638 set __BuildLogRootName=Tests_GenerateRuntimeLayout
639 call :msbuild "%__ProjectFilesDir%\runtest.proj" /p:GenerateRuntimeLayout=true
641 echo %__MsgPrefix%Test Dependency Resolution Failed
644 echo %__MsgPrefix%Created the runtime layout with all dependencies in %CORE_ROOT%
646 if "%__CoreFXTests%"=="true" goto ResolveCoreFXDependencies
650 REM =========================================================================================
652 REM === Generate the "testhost" directory for running CoreFX tests; download dependencies.
654 REM =========================================================================================
656 :ResolveCoreFXDependencies
658 echo %__MsgPrefix%Building CoreFX Test Host
660 set __BuildLogRootName=Tests_GenerateTestHost
661 call :msbuild "%__ProjectFilesDir%\runtest.proj" /p:GenerateTestHost=true
663 echo %__MsgPrefix%Test Host Dependency Resolution Failed
666 echo %__MsgPrefix%Created the Test Host layout with all dependencies in %_CoreFXTestHost%
668 REM Publish and call the CoreFX test helper projects - should this be integrated into runtest.proj?
669 REM Build Helper project
670 set NEXTCMD="%DotNetCli%" msbuild /t:Restore "%_CoreFXTestSetupUtility%"
677 set NEXTCMD=call "%DotNetCli%" msbuild "/p:Configuration=%CoreRT_BuildType%" "/p:OSGroup=%CoreRT_BuildOS%" "/p:Platform=%CoreRT_BuildArch%" "/p:OutputPath=%_CoreFXTestUtilitiesOutputPath%" "%_CoreFXTestSetupUtility%"
686 REM =========================================================================================
688 REM === Display a help message describing how to use this script.
690 REM =========================================================================================
693 @REM NOTE: The caret character is used to escape meta-characters known to the CMD shell. This character does
694 @REM NOTE: not appear in output. Thus, while it might look like in lines below that the "-" are not aligned,
695 @REM NOTE: they are in the output (and please keep them aligned).
698 echo %0 [options] [^<CORE_ROOT^>]
702 echo./? -? /h -h /help -help - View this message.
703 echo ^<build_architecture^> - Specifies build architecture: x64, x86, arm, or arm64 ^(default: x64^).
704 echo ^<build_type^> - Specifies build type: Debug, Release, or Checked ^(default: Debug^).
705 echo VSVersion ^<vs_version^> - VS2015 or VS2017 ^(default: VS2017^).
706 echo TestEnv ^<test_env_script^> - Run a custom script before every test to set custom test environment settings.
707 echo AgainstPackages - This indicates that we are running tests that were built against packages.
708 echo GenerateLayoutOnly - If specified will not run the tests and will only create the Runtime Dependency Layout
709 echo skipgeneratelayout - Do not generate the core root. Used for cross target testing.
710 echo sequential - Run tests sequentially (no parallelism).
711 echo crossgen - Precompile ^(crossgen^) the managed assemblies in CORE_ROOT before running the tests.
712 echo crossgenaltjit ^<altjit^> - Precompile ^(crossgen^) the managed assemblies in CORE_ROOT before running the tests, using the given altjit.
713 echo link ^<ILlink^> - Runs the tests after linking via the IL linker ^<ILlink^>.
714 echo CoreFXTests - Runs CoreFX tests
715 echo CoreFXTestsAll - Runs all CoreFX tests ^(no exclusions^)
716 echo CoreFXTestList ^<file^> - Specify a file containing a list of CoreFX tests to run, and runs them.
717 echo PerfTests - Runs perf tests
718 echo RunCrossgenTests - Runs ReadytoRun tests
719 echo jitstress ^<n^> - Runs the tests with COMPlus_JitStress=n
720 echo jitstressregs ^<n^> - Runs the tests with COMPlus_JitStressRegs=n
721 echo jitminopts - Runs the tests with COMPlus_JITMinOpts=1
722 echo jitforcerelocs - Runs the tests with COMPlus_ForceRelocs=1
723 echo jitdisasm - Runs jit-dasm on the tests
724 echo ilasmroundtrip - Runs ilasm round trip on the tests
725 echo longgc - Run the long-running GC tests
726 echo gcsimulator - Run the GC Simulator tests
727 echo gcstresslevel ^<n^> - Runs the tests with COMPlus_GCStress=n. n=0 means no GC Stress. Otherwise, n is a bitmask of the following:
728 echo 1: GC on all allocations and 'easy' places
729 echo 2: GC on transitions to preemptive GC
730 echo 4: GC on every allowable JITed instruction
731 echo 8: GC on every allowable NGEN instruction
732 echo 16: GC only on a unique stack trace
733 echo tieredcompilation - Run the tests with COMPlus_TieredCompilation=1
734 echo gcname ^<name^> - Runs the tests with COMPlus_GCName=name
735 echo timeout ^<n^> - Sets the per-test timeout in milliseconds ^(default is 10 minutes = 10 * 60 * 1000 = 600000^).
736 echo Note: some options override this ^(gcstresslevel, longgc, gcsimulator^).
737 echo printlastresultsonly - Print the last test results without running tests.
738 echo msbuildargs ^<args...^> - Pass all subsequent args directly to msbuild invocations.
739 echo ^<CORE_ROOT^> - Path to the runtime to test ^(if specified^).
741 echo Note that arguments are not case-sensitive.
745 echo %0 x64 checked GenerateLayoutOnly
750 echo Visual Studio 2015 or 2017 ^(Community is free^) is a prerequisite to build this repository.
751 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites