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 (w/ wildcard)"
229 cat > pathlist << EOF
233 wimextract test.wim 1 @pathlist --dest-dir=out.dir
234 ../tree-cmp hello1 out.dir/hello1
235 ../tree-cmp hello2 out.dir/hello2
236 [ ! -e out.dir/otherfile ]
238 cat > pathlist << EOF
242 msg "Testing path list extract (no wildcard, no match; error expected)"
243 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
245 cat > pathlist << EOF
249 msg "Testing path list extract (wildcard, no match; error expected)"
250 ! wimextract test.wim 1 @pathlist --dest-dir=out.dir
251 msg "Testing path list extract (wildcard, no match, nullglob; no error expected)"
252 wimextract test.wim 1 @pathlist --dest-dir=out.dir --nullglob
254 msg "Testing path list extract (w/ wildcard)"
255 cat > pathlist << EOF
259 wimextract test.wim 1 @pathlist --dest-dir=out.dir
260 ../tree-cmp hello1 out.dir/hello1
261 ../tree-cmp hello2 out.dir/hello2
262 ../tree-cmp otherfile out.dir/otherfile
264 msg "Testing path list extract (subdir files)"
266 wimupdate test.wim 1 << EOF
267 add hello1 /topdir/subdir1/hello1
268 add hello2 /topdir/subdir2/hello2
269 add hello1 /topdir/hello1
271 cat > pathlist << EOF
272 /topdir/subdir?/hello*
275 wimextract test.wim 1 @pathlist --dest-dir=out.dir
276 ../tree-cmp hello1 out.dir/topdir/subdir1/hello1
277 ../tree-cmp hello2 out.dir/topdir/subdir2/hello2
278 [ ! -e out.dir/topdir/hello1 ]
280 msg "Testing case insensitivity"
282 wimupdate test.wim 1 << EOF
285 cat > pathlist << EOF
289 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir
290 ! WIMLIB_IMAGEX_IGNORE_CASE=0 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
291 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir
292 WIMLIB_IMAGEX_IGNORE_CASE=1 wimextract test.wim 1 @pathlist --dest-dir=out.dir --no-wildcards
293 ../tree-cmp hello1 out.dir/HELLO1
294 [ ! -e out.dir/topdir/hello1 ]
297 echo "**********************************************************"
298 echo " wimupdate/extract tests passed "
299 echo "**********************************************************"