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 adding, then renaming file in WIM image in one command"
124 wimupdate test.wim << EOF
126 rename /file /newname
129 ../tree-cmp file out.dir/newname
130 [ ! -e out.dir/file ]
132 msg "Testing adding additional file to WIM image"
134 wimupdate test.wim << EOF
137 wimupdate test.wim << EOF
144 msg "Testing extracting file from WIM image"
147 wimextract test.wim 1 /file --dest-dir=out.dir
148 ../tree-cmp file out.dir/file
151 msg "Testing extracting file from WIM image to stdout"
154 wimlib_imagex extract test.wim 1 /file --to-stdout > out.dir/file
155 cmp file out.dir/file
158 msg "Testing adding directories and files to WIM image"
172 wimupdate test.wim 1 << EOF
174 add dir2 /prefix/dir2
178 wimextract test.wim 1 dir1 --dest-dir=out.dir
179 wimextract test.wim 1 prefix/dir2 --dest-dir=out.dir
180 ../tree-cmp dir1 out.dir/dir1
181 ../tree-cmp dir2 out.dir/dir2
183 msg "Testing adding files to WIM image"
186 wimappend in.dir test.wim "2"
187 cp $srcdir/src/*.c in.dir
188 wimupdate test.wim 2 << EOF
192 cp -a file in.dir/file
194 wimapply test.wim 2 out.dir
195 touch -r in.dir out.dir
196 ../tree-cmp in.dir out.dir
198 msg "Testing adding file with space in it"
199 echo hello > "Some File"
201 wimupdate test.wim 1 << EOF
202 add "Some File" 'Some Destination'
205 wimapply test.wim 1 out.dir
206 ../tree-cmp "Some File" out.dir/"Some Destination"
208 msg "Testing path list extract"
211 echo otherfile > otherfile
213 wimupdate test.wim 1 << EOF
216 add otherfile /otherfile
218 cat > pathlist << EOF
223 wimextract test.wim 1 @pathlist --dest-dir=out.dir
224 ../tree-cmp hello1 out.dir/hello1
225 ../tree-cmp hello2 out.dir/hello2
226 [ ! -e out.dir/otherfile ]
228 msg "Testing path list extract (stdin)"
230 wimextract test.wim 1 @- --dest-dir=out.dir << EOF
234 ../tree-cmp hello1 out.dir/hello1
235 ../tree-cmp hello2 out.dir/hello2
236 [ ! -e out.dir/otherfile ]
238 msg "Testing path list extract (w/ wildcard)"
239 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 cat > pathlist << EOF
252 msg "Testing path list extract (no wildcard, no match; error expected)"
253 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
255 cat > pathlist << EOF
259 msg "Testing path list extract (wildcard, no match; error expected)"
260 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir
261 msg "Testing path list extract (wildcard, no match, nullglob; no error expected)"
262 wimextract test.wim 1 @pathlist --dest-dir=out.dir --nullglob
264 msg "Testing path list extract (w/ wildcard)"
265 cat > pathlist << EOF
269 wimextract test.wim 1 @pathlist --dest-dir=out.dir
270 ../tree-cmp hello1 out.dir/hello1
271 ../tree-cmp hello2 out.dir/hello2
272 ../tree-cmp otherfile out.dir/otherfile
274 msg "Testing path list extract (subdir files)"
276 wimupdate test.wim 1 << EOF
277 add hello1 /topdir/subdir1/hello1
278 add hello2 /topdir/subdir2/hello2
279 add hello1 /topdir/hello1
281 cat > pathlist << EOF
282 /topdir/subdir?/hello*
285 wimextract test.wim 1 @pathlist --dest-dir=out.dir
286 ../tree-cmp hello1 out.dir/topdir/subdir1/hello1
287 ../tree-cmp hello2 out.dir/topdir/subdir2/hello2
288 [ ! -e out.dir/topdir/hello1 ]
290 msg "Testing case insensitivity"
292 wimupdate test.wim 1 << EOF
295 cat > pathlist << EOF
299 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir
300 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
301 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir
302 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
303 ../tree-cmp hello1 out.dir/HELLO1
304 [ ! -e out.dir/topdir/hello1 ]
307 echo "**********************************************************"
308 echo " wimupdate/extract tests passed "
309 echo "**********************************************************"