]> wimlib.net Git - wimlib/blob - tests/win32-test-imagex-capture_and_apply.bat
win32-test-imagex-capture_and_apply: re-enable some compatibility tests
[wimlib] / tests / win32-test-imagex-capture_and_apply.bat
1 @echo off\r
2 \r
3 REM\r
4 REM win32-test-imagex-capture_and_apply.bat\r
5 REM\r
6 REM Run some tests on the Windows version of wimlib-imagex.\r
7 REM\r
8 REM This must be run with Administrator privileges, in a directory containing\r
9 REM the wimlib-imagex, win32-tree-cmp, and set_reparse_point programs.\r
10 \r
11 setlocal EnableDelayedExpansion\r
12 set WIMLIB_IMAGEX=%cd%\wimlib-imagex\r
13 set WIN32_TREE_CMP=%cd%\win32-tree-cmp\r
14 set SET_REPARSE_POINT=%cd%\set_reparse_point\r
15 \r
16 if exist in.dir rd /S /Q in.dir\r
17 if exist out.dir rd /S /Q out.dir\r
18 md in.dir\r
19 cd in.dir\r
20 \r
21 REM\r
22 REM BEGIN TESTS\r
23 REM\r
24 \r
25 call :msg "empty directory"\r
26 call :do_test\r
27 \r
28 call :msg "single file"\r
29 echo 1 > file\r
30 call :do_test\r
31 \r
32 call :msg "different files"\r
33 echo 1 > file\r
34 echo 2 > anotherfile\r
35 call :do_test\r
36 \r
37 call :msg "identical files"\r
38 echo 1 > file\r
39 echo 1 > identicalfile\r
40 call :do_test\r
41 \r
42 call :msg "hard linked file"\r
43 echo 1 > file\r
44 mklink /h link file > nul\r
45 call :do_test\r
46 \r
47 call :msg "hard linked file, with other identical files"\r
48 echo 1 > file\r
49 mklink /h link file > nul\r
50 echo 1 > identicalfile\r
51 call :do_test\r
52 \r
53 call :msg "empty file"\r
54 type nul > emptyfile\r
55 call :do_test\r
56 \r
57 call :msg "hard linked empty file"\r
58 type nul > file\r
59 mklink /h link file > nul\r
60 REM Use skip_dism_cmp=1 due to DISM bug\r
61 call :do_test_with_params 0 1\r
62 \r
63 call :msg "various hard linked, identical, different, and empty files"\r
64 echo 1 > file\r
65 echo 5 > file\r
66 mklink /h link1 file > nul\r
67 mklink /h link2 file > nul\r
68 type nul > emptyfile\r
69 type nul > emptyfile2\r
70 mklink /h emptyfilelink emptyfile > nul\r
71 echo 5 > identicalfile\r
72 echo 1 > 1file\r
73 mklink /h 1filelink 1file > nul\r
74 REM Use skip_dism_cmp=1 due to DISM bug\r
75 call :do_test_with_params 0 1\r
76 \r
77 call :msg "multiple subdirectories, some empty, some not"\r
78 md subdir1\r
79 md subdir2\r
80 md subdir3\r
81 echo 1 > subdir1\1\r
82 echo 5 > subdir1\5\r
83 mklink /h link subdir1\1 > nul\r
84 md subdir2\subdir2subdir\r
85 type nul > subdir2\emptyfile\r
86 call :do_test\r
87 \r
88 REM FIXME: win32-tree-cmp can't handle this case.\r
89 REM\r
90 REM call :msg "file with custom security descriptor"\r
91 REM echo hello > file\r
92 REM icacls file /deny Administrator:F > nul\r
93 REM call :do_test\r
94 \r
95 call :msg "directory with custom security descriptor (inheritence enabled)"\r
96 md subdir\r
97 icacls subdir /inheritance:e > nul\r
98 call :do_test\r
99 \r
100 call :msg "directory with custom security descriptor (inheritence disabled)"\r
101 md subdir\r
102 icacls subdir /inheritance:d > nul\r
103 call :do_test\r
104 \r
105 REM FIXME: win32-tree-cmp can't handle this case.\r
106 REM\r
107 REM call :msg "file with custom security descriptor (all inherited ACEs removed)"\r
108 REM echo hello > file\r
109 REM icacls file /inheritance:r > nul\r
110 REM call :do_test\r
111 \r
112 call :msg "file with custom integrity level"\r
113 echo hello > file\r
114 icacls file /setintegritylevel H > nul\r
115 REM Use skip_dism_cmp=1 due to DISM bug\r
116 call :do_test_with_params 0 1\r
117 \r
118 call :msg "relative symlink"\r
119 mklink relink dest > nul\r
120 call :do_test\r
121 \r
122 call :msg "absolute symlink, with drive letter"\r
123 mklink abslink C:\absolute\target > nul\r
124 call :do_test\r
125 \r
126 call :msg "absolute symlink, without drive letter"\r
127 mklink abslink \absolute\target > nul\r
128 call :do_test\r
129 \r
130 call :msg "relative symlink, with file target"\r
131 echo 1 > 1\r
132 mklink relink 1 > nul\r
133 call :do_test\r
134 \r
135 call :msg "relative symlink, with directory target"\r
136 md subdir\r
137 mklink reldlink subdir > nul\r
138 call :do_test\r
139 \r
140 call :msg "junction"\r
141 md subdir\r
142 mklink /j junction subdir > nul\r
143 call :do_test\r
144 \r
145 call :msg "symlinks, junctions, files, subdirectories, etc."\r
146 echo 1 > 1\r
147 mklink relink 1 > nul\r
148 mklink rellinklink relink > nul\r
149 mklink /j junction . > nul\r
150 md subdir\r
151 mklink /h subdir\hardlink 1 > nul\r
152 echo "hello world!!!!" > hello\r
153 mklink subdir\hello hello > nul\r
154 mklink abslink C:\Users > nul\r
155 md subdir2\r
156 type nul > emptyfile\r
157 type nul > subdir2\emptyfile\r
158 md subdir2\s\r
159 md subdir2\s\s\r
160 md subdir2\s\s\s\r
161 echo "hello world!!!!" > subdir2\otherfile\r
162 call :do_test\r
163 \r
164 call :msg "reparse point that is neither a symlink nor a junction"\r
165 type nul > file\r
166 %SET_REPARSE_POINT% file\r
167 call :do_test\r
168 \r
169 call :msg "reparse point with named data streams"\r
170 type nul > file\r
171 echo 11 > file:a\r
172 echo 1 > file:aa\r
173 %SET_REPARSE_POINT% file\r
174 call :do_test\r
175 \r
176 call :msg "reparse point with unnamed data stream"\r
177 echo "test" > file\r
178 %SET_REPARSE_POINT% file\r
179 call :do_test\r
180 \r
181 call :msg "reparse point with unnamed data stream and named data streams"\r
182 echo "test" > file\r
183 echo 11 > file:a\r
184 echo 1 > file:aa\r
185 %SET_REPARSE_POINT% file\r
186 call :do_test\r
187 \r
188 call :msg "empty reparse point"\r
189 type nul > file\r
190 %SET_REPARSE_POINT% file 0\r
191 call :do_test\r
192 \r
193 call :msg "empty reparse point with unnamed data stream"\r
194 echo hello > file\r
195 %SET_REPARSE_POINT% file 0\r
196 call :do_test\r
197 \r
198 call :msg "empty reparse point with unnamed data stream and named data streams"\r
199 echo hello > file\r
200 echo hello > file:ads1\r
201 type nul > file:ads2\r
202 %SET_REPARSE_POINT% file 0\r
203 call :do_test\r
204 \r
205 call :msg "maximum length reparse point"\r
206 type nul > file\r
207 %SET_REPARSE_POINT% file 16376\r
208 call :do_test\r
209 \r
210 call :msg "directory reparse point that is neither a symlink nor a junction"\r
211 md subdir\r
212 %SET_REPARSE_POINT% subdir\r
213 call :do_test\r
214 \r
215 call :msg "directory reparse point with named data streams"\r
216 md subdir\r
217 echo 11 > subdir:a\r
218 echo 1 > subdir:aa\r
219 %SET_REPARSE_POINT% subdir\r
220 call :do_test\r
221 \r
222 call :msg "compressed file"\r
223 echo "test" > test\r
224 compact /C test > nul\r
225 call :do_test\r
226 \r
227 call :msg "compressed directory"\r
228 md subdir\r
229 compact /C subdir > nul\r
230 call :do_test\r
231 \r
232 call :msg "compressed directory with files in it"\r
233 md subdir\r
234 compact /C subdir > nul\r
235 echo 1 > subdir\file1\r
236 echo 2 > subdir\file2\r
237 echo 1 > subdir\file1\r
238 md subdir\subsubdir\r
239 mklink /h subdir\hardlink subdir\file1 > nul\r
240 mklink /j subdir\j subdir\subsubdir > nul\r
241 call :do_test\r
242 \r
243 call :msg "compressed directory with some uncompressed files in it"\r
244 md subdir\r
245 compact /C subdir > nul\r
246 echo 1 > subdir\1\r
247 echo 5 > subdir\5\r
248 compact /U subdir\1 > nul\r
249 call :do_test\r
250 \r
251 call :msg "file with alternate data stream"\r
252 echo 1 > file\r
253 echo 5 > file:ads\r
254 call :do_test\r
255 \r
256 call :msg "file with multiple alternate data streams"\r
257 echo 1 > file\r
258 echo a > file:a\r
259 echo aa > file:aa\r
260 echo aaa > file:aaa\r
261 echo aaaa > file:aaaa\r
262 call :do_test\r
263 \r
264 call :msg "file with multiple alternate data streams, with hard link"\r
265 echo 1 > file\r
266 echo a > file:a\r
267 echo aa > file:aa\r
268 echo aaa > file:aaa\r
269 echo aaaa > file:aaaa\r
270 mklink /h link file > nul\r
271 call :do_test\r
272 \r
273 call :msg "files with multiple alternate data streams, some identical, with hard link"\r
274 echo 1 > file\r
275 echo 5 > file2\r
276 echo 1 > file:1\r
277 echo 1 > file:1again\r
278 echo aaa > file:aaa\r
279 echo 5 > file:5\r
280 mklink /h link file > nul\r
281 echo aaa > file2:aaa\r
282 call :do_test\r
283 \r
284 call :msg "file with empty alternate data stream"\r
285 echo 1 > file\r
286 type nul > file:ads\r
287 call :do_test\r
288 \r
289 call :msg "directory with empty alternate data stream"\r
290 md subdir\r
291 type nul > subdir:ads\r
292 REM Use skip_dism_apply=1 due to DISM bug\r
293 call :do_test_with_params 1 0\r
294 \r
295 call :msg "root directory with alternate data stream"\r
296 echo 1 > ..\in.dir:ads\r
297 REM Use skip_dism_apply=1 due to DISM bug\r
298 call :do_test_with_params 1 0\r
299 \r
300 call :msg "root directory with empty alternate data stream"\r
301 type nul > ..\in.dir:ads\r
302 REM Use skip_dism_apply=1 due to DISM bug\r
303 call :do_test_with_params 1 0\r
304 \r
305 call :msg "subdirectory with alternate data streams"\r
306 md subdir\r
307 echo 1 > subdir:1\r
308 echo 2 > subdir:2\r
309 echo 2 > subdir:2again\r
310 REM Use skip_dism_apply=1 due to DISM bug\r
311 call :do_test_with_params 1 0\r
312 \r
313 call :msg "subdirectories and files with alternate data streams"\r
314 md subdir\r
315 echo hello > hello\r
316 echo hello > subdir:hello\r
317 echo hello > subdir:helloagain\r
318 echo hello > helloagain\r
319 mklink /h hellolink hello > nul\r
320 echo 1 > helloagain:1\r
321 echo 8 > helloagain:8\r
322 echo 1 > 1\r
323 type nul > helloagain:dummy\r
324 REM Use skip_dism_apply=1 due to DISM bug\r
325 call :do_test_with_params 1 0\r
326 \r
327 call :msg "symbolic link and hard link, to file with alternate data streams"\r
328 echo 1 > 1\r
329 echo test > .\1:test\r
330 mklink symlink 1 > nul\r
331 mklink /h hardlink 1 > nul\r
332 REM Use skip_dism_apply=1 due to DISM bug\r
333 call :do_test_with_params 1 0\r
334 \r
335 call :msg "compressed file with alternate data streams"\r
336 echo 1 > 1\r
337 echo 1 > .\1:1\r
338 echo 2 > .\1:2\r
339 compact /C 1 > nul\r
340 call :do_test\r
341 \r
342 call :msg "hidden file"\r
343 echo 1 > hidden\r
344 attrib +h hidden\r
345 call :do_test\r
346 \r
347 call :msg "hidden system file"\r
348 echo 1 > file\r
349 attrib +h +s file\r
350 call :do_test\r
351 \r
352 call :msg "hidden, readonly, system file"\r
353 echo 1 > file\r
354 attrib +h +r +s file\r
355 call :do_test\r
356 \r
357 call :msg "hidden directory"\r
358 md subdir\r
359 attrib +h subdir\r
360 call :do_test\r
361 \r
362 call :msg "hidden system directory"\r
363 md subdir\r
364 attrib +h +s subdir\r
365 call :do_test\r
366 \r
367 call :msg "hidden, readonly, system directory"\r
368 md subdir\r
369 attrib +h +r +s subdir\r
370 call :do_test\r
371 \r
372 call :msg "readonly directory with named data stream"\r
373 md subdir\r
374 echo foo > subdir:ads\r
375 attrib +r subdir\r
376 REM Use skip_dism_apply=1 due to DISM bug\r
377 call :do_test_with_params 1 0\r
378 \r
379 call :msg "encrypted file"\r
380 echo "hello" > encrypted\r
381 cipher /e encrypted > nul\r
382 call :do_test\r
383 \r
384 call :msg "identical encrypted files"\r
385 echo "hello" > encrypted1\r
386 echo "hello" > encrypted2\r
387 cipher /e encrypted1 > nul\r
388 cipher /e encrypted2 > nul\r
389 call :do_test\r
390 \r
391 call :msg "encrypted directory"\r
392 md subdir\r
393 cipher /e subdir > nul\r
394 call :do_test\r
395 \r
396 call :msg "encrypted directory with encrypted file in it"\r
397 md subdir\r
398 echo 1 > subdir\1\r
399 cipher /e subdir > nul\r
400 cipher /e subdir\1 > nul\r
401 call :do_test\r
402 \r
403 call :msg "encrypted directory with unencrypted file in it"\r
404 md subdir\r
405 echo 1 > subdir\1\r
406 cipher /e subdir > nul\r
407 cipher /d subdir\1 > nul\r
408 call :do_test\r
409 \r
410 REM FIXME: apply fails with STATUS_ACCESS_DENIED\r
411 REM\r
412 REM call :msg "encrypted root directory"\r
413 REM cd ..\r
414 REM cipher /e in.dir > nul\r
415 REM cd in.dir\r
416 REM echo "hello" > encrypted\r
417 REM call :do_test\r
418 \r
419 call :msg "unencrypted file in encrypted directory in compressed directory"\r
420 md 1\r
421 md 1\2\r
422 compact /c 1 > nul\r
423 cipher /e 1\2 > nul\r
424 echo hello > 1\2\file\r
425 cipher /d 1\2\file > nul\r
426 call :do_test\r
427 \r
428 call :msg "encrypted directory with alternate data streams"\r
429 md subdir\r
430 cipher /e subdir > nul\r
431 echo ads1 > subdir:ads1\r
432 echo ads2 > subdir:ads2\r
433 call :do_test\r
434 \r
435 call :msg "hardlinked, encrypted file with alternate data streams"\r
436 echo hello > file\r
437 echo hello > file:ads\r
438 cipher /e file > nul\r
439 mklink /h link file > nul\r
440 call :do_test\r
441 \r
442 REM Note: since object IDs must be unique per filesystem, we can't expect them\r
443 REM to preserved using our testing scheme.  Therefore, win32-tree-cmp doesn't\r
444 REM compare them, and the below tests really just ensure the object ID code is\r
445 REM run to some extent.\r
446 \r
447 call :msg "file with object ID"\r
448 echo hello > file\r
449 fsutil objectid create file > nul\r
450 call :do_test\r
451 \r
452 call :msg "directory with object ID"\r
453 md subdir\r
454 fsutil objectid set f67394c12b17608e1d050d181ba8ffd2 7df80cbdf620f4c82c79b9e6799147b6 97621aff72915ade05abb96b15dea1a3 e0bda4caa9e33cfd461c92c16be9713d subdir\r
455 call :do_test\r
456 \r
457 call :msg "sparse files"\r
458 fsutil file createnew sparse 1000000 > nul\r
459 fsutil sparse setflag sparse\r
460 fsutil sparse setrange sparse 0 1000000\r
461 \r
462 fsutil file createnew mostly_sparse 1000000 > nul\r
463 fsutil sparse setflag mostly_sparse\r
464 fsutil sparse setrange mostly_sparse 0 1000000\r
465 echo hello >> mostly_sparse\r
466 type sparse >> mostly_sparse\r
467 fsutil sparse setrange mostly_sparse 1000100 2000000\r
468 call :do_test\r
469 \r
470 call :msg "sparse and compressed files"\r
471 fsutil file createnew sparse 1000000 > nul\r
472 fsutil sparse setflag sparse\r
473 fsutil sparse setrange sparse 0 1000000\r
474 compact /c sparse > nul\r
475 \r
476 fsutil file createnew mostly_sparse 1000000 > nul\r
477 fsutil sparse setflag mostly_sparse\r
478 fsutil sparse setrange mostly_sparse 0 1000000\r
479 echo hello >> mostly_sparse\r
480 type sparse >> mostly_sparse\r
481 fsutil sparse setrange mostly_sparse 1000100 2000000\r
482 compact /c mostly_sparse > nul\r
483 \r
484 type nul > compressed_first\r
485 compact /c compressed_first > nul\r
486 type sparse >> compressed_first\r
487 fsutil sparse setflag compressed_first\r
488 fsutil sparse setrange compressed_first 0 500000\r
489 call :do_test\r
490 \r
491 :rpfix_tests\r
492 \r
493 echo Testing rpfix junction\r
494 md subdir\r
495 echo 1 > subdir\file\r
496 mklink /j junction subdir > nul\r
497 cd ..\r
498 %WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
499 rd /s /q in.dir\r
500 %WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
501 echo 1 > tmp1\r
502 type out.dir\junction\file > tmp2\r
503 fc tmp1 tmp2 > nul\r
504 if %errorlevel% neq 0 goto :fail\r
505 rd /s /q out.dir\r
506 del tmp1 tmp2\r
507 md in.dir\r
508 cd in.dir\r
509 \r
510 echo Testing rpfix relative\r
511 echo 1 > file\r
512 mklink relink file > nul\r
513 cd ..\r
514 %WIMLIB_IMAGEX% capture in.dir test.wim > nul\r
515 %WIMLIB_IMAGEX% apply test.wim out.dir > nul\r
516 type out.dir\relink > out.dir\tmp\r
517 if %errorlevel% neq 0 goto :fail\r
518 fc in.dir\file out.dir\tmp > nul\r
519 if %errorlevel% neq 0 goto :fail\r
520 rd /s /q in.dir out.dir\r
521 md in.dir\r
522 cd in.dir\r
523 \r
524 REM\r
525 REM END OF TESTS\r
526 REM\r
527 \r
528 cd ..\r
529 del test.wim\r
530 rd /s /q in.dir\r
531 exit /b 0\r
532 \r
533 :do_test\r
534 call :do_test_with_params 0 0\r
535 goto :eof\r
536 \r
537 :do_test_with_params\r
538 set skip_dism_apply=%1\r
539 set skip_dism_cmp=%2\r
540 cd ..\r
541 echo   wimlib test (first time)\r
542 %WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL\r
543 if %errorlevel% neq 0 goto :fail\r
544 %WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
545 if %errorlevel% neq 0 goto :fail\r
546 %WIN32_TREE_CMP% in.dir out.dir\r
547 if %errorlevel% neq 0 goto :fail\r
548 \r
549 REM  apply a second time so we test the case where the files already exist\r
550 echo   wimlib test (second time)\r
551 %WIMLIB_IMAGEX% apply test.wim out.dir > NUL\r
552 if %errorlevel% neq 0 goto :fail\r
553 %WIN32_TREE_CMP% in.dir out.dir\r
554 if %errorlevel% neq 0 goto :fail\r
555 \r
556 REM  compatibility test: apply the image with DISM\r
557 echo   DISM test\r
558 rd /S /Q out.dir\r
559 md out.dir\r
560 if %skip_dism_apply% neq 1 (\r
561     dism /apply-image /imagefile:test.wim /index:1 /applydir:out.dir > nul\r
562     if !errorlevel! neq 0 (\r
563         echo ERROR: DISM apply failed!\r
564         goto :fail\r
565     )\r
566     if %skip_dism_cmp% neq 1 (\r
567         %WIN32_TREE_CMP% in.dir out.dir\r
568         if !errorlevel! neq 0 (\r
569             echo ERROR: DISM comparison failed!\r
570             goto :fail\r
571         )\r
572     )\r
573 )\r
574 \r
575 rd /S /Q in.dir out.dir\r
576 md in.dir\r
577 cd in.dir\r
578 goto :eof\r
579 \r
580 :msg\r
581 echo Testing capture and apply of %~1\r
582 goto :eof\r
583 \r
584 :fail\r
585 echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
586 echo            TEST FAILED!!!!!!!\r
587 echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
588 exit %errorlevel%\r