3 # Test `wimupdate' and `wimextract'.
7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
9 . "$srcdir/tests/test_utils.sh"
11 TEST_SUBDIR=tmpdir_test-imagex-update_and_extract
18 echo "--------------------------------------------------------------------"
20 echo "--------------------------------------------------------------------"
24 msg "TEST FAILED (See above)"
32 wimcapture in.dir test.wim --compress=none
37 wimapply test.wim out.dir
41 cp $srcdir/src/add_image.c file
45 msg "Testing deleting nonexisting file from WIM image, without --force (errors expected)"
46 ! wimupdate test.wim << EOF
50 msg "Testing deleting nonexisting file from WIM image, with --force"
51 ! wimupdate test.wim << EOF
52 delete --force /nonexistent
55 msg "Testing deleting root directory from WIM image, without --recursive (errors expected)"
56 ! wimupdate test.wim << EOF
60 msg "Testing deleting root directory from WIM image, with --recursive"
61 wimupdate test.wim << EOF
65 msg "Testing update command with invalid option (errors expected)"
66 ! wimupdate test.wim << EOF
67 delete --invalid-option --recursive /
70 msg "Testing update command with too many arguments (errors expected)"
71 ! wimupdate test.wim << EOF
72 delete --recursive --force / /anotherdir
75 msg "Testing invalid update command (errors expected)"
76 ! wimupdate test.wim << EOF
80 msg "Testing update command file with comments and empty lines"
81 wimupdate test.wim << EOF
92 msg "Testing update with --rebuild"
93 wimupdate --rebuild test.wim < /dev/null
95 for flag in "" "--rebuild"; do
96 msg "Testing adding file to WIM image with flag \"$flag\""
97 wimupdate test.wim $flag << EOF
101 ../tree-cmp file out.dir/file
103 msg "Testing deleting file from WIM image"
104 wimupdate test.wim << EOF
108 [ ! -e out.dir/file ]
111 msg "Testing renaming file in WIM image"
112 wimupdate test.wim << EOF
115 wimupdate test.wim << EOF
119 ../tree-cmp file out.dir/newname
120 [ ! -e out.dir/file ]
123 msg "Testing UTF-16LE-NOBOM command update file"
124 echo -ne 'a\0d\0d\0 \0f\0i\0l\0e\0 \0/\0f\0i\0l\0e\0\n\0' \
127 ../tree-cmp file out.dir/file
130 msg "Testing UTF-16LE-BOM command update file"
131 echo -ne '\xff\xfea\0d\0d\0 \0f\0i\0l\0e\0 \0/\0f\0i\0l\0e\0\n\0' \
134 ../tree-cmp file out.dir/file
137 msg "Testing UTF-8-BOM command update file"
138 echo -ne '\xef\xbb\xbfadd file /file' | wimupdate test.wim
140 ../tree-cmp file out.dir/file
143 msg "Testing adding, then renaming file in WIM image in one command"
144 wimupdate test.wim << EOF
146 rename /file /newname
149 ../tree-cmp file out.dir/newname
150 [ ! -e out.dir/file ]
152 msg "Testing adding additional file to WIM image"
154 wimupdate test.wim << EOF
157 wimupdate test.wim << EOF
164 msg "Testing extracting file from WIM image"
167 wimextract test.wim 1 /file --dest-dir=out.dir
168 ../tree-cmp file out.dir/file
171 msg "Testing extracting file from WIM image to stdout"
174 wimlib_imagex extract test.wim 1 /file --to-stdout > out.dir/file
175 cmp file out.dir/file
178 msg "Testing adding directories and files to WIM image"
192 wimupdate test.wim 1 << EOF
194 add dir2 /prefix/dir2
198 wimextract test.wim 1 dir1 --dest-dir=out.dir
199 wimextract test.wim 1 prefix/dir2 --dest-dir=out.dir
200 ../tree-cmp dir1 out.dir/dir1
201 ../tree-cmp dir2 out.dir/dir2
203 msg "Testing adding files to WIM image"
206 wimappend in.dir test.wim "2"
207 cp $srcdir/src/*.c in.dir
208 wimupdate test.wim 2 << EOF
212 cp -a file in.dir/file
214 wimapply test.wim 2 out.dir
215 touch -r in.dir out.dir
216 ../tree-cmp in.dir out.dir
218 msg "Testing adding file with space in it"
219 echo hello > "Some File"
221 wimupdate test.wim 1 << EOF
222 add "Some File" 'Some Destination'
225 wimapply test.wim 1 out.dir
226 ../tree-cmp "Some File" out.dir/"Some Destination"
228 msg "Testing path list extract"
231 echo otherfile > otherfile
233 wimupdate test.wim 1 << EOF
236 add otherfile /otherfile
238 cat > pathlist << EOF
243 wimextract test.wim 1 @pathlist --dest-dir=out.dir
244 ../tree-cmp hello1 out.dir/hello1
245 ../tree-cmp hello2 out.dir/hello2
246 [ ! -e out.dir/otherfile ]
248 msg "Testing path list extract (stdin)"
250 wimextract test.wim 1 @- --dest-dir=out.dir << EOF
254 ../tree-cmp hello1 out.dir/hello1
255 ../tree-cmp hello2 out.dir/hello2
256 [ ! -e out.dir/otherfile ]
258 msg "Testing path list extract (w/ wildcard)"
259 cat > pathlist << EOF
263 wimextract test.wim 1 @pathlist --dest-dir=out.dir
264 ../tree-cmp hello1 out.dir/hello1
265 ../tree-cmp hello2 out.dir/hello2
266 [ ! -e out.dir/otherfile ]
268 cat > pathlist << EOF
272 msg "Testing path list extract (no wildcard, no match; error expected)"
273 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
275 cat > pathlist << EOF
279 msg "Testing path list extract (wildcard, no match; error expected)"
280 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir
281 msg "Testing path list extract (wildcard, no match, nullglob; no error expected)"
282 wimextract test.wim 1 @pathlist --dest-dir=out.dir --nullglob
284 msg "Testing path list extract (w/ wildcard)"
285 cat > pathlist << EOF
289 wimextract test.wim 1 @pathlist --dest-dir=out.dir
290 ../tree-cmp hello1 out.dir/hello1
291 ../tree-cmp hello2 out.dir/hello2
292 ../tree-cmp otherfile out.dir/otherfile
294 msg "Testing path list extract (subdir files)"
296 wimupdate test.wim 1 << EOF
297 add hello1 /topdir/subdir1/hello1
298 add hello2 /topdir/subdir2/hello2
299 add hello1 /topdir/hello1
301 cat > pathlist << EOF
302 /topdir/subdir?/hello*
305 wimextract test.wim 1 @pathlist --dest-dir=out.dir
306 ../tree-cmp hello1 out.dir/topdir/subdir1/hello1
307 ../tree-cmp hello2 out.dir/topdir/subdir2/hello2
308 [ ! -e out.dir/topdir/hello1 ]
310 msg "Testing case insensitivity"
312 wimupdate test.wim 1 << EOF
315 cat > pathlist << EOF
319 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir
320 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
321 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir
322 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
323 ../tree-cmp hello1 out.dir/HELLO1
324 [ ! -e out.dir/topdir/hello1 ]
327 echo "**********************************************************"
328 echo " wimupdate/extract tests passed "
329 echo "**********************************************************"