From 06947ea2c1f4384281cf17e4484e8e2ea887d96d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 27 Sep 2021 12:29:12 -0700 Subject: [PATCH] Allow ignoring mtime 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 --- tests/zfs-tests/include/libtest.shlib | 17 +++++++++++++---- .../tests/functional/rsend/rsend.kshlib | 2 +- .../functional/slog/slog_replay_fs_001.ksh | 2 +- .../functional/slog/slog_replay_fs_002.ksh | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 4c7356399fc2..7f4cfe04e98e 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -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 diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 66c9f011083c..c472112ce6f4 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -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 $? } diff --git a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh index 57e819c8c061..e82057e078ae 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_001.ksh @@ -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) diff --git a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_002.ksh b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_002.ksh index 4a16c460cabc..0e67d7a82897 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_replay_fs_002.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_replay_fs_002.ksh @@ -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."