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