11 ../imagex $@ > /dev/null
20 echo "imagex mountrw $@"
21 ../imagex mountrw --debug "$@" &> mount.log &
22 while ! mountpoint $2 >& /dev/null; do
29 fusermount -u tmp &> /dev/null || true
30 fusermount -u tmp.mnt &> /dev/null || true
31 rm -rf dir* tmp* *.wim *.swm empty.wim tmp.orig tmp.mnt \
32 tmp.apply mount.log test.tar wimlib-staging*
36 cp $srcdir/src/*.c $srcdir/src/*.h dir
38 echo 'hello' > dir/subdir/hello
39 echo 'hello' > dir/subdir/hello2
40 ln dir/subdir/hello dir/subdir/hellolink
41 echo -n > dir/subdir/empty_file
42 ln -s hello dir/subdir/rel_symlink
45 echo 'testing' > dir2/file
46 dd if=/dev/zero of=dir2/zeroes bs=4096 count=5
47 mkdir tmp.empty tmp.mnt tmp.apply tmp.orig
48 imagex capture tmp.empty empty.wim
52 echo "**********************************************"
55 echo "**********************************************"
64 for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
65 echo "Using flag $flag"
66 echo "Testing mounting WIM read-only"
67 if ! imagex capture dir dir.wim $flag; then
68 error "Failed to capture WIM"
71 if ! imagex mount dir.wim dir tmp; then
72 error "Failde to mount test WIM read-only"
74 echo "Testing extracting file from mounted read-only WIM"
75 if ! cp tmp/lz.c lz.c; then
76 error "Failed to extract file from read-only mounted WIM"
78 if ! diff -q dir/lz.c lz.c; then
79 error "Extracted file does not match copy in mounted WIM"
81 if ! diff -q tmp/lz.c dir/lz.c; then
82 error "Extractef file does not match original"
85 echo "Testing modifying mounted read-only WIM (should fail)"
87 error "Removing file from read-only mounted WIM didn't fail"
89 if touch tmp/newfile; then
90 error "Creating file on read-only mounted WIM didn't fail"
92 if echo 3 > tmp/lz.c; then
93 error "Writing to file on read-only mounted WIM didn't fail"
95 echo "Testing diff of mounted read-only WIM with original directory"
96 if ! diff -q -r tmp dir; then
97 error "Recursive diff of read-only mounted WIM with original directory failed"
99 echo "Testing unmount of read-only filesystem"
100 if ! imagex unmount tmp; then
101 error "Unmounting read-only WIM failed"
103 echo "Testing unmount of read-only filesystem with --commit given"
104 if ! imagex mount dir.wim dir tmp; then
105 error "Failed to re-mount WIM read-only"
107 if ! imagex unmount tmp --commit; then
108 error "Failed to unmount read-only WIM with --commit flag (should be ignored)"
114 echo "Testing mounting WIM read-write"
115 if ! imagex capture dir dir.wim; then
116 error "Failed to capture WIM"
119 if ! imagex mountrw dir.wim dir tmp; then
120 error "Failed to mount test WIM read-write"
122 echo "Testing unmounting WIM unmodified"
123 if ! imagex unmount tmp; then
124 error "Failed to unmount test WIM unmodified"
126 echo "Testing unmounting WIM unmodified with --commit and --check"
127 if ! imagex mountrw dir.wim dir tmp; then
128 error "Failed to re-mount test WIM read-write"
130 if ! imagex unmount tmp --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 ! imagex mountrw dir.wim dir tmp; then
135 error "Failed to re-mount test WIM read-write"
137 if ! rm tmp/lz.c; then
138 error "Failed to remove file from read-write mounted WIM"
140 if test -f tmp/lz.c; then
141 error "Removing file from read-write mounted WIM failed"
143 echo "Testing making directory in mounted WIM"
144 if ! mkdir tmp/newdir; then
145 error "Failed to make directory in read-write mounted WIM"
147 if ! test -d tmp/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/newdir/empty_file; then
152 error "Could not create new empty file in read-write mounted WIM"
154 if ! test -f tmp/newdir/empty_file; then
155 error "New empty file not created correctly in read-write mounted WIM"
157 if ! test "`stat -c %s tmp/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/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/newdir/zeroes2 bs=4096 count=1; then
165 error "Failed to make new non-empty file in mounted WIM"
167 if ! diff -q tmp/newdir/zeroes1 tmp/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 --commit --check; then
172 error "Failed to unmount read-write mounted WIM"
174 if test "`imagex_info dir.wim | grep Integrity | awk '{print $3}'`" != "yes"; then
175 error "Integrity information was not included"
178 if ! imagex apply dir.wim tmp; then
179 error "Failed to apply WIM we had previously mounted read-write"
181 if ! diff -q tmp/newdir/zeroes1 tmp/newdir/zeroes2; then
182 error "The new non-empty files we made in the read-write mounted WIM were not extracted correctly"
184 if test `stat -c %s tmp/newdir/empty_file` != 0; then
185 error "The new empty file we made in the read-write mounted WIM was not extracted correctly"
187 if test `stat -c %s tmp/newdir/zeroes1` != 4096; then
188 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 ! imagex_mountrw test.wim tmp.mnt; 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 ! imagex apply 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
268 echo "**********************************************************"
269 echo " WIM mount tests passed "
270 echo "**********************************************************"