forked from winfsp/winspd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.bat
executable file
·443 lines (379 loc) · 12.8 KB
/
run-tests.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
@echo off
setlocal
setlocal EnableDelayedExpansion
set Configuration=Release
if not X%1==X set Configuration=%1
cd %~dp0..
set ProjRoot=%cd%
cd build\VStudio
if not exist build\%Configuration% echo === No tests found >&2 & goto fail
cd build\%Configuration%
set dfl_tests=^
rawdisk-cc-stgtest-pipe-x64 ^
rawdisk-cc-stgtest-pipe-x86 ^
rawdisk-cc-stgtest-pipe-msil ^
rawdisk-nc-stgtest-pipe-x64 ^
rawdisk-nc-stgtest-pipe-x86 ^
rawdisk-nc-stgtest-pipe-msil ^
rawdisk-cc-stgtest-raw-x64 ^
rawdisk-cc-stgtest-raw-x86 ^
rawdisk-cc-stgtest-raw-msil ^
rawdisk-nc-stgtest-raw-x64 ^
rawdisk-nc-stgtest-raw-x86 ^
rawdisk-nc-stgtest-raw-msil ^
rawdisk-nu-stgtest-raw-x64 ^
rawdisk-nu-stgtest-raw-x86 ^
rawdisk-nu-stgtest-raw-msil ^
rawdisk-cc-format-ntfs-x64 ^
rawdisk-cc-format-ntfs-x86 ^
rawdisk-cc-format-ntfs-msil ^
rawdisk-nc-format-ntfs-x64 ^
rawdisk-nc-format-ntfs-x86 ^
rawdisk-nc-format-ntfs-msil ^
rawdisk-nu-format-ntfs-x64 ^
rawdisk-nu-format-ntfs-x86 ^
rawdisk-nu-format-ntfs-msil ^
rawdisk-scsicompliance-x64 ^
rawdisk-scsicompliance-x86 ^
rawdisk-scsicompliance-msil
set opt_tests=^
winspd-tests-x64 ^
winspd-tests-x86
set tests=
for %%f in (%dfl_tests%) do (
if X%2==X (
set tests=!tests! %%f
) else (
set test=%%f
if not "X!test:%2=!"=="X!test!" set tests=!tests! %%f
)
)
for %%f in (%opt_tests%) do (
if X%2==X (
rem
) else (
set test=%%f
if not "X!test:%2=!"=="X!test!" set tests=!tests! %%f
)
)
set testpass=0
set testfail=0
for %%f in (%tests%) do (
echo === Running %%f
if defined APPVEYOR (
appveyor AddTest "%%f" -FileName None -Framework None -Outcome Running
)
pushd %cd%
call :%%f
popd
if !ERRORLEVEL! neq 0 (
set /a testfail=testfail+1
echo === Failed %%f
if defined APPVEYOR (
appveyor UpdateTest "%%f" -FileName None -Framework None -Outcome Failed -Duration 0
)
) else (
set /a testpass=testpass+1
echo === Passed %%f
if defined APPVEYOR (
appveyor UpdateTest "%%f" -FileName None -Framework None -Outcome Passed -Duration 0
)
)
echo:
)
set /a total=testpass+testfail
echo === Total: %testpass%/%total%
call :leak-test
if !ERRORLEVEL! neq 0 goto fail
if not %testfail%==0 goto fail
exit /b 0
:fail
exit /b 1
:winspd-tests-x64
winspd-tests-x64 *
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:winspd-tests-x86
winspd-tests-x86 *
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-stgtest-pipe-common
set TestExit=0
start "" /b rawdisk-%1 -p \\.\pipe\rawdisk -f test.disk %~3
waitfor 7BF47D72F6664550B03248ECFE77C7DD /t 3 2>nul
stgtest-x64 \\.\pipe\rawdisk\0 %2 WRUR * *
if !ERRORLEVEL! neq 0 set TestExit=1
taskkill /f /im rawdisk-%1.exe
del test.disk 2>nul
exit /b !TestExit!
:rawdisk-cc-stgtest-pipe-x64
call :rawdisk-stgtest-pipe-common x64 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-stgtest-pipe-x86
call :rawdisk-stgtest-pipe-common x86 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-stgtest-pipe-msil
call :rawdisk-stgtest-pipe-common dotnet-msil 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-pipe-x64
call :rawdisk-stgtest-pipe-common x64 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-pipe-x86
call :rawdisk-stgtest-pipe-common x86 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-pipe-msil
call :rawdisk-stgtest-pipe-common dotnet-msil 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-stgtest-raw-common
set TestExit=0
start "" /b rawdisk-%1 -f test.disk %~3
waitfor 7BF47D72F6664550B03248ECFE77C7DD /t 3 2>nul
call :diskpart-partition 1 R
stgtest-x64 \\.\R: %2 WR * *
if !ERRORLEVEL! neq 0 set TestExit=1
call :diskpart-remove 1 R
taskkill /f /im rawdisk-%1.exe
del test.disk 2>nul
exit /b !TestExit!
:rawdisk-cc-stgtest-raw-x64
call :rawdisk-stgtest-raw-common x64 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-stgtest-raw-x86
call :rawdisk-stgtest-raw-common x86 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-stgtest-raw-msil
call :rawdisk-stgtest-raw-common dotnet-msil 10000 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-raw-x64
call :rawdisk-stgtest-raw-common x64 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-raw-x86
call :rawdisk-stgtest-raw-common x86 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-stgtest-raw-msil
call :rawdisk-stgtest-raw-common dotnet-msil 1000 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-stgtest-raw-x64
call :rawdisk-stgtest-raw-common x64 1000 "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-stgtest-raw-x86
call :rawdisk-stgtest-raw-common x86 1000 "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-stgtest-raw-msil
call :rawdisk-stgtest-raw-common dotnet-msil 1000 "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-format-ntfs-common
set TestExit=0
start "" /b rawdisk-%1 -f test.disk %~2
waitfor 7BF47D72F6664550B03248ECFE77C7DD /t 3 2>nul
call :diskpart-format-ntfs 1 R
pushd >nul
cd R: >nul 2>nul
if !ERRORLEVEL! neq 0 set TestExit=1
if X!TestExit!==X0 (
R:
echo hello>world
if !ERRORLEVEL! neq 0 set TestExit=1
type world
if !ERRORLEVEL! neq 0 set TestExit=1
dir
if !ERRORLEVEL! neq 0 set TestExit=1
)
popd
call :diskpart-remove 1 R
taskkill /f /im rawdisk-%1.exe
del test.disk 2>nul
exit /b !TestExit!
:rawdisk-cc-format-ntfs-x64
call :rawdisk-format-ntfs-common x64 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-format-ntfs-x86
call :rawdisk-format-ntfs-common x86 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-cc-format-ntfs-msil
call :rawdisk-format-ntfs-common dotnet-msil "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-format-ntfs-x64
call :rawdisk-format-ntfs-common x64 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-format-ntfs-x86
call :rawdisk-format-ntfs-common x86 "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nc-format-ntfs-msil
call :rawdisk-format-ntfs-common dotnet-msil "-C 0 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-format-ntfs-x64
call :rawdisk-format-ntfs-common x64 "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-format-ntfs-x86
call :rawdisk-format-ntfs-common x86 "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-nu-format-ntfs-msil
call :rawdisk-format-ntfs-common dotnet-msil "-C 1 -U 0"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-scsicompliance-common
set TestExit=0
start "" /b rawdisk-%1 -f test.disk %~3
waitfor 7BF47D72F6664550B03248ECFE77C7DD /t 3 2>nul
call :scsicompliance /device \\.\PhysicalDrive1 /operation test /scenario common /verbosity 2
if !ERRORLEVEL! neq 0 set TestExit=1
taskkill /f /im rawdisk-%1.exe
del test.disk 2>nul
exit /b !TestExit!
:rawdisk-scsicompliance-x64
call :rawdisk-scsicompliance-common x64 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-scsicompliance-x86
call :rawdisk-scsicompliance-common x86 "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:rawdisk-scsicompliance-msil
call :rawdisk-scsicompliance-common dotnet-msil "-C 1 -U 1"
if !ERRORLEVEL! neq 0 goto fail
exit /b 0
:diskpart-partition
echo rescan > %TMP%\diskpart.script
echo select disk %1 >>%TMP%\diskpart.script
echo attribute disk clear readonly noerr>>%TMP%\diskpart.script
echo online disk noerr >>%TMP%\diskpart.script
echo clean >>%TMP%\diskpart.script
echo create partition primary >>%TMP%\diskpart.script
echo assign letter %2 >>%TMP%\diskpart.script
echo exit >>%TMP%\diskpart.script
diskpart /s %TMP%\diskpart.script
del %TMP%\diskpart.script 2>nul
exit /b 0
:diskpart-format-ntfs
echo rescan > %TMP%\diskpart.script
echo select disk %1 >>%TMP%\diskpart.script
echo attribute disk clear readonly noerr>>%TMP%\diskpart.script
echo online disk noerr >>%TMP%\diskpart.script
echo clean >>%TMP%\diskpart.script
echo create partition primary >>%TMP%\diskpart.script
echo format fs=ntfs quick >>%TMP%\diskpart.script
echo assign letter %2 >>%TMP%\diskpart.script
echo exit >>%TMP%\diskpart.script
diskpart /s %TMP%\diskpart.script
del %TMP%\diskpart.script 2>nul
exit /b 0
:diskpart-remove
echo rescan > %TMP%\diskpart.script
echo select disk %1 >>%TMP%\diskpart.script
echo select partition 1 >>%TMP%\diskpart.script
echo remove letter %2 >>%TMP%\diskpart.script
echo exit >>%TMP%\diskpart.script
diskpart /s %TMP%\diskpart.script
del %TMP%\diskpart.script 2>nul
exit /b 0
:scsicompliance
set ScsiComplianceTestFound=
set ScsiComplianceTestName=
set ScsiComplianceTestActive=
set ScsiComplianceTestLines=
set ScsiComplianceTestStatus=
set ScsiComplianceTestExit=0
(SET LF=^
%=this line is empty=%
)
for /F "delims=" %%l in ('call "%ProjRoot%\tools\scsicompliance.bat" %* ^| findstr /n "^"') do (
set ScsiComplianceTestLine=%%l
set ScsiComplianceTestLine=!ScsiComplianceTestLine:*:=!
for /F "tokens=1,2,* delims=:" %%h in ("%%l") do (
set FieldName=%%i
set FieldName=!FieldName: =!
set FieldValue=%%j
if X!FieldName!==XStart (
for /F "tokens=1 delims=," %%a in ("!FieldValue!") do (
set ScsiComplianceTestName=####%%a
set ScsiComplianceTestName=!ScsiComplianceTestName:#### =####!
set ScsiComplianceTestName=!ScsiComplianceTestName:####=!
set ScsiComplianceTestName=!ScsiComplianceTestName:ASSERTION: =!
)
set ScsiComplianceTestActive=YES
set ScsiComplianceTestLines=
set ScsiComplianceTestFound=YES
)
if X!ScsiComplianceTestActive!==XYES (
set ScsiComplianceTestLines=!ScsiComplianceTestLines!!LF! !ScsiComplianceTestLine!
)
if X!FieldName!==XEnd (
for /F "tokens=1 delims=," %%a in ("!FieldValue!") do (
set ScsiComplianceTestStatus=####%%a
set ScsiComplianceTestStatus=!ScsiComplianceTestStatus:#### =####!
set ScsiComplianceTestStatus=!ScsiComplianceTestStatus:####=!
)
set ScsiComplianceTestPrefix=!ScsiComplianceTestName!..............................................................
set ScsiComplianceTestPrefix=!ScsiComplianceTestPrefix:~0,63!
if X!ScsiComplianceTestStatus!==XPass (
echo !ScsiComplianceTestPrefix! OK
) else if X!ScsiComplianceTestStatus!==XWarn (
echo !ScsiComplianceTestPrefix! SKIP
) else (
echo !ScsiComplianceTestPrefix! KO!ScsiComplianceTestLines!
set ScsiComplianceTestExit=1
)
set ScsiComplianceTestName=
set ScsiComplianceTestActive=
set ScsiComplianceTestLines=
set ScsiComplianceTestStatus=
)
)
)
if not X!ScsiComplianceTestFound!==XYES set ScsiComplianceTestExit=1
exit /b !ScsiComplianceTestExit!
:leak-test
for /F "tokens=1,2 delims=:" %%i in ('verifier /query ^| findstr ^
/c:"Current Pool Allocations:" ^
/c:"CurrentPagedPoolAllocations:" ^
/c:"CurrentNonPagedPoolAllocations:"'
) do (
set FieldName=%%i
set FieldName=!FieldName: =!
set FieldValue=%%j
set FieldValue=!FieldValue: =!
set FieldValue=!FieldValue:^(=!
set FieldValue=!FieldValue:^)=!
if X!FieldName!==XCurrentPoolAllocations (
for /F "tokens=1,2 delims=/" %%k in ("!FieldValue!") do (
set NonPagedAlloc=%%k
set PagedAlloc=%%l
)
) else if X!FieldName!==XCurrentPagedPoolAllocations (
set PagedAlloc=!FieldValue!
) else if X!FieldName!==XCurrentNonPagedPoolAllocations (
set NonPagedAlloc=!FieldValue!
)
)
set /A TotalAlloc=PagedAlloc+NonPagedAlloc
if !TotalAlloc! equ 0 (
echo === Leaks: None
) else (
echo === Leaks: !NonPagedAlloc! NP / !PagedAlloc! P
goto fail
)
exit /b 0