]> wimlib.net Git - wimlib/blob - tests/win32-test-imagex-capture_and_apply.bat
Add Windows rpfix 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 on Windows Vista or later in a clean directory, with\r
9 REM Administrator privileges.  wimlib-imagex and win32-tree-cmp must be callable\r
10 REM (on PATH or in same directory).\r
11 \r
12 setlocal EnableDelayedExpansion\r
13 \r
14 if exist in.dir rd /S /Q in.dir\r
15 if exist out.dir rd /S /Q out.dir\r
16 md in.dir\r
17 cd in.dir\r
18 \r
19 REM\r
20 REM BEGIN TESTS\r
21 REM\r
22 \r
23 REM goto :rpfix_tests\r
24 \r
25 call :msg "empty directory"\r
26 call :do_test\r
27 if %errorlevel% neq 0 exit /b %errorlevel%\r
28 \r
29 call :msg "single file"\r
30 echo 1 > file\r
31 call :do_test\r
32 if %errorlevel% neq 0 exit /b %errorlevel%\r
33 \r
34 call :msg "different files"\r
35 echo 1 > file\r
36 echo 2 > anotherfile\r
37 call :do_test\r
38 if %errorlevel% neq 0 exit /b %errorlevel%\r
39 \r
40 call :msg "identical files"\r
41 echo 1 > file\r
42 echo 1 > identicalfile\r
43 call :do_test\r
44 if %errorlevel% neq 0 exit /b %errorlevel%\r
45 \r
46 call :msg "hard linked file"\r
47 echo 1 > file\r
48 mklink /h link file > nul\r
49 call :do_test\r
50 if %errorlevel% neq 0 exit /b %errorlevel%\r
51 \r
52 call :msg "hard linked file, with other identical files"\r
53 echo 1 > file\r
54 mklink /h link file > nul\r
55 echo 1 > identicalfile\r
56 call :do_test\r
57 if %errorlevel% neq 0 exit /b %errorlevel%\r
58 \r
59 call :msg "empty file"\r
60 type nul > emptyfile\r
61 call :do_test\r
62 if %errorlevel% neq 0 exit /b %errorlevel%\r
63 \r
64 call :msg "various hard linked, identical, different, and empty files"\r
65 echo 1 > file\r
66 echo 5 > file\r
67 mklink /h link1 file > nul\r
68 mklink /h link2 file > nul\r
69 type nul > emptyfile\r
70 type nul > emptyfile2\r
71 mklink /h emptyfilelink emptyfile > nul\r
72 echo 5 > identicalfile\r
73 echo 1 > 1file\r
74 mklink /h 1filelink 1file > nul\r
75 call :do_test\r
76 if %errorlevel% neq 0 exit /b %errorlevel%\r
77 \r
78 call :msg "multiple subdirectories, some empty, some not"\r
79 md subdir1\r
80 md subdir2\r
81 md subdir3\r
82 echo 1 > subdir1\1\r
83 echo 5 > subdir1\5\r
84 mklink /h link subdir1\1 > nul\r
85 md subdir2\subdir2subdir\r
86 type nul > subdir2\emptyfile\r
87 call :do_test\r
88 if %errorlevel% neq 0 exit /b %errorlevel%\r
89 \r
90 call :msg "relative symlink"\r
91 mklink relink dest > nul\r
92 call :do_test\r
93 if %errorlevel% neq 0 exit /b %errorlevel%\r
94 \r
95 call :msg "absolute symlink, with drive letter"\r
96 mklink abslink C:\absolute\target > nul\r
97 call :do_test\r
98 if %errorlevel% neq 0 exit /b %errorlevel%\r
99 \r
100 call :msg "absolute symlink, without drive letter"\r
101 mklink abslink \absolute\target > nul\r
102 call :do_test\r
103 if %errorlevel% neq 0 exit /b %errorlevel%\r
104 \r
105 call :msg "relative symlink, with file target"\r
106 echo 1 > 1\r
107 mklink relink 1 > nul\r
108 call :do_test\r
109 if %errorlevel% neq 0 exit /b %errorlevel%\r
110 \r
111 call :msg "relative symlink, with directory target"\r
112 md subdir\r
113 mklink reldlink subdir > nul\r
114 call :do_test\r
115 if %errorlevel% neq 0 exit /b %errorlevel%\r
116 \r
117 call :msg "junction"\r
118 md subdir\r
119 mklink /j junction subdir > nul\r
120 call :do_test\r
121 if %errorlevel% neq 0 exit /b %errorlevel%\r
122 \r
123 call :msg "symlinks, junctions, files, subdirectories, etc."\r
124 echo 1 > 1\r
125 mklink relink 1 > nul\r
126 mklink rellinklink relink > nul\r
127 mklink /j junction . > nul\r
128 md subdir\r
129 mklink /h subdir\hardlink 1 > nul\r
130 echo "hello world!!!!" > hello\r
131 mklink subdir\hello hello > nul\r
132 mklink abslink C:\Users > nul\r
133 md subdir2\r
134 type nul > emptyfile\r
135 type nul > subdir2\emptyfile\r
136 md subdir2\s\r
137 md subdir2\s\s\r
138 md subdir2\s\s\s\r
139 echo "hello world!!!!" > subdir2\otherfile\r
140 call :do_test\r
141 if %errorlevel% neq 0 exit /b %errorlevel%\r
142 \r
143 call :msg "compressed file"\r
144 echo "test" > test\r
145 compact /C test > nul\r
146 call :do_test\r
147 if %errorlevel% neq 0 exit /b %errorlevel%\r
148 \r
149 call :msg "compressed directory"\r
150 md subdir\r
151 compact /C subdir > nul\r
152 call :do_test\r
153 if %errorlevel% neq 0 exit /b %errorlevel%\r
154 \r
155 call :msg "compressed directory with files in it"\r
156 md subdir\r
157 compact /C subdir > nul\r
158 echo 1 > subdir\file1\r
159 echo 2 > subdir\file2\r
160 echo 1 > subdir\file1\r
161 md subdir\subsubdir\r
162 mklink /h subdir\hardlink subdir\file1 > nul\r
163 mklink /j subdir\j subdir\subsubdir > nul\r
164 call :do_test\r
165 if %errorlevel% neq 0 exit /b %errorlevel%\r
166 \r
167 call :msg "compressed directory with some uncompressed files in it"\r
168 md subdir\r
169 compact /C subdir > nul\r
170 echo 1 > subdir\1\r
171 echo 5 > subdir\5\r
172 compact /U subdir\1 > nul\r
173 call :do_test\r
174 if %errorlevel% neq 0 exit /b %errorlevel%\r
175 \r
176 call :msg "file with alternate data stream"\r
177 echo 1 > file\r
178 echo 5 > file:ads\r
179 call :do_test\r
180 if %errorlevel% neq 0 exit /b %errorlevel%\r
181 \r
182 call :msg "file with multiple alternate data streams"\r
183 echo 1 > file\r
184 echo a > file:a\r
185 echo aa > file:aa\r
186 echo aaa > file:aaa\r
187 echo aaaa > file:aaaa\r
188 call :do_test\r
189 if %errorlevel% neq 0 exit /b %errorlevel%\r
190 \r
191 call :msg "file with multiple alternate data streams, with hard link"\r
192 echo 1 > file\r
193 echo a > file:a\r
194 echo aa > file:aa\r
195 echo aaa > file:aaa\r
196 echo aaaa > file:aaaa\r
197 mklink /h link file > nul\r
198 call :do_test\r
199 if %errorlevel% neq 0 exit /b %errorlevel%\r
200 \r
201 call :msg "files with multiple alternate data streams, some identical, with hard link"\r
202 echo 1 > file\r
203 echo 5 > file2\r
204 echo 1 > file:1\r
205 echo 1 > file:1again\r
206 echo aaa > file:aaa\r
207 echo 5 > file:5\r
208 mklink /h link file > nul\r
209 echo aaa > file2:aaa\r
210 call :do_test\r
211 if %errorlevel% neq 0 exit /b %errorlevel%\r
212 \r
213 call :msg "root directory with alternate data stream"\r
214 echo 1 > ..\in.dir:ads\r
215 call :do_test\r
216 if %errorlevel% neq 0 exit /b %errorlevel%\r
217 \r
218 call :msg "subdirectory with alternate data streams"\r
219 md subdir\r
220 echo 1 > subdir:1\r
221 echo 2 > subdir:2\r
222 echo 2 > subdir:2again\r
223 call :do_test\r
224 if %errorlevel% neq 0 exit /b %errorlevel%\r
225 \r
226 call :msg "subdirectories and files with alternate data streams"\r
227 md subdir\r
228 echo hello > hello\r
229 echo hello > subdir:hello\r
230 echo hello > subdir:helloagain\r
231 echo hello > helloagain\r
232 mklink /h hellolink hello > nul\r
233 echo 1 > helloagain:1\r
234 echo 8 > helloagain:8\r
235 echo 1 > 1\r
236 type nul > helloagain:dummy\r
237 call :do_test\r
238 if %errorlevel% neq 0 exit /b %errorlevel%\r
239 \r
240 call :msg "symbolic link and hard link, to file with alternate data streams"\r
241 echo 1 > 1\r
242 echo test > .\1:test\r
243 mklink symlink 1 > nul\r
244 mklink /h hardlink 1 > nul\r
245 call :do_test\r
246 if %errorlevel% neq 0 exit /b %errorlevel%\r
247 \r
248 call :msg "compressed file with alternate data streams"\r
249 echo 1 > 1\r
250 echo 1 > .\1:1\r
251 echo 2 > .\1:2\r
252 compact /C 1 > nul\r
253 call :do_test\r
254 if %errorlevel% neq 0 exit /b %errorlevel%\r
255 \r
256 call :msg "hidden file"\r
257 echo 1 > hidden\r
258 attrib +h hidden\r
259 call :do_test\r
260 if %errorlevel% neq 0 exit /b %errorlevel%\r
261 \r
262 call :msg "hidden directory"\r
263 md subdir\r
264 attrib +h subdir\r
265 call :do_test\r
266 if %errorlevel% neq 0 exit /b %errorlevel%\r
267 \r
268 call :msg "encrypted file"\r
269 echo "hello" > encrypted\r
270 cipher /e encrypted > nul\r
271 call :do_test\r
272 if %errorlevel% neq 0 exit /b %errorlevel%\r
273 \r
274 call :msg "identical encrypted files"\r
275 echo "hello" > encrypted1\r
276 echo "hello" > encrypted2\r
277 cipher /e encrypted1 > nul\r
278 cipher /e encrypted2 > nul\r
279 call :do_test\r
280 if %errorlevel% neq 0 exit /b %errorlevel%\r
281 \r
282 call :msg "encrypted directory"\r
283 md subdir\r
284 cipher /e subdir > nul\r
285 call :do_test\r
286 if %errorlevel% neq 0 exit /b %errorlevel%\r
287 \r
288 call :msg "encrypted directory with encrypted file in it"\r
289 md subdir\r
290 echo 1 > subdir\1\r
291 cipher /e subdir > nul\r
292 cipher /e subdir\1 > nul\r
293 call :do_test\r
294 if %errorlevel% neq 0 exit /b %errorlevel%\r
295 \r
296 call :msg "encrypted directory with unencrypted file in it"\r
297 md subdir\r
298 echo 1 > subdir\1\r
299 cipher /e subdir > nul\r
300 cipher /d subdir\1 > nul\r
301 call :do_test\r
302 if %errorlevel% neq 0 exit /b %errorlevel%\r
303 \r
304 call :msg "hardlinked, encrypted file with alternate data streams"\r
305 echo hello > file\r
306 echo hello > file:ads\r
307 cipher /e file > nul\r
308 mklink /h link file > nul\r
309 call :do_test\r
310 if %errorlevel% neq 0 exit /b %errorlevel%\r
311 \r
312 :rpfix_tests\r
313 \r
314 echo Testing rpfix junction\r
315 md subdir\r
316 echo 1 > subdir\file\r
317 mklink /j junction subdir > nul\r
318 cd ..\r
319 wimlib-imagex capture in.dir test.wim > nul\r
320 rd /s /q in.dir\r
321 wimlib-imagex apply test.wim out.dir > nul\r
322 echo 1 > tmp1\r
323 type out.dir\junction\file > tmp2\r
324 fc tmp1 tmp2 > nul\r
325 if %errorlevel% neq 0 exit /b %errorlevel%\r
326 rd /s /q out.dir\r
327 del tmp1 tmp2\r
328 md in.dir\r
329 cd in.dir\r
330 \r
331 echo Testing rpfix exclude\r
332 mklink otherlink c:\some\other\directory > nul\r
333 cd ..\r
334 wimlib-imagex capture in.dir test.wim > nul\r
335 wimlib-imagex apply test.wim out.dir > nul\r
336 rd out.dir\r
337 if %errorlevel% neq 0 exit /b %errorlevel%\r
338 rd /s /q in.dir\r
339 md in.dir\r
340 cd in.dir\r
341 \r
342 echo Testing rpfix relative\r
343 echo 1 > file\r
344 mklink relink file > nul\r
345 call :do_test\r
346 if %errorlevel% neq 0 exit /b %errorlevel%\r
347 \r
348 REM\r
349 REM END OF TESTS\r
350 REM\r
351 \r
352 cd ..\r
353 del test.wim\r
354 rd /s /q in.dir\r
355 exit /b 0\r
356 \r
357 :do_test\r
358 cd ..\r
359 wimlib-imagex capture in.dir test.wim --norpfix > NUL\r
360 if %errorlevel% neq 0 exit /b %errorlevel%\r
361 wimlib-imagex apply test.wim out.dir > NUL\r
362 if %errorlevel% neq 0 exit /b %errorlevel%\r
363 win32-tree-cmp in.dir out.dir\r
364 if %errorlevel% neq 0 (\r
365         echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
366         echo            TEST FAILED!!!!!!!\r
367         echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
368         exit /b %errorlevel%\r
369 )\r
370 \r
371 REM Fun fact:  There are bugs in Microsoft's imagex.exe that make it fail some\r
372 REM of our tests.\r
373 REM\r
374 REM rd /S /Q out.dir\r
375 REM md out.dir\r
376 REM imagex /capture in.dir test.wim "test" /norpfix > nul\r
377 REM if %errorlevel% neq 0 exit /b %errorlevel%\r
378 REM imagex /apply test.wim 1 out.dir > nul\r
379 REM if %errorlevel% neq 0 exit /b %errorlevel%\r
380 REM win32-tree-cmp in.dir out.dir\r
381 REM if %errorlevel% neq 0 (\r
382         REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
383         REM echo            TEST FAILED!!!!!!! ^(imagex^)\r
384         REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
385         REM exit /b %errorlevel%\r
386 REM )\r
387 \r
388 rd /S /Q in.dir out.dir\r
389 md in.dir\r
390 cd in.dir\r
391 goto :eof\r
392 \r
393 :msg\r
394 echo Testing capture and apply of %~1\r
395 goto :eof\r