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
85 __do_mount out.ntfs out.mnt
86 ./ntfs-cmp in.mnt out.mnt
87 rm -rf out.mnt/* in.mnt/*
91 echo "Testing image capture and application of $1"
97 msg "Empty NTFS volume"
100 msg "NTFS volume containing a single file"
101 do_test "echo 1 > file"
103 msg "NTFS volume containing a single directory"
106 msg "NTFS volume containing subdirectory with file"
107 do_test "mkdir dir; echo 1 > dir/file"
109 msg "NTFS volume containing empty file"
110 do_test "echo -n > empty_file"
112 msg "NTFS volume containing two empty files"
113 do_test "echo -n > empty_file_1; echo -n > empty_file_2"
115 msg "NTFS volume containing hard link in same directory"
116 do_test "echo 1 > file; ln file link"
118 msg "NTFS volume containing hard link between empty files"
119 do_test "echo -n > empty_file; ln empty_file link"
121 msg "NTFS volume containing relative symbolic link"
122 do_test "echo 1 > file; ln -s file symlink"
124 msg "NTFS volume containing absolute symbolic link"
125 do_test "echo 1 > file; ln -s /some/absolute/target symlink"
127 msg "NTFS volume containing large file"
128 do_test "dd if=/dev/zero of=file bs=4096 count=10 &> /dev/null"
130 msg "NTFS volume containing file with DOS name"
131 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file"
133 msg "NTFS volume containing file with DOS name with alphabetically smaller hardlink in same directory"
134 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file; ln file aaa_link"
136 msg "NTFS volume containing file with DOS name with alphabetically larger hardlink in same directory"
137 do_test "echo 1 > file; setfattr -v file -n system.ntfs_dos_name file; ln file zzz_link"
139 msg "NTFS volume containing file with long name and with DOS name with alphabetically smaller hardlink in same directory"
140 do_test 'echo 1 > file_with_a_long_name;
141 setfattr -v "file~1" -n system.ntfs_dos_name file_with_a_long_name;
142 ln file_with_a_long_name aaa_link'
144 msg "NTFS volume containing many nested directories"
145 do_test 'mkdir dir; mkdir dir/subdir; mkdir dir/subdir/subdir2; mkdir dir/subdir/subdir3'
147 msg "NTFS volume containing identical files and symlinks in subdirectory"
150 echo 888 > dir/idfile2;
151 ln -s dir dir/circle; ln -s file dir/filelink'
153 msg "NTFS volume containing hard link group and identical files not hard linked"
154 do_test 'echo 888 > file;
160 msg "NTFS volume containing file with named data stream"
161 do_test 'echo 1 > file;
162 setfattr -n user.ads -v 2 file'