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\""
26 if ! mkntfs --force $1 &> /dev/null; then
27 error "Could not create NTFS volume on \"$1\". Make sure ntfs-3g / ntfsprogs are installed"
32 echo "Creating NTFS volumes and empty directories to use as mountpoints"
33 dd if=/dev/zero of=in.ntfs bs=4096 count=1000 &> /dev/null
34 dd if=/dev/zero of=out.ntfs bs=4096 count=1000 &> /dev/null
43 rm -rf in.ntfs out.ntfs in.mnt out.mnt in.xattr out.xattr
49 echo "****************************************************************"
52 echo "****************************************************************"
57 if ! imagex capture in.ntfs ntfs.wim; then
58 error "Failed to capture NTFS volume into a WIM"
65 if ! imagex apply ntfs.wim 1 out.ntfs; then
66 error "Failed to apply WIM to NTFS volume"
75 #echo "Comparing xattr $xattr of $infile and $outfile"
76 if test "$xattr" = "system.ntfs_times"; then
81 if eval getfattr --only-values -d -n $xattr $infile 2>/dev/null\
82 | head -c $headnum > in.xattr; then
83 if eval getfattr --only-values -d -n $xattr $outfile 2>/dev/null\
84 | head -c $headnum > out.xattr; then
85 if ! cmp in.xattr out.xattr; then
86 error "Extended attribute $xattr of $infile and $outfile differs"
89 error "$infile has extended attribute $xattr, but $outfile doesn't"
92 if eval getfattr --only-values -d -n $xattr $outfile 2>/dev/null\
93 | head -c $headnum > out.xattr; then
94 error "$outfile has extended attribute $xattr, but $infile doesn't"
99 do_capture_and_apply() {
103 if ! ntfs-3g -o ro in.ntfs in.mnt || ! ntfs-3g -o ro out.ntfs out.mnt; then
104 error "Could not mount NTFS volume. Make sure ntfs-3g is installed"
106 if ! diff -r in.mnt out.mnt; then
107 error "Recursive diff of original NTFS volume with applied NTFS volume failed"
109 for infile in `find in.mnt`; do
110 outfile=out.mnt${infile##in.mnt}
111 echo "Comparing xattrs of $infile and $outfile"
112 cmp_xattrs $infile $outfile system.ntfs_attrib
113 cmp_xattrs $infile $outfile system.ntfs_reparse_data
114 cmp_xattrs $infile $outfile system.ntfs_acl
115 cmp_xattrs $infile $outfile system.ntfs_dos_name
116 cmp_xattrs $infile $outfile system.ntfs_times
123 echo "Testing capture and apply of empty NTFS volume"