hcttestcmds.cmd 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. @echo off
  2. if "%1"=="" (
  3. echo First argument to hcttestcmds should be directory with command-line tools.
  4. exit /b 1
  5. )
  6. echo Testing command line programs at %1 ...
  7. setlocal enableextensions enabledelayedexpansion
  8. set script_dir=%~dp0
  9. set testfiles=%script_dir%cmdtestfiles
  10. set Failed=0
  11. set FailingCmdWritten=0
  12. set OutputLog=%1\testcmd.log
  13. set LogOutput=1
  14. pushd %1
  15. set testname=Basic Rewriter Smoke Test
  16. call :run dxr.exe -remove-unused-globals "%testfiles%\smoke.hlsl" -Emain
  17. call :check_file log find-not g_unused
  18. if %Failed% neq 0 goto :failed
  19. echo Smoke test for dxc command line program ...
  20. set testname=Basic DXC Smoke Test
  21. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Fc smoke.hlsl.h
  22. call :check_file smoke.hlsl.h find "define void @main()" del
  23. if %Failed% neq 0 goto :failed
  24. set testname=Test extra DXC outputs together
  25. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /DDX12 /Dcheck_warning /Fh smoke.hlsl.h /Vn g_myvar /Fc smoke.ll /Fo smoke.cso /Fre smoke.reflection /Frs smoke.rootsig /Fe smoke.err
  26. call :check_file smoke.hlsl.h find g_myvar find "0x44, 0x58" find "define void @main()" del
  27. call :check_file smoke.ll find "define void @main()" del
  28. call :check_file smoke.cso del
  29. call :check_file smoke.reflection del
  30. call :check_file smoke.rootsig del
  31. call :check_file smoke.err find "warning: expression result unused" del
  32. if %Failed% neq 0 goto :failed
  33. set testname=/Fd implies /Qstrip_debug
  34. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Fd smoke.hlsl.d /Fo smoke.hlsl.Fd.dxo
  35. call :check_file smoke.hlsl.d del
  36. call :check_file smoke.hlsl.Fd.dxo
  37. if %Failed% neq 0 goto :failed
  38. call :run dxc.exe -dumpbin smoke.hlsl.Fd.dxo
  39. rem Should have debug name, and debug info should be stripped from module
  40. call :check_file log find "shader debug name: smoke.hlsl.d" find-not "DICompileUnit"
  41. if %Failed% neq 0 goto :failed
  42. rem del .pdb file if exists
  43. del %CD%\*.pdb 1>nul 2>nul
  44. set testname=/Fd implies /Qstrip_debug ; path with \ produces auto hash-named .pdb file
  45. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Fd .\ /Fo smoke.hlsl.strip
  46. rem .pdb file should be produced
  47. call :check_file *.PDB del
  48. if %Failed% neq 0 goto :failed
  49. call :run dxc.exe -dumpbin smoke.hlsl.strip
  50. rem auto debug name is hex digest + .pdb
  51. call :check_file log find-opt -r "shader debug name: [0-9a-f]*.pdb" find-not "DICompileUnit" del
  52. if %Failed% neq 0 goto :failed
  53. rem del .pdb file if exists
  54. del %CD%\*.pdb 1>nul 2>nul
  55. set testname=Embed debug info
  56. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Qembed_debug /Fo smoke.hlsl.embedpdb
  57. call :check_file smoke.hlsl.embedpdb
  58. if %Failed% neq 0 goto :failed
  59. rem .pdb file should NOT be produced
  60. call :check_file_not *.pdb del
  61. call :run dxc.exe -dumpbin smoke.hlsl.embedpdb
  62. rem should have auto debug name, which is hex digest + .pdb
  63. call :check_file log find-opt -r "shader debug name: [0-9a-f]*.pdb" find "DICompileUnit" del
  64. call :check_file smoke.hlsl.embedpdb del
  65. if %Failed% neq 0 goto :failed
  66. set testname=Auto-embed debug info when no debug output, and expect warning signifying that this is the case.
  67. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Fo smoke.hlsl.embedpdb /Fe smoke.err.embedpdb
  68. call :check_file smoke.hlsl.embedpdb
  69. rem Search for warning:
  70. call :check_file smoke.err.embedpdb find "warning: no output provided for debug - embedding PDB in shader container. Use -Qembed_debug to silence this warning." del
  71. rem .pdb file should NOT be produced
  72. call :check_file_not *.pdb del
  73. if %Failed% neq 0 goto :failed
  74. call :run dxc.exe -dumpbin smoke.hlsl.embedpdb
  75. rem should have auto debug name, which is hex digest + .pdb
  76. call :check_file log find-opt -r "shader debug name: [0-9a-f]*.pdb" find "DICompileUnit"
  77. call :check_file smoke.hlsl.embedpdb del
  78. if %Failed% neq 0 goto :failed
  79. set testname=/Zi with /Qstrip_debug and no output should not embed
  80. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Qstrip_debug /Fo smoke.hlsl.strip
  81. call :check_file smoke.hlsl.strip
  82. if %Failed% neq 0 goto :failed
  83. call :run dxc.exe -dumpbin smoke.hlsl.strip
  84. call :check_file log find-opt -r "shader debug name: [0-9a-f]*.pdb" find-not "DICompileUnit"
  85. call :check_file smoke.hlsl.strip del
  86. if %Failed% neq 0 goto :failed
  87. set testname=/Qstrip_reflect strips reflection
  88. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" -D DX12 /Qstrip_reflect /Fo smoke.hlsl.strip
  89. call :check_file smoke.hlsl.strip
  90. if %Failed% neq 0 goto :failed
  91. call :run dxc.exe -dumpbin smoke.hlsl.strip
  92. call :check_file log find-not "i32 6, !\"g\""
  93. call :check_file smoke.hlsl.strip del
  94. if %Failed% neq 0 goto :failed
  95. set testname=ast-dump
  96. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /ast-dump
  97. call :check_file log find TranslationUnitDecl
  98. if %Failed% neq 0 goto :failed
  99. set testname=Check Warning
  100. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Dcheck_warning
  101. call :check_file log find warning:
  102. if %Failed% neq 0 goto :failed
  103. set testname=/no-warnings
  104. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Dcheck_warning /no-warnings
  105. call :check_file log find-not warning:
  106. if %Failed% neq 0 goto :failed
  107. set testname=Preprocess
  108. call :run dxc.exe "%testfiles%\smoke.hlsl" /P preprocessed.hlsl
  109. call :check_file preprocessed.hlsl find "float4 main"
  110. if %Failed% neq 0 goto :failed
  111. set testname=-force_rootsig_ver
  112. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" -force_rootsig_ver rootsig_1_0
  113. if %Failed% neq 0 goto :failed
  114. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" -force_rootsig_ver rootsig_1_1
  115. if %Failed% neq 0 goto :failed
  116. call :run-fail dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" -force_rootsig_ver rootsig_2_0
  117. if %Failed% neq 0 goto :failed
  118. set testname=Root Signature target
  119. echo #define main "CBV(b0)"> test-global-rs.hlsl
  120. call :run dxc -T rootsig_1_1 test-global-rs.hlsl -rootsig-define main -Fo test-global-rs.cso
  121. call :check_file test-global-rs.cso del
  122. if %Failed% neq 0 goto :failed
  123. set testname=Local Root Signature target
  124. echo #define main "CBV(b0), RootFlags(LOCAL_ROOT_SIGNATURE)"> test-local-rs.hlsl
  125. call :run dxc -T rootsig_1_1 test-local-rs.hlsl -rootsig-define main -Fo test-local-rs.cso
  126. call :check_file test-local-rs.cso del
  127. if %Failed% neq 0 goto :failed
  128. set testname=HLSL Version
  129. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /HV 2016
  130. call :run-fail dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /HV 2015
  131. if %Failed% neq 0 goto :failed
  132. set testname=Embed Debug, Recompile
  133. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Qembed_debug /Fo smoke.cso 1> nul
  134. call :check_file smoke.cso
  135. if %Failed% neq 0 goto :failed
  136. call :run dxc.exe -dumpbin smoke.cso
  137. call :check_file log find "DICompileUnit"
  138. call :check_file smoke.cso del
  139. if %Failed% neq 0 goto :failed
  140. call :run dxc.exe /T ps_6_0 "%testfiles%\smoke.hlsl" /Zi /Qembed_debug /Fo smoke.cso /Cc /Ni /No /Lx
  141. call :check_file smoke.cso
  142. if %Failed% neq 0 goto :failed
  143. call :run dxc.exe -dumpbin smoke.cso
  144. call :check_file log find "DICompileUnit"
  145. if %Failed% neq 0 goto :failed
  146. call :run dxc.exe smoke.cso /recompile
  147. if %Failed% neq 0 goto :failed
  148. call :run dxc.exe smoke.cso /recompile /T ps_6_0 /E main
  149. if %Failed% neq 0 goto :failed
  150. rem Note: this smoke.cso is used for a lot of other tests, and they rely on options set here
  151. set testname=Command-line Defines, Recompile
  152. call :run dxc.exe "%testfiles%\smoke.hlsl" /D "semantic = SV_Position" /T vs_6_0 /Zi /Qembed_debug /DDX12 /Fo smoke.cso
  153. call :check_file smoke.cso
  154. if %Failed% neq 0 goto :failed
  155. call :run dxc.exe smoke.cso /recompile
  156. if %Failed% neq 0 goto :failed
  157. set testname=Strip Debug from compiled object
  158. call :run dxc.exe smoke.cso /dumpbin /Qstrip_debug /Fo nodebug.cso
  159. call :check_file nodebug.cso
  160. if %Failed% neq 0 goto :failed
  161. set testname=Strip Root Signature from compiled object
  162. call :run dxc.exe smoke.cso /dumpbin /Qstrip_rootsignature /Fo norootsignature.cso
  163. call :check_file norootsignature.cso
  164. if %Failed% neq 0 goto :failed
  165. set testname=Extract rootsignature from compiled object
  166. call :run dxc.exe smoke.cso /dumpbin /extractrootsignature /Fo rootsig.cso
  167. call :check_file rootsig.cso
  168. if %Failed% neq 0 goto :failed
  169. call :check_file smoke.cso del
  170. set testname=Add rootsignature to compiled object
  171. call :run dxc.exe norootsignature.cso /dumpbin /setrootsignature rootsig.cso /Fo smoke.cso
  172. call :check_file rootsig.cso del
  173. rem These are still needed later:
  174. call :check_file smoke.cso
  175. call :check_file norootsignature.cso
  176. if %Failed% neq 0 goto :failed
  177. rem Check that it added by extracting
  178. call :run dxc.exe smoke.cso /dumpbin /extractrootsignature /Fo rootsig.cso
  179. rem Need these later:
  180. call :check_file smoke.cso
  181. call :check_file rootsig.cso
  182. if %Failed% neq 0 goto :failed
  183. set testname=Compile NonUniform.hlsl, extract and strip root signature
  184. call :run dxc.exe "%testfiles%\NonUniform.hlsl" /T ps_6_0 /DDX12 /Fo NonUniform.cso
  185. call :check_file NonUniform.cso
  186. if %Failed% neq 0 goto :failed
  187. call :run dxc.exe NonUniform.cso /dumpbin /Qstrip_rootsignature /Fo NonUniformNoRootSig.cso
  188. call :check_file NonUniformNoRootSig.cso
  189. if %Failed% neq 0 goto :failed
  190. call :run dxc.exe NonUniform.cso /dumpbin /extractrootsignature /Fo NonUniformRootSig.cso
  191. call :check_file NonUniformRootSig.cso
  192. if %Failed% neq 0 goto :failed
  193. set testname=Verify root signature for smoke.cso
  194. call :run dxc.exe smoke.cso /dumpbin /verifyrootsignature rootsig.cso
  195. if %Failed% neq 0 goto :failed
  196. call :run dxc.exe norootsignature.cso /dumpbin /verifyrootsignature rootsig.cso
  197. if %Failed% neq 0 goto :failed
  198. set testname=Verify root signature for NonUniform.cso
  199. call :run dxc.exe NonUniform.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso
  200. if %Failed% neq 0 goto :failed
  201. call :run dxc.exe NonUniformNoRootSig.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso
  202. if %Failed% neq 0 goto :failed
  203. set testname=Verify mismatched root signatures fail verification
  204. call :run-fail dxc.exe NonUniformNoRootSig.cso /dumpbin /verifyrootsignature rootsig.cso
  205. if %Failed% neq 0 goto :failed
  206. call :run-fail dxc.exe norootsignature.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso
  207. if %Failed% neq 0 goto :failed
  208. set testname=Set root signature when already has one should succeed
  209. call :run dxc.exe smoke.cso /dumpbin /setrootsignature rootsig.cso /Fo smoke.rsadded.cso
  210. call :check_file smoke.rsadded.cso del
  211. if %Failed% neq 0 goto :failed
  212. set testname=Set mismatched root signature when already has one should fail
  213. call :run-fail dxc.exe smoke.cso /dumpbin /setrootsignature NonUniformRootSig.cso /Fo smoke.rsadded.cso
  214. call :check_file_not smoke.rsadded.cso del
  215. if %Failed% neq 0 goto :failed
  216. set testname=Compile TextVS.hlsl
  217. call :run dxc.exe "%testfiles%\TextVS.hlsl" /Tvs_6_0 /Zi /Qembed_debug /Fo TextVS.cso
  218. call :check_file TextVS.cso
  219. if %Failed% neq 0 goto :failed
  220. call :run dxc.exe smoke.cso /dumpbin /verifyrootsignature TextVS.cso
  221. call :check_file TextVS.cso del
  222. if %Failed% neq 0 goto :failed
  223. set testname=Set private data
  224. echo private data > private.txt
  225. call :check_file private.txt
  226. call :run dxc.exe smoke.cso /dumpbin /setprivate private.txt /Fo private.cso
  227. call :check_file private.cso
  228. if %Failed% neq 0 goto :failed
  229. call :run dxc.exe private.cso /dumpbin /setprivate private.txt /Fo private.cso
  230. call :check_file private.cso
  231. if %Failed% neq 0 goto :failed
  232. call :run dxc.exe private.cso /dumpbin /Qstrip_priv /Fo noprivate.cso
  233. call :check_file noprivate.cso
  234. if %Failed% neq 0 goto :failed
  235. call :run dxc.exe private.cso /dumpbin /getprivate private1.txt
  236. call :check_file private1.txt find "private data" del
  237. if %Failed% neq 0 goto :failed
  238. set testname=Appending and removing private data blob roundtrip
  239. call :run FC smoke.cso noprivate.cso
  240. call :check_file noprivate.cso del
  241. if %Failed% neq 0 goto :failed
  242. set testname=Strip multiple, verify stripping
  243. call :run dxc.exe private.cso /dumpbin /Qstrip_priv /Qstrip_debug /Qstrip_rootsignature /Fo noprivdebugroot.cso
  244. call :check_file noprivdebugroot.cso
  245. if %Failed% neq 0 goto :failed
  246. call :run-fail dxc.exe noprivdebugroot.cso /dumpbin /getprivate private1.txt
  247. call :check_file_not private1.txt del
  248. if %Failed% neq 0 goto :failed
  249. call :run-fail dxc.exe noprivdebugroot.cso /dumpbin /extractrootsignature rootsig1.cso
  250. call :check_file_not rootsig1.cso del
  251. if %Failed% neq 0 goto :failed
  252. call :run dxc.exe noprivdebugroot.cso /dumpbin
  253. call :check_file_not log find-not "DICompileUnit"
  254. if %Failed% neq 0 goto :failed
  255. rem Cleanup
  256. call :check_file private.cso del
  257. call :check_file noprivdebugroot.cso del
  258. if %Failed% neq 0 goto :failed
  259. set testname=dxc.exe shader model upgrade
  260. call :run dxc.exe -dumpbin smoke.cso -Fc smoke.ll
  261. rem smoke.ll is used later to assemble, so don't delete it.
  262. call :check_file smoke.ll find "DICompileUnit"
  263. if %Failed% neq 0 goto :failed
  264. set testname=dxa command line program
  265. call :run dxa.exe smoke.cso -listfiles
  266. if %Failed% neq 0 goto :failed
  267. call :check_file log find "smoke.hlsl"
  268. if %Failed% neq 0 goto :failed
  269. set testname=dxa -listparts
  270. call :run dxa.exe smoke.cso -listparts
  271. if %Failed% neq 0 goto :failed
  272. rem Check for expected parts for this container
  273. call :check_file log find DXIL find ILDB find RTS0 find PSV0 find STAT find ILDN find HASH find ISG1 find OSG1
  274. if %Failed% neq 0 goto :failed
  275. set testname=dxa extract debug module
  276. call :run dxa.exe smoke.cso -extractpart dbgmodule -o smoke.cso.dbgmodule
  277. call :check_file smoke.cso.dbgmodule
  278. if %Failed% neq 0 goto :failed
  279. call :run dxa.exe smoke.cso.dbgmodule -listfiles
  280. call :check_file log find "smoke.hlsl"
  281. if %Failed% neq 0 goto :failed
  282. set testname=dxa extract all files from debug module
  283. call :run dxa.exe smoke.cso.dbgmodule -extractfile *
  284. call :check_file log find "float4 main()"
  285. if %Failed% neq 0 goto :failed
  286. set testname=dxa extract DXIL module and build container from that
  287. call :run dxa.exe smoke.cso -extractpart module -o smoke.cso.plain.bc
  288. call :check_file smoke.cso.plain.bc
  289. if %Failed% neq 0 goto :failed
  290. call :run dxa.exe smoke.cso.plain.bc -o smoke.rebuilt-container.cso
  291. call :check_file smoke.rebuilt-container.cso del
  292. call :check_file smoke.cso.plain.bc del
  293. if %Failed% neq 0 goto :failed
  294. set testname=dxa assemble container from smoke.ll
  295. call :run dxa.exe smoke.ll -o smoke.rebuilt-container2.cso
  296. call :check_file smoke.rebuilt-container2.cso del
  297. if %Failed% neq 0 goto :failed
  298. set testname=Smoke test for dxopt command line
  299. call :run-nolog dxc /Odump /T ps_6_0 "%testfiles%\smoke.hlsl" > passes.txt
  300. call :check_file passes.txt find emit
  301. if %Failed% neq 0 goto :failed
  302. echo -print-module >> passes.txt
  303. call :run dxc /T ps_6_0 "%testfiles%\smoke.hlsl" /fcgl -Fc smoke.hl.ll
  304. call :check_file smoke.hl.ll
  305. if %Failed% neq 0 goto :failed
  306. call :run-nolog dxopt -pf passes.txt -o=smoke.opt.bc smoke.hl.ll > smoke.opt.prn.txt
  307. call :check_file smoke.opt.bc del
  308. call :check_file smoke.opt.prn.txt find MODULE-PRINT del
  309. if %Failed% neq 0 goto :failed
  310. set testname=Smoke test for dxc_batch command line
  311. call :run dxc_batch.exe -lib-link -multi-thread "%testfiles%\batch_cmds2.txt"
  312. if %Failed% neq 0 goto :failed
  313. call :run dxc_batch.exe -lib-link -multi-thread "%testfiles%\batch_cmds.txt"
  314. if %Failed% neq 0 goto :failed
  315. call :run dxc_batch.exe -multi-thread "%testfiles%\batch_cmds.txt"
  316. if %Failed% neq 0 goto :failed
  317. set testname=Smoke test for dxl command line
  318. call :run dxc.exe -T lib_6_x "%testfiles%\lib_entry4.hlsl" -Fo lib_entry4.dxbc
  319. call :check_file lib_entry4.dxbc
  320. if %Failed% neq 0 goto :failed
  321. call :run dxc.exe -T lib_6_x "%testfiles%\lib_res_match.hlsl" -Fo lib_res_match.dxbc
  322. call :check_file lib_res_match.dxbc
  323. if %Failed% neq 0 goto :failed
  324. call :run dxl.exe -T ps_6_0 lib_res_match.dxbc;lib_entry4.dxbc -Fo res_match_entry.dxbc
  325. call :check_file lib_entry4.dxbc del
  326. call :check_file lib_res_match.dxbc del
  327. call :check_file res_match_entry.dxbc del
  328. if %Failed% neq 0 goto :failed
  329. set testname=Test for denorm options
  330. call :run dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_2 /denorm preserve
  331. if %Failed% neq 0 goto :failed
  332. call :run dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_2 /denorm ftz
  333. if %Failed% neq 0 goto :failed
  334. call :run-fail dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_2 /denorm abc
  335. if %Failed% neq 0 goto :failed
  336. call :run-fail dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_1 /denorm any
  337. if %Failed% neq 0 goto :failed
  338. set testname=Test /enable-16bit-types
  339. call :run dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_2 /enable-16bit-types
  340. if %Failed% neq 0 goto :failed
  341. call :run-fail dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_1 /enable-16bit-types
  342. if %Failed% neq 0 goto :failed
  343. call :run-fail dxc.exe "%testfiles%\smoke.hlsl" /Tps_6_2 /enable-16bit-types /HV 2017
  344. if %Failed% neq 0 goto :failed
  345. set testname=Test file with relative path and include
  346. mkdir subfolder 2>nul
  347. mkdir inc 2>nul
  348. copy "%testfiles%\include-main.hlsl" subfolder >nul
  349. copy "%testfiles%\include-declarations.h" inc >nul
  350. call :run dxc.exe -Tps_6_0 -I inc subfolder\include-main.hlsl
  351. if %Failed% neq 0 goto :failed
  352. call :run dxc.exe -P include-main.hlsl.pp -I inc subfolder\include-main.hlsl
  353. if %Failed% neq 0 goto :failed
  354. rem SPIR-V Change Starts
  355. echo Smoke test for SPIR-V CodeGen ...
  356. set spirv_smoke_success=0
  357. dxc.exe "%testfiles%\smoke.hlsl" /T ps_6_0 -spirv 1>%CD%\smoke.spirv.log 2>&1
  358. if %errorlevel% equ 0 set spirv_smoke_success=1
  359. findstr /c:"SPIR-V CodeGen not available" %CD%\smoke.spirv.log >nul
  360. if %errorlevel% equ 0 set spirv_smoke_success=1
  361. if %spirv_smoke_success% neq 1 (
  362. echo dxc failed SPIR-V smoke test
  363. call :cleanup 2>nul
  364. exit /b 1
  365. )
  366. rem SPIR-V Change Ends
  367. call :cleanup
  368. exit /b 0
  369. :cleanup
  370. for %%f in (%cleanup_files%) do (
  371. del %%f 1>nul 2>nul
  372. )
  373. popd
  374. endlocal
  375. exit /b 0
  376. rem ============================================
  377. rem Check that output does not exist
  378. :check_file_not
  379. set check_file_pattern=%CD%\%1
  380. shift /1
  381. if exist %check_file_pattern% (
  382. call :set_failed
  383. echo Found unexpected file %check_file_pattern%
  384. if "%1"=="del" (
  385. del %check_file_pattern% 1>nul
  386. )
  387. exit /b 1
  388. )
  389. exit /b 0
  390. rem ============================================
  391. rem Check that file exists and find text
  392. :check_file
  393. rem echo check_file %*
  394. if "%1"=="log" (
  395. set check_file_pattern=%OutputLog%
  396. ) else (
  397. set check_file_pattern=%CD%\%1
  398. )
  399. if not exist %check_file_pattern% (
  400. if !Failed! equ 0 (
  401. call :set_failed
  402. echo Failed to find output file %check_file_pattern%
  403. )
  404. exit /b 1
  405. )
  406. shift /1
  407. :check_file_loop
  408. if "%1"=="" (
  409. set cleanup_files=!cleanup_files! !check_file_pattern!
  410. exit /b !Failed!
  411. ) else if "%1"=="del" (
  412. if !Failed! equ 0 (
  413. del %check_file_pattern% 1>nul
  414. )
  415. exit /b !Failed!
  416. ) else (
  417. set mode=find
  418. set find_not=0
  419. if "%1"=="find-not" (
  420. set find_not=1
  421. ) else if "%1"=="find-opt" (
  422. set mode=find-opt
  423. shift /1
  424. ) else if "%1"=="find-not-opt" (
  425. set mode=find-opt
  426. set find_not=1
  427. shift /1
  428. ) else if "%1"=="findstr" (
  429. set mode=findstr
  430. ) else if "%1"=="findstr-not" (
  431. set mode=findstr
  432. set find_not=1
  433. ) else if not "%1"=="find" (
  434. echo Error: unrecognized check_file command: %1
  435. call :set_failed
  436. exit /b 1
  437. )
  438. if "!mode!"=="find" (
  439. set findcmd=findstr /C:%2 %check_file_pattern%
  440. ) else if "!mode!"=="find-opt" (
  441. set findcmd=findstr %2 /C:%3 %check_file_pattern%
  442. ) else if "!mode!"=="findstr" (
  443. set findcmd=findstr %* %check_file_pattern%
  444. )
  445. !findcmd! 1>nul
  446. if !find_not! equ 0 (
  447. if !errorlevel! neq 0 (
  448. call :set_failed
  449. echo Failed: !findcmd!
  450. )
  451. ) else (
  452. if !errorlevel! equ 0 (
  453. call :set_failed
  454. echo Found: !findcmd!
  455. )
  456. )
  457. if "!mode!"=="findstr" (
  458. rem findstr must be last, since it uses all the rest of the args
  459. exit /b !Failed!
  460. )
  461. shift /1
  462. )
  463. shift /1
  464. goto :check_file_loop
  465. rem ============================================
  466. rem Run, log, and set Failed flag if failing
  467. :run
  468. rem echo run %*
  469. set testcmd=%*
  470. set FailingCmdWritten=0
  471. del %OutputLog% 1>nul 2>nul
  472. if %LogOutput% neq 0 (
  473. %testcmd% 1>%OutputLog% 2>&1
  474. ) else (
  475. %testcmd%
  476. )
  477. if %errorlevel% neq 0 (
  478. echo Command Returned: %errorlevel%
  479. echo See %OutputLog%
  480. call :set_failed %errorlevel%
  481. exit /b %errorlevel%
  482. )
  483. exit /b 0
  484. rem ============================================
  485. rem Run but without redirecting to log
  486. :run-nolog
  487. set LogOutput=0
  488. call :run %*
  489. set LogOutput=1
  490. exit /b %errorlevel%
  491. rem ============================================
  492. rem Run, log, and expect failing result, otherwise set Failed
  493. :run-fail
  494. set testcmd=%*
  495. %testcmd% 1>testcmd.log 2>&1
  496. if %errorlevel% equ 0 (
  497. call :set_failed
  498. exit /b 1
  499. )
  500. exit /b 0
  501. rem ============================================
  502. rem Set Failed and write testname/testcmd once.
  503. :set_failed
  504. if %FailingCmdWritten% neq 1 (
  505. if "%1"=="" (
  506. set Failed=1
  507. ) else (
  508. set Failed=%1
  509. )
  510. echo Test Failed: %testname%
  511. echo %testcmd%
  512. set FailingCmdWritten=1
  513. )
  514. exit /b 0
  515. rem ============================================
  516. rem Cleanup and return failure
  517. :failed
  518. call :cleanup 2>nul
  519. if %Failed%=="0" set Failed=1
  520. exit /b %Failed%