From 1cbb695dccd63b9d9f1175934aefd85770ee0b16 Mon Sep 17 00:00:00 2001 From: Tino Reichardt Date: Fri, 20 Sep 2024 00:53:57 +0200 Subject: [PATCH] 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 Reviewed-by: Brian Behlendorf Signed-off-by: Tino Reichardt Closes #16543 --- tests/zfs-tests/include/libtest.shlib | 26 ++----------------- .../functional/cli_root/zdb/zdb_backup.ksh | 4 +-- .../fault/suspend_resume_single.ksh | 4 +-- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index a2f42999a..275872ded 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -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}' } # @@ -3480,18 +3469,7 @@ function md5digest # 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 # diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh index d98ab86ab..b591b209a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_backup.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh index 05f3ac708..6998df78a 100755 --- a/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh +++ b/tests/zfs-tests/tests/functional/fault/suspend_resume_single.ksh @@ -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"