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 call :msg "empty directory"
\r
25 if %errorlevel% neq 0 exit /b %errorlevel%
\r
27 call :msg "single file"
\r
30 if %errorlevel% neq 0 exit /b %errorlevel%
\r
32 call :msg "different files"
\r
34 echo 2 > anotherfile
\r
36 if %errorlevel% neq 0 exit /b %errorlevel%
\r
38 call :msg "identical files"
\r
40 echo 1 > identicalfile
\r
42 if %errorlevel% neq 0 exit /b %errorlevel%
\r
44 call :msg "hard linked file"
\r
46 mklink /h link file > nul
\r
48 if %errorlevel% neq 0 exit /b %errorlevel%
\r
50 call :msg "hard linked file, with other identical files"
\r
52 mklink /h link file > nul
\r
53 echo 1 > identicalfile
\r
55 if %errorlevel% neq 0 exit /b %errorlevel%
\r
57 call :msg "empty file"
\r
58 type nul > emptyfile
\r
60 if %errorlevel% neq 0 exit /b %errorlevel%
\r
62 call :msg "various hard linked, identical, different, and empty files"
\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
72 mklink /h 1filelink 1file > nul
\r
74 if %errorlevel% neq 0 exit /b %errorlevel%
\r
76 call :msg "multiple subdirectories, some empty, some not"
\r
82 mklink /h link subdir1\1 > nul
\r
83 md subdir2\subdir2subdir
\r
84 type nul > subdir2\emptyfile
\r
86 if %errorlevel% neq 0 exit /b %errorlevel%
\r
88 call :msg "relative symlink"
\r
89 mklink relink dest > nul
\r
91 if %errorlevel% neq 0 exit /b %errorlevel%
\r
93 call :msg "absolute symlink, with drive letter"
\r
94 mklink abslink C:\absolute\target > nul
\r
96 if %errorlevel% neq 0 exit /b %errorlevel%
\r
98 call :msg "absolute symlink, without drive letter"
\r
99 mklink abslink \absolute\target > nul
\r
101 if %errorlevel% neq 0 exit /b %errorlevel%
\r
103 call :msg "relative symlink, with file target"
\r
105 mklink relink 1 > nul
\r
107 if %errorlevel% neq 0 exit /b %errorlevel%
\r
109 call :msg "relative symlink, with directory target"
\r
111 mklink reldlink subdir > nul
\r
113 if %errorlevel% neq 0 exit /b %errorlevel%
\r
115 call :msg "junction"
\r
117 mklink /j junction subdir > nul
\r
119 if %errorlevel% neq 0 exit /b %errorlevel%
\r
121 call :msg "symlinks, junctions, files, subdirectories, etc."
\r
123 mklink relink 1 > nul
\r
124 mklink rellinklink relink > nul
\r
125 mklink /j junction . > nul
\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
132 type nul > emptyfile
\r
133 type nul > subdir2\emptyfile
\r
137 echo "hello world!!!!" > subdir2\otherfile
\r
139 if %errorlevel% neq 0 exit /b %errorlevel%
\r
141 call :msg "compressed file"
\r
143 compact /C test > nul
\r
145 if %errorlevel% neq 0 exit /b %errorlevel%
\r
147 call :msg "compressed directory"
\r
149 compact /C subdir > nul
\r
151 if %errorlevel% neq 0 exit /b %errorlevel%
\r
153 call :msg "compressed directory with files in it"
\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
163 if %errorlevel% neq 0 exit /b %errorlevel%
\r
165 call :msg "compressed directory with some uncompressed files in it"
\r
167 compact /C subdir > nul
\r
170 compact /U subdir\1 > nul
\r
172 if %errorlevel% neq 0 exit /b %errorlevel%
\r
174 call :msg "file with alternate data stream"
\r
178 if %errorlevel% neq 0 exit /b %errorlevel%
\r
180 call :msg "file with multiple alternate data streams"
\r
184 echo aaa > file:aaa
\r
185 echo aaaa > file:aaaa
\r
187 if %errorlevel% neq 0 exit /b %errorlevel%
\r
189 call :msg "file with multiple alternate data streams, with hard link"
\r
193 echo aaa > file:aaa
\r
194 echo aaaa > file:aaaa
\r
195 mklink /h link file > nul
\r
197 if %errorlevel% neq 0 exit /b %errorlevel%
\r
199 call :msg "files with multiple alternate data streams, some identical, with hard link"
\r
203 echo 1 > file:1again
\r
204 echo aaa > file:aaa
\r
206 mklink /h link file > nul
\r
207 echo aaa > file2:aaa
\r
209 if %errorlevel% neq 0 exit /b %errorlevel%
\r
211 call :msg "root directory with alternate data stream"
\r
212 echo 1 > ..\in.dir:ads
\r
214 if %errorlevel% neq 0 exit /b %errorlevel%
\r
216 call :msg "subdirectory with alternate data streams"
\r
220 echo 2 > subdir:2again
\r
222 if %errorlevel% neq 0 exit /b %errorlevel%
\r
224 call :msg "subdirectories and files with alternate data streams"
\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
234 type nul > helloagain:dummy
\r
236 if %errorlevel% neq 0 exit /b %errorlevel%
\r
238 call :msg "symbolic link and hard link, to file with alternate data streams"
\r
240 echo test > .\1:test
\r
241 mklink symlink 1 > nul
\r
242 mklink /h hardlink 1 > nul
\r
244 if %errorlevel% neq 0 exit /b %errorlevel%
\r
246 call :msg "compressed file with alternate data streams"
\r
252 if %errorlevel% neq 0 exit /b %errorlevel%
\r
254 call :msg "hidden file"
\r
258 if %errorlevel% neq 0 exit /b %errorlevel%
\r
260 call :msg "hidden directory"
\r
264 if %errorlevel% neq 0 exit /b %errorlevel%
\r
266 call :msg "encrypted file"
\r
267 echo "hello" > encrypted
\r
268 cipher /e encrypted > nul
\r
270 if %errorlevel% neq 0 exit /b %errorlevel%
\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
278 if %errorlevel% neq 0 exit /b %errorlevel%
\r
280 call :msg "encrypted directory"
\r
282 cipher /e subdir > nul
\r
284 if %errorlevel% neq 0 exit /b %errorlevel%
\r
286 call :msg "encrypted directory with encrypted file in it"
\r
289 cipher /e subdir > nul
\r
290 cipher /e subdir\1 > nul
\r
292 if %errorlevel% neq 0 exit /b %errorlevel%
\r
294 call :msg "encrypted directory with unencrypted file in it"
\r
297 cipher /e subdir > nul
\r
298 cipher /d subdir\1 > nul
\r
300 if %errorlevel% neq 0 exit /b %errorlevel%
\r
302 call :msg "hardlinked, encrypted file with alternate data streams"
\r
304 echo hello > file:ads
\r
305 cipher /e file > nul
\r
306 mklink /h link file > nul
\r
308 if %errorlevel% neq 0 exit /b %errorlevel%
\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
330 REM Fun fact: There are bugs in Microsoft's imagex.exe that make it fail some
\r
333 REM rd /S /Q 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
347 rd /S /Q in.dir out.dir
\r
353 echo Testing capture and apply of %~1
\r