4 REM win32-test-imagex-capture_and_apply.bat
\r
6 REM Run some tests on the Windows version of wimlib-imagex.
\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
\r
10 REM executable using the paths set below.
\r
12 setlocal EnableDelayedExpansion
\r
13 set WIN32_TREE_CMP=win32-tree-cmp
\r
14 set WIMLIB_IMAGEX=wimlib-imagex
\r
16 if exist in.dir rd /S /Q in.dir
\r
17 if exist out.dir rd /S /Q out.dir
\r
25 REM goto :rpfix_tests
\r
27 call :msg "empty directory"
\r
29 if %errorlevel% neq 0 exit /b %errorlevel%
\r
31 call :msg "single file"
\r
34 if %errorlevel% neq 0 exit /b %errorlevel%
\r
36 call :msg "different files"
\r
38 echo 2 > anotherfile
\r
40 if %errorlevel% neq 0 exit /b %errorlevel%
\r
42 call :msg "identical files"
\r
44 echo 1 > identicalfile
\r
46 if %errorlevel% neq 0 exit /b %errorlevel%
\r
48 call :msg "hard linked file"
\r
50 mklink /h link file > nul
\r
52 if %errorlevel% neq 0 exit /b %errorlevel%
\r
54 call :msg "hard linked file, with other identical files"
\r
56 mklink /h link file > nul
\r
57 echo 1 > identicalfile
\r
59 if %errorlevel% neq 0 exit /b %errorlevel%
\r
61 call :msg "empty file"
\r
62 type nul > emptyfile
\r
64 if %errorlevel% neq 0 exit /b %errorlevel%
\r
66 call :msg "various hard linked, identical, different, and empty files"
\r
69 mklink /h link1 file > nul
\r
70 mklink /h link2 file > nul
\r
71 type nul > emptyfile
\r
72 type nul > emptyfile2
\r
73 mklink /h emptyfilelink emptyfile > nul
\r
74 echo 5 > identicalfile
\r
76 mklink /h 1filelink 1file > nul
\r
78 if %errorlevel% neq 0 exit /b %errorlevel%
\r
80 call :msg "multiple subdirectories, some empty, some not"
\r
86 mklink /h link subdir1\1 > nul
\r
87 md subdir2\subdir2subdir
\r
88 type nul > subdir2\emptyfile
\r
90 if %errorlevel% neq 0 exit /b %errorlevel%
\r
92 call :msg "relative symlink"
\r
93 mklink relink dest > nul
\r
95 if %errorlevel% neq 0 exit /b %errorlevel%
\r
97 call :msg "absolute symlink, with drive letter"
\r
98 mklink abslink C:\absolute\target > nul
\r
100 if %errorlevel% neq 0 exit /b %errorlevel%
\r
102 call :msg "absolute symlink, without drive letter"
\r
103 mklink abslink \absolute\target > nul
\r
105 if %errorlevel% neq 0 exit /b %errorlevel%
\r
107 call :msg "relative symlink, with file target"
\r
109 mklink relink 1 > nul
\r
111 if %errorlevel% neq 0 exit /b %errorlevel%
\r
113 call :msg "relative symlink, with directory target"
\r
115 mklink reldlink subdir > nul
\r
117 if %errorlevel% neq 0 exit /b %errorlevel%
\r
119 call :msg "junction"
\r
121 mklink /j junction subdir > nul
\r
123 if %errorlevel% neq 0 exit /b %errorlevel%
\r
125 call :msg "symlinks, junctions, files, subdirectories, etc."
\r
127 mklink relink 1 > nul
\r
128 mklink rellinklink relink > nul
\r
129 mklink /j junction . > nul
\r
131 mklink /h subdir\hardlink 1 > nul
\r
132 echo "hello world!!!!" > hello
\r
133 mklink subdir\hello hello > nul
\r
134 mklink abslink C:\Users > nul
\r
136 type nul > emptyfile
\r
137 type nul > subdir2\emptyfile
\r
141 echo "hello world!!!!" > subdir2\otherfile
\r
143 if %errorlevel% neq 0 exit /b %errorlevel%
\r
145 call :msg "compressed file"
\r
147 compact /C test > nul
\r
149 if %errorlevel% neq 0 exit /b %errorlevel%
\r
151 call :msg "compressed directory"
\r
153 compact /C subdir > nul
\r
155 if %errorlevel% neq 0 exit /b %errorlevel%
\r
157 call :msg "compressed directory with files in it"
\r
159 compact /C subdir > nul
\r
160 echo 1 > subdir\file1
\r
161 echo 2 > subdir\file2
\r
162 echo 1 > subdir\file1
\r
163 md subdir\subsubdir
\r
164 mklink /h subdir\hardlink subdir\file1 > nul
\r
165 mklink /j subdir\j subdir\subsubdir > nul
\r
167 if %errorlevel% neq 0 exit /b %errorlevel%
\r
169 call :msg "compressed directory with some uncompressed files in it"
\r
171 compact /C subdir > nul
\r
174 compact /U subdir\1 > nul
\r
176 if %errorlevel% neq 0 exit /b %errorlevel%
\r
178 call :msg "file with alternate data stream"
\r
182 if %errorlevel% neq 0 exit /b %errorlevel%
\r
184 call :msg "file with multiple alternate data streams"
\r
188 echo aaa > file:aaa
\r
189 echo aaaa > file:aaaa
\r
191 if %errorlevel% neq 0 exit /b %errorlevel%
\r
193 call :msg "file with multiple alternate data streams, with hard link"
\r
197 echo aaa > file:aaa
\r
198 echo aaaa > file:aaaa
\r
199 mklink /h link file > nul
\r
201 if %errorlevel% neq 0 exit /b %errorlevel%
\r
203 call :msg "files with multiple alternate data streams, some identical, with hard link"
\r
207 echo 1 > file:1again
\r
208 echo aaa > file:aaa
\r
210 mklink /h link file > nul
\r
211 echo aaa > file2:aaa
\r
213 if %errorlevel% neq 0 exit /b %errorlevel%
\r
215 call :msg "root directory with alternate data stream"
\r
216 echo 1 > ..\in.dir:ads
\r
218 if %errorlevel% neq 0 exit /b %errorlevel%
\r
220 call :msg "subdirectory with alternate data streams"
\r
224 echo 2 > subdir:2again
\r
226 if %errorlevel% neq 0 exit /b %errorlevel%
\r
228 call :msg "subdirectories and files with alternate data streams"
\r
231 echo hello > subdir:hello
\r
232 echo hello > subdir:helloagain
\r
233 echo hello > helloagain
\r
234 mklink /h hellolink hello > nul
\r
235 echo 1 > helloagain:1
\r
236 echo 8 > helloagain:8
\r
238 type nul > helloagain:dummy
\r
240 if %errorlevel% neq 0 exit /b %errorlevel%
\r
242 call :msg "symbolic link and hard link, to file with alternate data streams"
\r
244 echo test > .\1:test
\r
245 mklink symlink 1 > nul
\r
246 mklink /h hardlink 1 > nul
\r
248 if %errorlevel% neq 0 exit /b %errorlevel%
\r
250 call :msg "compressed file with alternate data streams"
\r
256 if %errorlevel% neq 0 exit /b %errorlevel%
\r
258 call :msg "hidden file"
\r
262 if %errorlevel% neq 0 exit /b %errorlevel%
\r
264 call :msg "hidden directory"
\r
268 if %errorlevel% neq 0 exit /b %errorlevel%
\r
270 call :msg "encrypted file"
\r
271 echo "hello" > encrypted
\r
272 cipher /e encrypted > nul
\r
274 if %errorlevel% neq 0 exit /b %errorlevel%
\r
276 call :msg "identical encrypted files"
\r
277 echo "hello" > encrypted1
\r
278 echo "hello" > encrypted2
\r
279 cipher /e encrypted1 > nul
\r
280 cipher /e encrypted2 > nul
\r
282 if %errorlevel% neq 0 exit /b %errorlevel%
\r
284 call :msg "encrypted directory"
\r
286 cipher /e subdir > nul
\r
288 if %errorlevel% neq 0 exit /b %errorlevel%
\r
290 call :msg "encrypted directory with encrypted file in it"
\r
293 cipher /e subdir > nul
\r
294 cipher /e subdir\1 > nul
\r
296 if %errorlevel% neq 0 exit /b %errorlevel%
\r
298 call :msg "encrypted directory with unencrypted file in it"
\r
301 cipher /e subdir > nul
\r
302 cipher /d subdir\1 > nul
\r
304 if %errorlevel% neq 0 exit /b %errorlevel%
\r
306 call :msg "hardlinked, encrypted file with alternate data streams"
\r
308 echo hello > file:ads
\r
309 cipher /e file > nul
\r
310 mklink /h link file > nul
\r
312 if %errorlevel% neq 0 exit /b %errorlevel%
\r
316 echo Testing rpfix junction
\r
318 echo 1 > subdir\file
\r
319 mklink /j junction subdir > nul
\r
321 %WIMLIB_IMAGEX% capture in.dir test.wim > nul
\r
323 %WIMLIB_IMAGEX% apply test.wim out.dir > nul
\r
325 type out.dir\junction\file > tmp2
\r
327 if %errorlevel% neq 0 exit /b %errorlevel%
\r
333 echo Testing rpfix exclude
\r
334 mklink otherlink c:\some\other\directory > nul
\r
336 %WIMLIB_IMAGEX% capture in.dir test.wim > nul
\r
337 %WIMLIB_IMAGEX% apply test.wim out.dir > nul
\r
339 if %errorlevel% neq 0 exit /b %errorlevel%
\r
344 echo Testing rpfix relative
\r
346 mklink relink file > nul
\r
348 %WIMLIB_IMAGEX% capture in.dir test.wim > nul
\r
349 %WIMLIB_IMAGEX% apply test.wim out.dir > nul
\r
350 fc in.dir\file out.dir\relink > nul
\r
351 if %errorlevel% neq 0 exit /b %errorlevel%
\r
352 rd /s /q in.dir out.dir
\r
367 %WIMLIB_IMAGEX% capture in.dir test.wim --norpfix > NUL
\r
368 if %errorlevel% neq 0 exit /b %errorlevel%
\r
369 %WIMLIB_IMAGEX% apply test.wim out.dir > NUL
\r
370 if %errorlevel% neq 0 exit /b %errorlevel%
\r
371 %WIN32_TREE_CMP% in.dir out.dir
\r
372 if %errorlevel% neq 0 (
\r
373 echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
374 echo TEST FAILED!!!!!!!
\r
375 echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
376 exit /b %errorlevel%
\r
379 REM Fun fact: There are bugs in Microsoft's imagex.exe that make it fail some
\r
382 REM rd /S /Q out.dir
\r
384 REM imagex /capture in.dir test.wim "test" /norpfix > nul
\r
385 REM if %errorlevel% neq 0 exit /b %errorlevel%
\r
386 REM imagex /apply test.wim 1 out.dir > nul
\r
387 REM if %errorlevel% neq 0 exit /b %errorlevel%
\r
388 REM %WIN32_TREE_CMP% in.dir out.dir
\r
389 REM if %errorlevel% neq 0 (
\r
390 REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
391 REM echo TEST FAILED!!!!!!! ^(imagex^)
\r
392 REM echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
393 REM exit /b %errorlevel%
\r
396 rd /S /Q in.dir out.dir
\r
402 echo Testing capture and apply of %~1
\r