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 mountpoint $1 &> /dev/null; then
19 if ! fusermount -u $1; then
20 error "Failed to unmount \"$1\""
28 if ! ntfs-3g ${options:+-o $options} $1 $2; then
29 error "Could not mount NTFS volume \"$1\" on \"$2\". Make sure ntfs-3g is installed."
34 if ! mkntfs --force --fast $1 &> /dev/null; then
35 error "Could not create NTFS volume on \"$1\". Make sure ntfs-3g / ntfsprogs are installed"
40 echo "Creating NTFS volumes and empty directories to use as mountpoints"
41 dd if=/dev/zero of=in.ntfs bs=4096 count=1000 &> /dev/null
42 dd if=/dev/zero of=out.ntfs bs=4096 count=1000 &> /dev/null
51 rm -rf in.ntfs out.ntfs in.mnt out.mnt in.xattr out.xattr
57 echo "****************************************************************"
60 echo "****************************************************************"
66 if ! imagex capture in.ntfs ntfs.wim; then
67 error "Failed to capture NTFS volume into a WIM"
74 if ! imagex apply ntfs.wim 1 out.ntfs; then
75 error "Failed to apply WIM to NTFS volume"
83 #echo "Comparing xattr $xattr of $infile and $outfile"
84 if test "$xattr" = "system.ntfs_times"; then
89 if eval getfattr --only-values -h -d -n $xattr $infile 2>/dev/null\
90 | head -c $headnum > in.xattr; then
91 if eval getfattr --only-values -h -d -n $xattr $outfile 2>/dev/null\
92 | head -c $headnum > out.xattr; then
93 if ! cmp in.xattr out.xattr; then
94 error "Extended attribute $xattr of $infile and $outfile differs"
97 error "$infile has extended attribute $xattr, but $outfile doesn't"
100 if eval getfattr --only-values -h -d -n $xattr $outfile 2>/dev/null\
101 | head -c $headnum > out.xattr; then
102 error "$outfile has extended attribute $xattr, but $infile doesn't"
107 # Captures in.ntfs, applies it to out.ntfs, and diffs the result including
108 # extended attributes
109 do_capture_and_apply() {
112 do_mount in.ntfs in.mnt ro
113 do_mount out.ntfs out.mnt ro
114 #if ! diff -r in.mnt out.mnt; then
115 #error "Recursive diff of original NTFS volume with applied NTFS volume failed"
117 for infile in `find in.mnt`; do
118 outfile=out.mnt${infile##in.mnt}
119 #echo "Comparing xattrs of $infile and $outfile"
120 if [ ! -L $infile -a ! -d $infile ]; then
121 if ! cmp $infile $outfile; then
122 error "Contents of $infile and $outfile differed"
125 cmp_xattrs $infile $outfile system.ntfs_attrib
126 cmp_xattrs $infile $outfile system.ntfs_reparse_data
127 cmp_xattrs $infile $outfile system.ntfs_acl
128 cmp_xattrs $infile $outfile system.ntfs_dos_name
129 cmp_xattrs $infile $outfile system.ntfs_times
136 do_mount in.ntfs in.mnt
137 ( cd in.mnt; eval "$1" )
145 echo "Testing image capture and application of $1"
151 msg "Empty NTFS volume"
154 msg "NTFS volume containing a single file"
155 do_test "echo 1 > file"
157 msg "NTFS volume containing a single directory"
160 msg "NTFS volume containing subdirectory with file"
161 do_test "mkdir dir; echo 1 > dir/file"
163 msg "NTFS volume containing empty file"
164 do_test "echo -n > empty_file"
166 msg "NTFS volume containing two empty files"
167 do_test "echo -n > empty_file_1; echo -n > empty_file_2"
169 msg "NTFS volume containing hard link in same directory"
170 do_test "echo 1 > file; ln file link"
172 msg "NTFS volume containing hard link between empty files"
173 do_test "echo -n > empty_file; ln empty_file link"
175 msg "NTFS volume containing relative symbolic link"
176 do_test "echo 1 > file; ln -s file symlink"
178 msg "NTFS volume containing absolute symbolic link"
179 do_test "echo 1 > file; ln -s /some/absolute/target symlink"
181 msg "NTFS volume containing large file"
182 do_test "dd if=/dev/zero of=file bs=4096 count=10 &> /dev/null"
184 msg "NTFS volume containing file with DOS name"
185 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file"
187 msg "NTFS volume containing file with DOS name with hardlink in same directory"
188 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file; ln file link"