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 callable
\r
10 REM (on PATH or in same directory).
\r
12 setlocal EnableDelayedExpansion
\r
14 if exist in.dir rd /S /Q in.dir
\r
15 if exist out.dir rd /S /Q out.dir
\r
23 REM goto :rpfix_tests
\r
25 call :msg "empty directory"
\r
27 if %errorlevel% neq 0 exit /b %errorlevel%
\r
29 call :msg "single file"
\r
32 if %errorlevel% neq 0 exit /b %errorlevel%
\r
34 call :msg "different files"
\r
36 echo 2 > anotherfile
\r
38 if %errorlevel% neq 0 exit /b %errorlevel%
\r
40 call :msg "identical files"
\r
42 echo 1 > identicalfile
\r
44 if %errorlevel% neq 0 exit /b %errorlevel%
\r
46 call :msg "hard linked file"
\r
48 mklink /h link file > nul
\r
50 if %errorlevel% neq 0 exit /b %errorlevel%
\r
52 call :msg "hard linked file, with other identical files"
\r
54 mklink /h link file > nul
\r
55 echo 1 > identicalfile
\r
57 if %errorlevel% neq 0 exit /b %errorlevel%
\r
59 call :msg "empty file"
\r
60 type nul > emptyfile
\r
62 if %errorlevel% neq 0 exit /b %errorlevel%
\r
64 call :msg "various hard linked, identical, different, and empty files"
\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
74 mklink /h 1filelink 1file > nul
\r
76 if %errorlevel% neq 0 exit /b %errorlevel%
\r
78 call :msg "multiple subdirectories, some empty, some not"
\r
84 mklink /h link subdir1\1 > nul
\r
85 md subdir2\subdir2subdir
\r
86 type nul > subdir2\emptyfile
\r
88 if %errorlevel% neq 0 exit /b %errorlevel%
\r
90 call :msg "relative symlink"
\r
91 mklink relink dest > nul
\r
93 if %errorlevel% neq 0 exit /b %errorlevel%
\r
95 call :msg "absolute symlink, with drive letter"
\r
96 mklink abslink C:\absolute\target > nul
\r
98 if %errorlevel% neq 0 exit /b %errorlevel%
\r
100 call :msg "absolute symlink, without drive letter"
\r
101 mklink abslink \absolute\target > nul
\r
103 if %errorlevel% neq 0 exit /b %errorlevel%
\r
105 call :msg "relative symlink, with file target"
\r
107 mklink relink 1 > nul
\r
109 if %errorlevel% neq 0 exit /b %errorlevel%
\r
111 call :msg "relative symlink, with directory target"
\r
113 mklink reldlink subdir > nul
\r
115 if %errorlevel% neq 0 exit /b %errorlevel%
\r
117 call :msg "junction"
\r
119 mklink /j junction subdir > nul
\r
121 if %errorlevel% neq 0 exit /b %errorlevel%
\r
123 call :msg "symlinks, junctions, files, subdirectories, etc."
\r
125 mklink relink 1 > nul
\r
126 mklink rellinklink relink > nul
\r
127 mklink /j junction . > nul
\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
134 type nul > emptyfile
\r
135 type nul > subdir2\emptyfile
\r
139 echo "hello world!!!!" > subdir2\otherfile
\r
141 if %errorlevel% neq 0 exit /b %errorlevel%
\r
143 call :msg "compressed file"
\r
145 compact /C test > nul
\r
147 if %errorlevel% neq 0 exit /b %errorlevel%
\r
149 call :msg "compressed directory"
\r
151 compact /C subdir > nul
\r
153 if %errorlevel% neq 0 exit /b %errorlevel%
\r
155 call :msg "compressed directory with files in it"
\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
165 if %errorlevel% neq 0 exit /b %errorlevel%
\r
167 call :msg "compressed directory with some uncompressed files in it"
\r
169 compact /C subdir > nul
\r
172 compact /U subdir\1 > nul
\r
174 if %errorlevel% neq 0 exit /b %errorlevel%
\r
176 call :msg "file with alternate data stream"
\r
180 if %errorlevel% neq 0 exit /b %errorlevel%
\r
182 call :msg "file with multiple alternate data streams"
\r
186 echo aaa > file:aaa
\r
187 echo aaaa > file:aaaa
\r
189 if %errorlevel% neq 0 exit /b %errorlevel%
\r
191 call :msg "file with multiple alternate data streams, with hard link"
\r
195 echo aaa > file:aaa
\r
196 echo aaaa > file:aaaa
\r
197 mklink /h link file > nul
\r
199 if %errorlevel% neq 0 exit /b %errorlevel%
\r
201 call :msg "files with multiple alternate data streams, some identical, with hard link"
\r
205 echo 1 > file:1again
\r
206 echo aaa > file:aaa
\r
208 mklink /h link file > nul
\r
209 echo aaa > file2:aaa
\r
211 if %errorlevel% neq 0 exit /b %errorlevel%
\r
213 call :msg "root directory with alternate data stream"
\r
214 echo 1 > ..\in.dir:ads
\r
216 if %errorlevel% neq 0 exit /b %errorlevel%
\r
218 call :msg "subdirectory with alternate data streams"
\r
222 echo 2 > subdir:2again
\r
224 if %errorlevel% neq 0 exit /b %errorlevel%
\r
226 call :msg "subdirectories and files with alternate data streams"
\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
236 type nul > helloagain:dummy
\r
238 if %errorlevel% neq 0 exit /b %errorlevel%
\r
240 call :msg "symbolic link and hard link, to file with alternate data streams"
\r
242 echo test > .\1:test
\r
243 mklink symlink 1 > nul
\r
244 mklink /h hardlink 1 > nul
\r
246 if %errorlevel% neq 0 exit /b %errorlevel%
\r
248 call :msg "compressed file with alternate data streams"
\r
254 if %errorlevel% neq 0 exit /b %errorlevel%
\r
256 call :msg "hidden file"
\r
260 if %errorlevel% neq 0 exit /b %errorlevel%
\r
262 call :msg "hidden directory"
\r
266 if %errorlevel% neq 0 exit /b %errorlevel%
\r
268 call :msg "encrypted file"
\r
269 echo "hello" > encrypted
\r
270 cipher /e encrypted > nul
\r
272 if %errorlevel% neq 0 exit /b %errorlevel%
\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
280 if %errorlevel% neq 0 exit /b %errorlevel%
\r
282 call :msg "encrypted directory"
\r
284 cipher /e subdir > nul
\r
286 if %errorlevel% neq 0 exit /b %errorlevel%
\r
288 call :msg "encrypted directory with encrypted file in it"
\r
291 cipher /e subdir > nul
\r
292 cipher /e subdir\1 > nul
\r
294 if %errorlevel% neq 0 exit /b %errorlevel%
\r
296 call :msg "encrypted directory with unencrypted file in it"
\r
299 cipher /e subdir > nul
\r
300 cipher /d subdir\1 > nul
\r
302 if %errorlevel% neq 0 exit /b %errorlevel%
\r
304 call :msg "hardlinked, encrypted file with alternate data streams"
\r
306 echo hello > file:ads
\r
307 cipher /e file > nul
\r
308 mklink /h link file > nul
\r
310 if %errorlevel% neq 0 exit /b %errorlevel%
\r
314 echo Testing rpfix junction
\r
316 echo 1 > subdir\file
\r
317 mklink /j junction subdir > nul
\r
319 wimlib-imagex capture in.dir test.wim > nul
\r
321 wimlib-imagex apply test.wim out.dir > nul
\r
323 type out.dir\junction\file > tmp2
\r
325 if %errorlevel% neq 0 exit /b %errorlevel%
\r
331 echo Testing rpfix exclude
\r
332 mklink otherlink c:\some\other\directory > nul
\r
334 wimlib-imagex capture in.dir test.wim > nul
\r
335 wimlib-imagex apply test.wim out.dir > nul
\r
337 if %errorlevel% neq 0 exit /b %errorlevel%
\r
342 echo Testing rpfix relative
\r
344 mklink relink file > nul
\r
346 if %errorlevel% neq 0 exit /b %errorlevel%
\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
371 REM Fun fact: There are bugs in Microsoft's imagex.exe that make it fail some
\r
374 REM rd /S /Q 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
388 rd /S /Q in.dir out.dir
\r
394 echo Testing capture and apply of %~1
\r