7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
10 if [ ! -r /dev/fuse ]; then
11 echo "WARNING: /dev/fuse is not readable."
12 echo "Skipping WIM mounting checks"
18 ../imagex $@ > /dev/null
27 echo "imagex mountrw $@"
28 ../imagex mountrw --debug "$@" &> mount.log &
29 while ! mountpoint $2 >& /dev/null; do
36 fusermount -u tmp &> /dev/null || true
37 fusermount -u tmp.mnt &> /dev/null || true
38 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
39 tmp.apply mount.log test.tar wimlib-staging*
43 cp $srcdir/src/*.c $srcdir/src/*.h dir
45 echo 'hello' > dir/subdir/hello
46 echo 'hello' > dir/subdir/hello2
47 ln dir/subdir/hello dir/subdir/hellolink
48 echo -n > dir/subdir/empty_file
49 ln -s hello dir/subdir/rel_symlink
52 echo 'testing' > dir2/file
53 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
54 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
55 imagex capture tmp.empty empty.wim
59 echo "****************************************************************"
61 while [ $# -gt 0 ]; do
65 echo "****************************************************************"
74 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
75 echo "Using flag $flag"
76 echo "Testing mounting WIM read-only"
77 if ! imagex capture dir dir.wim $flag; then
78 error "Failed to capture WIM"
81 if ! imagex mount dir.wim dir tmp; then
82 error "Failed to mount test WIM read-only" \
83 "Please read any error messages above before reporting this test failure."\
84 "Perhaps you don't have FUSE installed, or the FUSE kernel module isn't" \
85 "loaded, or you aren't a member of the FUSE group?"
87 echo "Testing extracting file from mounted read-only WIM"
88 if ! cp tmp/lz.c lz.c; then
89 error "Failed to extract file from read-only mounted WIM"
91 if ! diff -q dir/lz.c lz.c; then
92 error "Extracted file does not match copy in mounted WIM"
94 if ! diff -q tmp/lz.c dir/lz.c; then
95 error "Extractef file does not match original"
98 echo "Testing modifying mounted read-only WIM (should fail)"
100 error "Removing file from read-only mounted WIM didn't fail"
102 if touch tmp/newfile; then
103 error "Creating file on read-only mounted WIM didn't fail"
105 if echo 3 > tmp/lz.c; then
106 error "Writing to file on read-only mounted WIM didn't fail"
108 echo "Testing diff of mounted read-only WIM with original directory"
109 if ! diff -q -r tmp dir; then
110 error "Recursive diff of read-only mounted WIM with original directory failed"
112 echo "Testing unmount of read-only filesystem"
113 if ! imagex unmount tmp; then
114 error "Unmounting read-only WIM failed"
116 echo "Testing unmount of read-only filesystem with --commit given"
117 if ! imagex mount dir.wim dir tmp; then
118 error "Failed to re-mount WIM read-only"
120 if ! imagex unmount tmp --commit; then
121 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
127 echo "Testing mounting WIM read-write"
128 if ! imagex capture dir dir.wim; then
129 error "Failed to capture WIM"
132 if ! imagex mountrw dir.wim dir tmp; then
133 error "Failed to mount test WIM read-write"
135 echo "Testing unmounting WIM unmodified"
136 if ! imagex unmount tmp; then
137 error "Failed to unmount test WIM unmodified"
139 echo "Testing unmounting WIM unmodified with --commit and --check"
140 if ! imagex mountrw dir.wim dir tmp; then
141 error "Failed to re-mount test WIM read-write"
143 if ! imagex unmount tmp --commit --check; then
144 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
146 echo "Testing removing file from mounted WIM"
147 if ! imagex mountrw dir.wim dir tmp; then
148 error "Failed to re-mount test WIM read-write"
150 if ! rm tmp/lz.c; then
151 error "Failed to remove file from read-write mounted WIM"
153 if test -f tmp/lz.c; then
154 error "Removing file from read-write mounted WIM failed"
156 echo "Testing making directory in mounted WIM"
157 if ! mkdir tmp/newdir; then
158 error "Failed to make directory in read-write mounted WIM"
160 if ! test -d tmp/newdir; then
161 error "Making directory in read-write mounted WIM failed"
163 echo "Testing making new empty file in mounted WIM"
164 if ! touch tmp/newdir/empty_file; then
165 error "Could not create new empty file in read-write mounted WIM"
167 if ! test -f tmp/newdir/empty_file; then
168 error "New empty file not created correctly in read-write mounted WIM"
170 if ! test "`stat -c %s tmp/newdir/empty_file`" = 0; then
171 error "New empty file in read-write mounted WIM is not empty"
173 echo "Testing making new non-empty file in mounted WIM"
174 if ! dd if=/dev/zero of=tmp/newdir/zeroes1 bs=1 count=4096; then
175 error "Failed to make new non-empty file in mounted WIM"
177 if ! dd if=/dev/zero of=tmp/newdir/zeroes2 bs=4096 count=1; then
178 error "Failed to make new non-empty file in mounted WIM"
180 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
181 error "New files in mounted WIM not made correctly"
183 echo "Unmounting WIM with changes committed and --check"
184 if ! imagex unmount tmp --commit --check; then
185 error "Failed to unmount read-write mounted WIM"
187 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
188 error "Integrity information was not included"
191 if ! imagex apply dir.wim tmp; then
192 error "Failed to apply WIM we had previously mounted read-write"
194 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
195 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
197 if test `stat -c %s tmp/newdir/empty_file` != 0; then
198 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
200 if test `stat -c %s tmp/newdir/zeroes1` != 4096; then
201 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
204 # Now do some tests using tar.
206 if ! ./tree-cmp $1 $2; then
207 if [ -x /usr/bin/tree ]; then
208 echo "Dumping tree of applied image"
209 tree $2 --inodes -F -s --noreport
210 error 'Information was lost or corrupted while capturing
211 and then applying a directory tree'
217 echo "--------------------------------------------------------------------"
218 echo "Testing making $1 on read-write mounted WIM"
219 echo "--------------------------------------------------------------------"
224 # Create tree, tar it up, and untar it on an empty WIM image mounted
227 cp empty.wim test.wim
231 if [ -x /usr/bin/tree ]; then
232 tree . --inodes -F -s --noreport
237 if ! imagex_mountrw test.wim tmp.mnt; then
238 error "Failed to mount WIM read-write"
242 if ! tar xf ../test.tar --no-same-owner; then
243 error "Failed to untar archive on read-write mounted WIM"
247 # Diff the original tree with the mounted WIM
248 do_tree_cmp tmp.orig tmp.mnt
250 # Clear the mounted WIM and do it again! (We need to test deleting
251 # stuff as well as creating stuff.)
252 if ! rm -rf tmp.mnt/*; then
253 error "Failed to clear mounted WIM"
257 if ! tar xf ../test.tar --no-same-owner; then
258 error "Failed to untar archive on read-write mounted WIM"
262 # Diff the original tree with the mounted WIM
263 do_tree_cmp tmp.orig tmp.mnt
265 # Unmount the WIM, apply it, and diff the original tree with the applied
267 if ! imagex unmount tmp.mnt --commit; then
268 error "Failed to unmount WIM mounted read-write"
270 if ! imagex apply test.wim tmp.apply; then
271 error "Failed to apply WIM we previously had mounted read-write"
273 do_tree_cmp tmp.orig tmp.apply
274 rm -rf tmp.orig/* tmp.apply/*
277 . $srcdir/tests/common_tests.sh
281 echo "**********************************************************"
282 echo " WIM mount tests passed "
283 echo "**********************************************************"