runtests.cmd 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. ::-------------------------------------------------------------------------------------------------------
  2. :: Copyright (C) Microsoft. All rights reserved.
  3. :: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. ::-------------------------------------------------------------------------------------------------------
  5. :: ============================================================================
  6. ::
  7. :: runtests.cmd
  8. ::
  9. :: Runs checkin tests using the ch.exe on the path, in 2 variants:
  10. ::
  11. :: -maxInterpretCount:1 -maxSimpleJitRunCount:1 -bgjit-
  12. :: <dynapogo>
  13. ::
  14. :: Logs are placed into:
  15. ::
  16. :: logs\interpreted
  17. :: logs\dynapogo
  18. ::
  19. :: User specified variants:
  20. :: logs\forcedeferparse
  21. :: logs\nodeferparse
  22. :: logs\forceundodefer
  23. :: logs\bytecodeserialized (serialized to byte codes)
  24. :: logs\forceserialized (force bytecode serialization internally)
  25. ::
  26. :: ============================================================================
  27. @echo off
  28. setlocal
  29. goto :main
  30. :: ============================================================================
  31. :: Print usage
  32. :: ============================================================================
  33. :printUsage
  34. echo runtests.cmd -x86^|-x64^|-arm -debug^|-test [options]
  35. echo.
  36. echo Required switches:
  37. echo.
  38. echo Specify architecture of ChakraCore:
  39. echo.
  40. echo -x86 Build arch of binaries is x86
  41. echo -x64 Build arch of binaries is x64
  42. echo -arm Build arch of binaries is ARM
  43. echo.
  44. echo Specify type of ChakraCore:
  45. echo.
  46. echo -debug Build type of binaries is debug
  47. echo -test Build type of binaries is test
  48. echo -codecoverage Build type of binaries is codecoverage
  49. echo.
  50. echo Shorthand combinations can be used, e.g. -x64debug
  51. echo.
  52. echo Note: release build type currently unsupported by ch.exe
  53. echo.
  54. echo Options:
  55. echo.
  56. echo -dirs dirname Run only the specified directory
  57. :: TODO Add more usage help
  58. goto :eof
  59. :: ============================================================================
  60. :: Print how to get help
  61. :: ============================================================================
  62. :printGetHelp
  63. echo For help use runtests.cmd -?
  64. goto :eof
  65. :: ============================================================================
  66. :: Main script
  67. :: ============================================================================
  68. :main
  69. if not exist %cd%\rlexedirs.xml (
  70. echo Error: rlexedirs.xml not found in current directory.
  71. echo runtests.cmd must be run from a test root directory containing rlexedirs.xml.
  72. exit /b 1
  73. )
  74. call :initVars
  75. call :parseArgs %*
  76. if not "%fShowUsage%" == "" (
  77. call :printUsage
  78. goto :eof
  79. )
  80. call :validateArgs
  81. if not "%fShowGetHelp%" == "" (
  82. call :printGetHelp
  83. goto :eof
  84. )
  85. call :configureVars
  86. set _logsRoot=%cd%\logs
  87. call :doSilent del /s /q profile.dpl.*
  88. for %%i in (%_Variants%) do (
  89. set _TESTCONFIG=%%i
  90. call :RunOneVariant
  91. )
  92. call :cleanUp
  93. for %%i in (%_Variants%) do (
  94. echo.
  95. echo ######## Logs for %%i variant ########
  96. if exist %_logsRoot%\%_BuildArch%_%_BuildType%\%%i\rl.log (
  97. type %_logsRoot%\%_BuildArch%_%_BuildType%\%%i\rl.log
  98. ) else (
  99. echo ERROR: Log file '%_logsRoot%\%_BuildArch%_%_BuildType%\%%i\rl.log' does not exist
  100. )
  101. )
  102. exit /b %_HadFailures%
  103. :: ============================================================================
  104. :: Parse the user arguments into environment variables
  105. :: ============================================================================
  106. :parseArgs
  107. :NextArgument
  108. if "%1" == "-?" set fShowUsage=1& goto :ArgOk
  109. if "%1" == "/?" set fShowUsage=1& goto :ArgOk
  110. if /i "%1" == "-x86" set _BuildArch=x86& goto :ArgOk
  111. if /i "%1" == "-x64" set _BuildArch=x64& goto :ArgOk
  112. if /i "%1" == "-arm" set _BuildArch=arm& goto :ArgOk
  113. if /i "%1" == "-debug" set _BuildType=debug& goto :ArgOk
  114. if /i "%1" == "-test" set _BuildType=test& goto :ArgOk
  115. if /i "%1" == "-codecoverage" set _BuildType=codecoverage& goto :ArgOk
  116. if /i "%1" == "-x86debug" set _BuildArch=x86&set _BuildType=debug& goto :ArgOk
  117. if /i "%1" == "-x64debug" set _BuildArch=x64&set _BuildType=debug& goto :ArgOk
  118. if /i "%1" == "-armdebug" set _BuildArch=arm&set _BuildType=debug& goto :ArgOk
  119. if /i "%1" == "-x86test" set _BuildArch=x86&set _BuildType=test& goto :ArgOk
  120. if /i "%1" == "-x64test" set _BuildArch=x64&set _BuildType=test& goto :ArgOk
  121. if /i "%1" == "-armtest" set _BuildArch=arm&set _BuildType=test& goto :ArgOk
  122. if /i "%1" == "-x86codecoverage" set _BuildArch=x86&set _BuildType=codecoverage& goto :ArgOk
  123. if /i "%1" == "-x64codecoverage" set _BuildArch=x64&set _BuildType=codecoverage& goto :ArgOk
  124. if /i "%1" == "-armcodecoverage" set _BuildArch=arm&set _BuildType=codecoverage& goto :ArgOk
  125. if /i "%1" == "-binary" set _Binary=-binary:%2& goto :ArgOkShift2
  126. if /i "%1" == "-bindir" set _BinDir=%~f2& goto :ArgOkShift2
  127. if /i "%1" == "-dirs" set _DIRS=-dirs:%~2& goto :ArgOkShift2
  128. if /i "%1" == "-win7" set TARGET_OS=win7& goto :ArgOk
  129. if /i "%1" == "-win8" set TARGET_OS=win8& goto :ArgOk
  130. if /i "%1" == "-winBlue" set TARGET_OS=winBlue& goto :ArgOk
  131. if /i "%1" == "-win10" set TARGET_OS=win10& goto :ArgOk
  132. if /i "%1" == "-nottags" set _NOTTAGS=%_NOTTAGS% -nottags:%~2& goto :ArgOkShift2
  133. if /i "%1" == "-tags" set _TAGS=%_TAGS% -tags:%~2& goto :ArgOkShift2
  134. if /i "%1" == "-dirtags" set _DIRTAGS=%_DIRTAGS% -dirtags:%~2& goto :ArgOkShift2
  135. if /i "%1" == "-dirnottags" set _DIRNOTTAGS=%_DIRNOTTAGS% -dirnottags:%~2& goto :ArgOkShift2
  136. if /i "%1" == "-includeSlow" set _includeSlow=1& goto :ArgOk
  137. if /i "%1" == "-onlySlow" set _onlySlow=1& goto :ArgOk
  138. if /i "%1" == "-quiet" set _quiet=-quiet& goto :ArgOk
  139. :: TODO Consider removing -drt and exclude_drt in some reasonable manner
  140. if /i "%1" == "-drt" set _drt=1& set _NOTTAGS=%_NOTTAGS% -nottags:exclude_drt& goto :ArgOk
  141. if /i "%1" == "-nightly" set _nightly=1& goto :ArgOk
  142. if /i "%1" == "-rebase" set _rebase=-rebase& goto :ArgOk
  143. if /i "%1" == "-rundebug" set _RUNDEBUG=1& goto :ArgOk
  144. :: TODO Figure out best way to specify build arch for tests that are excluded to specific archs
  145. if /i "%1" == "-platform" set _buildArch=%2& goto :ArgOkShift2
  146. :: TODO Figure out best way to specify build type for tests that are excluded to specific type (chk, fre, etc)
  147. if /i "%1" == "-buildType" set _buildType=%2& goto :ArgOkShift2
  148. if /i "%1" == "-binaryRoot" set _binaryRoot=%~f2& goto :ArgOkShift2
  149. if /i "%1" == "-variants" set _Variants=%~2& goto :ArgOkShift2
  150. if /i "%1" == "-cleanupall" set _CleanUpAll=1& goto :ArgOk
  151. ::Extra ch.exe command line flags
  152. if /i "%1" == "-ExtraHostFlags" set _ExtraHostFlags=%~2& goto :ArgOkShift2
  153. if /i "%1" == "-DumpOnCrash" set _DumpOnCrash=1& goto :ArgOk
  154. if /i "%1" == "-CrashOnException" set _CrashOnException=1& goto :ArgOk
  155. if /i "%1" == "-extraVariants" (
  156. :: Extra variants are specified by the user but not run by default.
  157. if "%_ExtraVariants%" == "" (
  158. set _ExtraVariants=%~2
  159. ) else (
  160. set _ExtraVariants=%_ExtraVariants%,%~2
  161. )
  162. goto :ArgOkShift2
  163. )
  164. :: Defined here are shorthand versions for specifying
  165. :: extra variants when running.
  166. if /i "%1" == "-parser" (
  167. if "%_ExtraVariants%" == "" (
  168. set _ExtraVariants=forcedeferparse,nodeferparse,forceundodefer
  169. ) else (
  170. set _ExtraVariants=%_ExtraVariants%,forcedeferparse,nodeferparse,forceundodefer
  171. )
  172. goto :ArgOk
  173. )
  174. if /i "%1" == "-serialization" (
  175. if "%_ExtraVariants%" == "" (
  176. set _ExtraVariants=bytecodeserialized,forceserialized
  177. ) else (
  178. set _ExtraVariants=%_ExtraVariants%,bytecodeserialized,forceserialized
  179. )
  180. goto :ArgOk
  181. )
  182. if /i "%1" == "-disablejit" (
  183. set _DisableJit=1
  184. set _Variants=disable_jit
  185. goto :ArgOk
  186. )
  187. if not "%1" == "" echo Unknown argument: %1 & set fShowGetHelp=1
  188. goto :eof
  189. :ArgOkShift2
  190. shift
  191. :ArgOk
  192. shift
  193. goto :NextArgument
  194. :: ============================================================================
  195. :: Initialize batch script variables to defaults
  196. :: ============================================================================
  197. :initVars
  198. set _HadFailures=0
  199. set _RootDir=%~dp0..
  200. set _BinDir=%_RootDir%\Build\VcBuild\Bin
  201. set _BuildArch=
  202. set _BuildType=
  203. set _Binary=-binary:ch.exe
  204. set _Variants=
  205. set _TAGS=
  206. set _NOTTAGS=
  207. set _DIRNOTTAGS=
  208. set _DIRTAGS=
  209. set _drt=
  210. set _rebase=
  211. set _ExtraVariants=
  212. set _dynamicprofilecache=-dynamicprofilecache:profile.dpl
  213. set _dynamicprofileinput=-dynamicprofileinput:profile.dpl
  214. set _includeSlow=
  215. set _onlySlow=
  216. set _CleanUpAll=
  217. set _nightly=
  218. set TARGET_OS=win10
  219. set _quiet=
  220. set _ExtraHostFlags=
  221. set _DumpOnCrash=
  222. set _CrashOnException=
  223. goto :eof
  224. :: ============================================================================
  225. :: Validate that required arguments were specified
  226. :: ============================================================================
  227. :validateArgs
  228. if "%_BuildArch%" == "" (
  229. echo Error missing required build architecture or build type switch
  230. set fShowGetHelp=1
  231. goto :eof
  232. )
  233. if "%_BuildType%" == "" (
  234. echo Error missing required build architecture or build type switch
  235. set fShowGetHelp=1
  236. )
  237. if not exist %_binDir%\%_BuildArch%_%_BuildType%\%_Binary:~8% (
  238. echo Error missing binary %_binDir%\%_BuildArch%_%_BuildType%\%_Binary:~8%
  239. set fShowGetHelp=1
  240. )
  241. goto :eof
  242. :: ============================================================================
  243. :: Configure the script variables and environment based on parsed arguments
  244. :: ============================================================================
  245. :configureVars
  246. echo Adding to PATH: %_binDir%\%_BuildArch%_%_BuildType%
  247. set path=%_binDir%\%_BuildArch%_%_BuildType%;%path%
  248. :: If the user didn't specify explicit variants then do the defaults
  249. if "%_Variants%"=="" set _Variants=interpreted,dynapogo
  250. :: If the user specified extra variants to run (i.e. in addition to the defaults), include them.
  251. if not "%_ExtraVariants%" == "" set _Variants=%_Variants%,%_ExtraVariants%
  252. rem TODO: Move any apollo tests from core\test back into private unittests
  253. set _ExcludeApolloTests=
  254. if "%APOLLO%" == "1" (
  255. set _ExcludeApolloTests=-nottags:exclude_apollo
  256. set TARGET_OS=wp8
  257. )
  258. if not "%_nightly%" == "1" (
  259. set _NOTTAGS=%_NOTTAGS% -nottags:nightly
  260. ) else (
  261. set _NOTTAGS=%_NOTTAGS% -nottags:exclude_nightly
  262. )
  263. if "%_includeSlow%%_onlySlow%" == "" (
  264. set _NOTTAGS=%_NOTTAGS% -nottags:Slow
  265. )
  266. if "%_onlySlow%" == "1" (
  267. set _TAGS=%_TAGS% -tags:Slow
  268. )
  269. if not "%NUM_RL_THREADS%" == "" (
  270. set _RL_THREAD_FLAGS=-threads:%NUM_RL_THREADS%
  271. )
  272. if "%_DIRS%" == "" (
  273. set _DIRS=-all
  274. )
  275. set _BuildArchMapped=%_BuildArch%
  276. set _BuildTypeMapped=%_BuildType%
  277. :: Map new build arch and type names to old names until rl test tags are
  278. :: updated to the new names
  279. if "%_BuildArchMapped%" == "x64" set _BuildArchMapped=amd64
  280. if "%_BuildTypeMapped%" == "debug" set _BuildTypeMapped=chk
  281. if "%_BuildTypeMapped%" == "test" set _BuildTypeMapped=fre
  282. if "%_BuildTypeMapped%" == "codecoverage" set _BuildTypeMapped=fre
  283. if "%Disable_JIT%" == "1" (
  284. set _dynamicprofilecache=
  285. set _dynamicprofileinput=
  286. )
  287. goto :eof
  288. :: ============================================================================
  289. :: Run one variant
  290. :: ============================================================================
  291. :RunOneVariant
  292. set _OLD_CC_FLAGS=%EXTRA_CC_FLAGS%
  293. set EXTRA_RL_FLAGS=-appendtestnametoextraccflags
  294. set _exclude_serialized=
  295. if "%_BuildType%" == "debug" (
  296. rem Enabling storing dumps on user directory.
  297. set _DumpOnCrash=1
  298. )
  299. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% %_ExtraHostFlags%
  300. if not "%_DumpOnCrash%" == "" (
  301. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -DumpOnCrash
  302. )
  303. if not "%_CrashOnException%" == "" (
  304. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -CrashOnException
  305. )
  306. if "%_Binary%" == "-binary:ch.exe" (
  307. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -WERExceptionSupport -ExtendedErrorStackForTestHost
  308. )
  309. if "%_TESTCONFIG%"=="interpreted" (
  310. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -maxInterpretCount:1 -maxSimpleJitRunCount:1 -bgjit- %_dynamicprofilecache%
  311. )
  312. if "%_TESTCONFIG%"=="nonative" (
  313. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -nonative
  314. set EXTRA_RL_FLAGS=-nottags:exclude_interpreted -nottags:fails_interpreted
  315. )
  316. :: DisableJit is different from NoNative in that NoNative can be used
  317. :: with builds which include backend code, whereas DisableJit doesn't have
  318. :: backend code linked in, and also disables other features that incidentally
  319. :: depends on the backend like dynamic profile, asmjs, simdjs, background parsing etc.
  320. :: TODO: Re-enable interpreter mode asmjs and simdjs
  321. if "%_TESTCONFIG%"=="disable_jit" (
  322. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -nonative
  323. set EXTRA_RL_FLAGS=-nottags:exclude_interpreted -nottags:fails_interpreted -nottags:require_backend
  324. )
  325. if "%_TESTCONFIG%"=="dynapogo" (
  326. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -forceNative -off:simpleJit -bgJitDelay:0 %_dynamicprofileinput%
  327. )
  328. :: Variants after here are user supplied variants (not run by default).
  329. if "%_TESTCONFIG%"=="forcedeferparse" (
  330. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -forceDeferParse %_dynamicprofilecache%
  331. set _exclude_forcedeferparse=-nottags:exclude_forcedeferparse
  332. )
  333. if "%_TESTCONFIG%"=="nodeferparse" (
  334. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -noDeferParse %_dynamicprofilecache%
  335. set _exclude_nodeferparse=-nottags:exclude_nodeferparse
  336. )
  337. if "%_TESTCONFIG%"=="forceundodefer" (
  338. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -forceUndoDefer %_dynamicprofilecache%
  339. set _exclude_forceundodefer=-nottags:exclude_forceundodefer
  340. )
  341. if "%_TESTCONFIG%"=="bytecodeserialized" (
  342. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -recreatebytecodefile -serialized:%TEMP%\ByteCode
  343. set _exclude_serialized=-nottags:exclude_serialized
  344. )
  345. if "%_TESTCONFIG%"=="forceserialized" (
  346. set EXTRA_CC_FLAGS=%EXTRA_CC_FLAGS% -forceserialized
  347. set EXTRA_RL_FLAGS=
  348. set _exclude_serialized=-nottags:exclude_serialized
  349. )
  350. echo.
  351. echo ############# Starting %_TESTCONFIG% variant #############
  352. call :doSilent del /q %_logsRoot%\%_BuildArch%_%_BuildType%\%_TESTCONFIG%\rl*
  353. call :doSilent md %_logsRoot%\%_BuildArch%_%_BuildType%\%_TESTCONFIG%
  354. set _rlArgs=%_Binary%
  355. set _rlArgs=%_rlArgs% -target:%_BuildArchMapped%
  356. set _rlArgs=%_rlArgs% -nottags:fail
  357. set _rlArgs=%_rlArgs% %_RL_THREAD_FLAGS%
  358. set _rlArgs=%_rlArgs% %_DIRS%
  359. set _rlArgs=%_rlArgs% -verbose
  360. set _rlArgs=%_rlArgs% %_TAGS%
  361. set _rlArgs=%_rlArgs% %_NOTTAGS%
  362. set _rlArgs=%_rlArgs% %_DIRTAGS%
  363. set _rlArgs=%_rlArgs% %_DIRNOTTAGS%
  364. set _rlArgs=%_rlArgs% -nottags:fails_%_TESTCONFIG%
  365. set _rlArgs=%_rlArgs% -nottags:exclude_%_TESTCONFIG%
  366. set _rlArgs=%_rlArgs% -nottags:exclude_%TARGET_OS%
  367. set _rlArgs=%_rlArgs% -nottags:exclude_%_BuildArchMapped%
  368. set _rlArgs=%_rlArgs% -nottags:exclude_%_BuildTypeMapped%
  369. set _rlArgs=%_rlArgs% %_exclude_serialized%
  370. set _rlArgs=%_rlArgs% %_exclude_forcedeferparse%
  371. set _rlArgs=%_rlArgs% %_exclude_nodeferparse%
  372. set _rlArgs=%_rlArgs% %_exclude_forceundodefer%
  373. set _rlArgs=%_rlArgs% %_ExcludeApolloTests%
  374. set _rlArgs=%_rlArgs% %_quiet%
  375. set _rlArgs=%_rlArgs% -exe
  376. set _rlArgs=%_rlArgs% %EXTRA_RL_FLAGS%
  377. set _rlArgs=%_rlArgs% %_rebase%
  378. set REGRESS=%CD%
  379. call :do rl %_rlArgs%
  380. if ERRORLEVEL 1 set _HadFailures=1
  381. call :do move /Y %_logsRoot%\*.log %_logsRoot%\%_BuildArch%_%_BuildType%\%_TESTCONFIG%
  382. set EXTRA_CC_FLAGS=%_OLD_CC_FLAGS%
  383. goto :eof
  384. :: ============================================================================
  385. :: Clean up left over files
  386. :: ============================================================================
  387. :cleanUp
  388. call :doSilent del /s *.bc
  389. call :doSilent del /s *.out
  390. call :doSilent del /s *.dpl
  391. call :doSilent del /s profile.dpl.*
  392. call :doSilent del /s testout*
  393. if "%_CleanUpAll%" == "1" (
  394. call :doSilent del /s *.rebase
  395. )
  396. goto :eof
  397. :: ============================================================================
  398. :: Echo a command line before executing it
  399. :: ============================================================================
  400. :do
  401. echo ^>^> %*
  402. cmd /s /c "%*"
  403. goto :eof
  404. :: ============================================================================
  405. :: Echo a command line before executing it and redirect the command's output
  406. :: to nul
  407. :: ============================================================================
  408. :doSilent
  409. echo ^>^> %* ^> nul 2^>^&1
  410. cmd /s /c "%* > nul 2>&1"
  411. goto :eof