7 srcdir="${srcdir:-.}/.."
8 srcdir="$(cd $srcdir; pwd)"
9 . "$srcdir/tests/tests-common.sh"
11 TEST_SUBDIR=tmpdir_test-imagex-mount
20 # Give the --lazy flag to work around a problem testing on Ubuntu and
21 # other OS's running Gnome, as they have a daemon
22 # "gvfs-gdu-volume-monitor" that apparently likes to randomly read
23 # filesystems that get mounted, thereby stopping them from being
25 wimunmount "$@" --lazy
29 fusermount -u $TEST_SUBDIR/tmp.mnt &> /dev/null || true
35 cp $srcdir/src/*.c dir
37 echo 'hello' > dir/subdir/hello
38 echo 'hello' > dir/subdir/hello2
39 ln dir/subdir/hello dir/subdir/hellolink
40 echo -n > dir/subdir/empty_file
41 ln -s hello dir/subdir/rel_symlink
44 echo 'testing' > dir2/file
45 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
46 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
47 wimcapture tmp.empty empty.wim --norpfix
50 if [ ! -r /dev/fuse ] || [ ! -w /dev/fuse ]; then
51 echo "WARNING: /dev/fuse is not readable and writable."
52 echo "Skipping WIM mounting checks"
63 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
64 echo "Using flag $flag"
65 echo "Testing mounting WIM read-only"
66 if ! wimcapture dir dir.wim $flag; then
67 error "Failed to capture WIM"
69 if ! wimmount dir.wim dir tmp.mnt; then
70 error "Failed to mount test WIM read-only. " \
71 "Please read any error messages above before reporting this test failure. "\
72 "Perhaps you don't have FUSE installed, or the FUSE kernel module isn't" \
73 "loaded, or you aren't a member of the FUSE group?"
75 echo "Testing extracting file from mounted read-only WIM"
76 if ! cp tmp.mnt/write.c write.c; then
77 error "Failed to extract file from read-only mounted WIM"
79 if ! diff -q dir/write.c write.c; then
80 error "Extracted file does not match copy in mounted WIM"
82 if ! diff -q tmp.mnt/write.c dir/write.c; then
83 error "Extractef file does not match original"
86 echo "Testing modifying mounted read-only WIM (should fail)"
87 if rm tmp.mnt/write.c; then
88 error "Removing file from read-only mounted WIM didn't fail"
90 if touch tmp.mnt/newfile; then
91 error "Creating file on read-only mounted WIM didn't fail"
93 if echo 3 > tmp.mnt/write.c; then
94 error "Writing to file on read-only mounted WIM didn't fail"
96 echo "Testing diff of mounted read-only WIM with original directory"
97 if ! diff -q -r tmp.mnt dir; then
98 error "Recursive diff of read-only mounted WIM with original directory failed"
100 echo "Testing unmount of read-only filesystem"
101 if ! imagex_unmount tmp.mnt; then
102 error "Unmounting read-only WIM failed"
104 echo "Testing unmount of read-only filesystem with --commit given"
105 if ! wimmount dir.wim dir tmp.mnt; then
106 error "Failed to re-mount WIM read-only"
108 if ! imagex_unmount tmp.mnt --commit; then
109 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
115 echo "Testing mounting WIM read-write"
116 if ! wimcapture dir dir.wim; then
117 error "Failed to capture WIM"
119 if ! wimmountrw dir.wim dir tmp.mnt; then
120 error "Failed to mount test WIM read-write"
122 echo "Testing unmounting WIM unmodified"
123 if ! imagex_unmount tmp.mnt; then
124 error "Failed to unmount test WIM unmodified"
126 echo "Testing unmounting WIM unmodified with --commit and --check"
127 if ! wimmountrw dir.wim dir tmp.mnt; then
128 error "Failed to re-mount test WIM read-write"
130 if ! imagex_unmount tmp.mnt --commit --check; then
131 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
133 echo "Testing removing file from mounted WIM"
134 if ! wimmountrw dir.wim dir tmp.mnt; then
135 error "Failed to re-mount test WIM read-write"
137 if ! rm tmp.mnt/write.c; then
138 error "Failed to remove file from read-write mounted WIM"
140 if test -f tmp.mnt/write.c; then
141 error "Removing file from read-write mounted WIM failed"
143 echo "Testing making directory in mounted WIM"
144 if ! mkdir tmp.mnt/newdir; then
145 error "Failed to make directory in read-write mounted WIM"
147 if ! test -d tmp.mnt/newdir; then
148 error "Making directory in read-write mounted WIM failed"
150 echo "Testing making new empty file in mounted WIM"
151 if ! touch tmp.mnt/newdir/empty_file; then
152 error "Could not create new empty file in read-write mounted WIM"
154 if ! test -f tmp.mnt/newdir/empty_file; then
155 error "New empty file not created correctly in read-write mounted WIM"
157 if ! test "`get_file_size tmp.mnt/newdir/empty_file`" = 0; then
158 error "New empty file in read-write mounted WIM is not empty"
160 echo "Testing making new non-empty file in mounted WIM"
161 if ! dd if=/dev/zero of=tmp.mnt/newdir/zeroes1 bs=1 count=4096; then
162 error "Failed to make new non-empty file in mounted WIM"
164 if ! dd if=/dev/zero of=tmp.mnt/newdir/zeroes2 bs=4096 count=1; then
165 error "Failed to make new non-empty file in mounted WIM"
167 if ! diff -q tmp.mnt/newdir/zeroes1 tmp.mnt/newdir/zeroes2; then
168 error "New files in mounted WIM not made correctly"
170 echo "Unmounting WIM with changes committed and --check"
171 if ! imagex_unmount tmp.mnt --commit --check; then
172 error "Failed to unmount read-write mounted WIM"
174 if ! wiminfo dir.wim | grep -q Integrity; then
175 error "Integrity information was not included"
177 if ! wimapply dir.wim tmp.apply; then
178 error "Failed to apply WIM we had previously mounted read-write"
180 if ! diff -q tmp.apply/newdir/zeroes1 tmp.apply/newdir/zeroes2; then
181 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
183 if test `get_file_size tmp.apply/newdir/empty_file` != 0; then
184 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
186 if test `get_file_size tmp.apply/newdir/zeroes1` != 4096; then
187 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
191 # Now do some tests using tar.
193 if ! ../tree-cmp $1 $2; then
194 if [ -x /usr/bin/tree ]; then
195 echo "Dumping tree of applied image"
196 tree $2 --inodes -F -s --noreport
197 error 'Information was lost or corrupted while capturing
198 and then applying a directory tree'
204 echo "--------------------------------------------------------------------"
205 echo "Testing making $1 on read-write mounted WIM"
206 echo "--------------------------------------------------------------------"
211 # Create tree, tar it up, and untar it on an empty WIM image mounted
214 cp empty.wim test.wim
218 if [ -x /usr/bin/tree ]; then
219 tree . --inodes -F -s --noreport
224 if ! wimmountrw test.wim tmp.mnt --unix-data; then
225 error "Failed to mount WIM read-write"
229 if ! tar xf ../test.tar; then
230 error "Failed to untar archive on read-write mounted WIM"
234 # Diff the original tree with the mounted WIM
235 do_tree_cmp tmp.orig tmp.mnt
237 # Clear the mounted WIM and do it again! (We need to test deleting
238 # stuff as well as creating stuff.)
239 if ! rm -rf tmp.mnt/*; then
240 error "Failed to clear mounted WIM"
244 if ! tar xf ../test.tar; then
245 error "Failed to untar archive on read-write mounted WIM"
249 # Diff the original tree with the mounted WIM
250 do_tree_cmp tmp.orig tmp.mnt
252 # Unmount the WIM, apply it, and diff the original tree with the applied
254 if ! imagex_unmount tmp.mnt --commit; then
255 error "Failed to unmount WIM mounted read-write"
257 if ! wimapply test.wim tmp.apply; then
258 error "Failed to apply WIM we previously had mounted read-write"
260 do_tree_cmp tmp.orig tmp.apply
261 rm -rf tmp.orig/* tmp.apply/*
264 . $srcdir/tests/common_tests.sh
267 echo "**********************************************************"
268 echo " WIM mount tests passed "
269 echo "**********************************************************"