aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-03-09 00:51:07 +0100
committerBrian Behlendorf <[email protected]>2022-04-01 17:57:03 -0700
commit9423c932d49afc715f8422b94321fd656842fa41 (patch)
tree8705d402116fe2c2c4b85a5e4e3b60bac118ac80 /tests
parentc2fcc55d972fb49d24bfb626cc20b954040ecc5a (diff)
tests: replace sum(1) with cksum(1)
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Kennedy <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13259
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs-tests/include/commands.cfg1
-rw-r--r--tests/zfs-tests/tests/functional/acl/acl_common.kshlib12
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib2
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh8
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh7
-rw-r--r--tests/zfs-tests/tests/functional/migration/migration.cfg5
-rw-r--r--tests/zfs-tests/tests/functional/migration/migration.kshlib8
12 files changed, 31 insertions, 46 deletions
diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg
index b247a67ff..50449633a 100644
--- a/tests/zfs-tests/include/commands.cfg
+++ b/tests/zfs-tests/include/commands.cfg
@@ -91,7 +91,6 @@ export SYSTEM_FILES_COMMON='arp
strings
su
sudo
- sum
swapoff
swapon
sync
diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
index ba08bcb48..1e9d736fd 100644
--- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
+++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
@@ -411,7 +411,7 @@ function get_xattr #<obj>
for xattr in `runat $obj ls | \
grep -E -v -e SUNWattr_ro -e SUNWattr_rw` ; do
- runat $obj sum $xattr
+ runat $obj cksum $xattr
done
}
@@ -424,16 +424,14 @@ function get_owner #node
typeset value
if [[ -z $node ]]; then
- log_fail "node are not defined."
+ log_fail "node is not defined."
fi
if [[ -d $node ]]; then
- value=$(ls -dl $node | awk '{print $3}')
+ ls -dl $node
elif [[ -e $node ]]; then
- value=$(ls -l $node | awk '{print $3}')
- fi
-
- echo $value
+ ls -l $node
+ fi | awk '{print $3}'
}
#
diff --git a/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
index 4788de598..2b84f6a9c 100644
--- a/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
@@ -39,7 +39,7 @@ function get_cksum # <file path>
}
#
-# Compare the check sum of target files with the original file
+# Compare the checksum of target files with the original file
#
function compare_cksum #<orig_data> <target_data1>...<target_datan>
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
index 2eadb68c3..04a886773 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
@@ -36,9 +36,9 @@
# $1 full file name
function getsum #fname
{
- (( ${#1} == 0 )) && \
- log_fail "Need give file name."
- return $(sum $1 | awk '{print $1}')
+ typeset sum
+ read -r sum _ < <(cksum "$1")
+ echo $sum
}
# Define global variable checksum, get the original file sum.
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh
index 77fe11698..e159c1a04 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh
@@ -91,7 +91,7 @@ log_assert "Verify that an exported pool can be imported."
setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 _ < <(cksum $MYTESTFILE)
typeset -i i=0
typeset -i j=0
@@ -125,9 +125,8 @@ while (( i < ${#pools[*]} )); do
[[ ! -e $basedir/$TESTFILE0 ]] && \
log_fail "$basedir/$TESTFILE0 missing after import."
- checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
+ read -r checksum2 _ < <(cksum $basedir/$TESTFILE0)
+ log_must [ "$checksum1" = "$checksum2" ]
((j = j + 1))
done
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh
index 898f93cc9..95ebe0ae2 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_002_pos.ksh
@@ -90,7 +90,7 @@ log_assert "Verify that an exported pool cannot be imported more than once."
setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 _ < <(cksum $MYTESTFILE)
typeset -i i=0
typeset -i j=0
@@ -126,9 +126,8 @@ while (( i < ${#pools[*]} )); do
[[ ! -e $basedir/$TESTFILE0 ]] && \
log_fail "$basedir/$TESTFILE0 missing after import."
- checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
+ read -r checksum2 _ < <(cksum $basedir/$TESTFILE0)
+ log_must [ "$checksum1" = "$checksum2" ]
log_mustnot zpool import ${devs[i]} $target
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
index b384ec9b1..4ebe6b591 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
@@ -108,9 +108,8 @@ function checksum_all #alter_root
[[ ! -e $file ]] && \
log_fail "$file missing after import."
- checksum2=$(sum $file | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
+ read -r checksum2 _ < <(cksum $file)
+ log_must [ "$checksum1" = "$checksum2" ]
(( id = id + 1 ))
done
@@ -122,7 +121,7 @@ function checksum_all #alter_root
log_assert "Verify that 'zpool import -a' succeeds as root."
log_onexit cleanup_all
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 _ < <(cksum $MYTESTFILE)
number=1
#
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh
index 3b5167ff0..22cec24ff 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_001_pos.ksh
@@ -111,7 +111,7 @@ log_assert "Verify that import could handle damaged or missing device."
CWD=$PWD
cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR"
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 _ < <(cksum $MYTESTFILE)
typeset -i i=0
typeset -i j=0
@@ -199,10 +199,8 @@ while (( i < ${#vdevs[*]} )); do
[[ ! -e $basedir/$TESTFILE0 ]] && \
log_fail "$basedir/$TESTFILE0 missing after import."
- checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
-
+ read -r checksum2 _ < <(cksum $basedir/$TESTFILE0)
+ log_must [ "$checksum1" = "$checksum2" ]
done
((j = j + 1))
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh
index bcb795b19..ac76f879c 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh
@@ -97,9 +97,8 @@ function verify
[[ ! -e $mtpt/$file ]] && \
log_fail "$mtpt/$file missing after import."
- checksum2=$(sum $mymtpt/$file | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
+ read -r checksum2 _ < <(cksum $mymtpt/$file)
+ log_must [ "$checksum1" = "$checksum2" ]
return 0
@@ -149,7 +148,7 @@ CWD=$PWD
log_must cd $DEVICE_DIR
log_must tar cf $DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}*
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 < <(cksum $MYTESTFILE)
typeset -i i=0
typeset -i j=0
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh
index bb6bf86d7..4e49e8d01 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_rename_001_pos.ksh
@@ -101,7 +101,7 @@ log_onexit cleanup
log_assert "Verify that an imported pool can be renamed."
setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
-checksum1=$(sum $MYTESTFILE | awk '{print $1}')
+read -r checksum1 _ < <(cksum $MYTESTFILE)
typeset -i i=0
typeset -i j=0
@@ -140,9 +140,8 @@ while (( i < ${#pools[*]} )); do
[[ ! -e $basedir/$TESTFILE0 ]] && \
log_fail "$basedir/$TESTFILE0 missing after import."
- checksum2=$(sum $basedir/$TESTFILE0 | awk '{print $1}')
- [[ "$checksum1" != "$checksum2" ]] && \
- log_fail "Checksums differ ($checksum1 != $checksum2)"
+ read -r checksum2 _ < <(cksum $basedir/$TESTFILE0)
+ log_must [ "$checksum1" = "$checksum2" ]
log_must zpool export "${pools[i]}-new"
diff --git a/tests/zfs-tests/tests/functional/migration/migration.cfg b/tests/zfs-tests/tests/functional/migration/migration.cfg
index 12a5a7799..a8a24e0a3 100644
--- a/tests/zfs-tests/tests/functional/migration/migration.cfg
+++ b/tests/zfs-tests/tests/functional/migration/migration.cfg
@@ -102,9 +102,8 @@ export DISK_COUNT ZFS_DISK NONZFS_DISK SINGLE_DISK ZFSSIDE_DISK NONZFSSIDE_DISK
export TESTFILE=/etc/passwd
export NONZFS_TESTDIR=$TESTDIR/nonzfstestdir
-tmp=`sum $TESTFILE`
-export SUMA=`echo $tmp | awk '{print $1}'`
-export SUMB=`echo $tmp | awk '{print $2}'`
+read -r SUMA SUMB _ < <(cksum $TESTFILE)
+export SUMA SUMB
export FS_SIZE=1g
export BNAME=`basename $TESTFILE`
export DNAME=`dirname $TESTFILE`
diff --git a/tests/zfs-tests/tests/functional/migration/migration.kshlib b/tests/zfs-tests/tests/functional/migration/migration.kshlib
index a2b4ed99b..2b1955fe9 100644
--- a/tests/zfs-tests/tests/functional/migration/migration.kshlib
+++ b/tests/zfs-tests/tests/functional/migration/migration.kshlib
@@ -99,9 +99,7 @@ function migrate #destdir oldsuma oldsumb cmd
$cmd
(( $? != 0 )) && return 1
- sumy=`sum ./$BNAME`
- suma=`echo $sumy | awk '{print $1}'`
- sumb=`echo $sumy | awk '{print $2}'`
+ read -r suma sumb _ < <(cksum ./$BNAME)
if (( $oldsuma != $suma )); then
log_note "sum values are not the same"
@@ -133,9 +131,7 @@ function migrate_cpio
cpio -iv < $archive
(( $? != 0 )) && return 1
- sumy=`sum ./$BNAME`
- suma=`echo $sumy | awk '{print $1}'`
- sumb=`echo $sumy | awk '{print $2}'`
+ read -r suma sumb _ < <(cksum ./$BNAME)
if (( $oldsuma != $suma )); then
log_note "sum values are not the same"