ZTS: use openssl for md5digest and sha256digest

On larger files this should improve the speed.

Sample values of my system:

[mcmilk@xz]$ time dd if=/dev/zero bs=128k count=1k | sha256sum
254bcc3fc4f27172636df4bf32de9f107f620d559b20d760197e452b97453917  -
real    0m1,050s
user    0m0,985s
sys     0m0,153s

[mcmilk@xz]$ time dd if=/dev/zero bs=128k count=1k | openssl sha256 -r
254bcc3fc4f27172636df4bf32de9f107f620d559b20d760197e452b97453917 *stdin
real    0m0,254s
user    0m0,206s
sys     0m0,160s

I think cli_root/zdb/zdb_backup.ksh runs also an FreeBSD and I needed to
include the sysutils/coreutils package for the FreeBSD tests within the
QEMU patchset.

This could be reverted, when this pull request gets upstream

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #16543
This commit is contained in:
Tino Reichardt 2024-09-20 00:53:57 +02:00 committed by GitHub
parent e8ede2ba78
commit 4bf6a2ab87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 28 deletions

View File

@ -3460,18 +3460,7 @@ function tunable_exists
#
function md5digest
{
typeset file=$1
case "$UNAME" in
FreeBSD)
md5 -q $file
;;
*)
typeset sum _
read -r sum _ < <(md5sum -b $file)
echo $sum
;;
esac
openssl md5 -r $1 | awk '{print $1}'
}
#
@ -3492,18 +3481,7 @@ function cmp_md5s {
#
function sha256digest
{
typeset file=$1
case "$UNAME" in
FreeBSD)
sha256 -q $file
;;
*)
typeset sum _
read -r sum _ < <(sha256sum -b $file)
echo $sum
;;
esac
openssl sha256 -r $1 | awk '{print $1}'
}
function new_fs #<args>

View File

@ -47,8 +47,8 @@ sync_pool $TESTPOOL
log_must eval "zfs send -ecL $snap > $tmpfile.1"
log_must eval "zdb -B $TESTPOOL/$objsetid ecL > $tmpfile.2"
typeset sum1=$(cat $tmpfile.1 | md5sum)
typeset sum2=$(cat $tmpfile.2 | md5sum)
typeset sum1=$(md5digest $tmpfile.1)
typeset sum2=$(md5digest $tmpfile.2)
log_must test "$sum1" = "$sum2"

View File

@ -43,7 +43,7 @@ log_assert "ensure single-disk pool resumes properly after suspend and clear"
# create a file, and take a checksum, so we can compare later
log_must dd if=/dev/urandom of=$DATAFILE bs=128K count=1
typeset sum1=$(cat $DATAFILE | md5sum)
typeset sum1=$(md5digest $DATAFILE)
# make a debug device that we can "unplug"
load_scsi_debug 100 1 1 1 '512b'
@ -94,7 +94,7 @@ log_must zpool export $TESTPOOL
log_must zpool import $TESTPOOL
# sum the file we wrote earlier
typeset sum2=$(cat /$TESTPOOL/file | md5sum)
typeset sum2=$(md5digest /$TESTPOOL/file)
# make sure the checksums match
log_must test "$sum1" = "$sum2"