9 if [ ! -r /dev/fuse ]; then
10 echo "WARNING: /dev/fuse is not readable."
11 echo "Skipping WIM mounting checks"
17 ../imagex $@ > /dev/null
26 echo "imagex mountrw $@"
27 ../imagex mountrw --debug "$@" &> mount.log &
28 while ! mountpoint $2 >& /dev/null; do
35 fusermount -u tmp &> /dev/null || true
36 fusermount -u tmp.mnt &> /dev/null || true
37 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
38 tmp.apply mount.log test.tar wimlib-staging*
42 cp $srcdir/src/*.c $srcdir/src/*.h dir
44 echo 'hello' > dir/subdir/hello
45 echo 'hello' > dir/subdir/hello2
46 ln dir/subdir/hello dir/subdir/hellolink
47 echo -n > dir/subdir/empty_file
48 ln -s hello dir/subdir/rel_symlink
51 echo 'testing' > dir2/file
52 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
53 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
54 imagex capture tmp.empty empty.wim
58 echo "****************************************************************"
60 while [ $# -gt 0 ]; do
64 echo "****************************************************************"
73 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
74 echo "Using flag $flag"
75 echo "Testing mounting WIM read-only"
76 if ! imagex capture dir dir.wim $flag; then
77 error "Failed to capture WIM"
80 if ! imagex mount dir.wim dir tmp; then
81 error "Failed to mount test WIM read-only" \
82 "Please read any error messages above before reporting this test failure."\
83 "Perhaps you don't have FUSE installed, or the FUSE kernel module isn't" \
84 "loaded, or you aren't a member of the FUSE group?"
86 echo "Testing extracting file from mounted read-only WIM"
87 if ! cp tmp/lz.c lz.c; then
88 error "Failed to extract file from read-only mounted WIM"
90 if ! diff -q dir/lz.c lz.c; then
91 error "Extracted file does not match copy in mounted WIM"
93 if ! diff -q tmp/lz.c dir/lz.c; then
94 error "Extractef file does not match original"
97 echo "Testing modifying mounted read-only WIM (should fail)"
99 error "Removing file from read-only mounted WIM didn't fail"
101 if touch tmp/newfile; then
102 error "Creating file on read-only mounted WIM didn't fail"
104 if echo 3 > tmp/lz.c; then
105 error "Writing to file on read-only mounted WIM didn't fail"
107 echo "Testing diff of mounted read-only WIM with original directory"
108 if ! diff -q -r tmp dir; then
109 error "Recursive diff of read-only mounted WIM with original directory failed"
111 echo "Testing unmount of read-only filesystem"
112 if ! imagex unmount tmp; then
113 error "Unmounting read-only WIM failed"
115 echo "Testing unmount of read-only filesystem with --commit given"
116 if ! imagex mount dir.wim dir tmp; then
117 error "Failed to re-mount WIM read-only"
119 if ! imagex unmount tmp --commit; then
120 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
126 echo "Testing mounting WIM read-write"
127 if ! imagex capture dir dir.wim; then
128 error "Failed to capture WIM"
131 if ! imagex mountrw dir.wim dir tmp; then
132 error "Failed to mount test WIM read-write"
134 echo "Testing unmounting WIM unmodified"
135 if ! imagex unmount tmp; then
136 error "Failed to unmount test WIM unmodified"
138 echo "Testing unmounting WIM unmodified with --commit and --check"
139 if ! imagex mountrw dir.wim dir tmp; then
140 error "Failed to re-mount test WIM read-write"
142 if ! imagex unmount tmp --commit --check; then
143 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
145 echo "Testing removing file from mounted WIM"
146 if ! imagex mountrw dir.wim dir tmp; then
147 error "Failed to re-mount test WIM read-write"
149 if ! rm tmp/lz.c; then
150 error "Failed to remove file from read-write mounted WIM"
152 if test -f tmp/lz.c; then
153 error "Removing file from read-write mounted WIM failed"
155 echo "Testing making directory in mounted WIM"
156 if ! mkdir tmp/newdir; then
157 error "Failed to make directory in read-write mounted WIM"
159 if ! test -d tmp/newdir; then
160 error "Making directory in read-write mounted WIM failed"
162 echo "Testing making new empty file in mounted WIM"
163 if ! touch tmp/newdir/empty_file; then
164 error "Could not create new empty file in read-write mounted WIM"
166 if ! test -f tmp/newdir/empty_file; then
167 error "New empty file not created correctly in read-write mounted WIM"
169 if ! test "`get_file_size tmp/newdir/empty_file`" = 0; then
170 error "New empty file in read-write mounted WIM is not empty"
172 echo "Testing making new non-empty file in mounted WIM"
173 if ! dd if=/dev/zero of=tmp/newdir/zeroes1 bs=1 count=4096; then
174 error "Failed to make new non-empty file in mounted WIM"
176 if ! dd if=/dev/zero of=tmp/newdir/zeroes2 bs=4096 count=1; then
177 error "Failed to make new non-empty file in mounted WIM"
179 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
180 error "New files in mounted WIM not made correctly"
182 echo "Unmounting WIM with changes committed and --check"
183 if ! imagex unmount tmp --commit --check; then
184 error "Failed to unmount read-write mounted WIM"
186 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
187 error "Integrity information was not included"
190 if ! imagex apply dir.wim tmp; then
191 error "Failed to apply WIM we had previously mounted read-write"
193 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
194 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
196 if test `get_file_size tmp/newdir/empty_file` != 0; then
197 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
199 if test `get_file_size tmp/newdir/zeroes1` != 4096; then
200 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
203 # Now do some tests using tar.
205 if ! ./tree-cmp $1 $2; then
206 if [ -x /usr/bin/tree ]; then
207 echo "Dumping tree of applied image"
208 tree $2 --inodes -F -s --noreport
209 error 'Information was lost or corrupted while capturing
210 and then applying a directory tree'
216 echo "--------------------------------------------------------------------"
217 echo "Testing making $1 on read-write mounted WIM"
218 echo "--------------------------------------------------------------------"
223 # Create tree, tar it up, and untar it on an empty WIM image mounted
226 cp empty.wim test.wim
230 if [ -x /usr/bin/tree ]; then
231 tree . --inodes -F -s --noreport
236 if ! imagex_mountrw test.wim tmp.mnt; then
237 error "Failed to mount WIM read-write"
241 if ! tar xf ../test.tar --no-same-owner; then
242 error "Failed to untar archive on read-write mounted WIM"
246 # Diff the original tree with the mounted WIM
247 do_tree_cmp tmp.orig tmp.mnt
249 # Clear the mounted WIM and do it again! (We need to test deleting
250 # stuff as well as creating stuff.)
251 if ! rm -rf tmp.mnt/*; then
252 error "Failed to clear mounted WIM"
256 if ! tar xf ../test.tar --no-same-owner; then
257 error "Failed to untar archive on read-write mounted WIM"
261 # Diff the original tree with the mounted WIM
262 do_tree_cmp tmp.orig tmp.mnt
264 # Unmount the WIM, apply it, and diff the original tree with the applied
266 if ! imagex unmount tmp.mnt --commit; then
267 error "Failed to unmount WIM mounted read-write"
269 if ! imagex apply test.wim tmp.apply; then
270 error "Failed to apply WIM we previously had mounted read-write"
272 do_tree_cmp tmp.orig tmp.apply
273 rm -rf tmp.orig/* tmp.apply/*
276 . $srcdir/tests/common_tests.sh
280 echo "**********************************************************"
281 echo " WIM mount tests passed "
282 echo "**********************************************************"