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 if mountpoint tmp &> /dev/null; then
31 fusermount -u tmp > /dev/null;
33 if mountpoint tmp.mnt &> /dev/null; then
34 fusermount -u tmp.mnt > /dev/null;
36 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
37 tmp.apply mount.log test.tar wimlib-staging*
41 cp $srcdir/src/*.c $srcdir/src/*.h dir
43 echo 'hello' > dir/subdir/hello
44 echo 'hello' > dir/subdir/hello2
45 ln dir/subdir/hello dir/subdir/hellolink
46 echo -n > dir/subdir/empty_file
47 ln -s hello dir/subdir/rel_symlink
50 echo 'testing' > dir2/file
51 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
52 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
53 imagex capture tmp.empty empty.wim
57 echo "**********************************************"
60 echo "**********************************************"
69 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
70 echo "Using flag $flag"
71 echo "Testing mounting WIM read-only"
72 if ! imagex capture dir dir.wim $flag; then
73 error "Failed to capture WIM"
76 if ! imagex mount dir.wim dir tmp; then
77 error "Failde to mount test WIM read-only"
79 echo "Testing extracting file from mounted read-only WIM"
80 if ! cp tmp/lz.c lz.c; then
81 error "Failed to extract file from read-only mounted WIM"
83 if ! diff -q dir/lz.c lz.c; then
84 error "Extracted file does not match copy in mounted WIM"
86 if ! diff -q tmp/lz.c dir/lz.c; then
87 error "Extractef file does not match original"
90 echo "Testing modifying mounted read-only WIM (should fail)"
92 error "Removing file from read-only mounted WIM didn't fail"
94 if touch tmp/newfile; then
95 error "Creating file on read-only mounted WIM didn't fail"
97 if echo 3 > tmp/lz.c; then
98 error "Writing to file on read-only mounted WIM didn't fail"
100 echo "Testing diff of mounted read-only WIM with original directory"
101 if ! diff -q -r tmp dir; then
102 error "Recursive diff of read-only mounted WIM with original directory failed"
104 echo "Testing unmount of read-only filesystem"
105 if ! imagex unmount tmp; then
106 error "Unmounting read-only WIM failed"
108 echo "Testing unmount of read-only filesystem with --commit given"
109 if ! imagex mount dir.wim dir tmp; then
110 error "Failed to re-mount WIM read-only"
112 if ! imagex unmount tmp --commit; then
113 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
119 echo "Testing mounting WIM read-write"
120 if ! imagex capture dir dir.wim; then
121 error "Failed to capture WIM"
124 if ! imagex mountrw dir.wim dir tmp; then
125 error "Failed to mount test WIM read-write"
127 echo "Testing unmounting WIM unmodified"
128 if ! imagex unmount tmp; then
129 error "Failed to unmount test WIM unmodified"
131 echo "Testing unmounting WIM unmodified with --commit and --check"
132 if ! imagex mountrw dir.wim dir tmp; then
133 error "Failed to re-mount test WIM read-write"
135 if ! imagex unmount tmp --commit --check; then
136 error "Failed to unmount read-write mounted WIM with changes commited (no changes made)"
138 echo "Testing removing file from mounted WIM"
139 if ! imagex mountrw dir.wim dir tmp; then
140 error "Failed to re-mount test WIM read-write"
142 if ! rm tmp/lz.c; then
143 error "Failed to remove file from read-write mounted WIM"
145 if test -f tmp/lz.c; then
146 error "Removing file from read-write mounted WIM failed"
148 echo "Testing making directory in mounted WIM"
149 if ! mkdir tmp/newdir; then
150 error "Failed to make directory in read-write mounted WIM"
152 if ! test -d tmp/newdir; then
153 error "Making directory in read-write mounted WIM failed"
155 echo "Testing making new empty file in mounted WIM"
156 if ! touch tmp/newdir/empty_file; then
157 error "Could not create new empty file in read-write mounted WIM"
159 if ! test -f tmp/newdir/empty_file; then
160 error "New empty file not created correctly in read-write mounted WIM"
162 if ! test "`stat -c %s tmp/newdir/empty_file`" = 0; then
163 error "New empty file in read-write mounted WIM is not empty"
165 echo "Testing making new non-empty file in mounted WIM"
166 if ! dd if=/dev/zero of=tmp/newdir/zeroes1 bs=1 count=4096; then
167 error "Failed to make new non-empty file in mounted WIM"
169 if ! dd if=/dev/zero of=tmp/newdir/zeroes2 bs=4096 count=1; then
170 error "Failed to make new non-empty file in mounted WIM"
172 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
173 error "New files in mounted WIM not made correctly"
175 echo "Unmounting WIM with changes committed and --check"
176 if ! imagex unmount tmp --commit --check; then
177 error "Failed to unmount read-write mounted WIM"
179 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
180 error "Integrity information was not included"
183 if ! imagex apply dir.wim tmp; then
184 error "Failed to apply WIM we had previously mounted read-write"
186 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
187 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
189 if test `stat -c %s tmp/newdir/empty_file` != 0; then
190 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
192 if test `stat -c %s tmp/newdir/zeroes1` != 4096; then
193 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
196 # Now do some tests using tar.
198 if ! ./tree-cmp $1 $2; then
199 if [ -x /usr/bin/tree ]; then
200 echo "Dumping tree of applied image"
201 tree $2 --inodes -F -s --noreport
202 error 'Information was lost or corrupted while capturing
203 and then applying a directory tree'
209 echo "--------------------------------------------------------------------"
210 echo "Testing making $1 on read-write mounted WIM"
211 echo "--------------------------------------------------------------------"
216 # Create tree, tar it up, and untar it on an empty WIM image mounted
219 cp empty.wim test.wim
223 if [ -x /usr/bin/tree ]; then
224 tree . --inodes -F -s --noreport
229 if ! imagex_mountrw test.wim tmp.mnt; then
230 error "Failed to mount WIM read-write"
234 if ! tar xf ../test.tar; then
235 error "Failed to untar archive on read-write mounted WIM"
239 # Diff the original tree with the mounted WIM
240 do_tree_cmp tmp.orig tmp.mnt
242 # Clear the mounted WIM and do it again! (We need to test deleting
243 # stuff as well as creating stuff.)
244 if ! rm -rf tmp.mnt/*; then
245 error "Failed to clear mounted WIM"
249 if ! tar xf ../test.tar; then
250 error "Failed to untar archive on read-write mounted WIM"
254 # Diff the original tree with the mounted WIM
255 do_tree_cmp tmp.orig tmp.mnt
257 # Unmount the WIM, apply it, and diff the original tree with the applied
259 if ! imagex unmount tmp.mnt --commit; then
260 error "Failed to unmount WIM mounted read-write"
262 if ! imagex apply test.wim tmp.apply; then
263 error "Failed to apply WIM we previously had mounted read-write"
265 do_tree_cmp tmp.orig tmp.apply
266 rm -rf tmp.orig/* tmp.apply/*
269 . $srcdir/tests/common_tests.sh
273 echo "**********************************************************"
274 echo " WIM mount tests passed "
275 echo "**********************************************************"