7 srcdir=`realpath $srcdir`
12 ../imagex $@ > /dev/null
21 echo "imagex mountrw $@"
22 ../imagex mountrw --debug "$@" &> mount.log &
23 while ! mountpoint $2 >& /dev/null; do
30 fusermount -u tmp &> /dev/null || true
31 fusermount -u tmp.mnt &> /dev/null || true
32 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
33 tmp.apply mount.log test.tar wimlib-staging*
37 cp $srcdir/src/*.c $srcdir/src/*.h dir
39 echo 'hello' > dir/subdir/hello
40 echo 'hello' > dir/subdir/hello2
41 ln dir/subdir/hello dir/subdir/hellolink
42 echo -n > dir/subdir/empty_file
43 ln -s hello dir/subdir/rel_symlink
46 echo 'testing' > dir2/file
47 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
48 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
49 imagex capture tmp.empty empty.wim
53 echo "**********************************************"
56 echo "**********************************************"
65 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
66 echo "Using flag $flag"
67 echo "Testing mounting WIM read-only"
68 if ! imagex capture dir dir.wim $flag; then
69 error "Failed to capture WIM"
72 if ! imagex mount dir.wim dir tmp; then
73 error "Failde to mount test WIM read-only"
75 echo "Testing extracting file from mounted read-only WIM"
76 if ! cp tmp/lz.c lz.c; then
77 error "Failed to extract file from read-only mounted WIM"
79 if ! diff -q dir/lz.c lz.c; then
80 error "Extracted file does not match copy in mounted WIM"
82 if ! diff -q tmp/lz.c dir/lz.c; then
83 error "Extractef file does not match original"
86 echo "Testing modifying mounted read-only WIM (should fail)"
88 error "Removing file from read-only mounted WIM didn't fail"
90 if touch tmp/newfile; then
91 error "Creating file on read-only mounted WIM didn't fail"
93 if echo 3 > tmp/lz.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 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; then
102 error "Unmounting read-only WIM failed"
104 echo "Testing unmount of read-only filesystem with --commit given"
105 if ! imagex mount dir.wim dir tmp; then
106 error "Failed to re-mount WIM read-only"
108 if ! imagex unmount tmp --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 ! imagex capture dir dir.wim; then
117 error "Failed to capture WIM"
120 if ! imagex mountrw dir.wim dir tmp; then
121 error "Failed to mount test WIM read-write"
123 echo "Testing unmounting WIM unmodified"
124 if ! imagex unmount tmp; then
125 error "Failed to unmount test WIM unmodified"
127 echo "Testing unmounting WIM unmodified with --commit and --check"
128 if ! imagex mountrw dir.wim dir tmp; then
129 error "Failed to re-mount test WIM read-write"
131 if ! imagex unmount tmp --commit --check; then
132 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
134 echo "Testing removing file from mounted WIM"
135 if ! imagex mountrw dir.wim dir tmp; then
136 error "Failed to re-mount test WIM read-write"
138 if ! rm tmp/lz.c; then
139 error "Failed to remove file from read-write mounted WIM"
141 if test -f tmp/lz.c; then
142 error "Removing file from read-write mounted WIM failed"
144 echo "Testing making directory in mounted WIM"
145 if ! mkdir tmp/newdir; then
146 error "Failed to make directory in read-write mounted WIM"
148 if ! test -d tmp/newdir; then
149 error "Making directory in read-write mounted WIM failed"
151 echo "Testing making new empty file in mounted WIM"
152 if ! touch tmp/newdir/empty_file; then
153 error "Could not create new empty file in read-write mounted WIM"
155 if ! test -f tmp/newdir/empty_file; then
156 error "New empty file not created correctly in read-write mounted WIM"
158 if ! test "`stat -c %s tmp/newdir/empty_file`" = 0; then
159 error "New empty file in read-write mounted WIM is not empty"
161 echo "Testing making new non-empty file in mounted WIM"
162 if ! dd if=/dev/zero of=tmp/newdir/zeroes1 bs=1 count=4096; then
163 error "Failed to make new non-empty file in mounted WIM"
165 if ! dd if=/dev/zero of=tmp/newdir/zeroes2 bs=4096 count=1; then
166 error "Failed to make new non-empty file in mounted WIM"
168 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
169 error "New files in mounted WIM not made correctly"
171 echo "Unmounting WIM with changes committed and --check"
172 if ! imagex unmount tmp --commit --check; then
173 error "Failed to unmount read-write mounted WIM"
175 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
176 error "Integrity information was not included"
179 if ! imagex apply dir.wim tmp; then
180 error "Failed to apply WIM we had previously mounted read-write"
182 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
183 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
185 if test `stat -c %s tmp/newdir/empty_file` != 0; then
186 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
188 if test `stat -c %s tmp/newdir/zeroes1` != 4096; then
189 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
192 # Now do some tests using tar.
194 if ! ./tree-cmp $1 $2; then
195 if [ -x /usr/bin/tree ]; then
196 echo "Dumping tree of applied image"
197 tree $2 --inodes -F -s --noreport
198 error 'Information was lost or corrupted while capturing
199 and then applying a directory tree'
205 echo "--------------------------------------------------------------------"
206 echo "Testing making $1 on read-write mounted WIM"
207 echo "--------------------------------------------------------------------"
212 # Create tree, tar it up, and untar it on an empty WIM image mounted
215 cp empty.wim test.wim
219 if [ -x /usr/bin/tree ]; then
220 tree . --inodes -F -s --noreport
225 if ! imagex_mountrw test.wim tmp.mnt; then
226 error "Failed to mount WIM read-write"
230 if ! tar xf ../test.tar; then
231 error "Failed to untar archive on read-write mounted WIM"
235 # Diff the original tree with the mounted WIM
236 do_tree_cmp tmp.orig tmp.mnt
238 # Clear the mounted WIM and do it again! (We need to test deleting
239 # stuff as well as creating stuff.)
240 if ! rm -rf tmp.mnt/*; then
241 error "Failed to clear mounted WIM"
245 if ! tar xf ../test.tar; then
246 error "Failed to untar archive on read-write mounted WIM"
250 # Diff the original tree with the mounted WIM
251 do_tree_cmp tmp.orig tmp.mnt
253 # Unmount the WIM, apply it, and diff the original tree with the applied
255 if ! imagex unmount tmp.mnt --commit; then
256 error "Failed to unmount WIM mounted read-write"
258 if ! imagex apply test.wim tmp.apply; then
259 error "Failed to apply WIM we previously had mounted read-write"
261 do_tree_cmp tmp.orig tmp.apply
262 rm -rf tmp.orig/* tmp.apply/*
265 . $srcdir/tests/common_tests.sh
269 echo "**********************************************************"
270 echo " WIM mount tests passed "
271 echo "**********************************************************"