3 # This script does some sanity testing of the 'imagex' program, specifically
4 # checking the NTFS capture and apply features.
6 # This test will fail if wimlib was compiled with --without-ntfs-3g.
8 # Assume an in-tree build.
14 ../imagex $@ > /dev/null
18 if ! fusermount -u $1; then
19 error "Failed to unmount \"$1\""
24 if mountpoint $1 &> /dev/null; then
31 if ! ntfs-3g ${options:+-o $options} $1 $2; then
32 error "Could not mount NTFS volume \"$1\" on \"$2\". Make sure ntfs-3g is installed."
42 if ! mkntfs --force --fast $1 &> /dev/null; then
43 error "Could not create NTFS volume on \"$1\". Make sure ntfs-3g / ntfsprogs are installed"
48 echo "Creating NTFS volumes and empty directories to use as mountpoints"
49 dd if=/dev/zero of=in.ntfs bs=4096 count=260 &> /dev/null
50 dd if=/dev/zero of=out.ntfs bs=4096 count=260 &> /dev/null
54 do_mount in.ntfs in.mnt
60 rm -rf in.ntfs out.ntfs in.mnt out.mnt in.xattr out.xattr
66 echo "****************************************************************"
69 echo "****************************************************************"
78 if ! imagex capture in.ntfs ntfs.wim; then
79 error "Failed to capture NTFS volume into a WIM"
81 if ! imagex apply ntfs.wim 1 out.ntfs; then
82 error "Failed to apply WIM to NTFS volume"
84 __do_mount in.ntfs in.mnt noatime
85 __do_mount out.ntfs out.mnt noatime
86 if [ -x /usr/bin/tree ]; then
87 tree in.mnt --inodes -F -s --noreport
89 if ! ./ntfs-cmp in.mnt out.mnt; then
90 if [ -x /usr/bin/tree ]; then
91 echo "Dumping tree of applied image"
92 tree out.mnt --inodes -F -s --noreport
93 error 'Information was lost or corrupted while capturing
94 and then applying a NTFS volume'
97 rm -rf out.mnt/* in.mnt/*
101 echo "Testing image capture and application of $1"
107 msg "Empty NTFS volume"
110 msg "NTFS volume containing a single file"
111 do_test "echo 1 > file"
113 msg "NTFS volume containing a single directory"
116 msg "NTFS volume containing subdirectory with file"
117 do_test "mkdir dir; echo 1 > dir/file"
119 msg "NTFS volume containing empty file"
120 do_test "echo -n > empty_file"
122 msg "NTFS volume containing two empty files"
123 do_test "echo -n > empty_file_1; echo -n > empty_file_2"
125 msg "NTFS volume containing hard link in same directory"
126 do_test "echo 1 > file; ln file link"
128 msg "NTFS volume containing hard link between empty files"
129 do_test "echo -n > empty_file; ln empty_file link"
131 msg "NTFS volume containing relative symbolic link"
132 do_test "echo 1 > file; ln -s file symlink"
134 msg "NTFS volume containing absolute symbolic link"
135 do_test "echo 1 > file; ln -s /some/absolute/target symlink"
137 msg "NTFS volume containing large file"
138 do_test "dd if=/dev/zero of=file bs=4096 count=10 &> /dev/null"
140 msg "NTFS volume containing file with DOS name"
141 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file"
143 msg "NTFS volume containing file with DOS name with alphabetically smaller hardlink in same directory"
144 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file; ln file aaa_link"
146 msg "NTFS volume containing file with DOS name with alphabetically larger hardlink in same directory"
147 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file; ln file zzz_link"
149 msg "NTFS volume containing file with long name and with DOS name with alphabetically smaller hardlink in same directory"
150 do_test 'echo 1 > file_with_a_long_name;
151 setfattr -v "file~1" -n system.ntfs_dos_name file_with_a_long_name;
152 ln file_with_a_long_name aaa_link'
154 msg "NTFS volume containing many nested directories"
155 do_test 'mkdir dir; mkdir dir/subdir; mkdir dir/subdir/subdir2; mkdir dir/subdir/subdir3'
157 msg "NTFS volume containing identical files and symlinks in subdirectory"
160 echo 888 > dir/idfile2;
161 ln -s ../dir dir/circle; ln -s file dir/filelink'
163 msg "NTFS volume containing hard link group and identical files not hard linked"
164 do_test 'echo 888 > file;
170 msg "NTFS volume containing file with named data stream"
171 do_test 'echo 1 > file;
172 setfattr -n user.ads -v 2 file'
174 msg "NTFS volume containing file with multiple named data streams"
175 do_test 'echo 1 > file;
176 setfattr -n user.a -v 1 file;
177 setfattr -n user.aa -v 11 file;
178 setfattr -n user.aaa -v 111 file;
179 setfattr -n user.aaaa -v 1111 file'
181 msg "NTFS volume containing file with multiple named data streams with same contents"
182 do_test 'echo 1 > file;
183 setfattr -n user.a -v 1111 file;
184 setfattr -n user.aa -v 1111 file;
185 setfattr -n user.aaa -v 1111 file;
186 setfattr -n user.aaaa -v 1111 file;'
188 msg "NTFS volume containing file with named data streams with same contents as other file"
189 do_test 'echo -n > file;
190 setfattr -n user.a -v 1111 file;
191 echo -n 1111 > otherfile;'
193 msg "NTFS volume containing file with empty named data stream and non-empty unnamed data stream"
194 do_test 'echo 1 > file;
195 setfattr -n user.ads -v "" file;'
197 msg "NTFS volume containing file with empty named data stream and empty unnamed data stream"
198 do_test 'echo -n > file;
199 setfattr -n user.ads -v "" file;'
201 msg "NTFS volume containing file with named data stream with hardlink"
202 do_test 'echo 999 > file;
203 setfattr -n user.ads -v "888" file;
206 msg "NTFS volume containing file with named data stream with hardlink and DOS name"
207 do_test 'echo 999 > file;
208 setfattr -n user.ads -v "888" file;
210 setfattr -v DOSNAME -n system.ntfs_dos_name file;'