3 # Test `imagex update' and `imagex extract'.
7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
9 . "$srcdir/tests/tests-common.sh"
11 TEST_SUBDIR=tmpdir_test-imagex-update_and_extract
18 echo "--------------------------------------------------------------------"
20 echo "--------------------------------------------------------------------"
24 msg "TEST FAILED (See above)"
32 imagex capture in.dir test.wim
37 imagex apply 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 ! imagex update test.wim << EOF
50 msg "Testing deleting nonexisting file from WIM image, with --force"
51 ! imagex update test.wim << EOF
52 delete --force /nonexistent
55 msg "Testing deleting root directory from WIM image, without --recursive (errors expected)"
56 ! imagex update test.wim << EOF
60 msg "Testing deleting root directory from WIM image, with --recursive"
61 imagex update test.wim << EOF
65 msg "Testing update command with invalid option (errors expected)"
66 ! imagex update test.wim << EOF
67 delete --invalid-option --recursive /
70 msg "Testing update command with too many arguments (errors expected)"
71 ! imagex update test.wim << EOF
72 delete --recursive --force / /anotherdir
75 msg "Testing invalid update command (errors expected)"
76 ! imagex update test.wim << EOF
80 msg "Testing update command file with comments and empty lines"
81 imagex update test.wim << EOF
92 msg "Testing update with --rebuild"
93 imagex update --rebuild test.wim < /dev/null
95 for flag in "" "--rebuild"; do
96 msg "Testing adding file to WIM image with flag \"$flag\""
97 imagex update test.wim $flag << EOF
101 ../tree-cmp file out.dir/file
103 msg "Testing deleting file from WIM image"
104 imagex update test.wim << EOF
108 [ ! -e out.dir/file ]
111 msg "Testing renaming file in WIM image"
112 imagex update test.wim << EOF
115 imagex update test.wim << EOF
119 ../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
122 msg "Testing adding, then renaming file in WIM image in one command"
123 imagex update test.wim << EOF
125 rename /file /newname
128 ../tree-cmp file out.dir/newname && [ ! -e out.dir/file ]
130 msg "Testing adding additional file to WIM image"
132 imagex update test.wim << EOF
135 imagex update test.wim << EOF
139 [ -e out.dir/1 ] && [ -e out.dir/file ]
141 msg "Testing extracting file from WIM image"
142 rm -rf out.dir && mkdir out.dir
143 imagex extract test.wim 1 /file --dest-dir=out.dir
144 ../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
146 msg "Testing extracting file from WIM image to stdout"
147 rm -rf out.dir && mkdir out.dir
148 ../../imagex extract test.wim 1 /file --to-stdout > out.dir/file
149 ../tree-cmp file out.dir/file && [ ! -e out.dir/1 ]
151 msg "Testing adding directories and files to WIM image"
152 rm -rf dir1 && mkdir dir1
153 rm -rf dir2 && mkdir dir2
163 imagex update test.wim 1 << EOF
165 add dir2 /prefix/dir2
167 rm -rf out.dir && mkdir out.dir
168 imagex extract test.wim 1 dir1 --dest-dir=out.dir
169 imagex extract test.wim 1 prefix/dir2 --dest-dir=out.dir
170 ../tree-cmp dir1 out.dir/dir1
171 ../tree-cmp dir2 out.dir/dir2
173 msg "Testing adding files to WIM image"
174 rm -rf in.dir && mkdir in.dir
175 imagex append in.dir test.wim "2"
176 cp $srcdir/src/*.c in.dir
177 imagex update test.wim 2 << EOF
183 imagex apply test.wim 2 out.dir
184 ../tree-cmp in.dir out.dir
186 msg "Testing adding file with space in it"
187 echo hello > "Some File"
189 imagex update test.wim 1 << EOF
190 add "Some File" 'Some Destination'
193 imagex apply test.wim 1 out.dir
194 ../tree-cmp "Some File" out.dir/"Some Destination"
197 echo "**********************************************************"
198 echo " imagex update/extract tests passed "
199 echo "**********************************************************"