Skip to content

Commit

Permalink
Allow ignoring mtime
Browse files Browse the repository at this point in the history
For several of the test cases we expect that the mtime may be
modified.  For example, the creation time is stored in the intent
log but not the mtime.  Thus when replaying the log the correct
crtime is set but the current mtime is used.  This is the expected
behavior, to prevent these tests from failing add a flag to ignore
the mtime when it is the only difference of a file or directory.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
behlendorf committed Sep 27, 2021
1 parent adfa05f commit 06947ea
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -4280,11 +4280,20 @@ function wait_for_children #children
#
function directory_diff # dir_a dir_b
{
# Run rsync with --dry-run --itemize-changes to get something akin to diff
# output, but rsync is far more thorough in detecting differences (diff
# doesn't compare file metadata, and cannot handle special files).
diff="$(rsync -ni -acAHX --delete "$1/" "$2/")"
typeset ignore_mtime=${3:-0}

# Run rsync with --dry-run --itemize-changes to get something akin to
# diff output, but rsync is far more thorough in detecting differences
# (diff doesn't compare file metadata, and cannot handle special
# files). Set the ignore_mtimes flag to ignore mtime modifications.
if [[ $ignore_mtime -eq 0 ]]; then
diff="$(rsync -ni -acAHX --delete "$1/" "$2/")"
else
diff="$(rsync -ni -acAHX --delete "$1/" "$2/" | \
sed '/.[df]..t....../d')"
fi
rv=0

if [ -n "$diff" ]; then
echo "$diff"
rv=1
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/rsend/rsend.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function cmp_ds_cont
srcdir=$(get_prop mountpoint $src_fs)
dstdir=$(get_prop mountpoint $dst_fs)

directory_diff $srcdir $dstdir
directory_diff $srcdir $dstdir 1
return $?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ log_must ls_xattr /$TESTPOOL/$TESTFS/xattr.dir
log_must ls_xattr /$TESTPOOL/$TESTFS/xattr.file

log_note "Verify working set diff:"
log_must directory_diff $TESTDIR/copy /$TESTPOOL/$TESTFS
log_must directory_diff $TESTDIR/copy /$TESTPOOL/$TESTFS 1

log_note "Verify file checksum:"
typeset checksum1=$(sha256digest /$TESTPOOL/$TESTFS/payload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ log_note "Verify number of files"
log_must test "$(ls /$TESTPOOL/$TESTFS/dir0 | wc -l)" -eq $NFILES

log_note "Verify working set diff:"
log_must directory_diff $TESTDIR/copy /$TESTPOOL/$TESTFS
log_must directory_diff $TESTDIR/copy /$TESTPOOL/$TESTFS 1

log_pass "Replay of intent log succeeds."

0 comments on commit 06947ea

Please sign in to comment.