7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
9 . "$srcdir/tests/tests-common.sh"
11 if [ ! -r /dev/fuse ]; then
12 echo "WARNING: /dev/fuse is not readable."
13 echo "Skipping WIM mounting checks"
19 ../imagex $@ > /dev/null
28 echo "imagex mountrw $@"
29 ../imagex mountrw --debug "$@" &> mount.log &
30 while ! mountpoint $2 >& /dev/null; do
37 fusermount -u tmp &> /dev/null || true
38 fusermount -u tmp.mnt &> /dev/null || true
39 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
40 tmp.apply mount.log test.tar wimlib-staging*
44 cp $srcdir/src/*.c $srcdir/src/*.h dir
46 echo 'hello' > dir/subdir/hello
47 echo 'hello' > dir/subdir/hello2
48 ln dir/subdir/hello dir/subdir/hellolink
49 echo -n > dir/subdir/empty_file
50 ln -s hello dir/subdir/rel_symlink
53 echo 'testing' > dir2/file
54 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
55 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
56 imagex capture tmp.empty empty.wim
60 echo "****************************************************************"
62 while [ $# -gt 0 ]; do
66 echo "****************************************************************"
75 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
76 echo "Using flag $flag"
77 echo "Testing mounting WIM read-only"
78 if ! imagex capture dir dir.wim $flag; then
79 error "Failed to capture WIM"
82 if ! imagex mount dir.wim dir tmp; then
83 error "Failed to mount test WIM read-only" \
84 "Please read any error messages above before reporting this test failure."\
85 "Perhaps you don't have FUSE installed, or the FUSE kernel module isn't" \
86 "loaded, or you aren't a member of the FUSE group?"
88 echo "Testing extracting file from mounted read-only WIM"
89 if ! cp tmp/lz77.c lz77.c; then
90 error "Failed to extract file from read-only mounted WIM"
92 if ! diff -q dir/lz77.c lz77.c; then
93 error "Extracted file does not match copy in mounted WIM"
95 if ! diff -q tmp/lz77.c dir/lz77.c; then
96 error "Extractef file does not match original"
99 echo "Testing modifying mounted read-only WIM (should fail)"
100 if rm tmp/lz77.c; then
101 error "Removing file from read-only mounted WIM didn't fail"
103 if touch tmp/newfile; then
104 error "Creating file on read-only mounted WIM didn't fail"
106 if echo 3 > tmp/lz77.c; then
107 error "Writing to file on read-only mounted WIM didn't fail"
109 echo "Testing diff of mounted read-only WIM with original directory"
110 if ! diff -q -r tmp dir; then
111 error "Recursive diff of read-only mounted WIM with original directory failed"
113 echo "Testing unmount of read-only filesystem"
114 if ! imagex unmount tmp; then
115 error "Unmounting read-only WIM failed"
117 echo "Testing unmount of read-only filesystem with --commit given"
118 if ! imagex mount dir.wim dir tmp; then
119 error "Failed to re-mount WIM read-only"
121 if ! imagex unmount tmp --commit; then
122 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
128 echo "Testing mounting WIM read-write"
129 if ! imagex capture dir dir.wim; then
130 error "Failed to capture WIM"
133 if ! imagex mountrw dir.wim dir tmp; then
134 error "Failed to mount test WIM read-write"
136 echo "Testing unmounting WIM unmodified"
137 if ! imagex unmount tmp; then
138 error "Failed to unmount test WIM unmodified"
140 echo "Testing unmounting WIM unmodified with --commit and --check"
141 if ! imagex mountrw dir.wim dir tmp; then
142 error "Failed to re-mount test WIM read-write"
144 if ! imagex unmount tmp --commit --check; then
145 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
147 echo "Testing removing file from mounted WIM"
148 if ! imagex mountrw dir.wim dir tmp; then
149 error "Failed to re-mount test WIM read-write"
151 if ! rm tmp/lz77.c; then
152 error "Failed to remove file from read-write mounted WIM"
154 if test -f tmp/lz77.c; then
155 error "Removing file from read-write mounted WIM failed"
157 echo "Testing making directory in mounted WIM"
158 if ! mkdir tmp/newdir; then
159 error "Failed to make directory in read-write mounted WIM"
161 if ! test -d tmp/newdir; then
162 error "Making directory in read-write mounted WIM failed"
164 echo "Testing making new empty file in mounted WIM"
165 if ! touch tmp/newdir/empty_file; then
166 error "Could not create new empty file in read-write mounted WIM"
168 if ! test -f tmp/newdir/empty_file; then
169 error "New empty file not created correctly in read-write mounted WIM"
171 if ! test "`get_file_size tmp/newdir/empty_file`" = 0; then
172 error "New empty file in read-write mounted WIM is not empty"
174 echo "Testing making new non-empty file in mounted WIM"
175 if ! dd if=/dev/zero of=tmp/newdir/zeroes1 bs=1 count=4096; then
176 error "Failed to make new non-empty file in mounted WIM"
178 if ! dd if=/dev/zero of=tmp/newdir/zeroes2 bs=4096 count=1; then
179 error "Failed to make new non-empty file in mounted WIM"
181 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
182 error "New files in mounted WIM not made correctly"
184 echo "Unmounting WIM with changes committed and --check"
185 if ! imagex unmount tmp --commit --check; then
186 error "Failed to unmount read-write mounted WIM"
188 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
189 error "Integrity information was not included"
192 if ! imagex apply dir.wim tmp; then
193 error "Failed to apply WIM we had previously mounted read-write"
195 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
196 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
198 if test `get_file_size tmp/newdir/empty_file` != 0; then
199 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
201 if test `get_file_size tmp/newdir/zeroes1` != 4096; then
202 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
205 # Now do some tests using tar.
207 if ! ./tree-cmp $1 $2; then
208 if [ -x /usr/bin/tree ]; then
209 echo "Dumping tree of applied image"
210 tree $2 --inodes -F -s --noreport
211 error 'Information was lost or corrupted while capturing
212 and then applying a directory tree'
218 echo "--------------------------------------------------------------------"
219 echo "Testing making $1 on read-write mounted WIM"
220 echo "--------------------------------------------------------------------"
225 # Create tree, tar it up, and untar it on an empty WIM image mounted
228 cp empty.wim test.wim
232 if [ -x /usr/bin/tree ]; then
233 tree . --inodes -F -s --noreport
238 if ! imagex_mountrw test.wim tmp.mnt; then
239 error "Failed to mount WIM read-write"
243 if ! tar xf ../test.tar --no-same-owner; then
244 error "Failed to untar archive on read-write mounted WIM"
248 # Diff the original tree with the mounted WIM
249 do_tree_cmp tmp.orig tmp.mnt
251 # Clear the mounted WIM and do it again! (We need to test deleting
252 # stuff as well as creating stuff.)
253 if ! rm -rf tmp.mnt/*; then
254 error "Failed to clear mounted WIM"
258 if ! tar xf ../test.tar --no-same-owner; then
259 error "Failed to untar archive on read-write mounted WIM"
263 # Diff the original tree with the mounted WIM
264 do_tree_cmp tmp.orig tmp.mnt
266 # Unmount the WIM, apply it, and diff the original tree with the applied
268 if ! imagex unmount tmp.mnt --commit; then
269 error "Failed to unmount WIM mounted read-write"
271 if ! imagex apply test.wim tmp.apply; then
272 error "Failed to apply WIM we previously had mounted read-write"
274 do_tree_cmp tmp.orig tmp.apply
275 rm -rf tmp.orig/* tmp.apply/*
278 . $srcdir/tests/common_tests.sh
282 echo "**********************************************************"
283 echo " WIM mount tests passed "
284 echo "**********************************************************"