tests: snapshot_00[15]_pos: use cksum instead of sum -r

This only worked by accident on FreeBSD, where sum doesn't take flags

POSIX guarantees us cksum (Ethernet CRC) ‒ use that instead

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-09 00:30:52 +01:00 committed by Brian Behlendorf
parent 7aa7e6bd0a
commit c2fcc55d97
2 changed files with 10 additions and 17 deletions

View File

@ -35,8 +35,8 @@
#
# DESCRIPTION:
# A zfs file system snapshot is identical to
# the originally snapshot'd file system, after the file
# system has been changed. Uses 'sum -r'.
# the originally snapshotted file system, after the file
# system has been changed. Uses 'cksum'.
#
# STRATEGY:
# 1. Create a file in the zfs file system
@ -50,18 +50,11 @@ verify_runnable "both"
function cleanup
{
snapexists $SNAPFS
if [[ $? -eq 0 ]]; then
if snapexists $SNAPFS; then
log_must zfs destroy $SNAPFS
fi
if [[ -e $SNAPDIR ]]; then
log_must rm -rf $SNAPDIR > /dev/null 2>&1
fi
if [[ -e $TESTDIR ]]; then
log_must rm -rf $TESTDIR/* > /dev/null 2>&1
fi
log_must rm -rf $SNAPDIR $TESTDIR/* > /dev/null 2>&1
}
log_assert "Verify a file system snapshot is identical to original."
@ -73,7 +66,7 @@ log_must file_write -o create -f $TESTDIR/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
log_note "Sum the file, save for later comparison..."
FILE_SUM=`sum -r $TESTDIR/$TESTFILE | awk '{ print $1 }'`
read -r FILE_SUM _ < <(cksum $TESTDIR/$TESTFILE)
log_note "FILE_SUM = $FILE_SUM"
log_note "Create a snapshot and mount it..."
@ -83,7 +76,7 @@ log_note "Append to the original file..."
log_must file_write -o append -f $TESTDIR/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
SNAP_FILE_SUM=`sum -r $SNAPDIR/$TESTFILE | awk '{ print $1 }'`
read -r SNAP_FILE_SUM _ < <(cksum $SNAPDIR/$TESTFILE)
if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then
log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)"
fi

View File

@ -35,7 +35,7 @@
#
# DESCRIPTION:
# to the originally snapshot'd file system, after the file
# system has been changed. Uses 'sum -r'.
# system has been changed. Uses 'cksum'.
#
# STRATEGY:
# 1) Create a file in the zfs dataset
@ -72,7 +72,7 @@ log_must file_write -o create -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
log_note "Sum the file, save for later comparison..."
FILE_SUM=`sum -r $TESTDIR1/$TESTFILE | awk '{ print $1 }'`
read -r FILE_SUM _ < <(cksum $TESTDIR1/$TESTFILE)
log_note "FILE_SUM = $FILE_SUM"
log_note "Create a snapshot and mount it..."
@ -82,8 +82,8 @@ log_note "Append to the original file..."
log_must file_write -o append -f $TESTDIR1/$TESTFILE -b $BLOCKSZ \
-c $NUM_WRITES -d $DATA
SNAP_FILE_SUM=`sum -r $SNAPDIR1/$TESTFILE | awk '{ print $1 }'`
if [[ $SNAP_FILE_SUM -ne $FILE_SUM ]]; then
read -r SNAP_FILE_SUM _ < <(cksum $SNAPDIR1/$TESTFILE)
if [ $SNAP_FILE_SUM -ne $FILE_SUM ]; then
log_fail "Sums do not match, aborting!! ($SNAP_FILE_SUM != $FILE_SUM)"
fi