tests: replace sum(1) with cksum(1)

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:51:07 +01:00 committed by Brian Behlendorf
parent c2fcc55d97
commit 9423c932d4
12 changed files with 31 additions and 46 deletions

View File

@ -91,7 +91,6 @@ export SYSTEM_FILES_COMMON='arp
strings
su
sudo
sum
swapoff
swapon
sync

View File

@ -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}'
}
#

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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
#

View File

@ -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))

View File

@ -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

View File

@ -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"

View File

@ -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`

View File

@ -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"