From 05eae1c15243942ec2e502c7425d75eb9296d3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 4 Mar 2022 00:09:08 +0100 Subject: [PATCH 01/63] tests: standardise on no-arg uname with *) case for illumos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs-tests.sh | 2 +- scripts/zfs.sh | 2 +- tests/zfs-tests/include/default.cfg.in | 6 +- tests/zfs-tests/include/libtest.shlib | 84 +++++--------------------- 4 files changed, 21 insertions(+), 73 deletions(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index 851ff8b74e52..d82c5923a990 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -53,7 +53,7 @@ TAGS="" ITERATIONS=1 ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" -UNAME=$(uname -s) +UNAME=$(uname) RERUN="" KMEMLEAK="" diff --git a/scripts/zfs.sh b/scripts/zfs.sh index 0561092a089f..edce2cbd4c64 100755 --- a/scripts/zfs.sh +++ b/scripts/zfs.sh @@ -260,7 +260,7 @@ if [ "$(id -u)" != 0 ]; then exit 1 fi -UNAME=$(uname -s) +UNAME=$(uname) if [ "$UNLOAD" = "yes" ]; then kill_zed diff --git a/tests/zfs-tests/include/default.cfg.in b/tests/zfs-tests/include/default.cfg.in index cf382cfe994c..a9a17de34ae7 100644 --- a/tests/zfs-tests/include/default.cfg.in +++ b/tests/zfs-tests/include/default.cfg.in @@ -170,8 +170,8 @@ if [ "@UBSAN_ENABLED@" = "yes" ]; then fi -case $(uname -o) in -GNU/Linux) +case $(uname) in +Linux) unpack_opts="--sparse -xf" pack_opts="--sparse -cf" verbose=" -v" @@ -209,7 +209,7 @@ FreeBSD) NEWFS_DEFAULT_FS="ufs" SLICE_PREFIX="p" ;; -illumos) +*) export AUTO_SNAP=$(svcs -a | \ awk '/auto-snapshot/ && /online/ { print $3 }') # finally, if we're running in a local zone diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 3c0cd04c5e0f..79930bb293e1 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -88,11 +88,7 @@ function linux_version function is_linux { - if [[ $(uname -o) == "GNU/Linux" ]]; then - return 0 - else - return 1 - fi + [ $(uname) = "Linux" ] } # Determine if this is an illumos test system @@ -100,11 +96,7 @@ function is_linux # Return 0 if platform illumos, 1 if otherwise function is_illumos { - if [[ $(uname -o) == "illumos" ]]; then - return 0 - else - return 1 - fi + [ $(uname) = "illumos" ] } # Determine if this is a FreeBSD test system @@ -113,11 +105,7 @@ function is_illumos function is_freebsd { - if [[ $(uname -o) == "FreeBSD" ]]; then - return 0 - else - return 1 - fi + [ $(uname) = "FreeBSD" ] } # Determine if this is a DilOS test system @@ -128,11 +116,7 @@ function is_dilos { typeset ID="" [[ -f /etc/os-release ]] && . /etc/os-release - if [[ $ID == "dilos" ]]; then - return 0 - else - return 1 - fi + [ "$ID" = "dilos" ] } # Determine if this is a 32-bit system @@ -141,11 +125,7 @@ function is_dilos function is_32bit { - if [[ $(getconf LONG_BIT) == "32" ]]; then - return 0 - else - return 1 - fi + [ $(getconf LONG_BIT) = "32" ] } # Determine if kmemleak is enabled @@ -154,11 +134,7 @@ function is_32bit function is_kmemleak { - if is_linux && [[ -e /sys/kernel/debug/kmemleak ]]; then - return 0 - else - return 1 - fi + is_linux && [ -e /sys/kernel/debug/kmemleak ] } # Determine whether a dataset is mounted @@ -1487,14 +1463,7 @@ function is_shared_smb # function not_shared { - typeset fs=$1 - - is_shared $fs - if (($? == 0)); then - return 1 - fi - - return 0 + ! is_shared $1 } # @@ -1504,14 +1473,7 @@ function not_shared # function not_shared_smb { - typeset fs=$1 - - is_shared_smb $fs - if (($? == 0)); then - return 1 - fi - - return 0 + ! is_shared_smb $1 } # @@ -1521,12 +1483,9 @@ function unshare_fs #fs { typeset fs=$1 - is_shared $fs || is_shared_smb $fs - if (($? == 0)); then + if is_shared $fs || is_shared_smb $fs; then zfs unshare $fs || log_fail "zfs unshare $fs failed" fi - - return 0 } # @@ -1536,14 +1495,10 @@ function share_nfs #fs { typeset fs=$1 - if is_linux; then - is_shared $fs - if (($? != 0)); then + if ! is_shared $fs; then + if is_linux; then log_must share "*:$fs" - fi - else - is_shared $fs - if (($? != 0)); then + else log_must share -F nfs $fs fi fi @@ -1558,14 +1513,10 @@ function unshare_nfs #fs { typeset fs=$1 - if is_linux; then - is_shared $fs - if (($? == 0)); then + if is_shared $fs; then + if is_linux; then log_must unshare -u "*:$fs" - fi - else - is_shared $fs - if (($? == 0)); then + else log_must unshare -F nfs $fs fi fi @@ -1693,10 +1644,7 @@ function is_global_zone return 0 else typeset cur_zone=$(zonename 2>/dev/null) - if [[ $cur_zone != "global" ]]; then - return 1 - fi - return 0 + [ $cur_zone = "global" ] fi } From 938d340158dd54c67d01ee448c124283f4c2c4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 4 Mar 2022 00:12:39 +0100 Subject: [PATCH 02/63] tests: zfs_unshare_001_pos: print which filesystem failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh index ac16fe97b928..3955f0ee3590 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_001_pos.ksh @@ -149,7 +149,7 @@ while (( i < ${#mntp_fs[*]} )); do else log_must zfs set sharenfs=on ${mntp_fs[((i+1))]} is_shared ${mntp_fs[i]} || \ - log_fail "'zfs set sharenfs=on' fails to share filesystem." + log_fail "'zfs set sharenfs=on' fails to share filesystem: ${mntp_fs[i]} not shared." fi ((i = i + 2)) @@ -166,7 +166,7 @@ log_must zfs unshare -a i=0 while (( i < ${#mntp_fs[*]} )); do not_shared ${mntp_fs[i]} || \ - log_fail "'zfs unshare -a' fails to unshare all shared zfs filesystems." + log_fail "'zfs unshare -a' fails to unshare all shared zfs filesystems: ${mntp_fs[i]} still shared." ((i = i + 2)) done From 945cdf2bf18cc6419a7b1cd23c9eecff515b5673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 5 Mar 2022 19:31:01 +0100 Subject: [PATCH 03/63] tests: don't always skip zfs_unshare tests on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, they'd all be skipped on FreeBSD where share is showmount Signed-off-by: Ahelenia Ziemiańska --- .../functional/cli_root/zfs_unshare/setup.ksh | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) mode change 100755 => 120000 tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh deleted file mode 100755 index 29f38e802c57..000000000000 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/ksh -p -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -. $STF_SUITE/include/libtest.shlib - -share -s -if [ $? -ne 0 ]; then - log_unsupported "The NFS utilities are not installed" -fi - -# Make sure NFS server is running before testing. -setup_nfs_server - -DISK=${DISKS%% *} -default_container_volume_setup $DISK diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh new file mode 120000 index 000000000000..b5208415d45c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/setup.ksh @@ -0,0 +1 @@ +../zfs_share/setup.ksh \ No newline at end of file From 8e63af20a7a0353426c1081dc413e36d48f6400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 6 Mar 2022 01:14:12 +0100 Subject: [PATCH 04/63] tests: don't use share/unshare exportfs aliases, support FreeBSD NFS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs-tests.sh | 2 - tests/test-runner/bin/zts-report.py.in | 8 - tests/zfs-tests/include/libtest.shlib | 159 ++++++++---------- .../cli_root/zfs_set/canmount_002_pos.ksh | 2 +- .../zfs_unshare/zfs_unshare_002_pos.ksh | 1 - .../tests/functional/migration/setup.ksh | 3 +- 6 files changed, 75 insertions(+), 100 deletions(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index d82c5923a990..a058eb9c59d1 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -303,8 +303,6 @@ constrain_path() { ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" - ln -fs "$STF_PATH/exportfs" "$STF_PATH/share" - ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare" elif [ "$UNAME" = "FreeBSD" ] ; then ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh" fi diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index 560f7dce6814..e15d6bded84a 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -82,11 +82,6 @@ tmpfile_reason = 'Kernel O_TMPFILE support required' # statx_reason = 'Kernel statx(2) system call required on Linux' -# -# Some tests require that the NFS client and server utilities be installed. -# -share_reason = 'NFS client and server utilities required' - # # Some tests require that the lsattr utility support the project id feature. # @@ -219,9 +214,7 @@ maybe = { 'cli_root/zfs_get/zfs_get_009_pos': ['SKIP', '5479'], 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason], 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason], - 'cli_root/zfs_share/setup': ['SKIP', share_reason], 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason], - 'cli_root/zfs_unshare/setup': ['SKIP', share_reason], 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason], 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'], 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'], @@ -267,7 +260,6 @@ if sys.platform.startswith('freebsd'): maybe.update({ 'cli_root/zfs_copies/zfs_copies_002_pos': ['FAIL', known_reason], 'cli_root/zfs_inherit/zfs_inherit_001_neg': ['FAIL', known_reason], - 'cli_root/zfs_share/zfs_share_011_pos': ['FAIL', known_reason], 'cli_root/zfs_share/zfs_share_concurrent_shares': ['FAIL', known_reason], 'cli_root/zpool_import/zpool_import_012_pos': ['FAIL', known_reason], diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 79930bb293e1..b9bebc1ab7e1 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -52,11 +52,7 @@ fi # function compare_version_gte { - if [[ "$(printf "$1\n$2" | sort -V | tail -n1)" == "$1" ]]; then - return 0 - else - return 1 - fi + [ "$(printf "$1\n$2" | sort -V | tail -n1)" = "$1" ] } # Linux kernel version comparison function @@ -222,15 +218,6 @@ function unmounted return 1 } -# split line on "," -# -# $1 - line to split - -function splitline -{ - echo $1 | tr ',' ' ' -} - function default_setup { default_setup_noexit "$@" @@ -1287,7 +1274,7 @@ function is_shared_freebsd { typeset fs=$1 - pgrep -q mountd && showmount -E | grep -qx $fs + pgrep -q mountd && showmount -E | grep -qx "$fs" } function is_shared_illumos @@ -1312,14 +1299,7 @@ function is_shared_illumos function is_shared_linux { typeset fs=$1 - typeset mtpt - - for mtpt in `share | awk '{print $1}'` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done - return 1 + ! exportfs -s | awk -v fs="${fs//\\/\\\\}" '/^\// && $1 == fs {exit 1}' } # @@ -1337,7 +1317,7 @@ function is_shared return 1 else mtpt=$(get_prop mountpoint "$fs") - case $mtpt in + case "$mtpt" in none|legacy|-) return 1 ;; *) fs=$mtpt @@ -1356,13 +1336,11 @@ function is_shared function is_exported_illumos { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/dfs/sharetab` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$mtpt" = "$fs" ] && return + done < /etc/dfs/sharetab return 1 } @@ -1370,13 +1348,11 @@ function is_exported_illumos function is_exported_freebsd { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/zfs/exports` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$mtpt" = "$fs" ] && return + done < /etc/zfs/exports return 1 } @@ -1384,13 +1360,11 @@ function is_exported_freebsd function is_exported_linux { typeset fs=$1 - typeset mtpt + typeset mtpt _ - for mtpt in `awk '{print $1}' /etc/exports.d/zfs.exports` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done + while read -r mtpt _; do + [ "$(printf "$mtpt")" = "$fs" ] && return + done < /etc/exports.d/zfs.exports return 1 } @@ -1435,23 +1409,13 @@ function is_exported function is_shared_smb { typeset fs=$1 - typeset mtpt - if datasetnonexists "$fs" ; then - return 1 - else - fs=$(echo $fs | tr / _) - fi + datasetexists "$fs" || return if is_linux; then - for mtpt in `net usershare list | awk '{print $1}'` ; do - if [[ $mtpt == $fs ]] ; then - return 0 - fi - done - return 1 + net usershare list | grep -xFq "${fs//\//_}" else - log_note "Currently unsupported by the test framework" + log_note "SMB on $(uname) currently unsupported by the test framework" return 1 fi } @@ -1495,13 +1459,22 @@ function share_nfs #fs { typeset fs=$1 - if ! is_shared $fs; then - if is_linux; then - log_must share "*:$fs" - else - log_must share -F nfs $fs - fi - fi + is_shared "$fs" && return + + case $(uname) in + Linux) + log_must exportfs "*:$fs" + ;; + FreeBSD) + typeset mountd + read -r mountd < /var/run/mountd.pid + log_must eval "printf '%s\t\n' \"$fs\" >> /etc/zfs/exports" + log_must kill -s HUP "$mountd" + ;; + *) + log_must share -F nfs "$fs" + ;; + esac return 0 } @@ -1513,13 +1486,23 @@ function unshare_nfs #fs { typeset fs=$1 - if is_shared $fs; then - if is_linux; then - log_must unshare -u "*:$fs" - else - log_must unshare -F nfs $fs - fi - fi + ! is_shared "$fs" && return + + case $(uname) in + Linux) + log_must exportfs -u "*:$fs" + ;; + FreeBSD) + typeset mountd + read -r mountd < /var/run/mountd.pid + awk -v fs="${fs//\\/\\\\}" '$1 != fs' /etc/zfs/exports > /etc/zfs/exports.$$ + log_must mv /etc/zfs/exports.$$ /etc/zfs/exports + log_must kill -s HUP "$mountd" + ;; + *) + log_must unshare -F nfs $fs + ;; + esac return 0 } @@ -1529,13 +1512,17 @@ function unshare_nfs #fs # function showshares_nfs { - if is_linux; then - share -v - else + case $(uname) in + Linux) + exportfs -v + ;; + FreeBSD) + showmount + ;; + *) share -F nfs - fi - - return 0 + ;; + esac } # @@ -1554,17 +1541,17 @@ function showshares_smb function check_nfs { - if is_linux; then - share -s - elif is_freebsd; then + case $(uname) in + Linux) + exportfs -s + ;; + FreeBSD) showmount -e - else + ;; + *) log_unsupported "Unknown platform" - fi - - if [[ $? -ne 0 ]]; then - log_unsupported "The NFS utilities are not installed" - fi + ;; + esac || log_unsupported "The NFS utilities are not installed" } # @@ -1584,12 +1571,12 @@ function setup_nfs_server # Re-synchronize /var/lib/nfs/etab with /etc/exports and # /etc/exports.d./* to provide a clean test environment. # - log_must share -r + log_must exportfs -r log_note "NFS server must be started prior to running ZTS." return elif is_freebsd; then - kill -s HUP $(cat /var/run/mountd.pid) + log_must kill -s HUP $( /dev/null 2>&1 log_must mounted $dataset log_must zfs unmount $dataset diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh index 1ded1b42c7ec..e26ca5c2aa89 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh @@ -179,4 +179,3 @@ while (( i < ${#mntp_fs[*]} )); do done log_pass "'zfs unshare [-a]' succeeds to be aware of legacy share." - diff --git a/tests/zfs-tests/tests/functional/migration/setup.ksh b/tests/zfs-tests/tests/functional/migration/setup.ksh index 58edc0a9291d..4992f954eeee 100755 --- a/tests/zfs-tests/tests/functional/migration/setup.ksh +++ b/tests/zfs-tests/tests/functional/migration/setup.ksh @@ -57,8 +57,7 @@ log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS rm -rf $NONZFS_TESTDIR || log_unresolved Could not remove $NONZFS_TESTDIR mkdir -p $NONZFS_TESTDIR || log_unresolved Could not create $NONZFS_TESTDIR -new_fs ${DEV_DSKDIR}/$NONZFS_DISK -(( $? != 0 )) && +new_fs ${DEV_DSKDIR}/$NONZFS_DISK || log_untested "Unable to setup a $NEWFS_DEFAULT_FS file system" log_must mount ${DEV_DSKDIR}/$NONZFS_DISK $NONZFS_TESTDIR From 29d947b69db407eea62ebd48a22473b0b9f17b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 8 Mar 2022 22:08:55 +0100 Subject: [PATCH 05/63] zfs: simplify usage_prop_cb values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- cmd/zfs/zfs_main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index b153d217df1a..6222f03de130 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -486,10 +486,7 @@ usage_prop_cb(int prop, void *cb) else (void) fprintf(fp, " NO "); - if (zfs_prop_values(prop) == NULL) - (void) fprintf(fp, "-\n"); - else - (void) fprintf(fp, "%s\n", zfs_prop_values(prop)); + (void) fprintf(fp, "%s\n", zfs_prop_values(prop) ?: "-"); return (ZPROP_CONT); } From bd2198eb1d5465e46d7b27e2308929dd81e9e2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 8 Mar 2022 22:50:45 +0100 Subject: [PATCH 06/63] zfs, zpool: safe_malloc() duplicate argv MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- cmd/zfs/zfs_main.c | 2 +- cmd/zpool/zpool_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 6222f03de130..404fef7fa813 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -8699,7 +8699,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 5d1cae3e9552..043b6a226462 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -10924,7 +10924,7 @@ main(int argc, char **argv) * Many commands modify input strings for string parsing reasons. * We create a copy to protect the original argv. */ - newargv = malloc((argc + 1) * sizeof (newargv[0])); + newargv = safe_malloc((argc + 1) * sizeof (newargv[0])); for (i = 0; i < argc; i++) newargv[i] = strdup(argv[i]); newargv[argc] = NULL; From 97701b93692866b0dcac120d6a28b160ef666832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 11 Mar 2022 01:42:32 +0100 Subject: [PATCH 07/63] tests: zfs_unshare_006: log_unsupported iff usershares are actually off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/test-runner/bin/zts-report.py.in | 2 +- .../zfs_unshare/zfs_unshare_006_pos.ksh | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in index e15d6bded84a..93d593791b5f 100755 --- a/tests/test-runner/bin/zts-report.py.in +++ b/tests/test-runner/bin/zts-report.py.in @@ -162,7 +162,6 @@ known = { 'casenorm/mixed_none_lookup_ci': ['FAIL', '7633'], 'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'], 'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason], - 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason], 'cli_root/zpool_import/import_rewind_device_replaced': ['FAIL', rewind_reason], 'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason], @@ -215,6 +214,7 @@ maybe = { 'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason], 'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason], 'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason], + 'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason], 'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason], 'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'], 'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'], diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh index b4318020cc7f..b6e5178cf2bb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh @@ -41,9 +41,7 @@ verify_runnable "global" -if is_linux; then - log_unsupported "some distros come with Samba "user shares" disabled" -fi +[ -d "/var/lib/samba/usershares" ] || log_unsupported "Samba usershares disabled" function cleanup { @@ -51,9 +49,10 @@ function cleanup log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared2 log_must zfs destroy -f $TESTPOOL/$TESTFS/shared3 + log_must rm -f /var/lib/samba/usershares/testpool_testfs_shared{2,3} } -log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified "\ +log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified" \ "protocol." log_onexit cleanup @@ -74,19 +73,19 @@ log_must zfs share -a log_must zfs unshare nfs -a # 3. Verify that only nfs filesystems are unshared. -log_must eval "not_shared $TESTPOOL/$TESTFS/shared1" -log_must eval "not_shared $TESTPOOL/$TESTFS/shared2" -log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared2" -log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared3" +log_must not_shared $TESTPOOL/$TESTFS/shared1 +log_must not_shared $TESTPOOL/$TESTFS/shared2 +log_must is_shared_smb $TESTPOOL/$TESTFS/shared2 +log_must is_shared_smb $TESTPOOL/$TESTFS/shared3 # 4. Share all filesystems again. log_must zfs share -a # 5. Invoke 'zfs unshare smb -a' and verify only smb filesystems are unshared. log_must zfs unshare smb -a -log_must eval "is_shared $TESTPOOL/$TESTFS/shared1" -log_must eval "is_shared $TESTPOOL/$TESTFS/shared2" -log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared2" -log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared3" +log_must is_shared $TESTPOOL/$TESTFS/shared1 +log_must is_shared $TESTPOOL/$TESTFS/shared2 +log_must not_shared_smb $TESTPOOL/$TESTFS/shared2 +log_must not_shared_smb $TESTPOOL/$TESTFS/shared3 log_pass "'zfs unshare [nfs|smb] -a' only works on the specified protocol." From 59ef554c2a0958be367620c0f94fea9b47f4d152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 14:23:51 +0100 Subject: [PATCH 08/63] tests: zfs_share_concurrent_shares: don't use log_musts in subprocesses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This thoroughly destroys logapi and races to the log files horribly Signed-off-by: Ahelenia Ziemiańska --- .../zfs_share/zfs_share_concurrent_shares.ksh | 133 +++++++++--------- 1 file changed, 64 insertions(+), 69 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh index dbaaf39b65d4..22b8af4e89d8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_concurrent_shares.ksh @@ -47,31 +47,20 @@ verify_runnable "global" function cleanup { wait - for fs in $(seq 0 50) + for fs in {0..50} do - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS1/$fs - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS2/$fs - log_must zfs set sharenfs=off $TESTPOOL/$TESTFS3/$fs - unshare_fs $TESTPOOL/$TESTFS1/$fs - unshare_fs $TESTPOOL/$TESTFS2/$fs - unshare_fs $TESTPOOL/$TESTFS3/$fs - - if mounted $TESTPOOL/$TESTFS1/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS1/$fs - fi - if mounted $TESTPOOL/$TESTFS2/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS2/$fs - fi - if mounted $TESTPOOL/$TESTFS3/$fs; then - log_must zfs unmount $TESTPOOL/$TESTFS3/$fs - fi - - datasetexists $TESTPOOL/$TESTFS1/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS1/$fs -f - datasetexists $TESTPOOL/$TESTFS2/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS2/$fs -f - datasetexists $TESTPOOL/$TESTFS3/$fs && \ - destroy_dataset $TESTPOOL/$TESTFS3/$fs -f + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + log_must zfs set sharenfs=off $TESTPOOL/$pfs/$fs + unshare_fs $TESTPOOL/$pfs/$fs + + if mounted $TESTPOOL/$pfs/$fs; then + log_must zfs unmount $TESTPOOL/$pfs/$fs + fi + + datasetexists $TESTPOOL/$pfs/$fs && \ + destroy_dataset $TESTPOOL/$pfs/$fs -f + done done log_must zfs share -a @@ -79,7 +68,7 @@ function cleanup function create_filesystems { - for fs in $(seq 0 50) + for fs in {0..50} do log_must zfs create -p $TESTPOOL/$TESTFS1/$fs log_must zfs create -p $TESTPOOL/$TESTFS2/$fs @@ -87,6 +76,12 @@ function create_filesystems done } +function sub_fail +{ + log_note $$: "$@" + exit 1 +} + # # Main test routine. # @@ -99,32 +94,45 @@ function test_share # filesystem typeset mntp=$(get_prop mountpoint $filesystem) not_shared $mntp || \ - log_fail "File system $filesystem is already shared." + sub_fail "File system $filesystem is already shared." zfs set sharenfs=on $filesystem || \ - log_fail "zfs set sharenfs=on $filesystem failed." + sub_fail "zfs set sharenfs=on $filesystem failed." is_shared $mntp || \ - log_fail "File system $filesystem is not shared (set sharenfs)." + sub_fail "File system $filesystem is not shared (set sharenfs)." # # Verify 'zfs share' works as well. # zfs unshare $filesystem || \ - log_fail "zfs unshare $filesystem failed." + sub_fail "zfs unshare $filesystem failed." is_shared $mntp && \ - log_fail "File system $filesystem is still shared." + sub_fail "File system $filesystem is still shared." + zfs share $filesystem || \ - log_fail "zfs share $filesystem failed." + sub_fail "zfs share $filesystem failed." is_shared $mntp || \ - log_fail "file system $filesystem is not shared (zfs share)." + sub_fail "file system $filesystem is not shared (zfs share)." + #log_note "Sharing a shared file system fails." zfs share $filesystem && \ - log_fail "zfs share $filesystem did not fail" + sub_fail "zfs share $filesystem did not fail" + return 0 } +function unshare_fs_nolog +{ + typeset fs=$1 + + if is_shared $fs || is_shared_smb $fs; then + zfs unshare $fs || + sub_fail "zfs unshare $fs: $?" + fi +} + # # Set the main process id so that we know to capture # failures from child processes and allow the parent process @@ -137,20 +145,16 @@ log_onexit cleanup create_filesystems child_pids=() -for fs in $(seq 0 50) +for fs in {0..50} do - test_share $TESTPOOL/$TESTFS1/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS1/$fs ==> $!" - test_share $TESTPOOL/$TESTFS2/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS2/$fs ==> $!" - test_share $TESTPOOL/$TESTFS3/$fs & - child_pids+=($!) - log_note "$TESTPOOL/$TESTFS3/$fs ==> $!" + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + test_share $TESTPOOL/$pfs/$fs & + child_pids+=($!) + log_note "$TESTPOOL/$pfs/$fs ==> $!" + done done -wait_for_children "${child_pids[@]}" || - log_fail "multithreaded share test failed" +log_must wait_for_children "${child_pids[@]}" log_note "Verify 'zfs share -a' succeeds." @@ -158,17 +162,16 @@ log_note "Verify 'zfs share -a' succeeds." # Unshare each of the file systems. # child_pids=() -for fs in $(seq 0 50) +for fs in {0..50} do - unshare_fs $TESTPOOL/$TESTFS1/$fs & - child_pids+=($!) - unshare_fs $TESTPOOL/$TESTFS2/$fs & - child_pids+=($!) - unshare_fs $TESTPOOL/$TESTFS3/$fs & - child_pids+=($!) + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + unshare_fs_nolog $TESTPOOL/$pfs/$fs & + child_pids+=($!) + log_note "$TESTPOOL/$pfs/$fs (unshare) ==> $!" + done done -wait_for_children "${child_pids[@]}" || - log_fail "multithreaded unshare failed" +log_must wait_for_children "${child_pids[@]}" # # Try a zfs share -a and verify all file systems are shared. @@ -181,21 +184,13 @@ log_must zfs share -a # unset __ZFS_POOL_EXCLUDE -for fs in $(seq 0 50) +for fs in {0..50} do - is_shared $TESTPOOL/$TESTFS1/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS1/$fs is not shared" - is_shared $TESTPOOL/$TESTFS2/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS2/$fs is not shared" - is_shared $TESTPOOL/$TESTFS3/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS3/$fs is not shared" - - is_exported $TESTPOOL/$TESTFS1/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS1/$fs is not exported" - is_exported $TESTPOOL/$TESTFS2/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS2/$fs is not exported" - is_exported $TESTPOOL/$TESTFS3/$fs || \ - log_fail "File system $TESTPOOL/$TESTFS3/$fs is not exported" + for pfs in $TESTFS1 $TESTFS2 $TESTFS3 + do + log_must is_shared $TESTPOOL/$pfs/$fs + log_must is_exported $TESTPOOL/$pfs/$fs + done done -log_pass "'zfs share [ -a ] ' succeeds as root." +log_pass "'zfs share [-a] ' succeeds as root." From a85030c798b542101afc0be5d6df6d7053f0b269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 14:23:51 +0100 Subject: [PATCH 09/63] tests: nonspecific cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/libtest.shlib | 106 +++++------------- tests/zfs-tests/include/properties.shlib | 10 +- .../zfs_reservation_002_pos.ksh | 12 +- .../cli_root/zfs_set/canmount_002_pos.ksh | 8 +- .../cli_root/zfs_set/snapdir_001_pos.ksh | 25 ++--- .../cli_root/zfs_set/zfs_set_001_neg.ksh | 6 +- .../cli_root/zfs_set/zfs_set_common.kshlib | 43 ++----- .../cli_root/zfs_share/zfs_share_011_pos.ksh | 14 +-- .../zfs_unshare/zfs_unshare_002_pos.ksh | 2 +- .../zpool_events/zpool_events_duplicates.ksh | 3 +- .../zpool_import/zpool_import_001_pos.ksh | 2 +- .../zpool_import/zpool_import_errata4.ksh | 18 +-- .../zpool_import_missing_003_pos.ksh | 6 +- .../cli_user/misc/zfs_share_001_neg.ksh | 11 +- .../cli_user/misc/zfs_unshare_001_neg.ksh | 12 +- .../functional/delegate/zfs_allow_001_pos.ksh | 6 +- .../functional/fault/auto_spare_shared.ksh | 5 +- .../functional/history/history_008_pos.ksh | 3 +- .../reservation/reservation_001_pos.ksh | 8 +- .../functional/rootpool/rootpool_002_neg.ksh | 2 +- .../tests/functional/rootpool/setup.ksh | 2 +- .../rsend/send-c_stream_size_estimate.ksh | 28 ++--- .../tests/functional/xattr/xattr_012_pos.ksh | 21 +--- tests/zfs-tests/tests/perf/perf.shlib | 2 +- 24 files changed, 102 insertions(+), 253 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index b9bebc1ab7e1..ad2c26976d14 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -1448,7 +1448,7 @@ function unshare_fs #fs typeset fs=$1 if is_shared $fs || is_shared_smb $fs; then - zfs unshare $fs || log_fail "zfs unshare $fs failed" + log_must zfs unshare $fs fi } @@ -2141,10 +2141,7 @@ function check_hotspare_state # pool disk state{inuse,avail} cur_state=$(get_device_state $pool $disk "spares") - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -2204,10 +2201,7 @@ function check_vdev_state # pool disk state{online,offline,unavail} cur_state=$(get_device_state $pool $disk) - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -3197,32 +3191,8 @@ function get_rootfs # function get_rootpool { - typeset rootfs="" - typeset rootpool="" - - if is_freebsd; then - rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') - elif ! is_linux; then - rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ - /etc/mnttab) - fi - if [[ -z "$rootfs" ]]; then - log_fail "Can not get rootpool" - fi - zfs list $rootfs > /dev/null 2>&1 - if (($? == 0)); then - echo ${rootfs%%/*} - else - log_fail "This is not a zfsroot system." - fi -} - -# -# Get the word numbers from a string separated by white space -# -function get_word_count -{ - echo $1 | wc -w + typeset rootfs=$(get_rootfs) + echo ${rootfs%%/*} } # @@ -3232,7 +3202,7 @@ function verify_disk_count { typeset -i min=${2:-1} - typeset -i count=$(get_word_count "$1") + typeset -i count=$(echo "$1" | wc -w) if ((count < min)); then log_untested "A minimum of $min disks is required to run." \ @@ -3266,26 +3236,23 @@ function ds_is_snapshot # function is_te_enabled { - svcs -H -o state labeld 2>/dev/null | grep "enabled" - if (($? != 0)); then - return 1 - else - return 0 - fi + svcs -H -o state labeld 2>/dev/null | grep -q "enabled" } # Utility function to determine if a system has multiple cpus. function is_mp { - if is_linux; then - (($(nproc) > 1)) - elif is_freebsd; then - sysctl -n kern.smp.cpus - else - (($(psrinfo | wc -l) > 1)) - fi - - return $? + case $(uname) in + Linux) + (($(nproc) > 1)) + ;; + FreeBSD) + sysctl -n kern.smp.cpus + ;; + *) + (($(psrinfo | wc -l) > 1)) + ;; + esac } function get_cpu_freq @@ -3409,20 +3376,20 @@ function write_compressible done done else - log_must eval "fio \ + log_must eval fio \ --name=job \ --fallocate=0 \ --minimal \ --randrepeat=0 \ --buffer_compress_percentage=66 \ --buffer_compress_chunk=4096 \ - --directory=$dir \ - --numjobs=$nfiles \ - --nrfiles=$nfiles \ + --directory="$dir" \ + --numjobs="$nfiles" \ + --nrfiles="$nfiles" \ --rw=write \ - --bs=$bs \ - --filesize=$megs \ - --filename_format='$fname.\$jobnum' >/dev/null" + --bs="$bs" \ + --filesize="$megs" \ + "--filename_format='$fname.\$jobnum' >/dev/null" fi } @@ -3593,24 +3560,13 @@ function zed_cleanup if ! is_linux; then return fi - EXTRA_ZEDLETS=$@ - log_must rm -f ${ZEDLET_DIR}/zed.rc - log_must rm -f ${ZEDLET_DIR}/zed-functions.sh - log_must rm -f ${ZEDLET_DIR}/all-syslog.sh - log_must rm -f ${ZEDLET_DIR}/all-debug.sh - log_must rm -f ${ZEDLET_DIR}/state - - if [[ -n "$EXTRA_ZEDLETS" ]] ; then - for i in $EXTRA_ZEDLETS ; do - log_must rm -f ${ZEDLET_DIR}/$i - done - fi - log_must rm -f $ZED_LOG - log_must rm -f $ZED_DEBUG_LOG - log_must rm -f $VDEVID_CONF_ETC - log_must rm -f $VDEVID_CONF - rmdir $ZEDLET_DIR + for extra_zedlet; do + log_must rm -f ${ZEDLET_DIR}/$extra_zedlet + done + log_must rm -fd ${ZEDLET_DIR}/zed.rc ${ZEDLET_DIR}/zed-functions.sh ${ZEDLET_DIR}/all-syslog.sh ${ZEDLET_DIR}/all-debug.sh ${ZEDLET_DIR}/state \ + $ZED_LOG $ZED_DEBUG_LOG $VDEVID_CONF_ETC $VDEVID_CONF \ + $ZEDLET_DIR } # diff --git a/tests/zfs-tests/include/properties.shlib b/tests/zfs-tests/include/properties.shlib index 6d467b60051d..e66dc0a21ede 100644 --- a/tests/zfs-tests/include/properties.shlib +++ b/tests/zfs-tests/include/properties.shlib @@ -100,12 +100,8 @@ else binary_props+=('zoned') fi -if is_linux; then - # Only older kernels support non-blocking mandatory locks - if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then - binary_props+=('nbmand') - fi -else +# Newer Linuxes dropped non-blocking mandatory locks +if ! is_linux || [ $(linux_version) -lt $(linux_version "4.4") ]; then binary_props+=('nbmand') fi @@ -114,7 +110,6 @@ function toggle_prop typeset ds=$1 typeset prop=$2 - datasetexists $ds || log_fail "$ds does not exist" typeset val=$(get_prop $prop $ds) typeset newval='off' @@ -137,7 +132,6 @@ function randomize_ds_props typeset ds=$1 typeset prop proplist val - datasetexists $ds || log_fail "$ds does not exist" if ds_is_volume $ds; then toggle_prop $ds readonly proplist="${vol_props[@]}" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh index c482f9c3c7df..7f90630360ff 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh @@ -73,16 +73,8 @@ log_must zfs set reservation=none $TESTPOOL/$RESERVATION2 for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2 do - - reserve=`zfs get -pH reservation $FS | awk '{print $3}'` - if [[ $reserve -ne 0 ]]; then - log_fail "ZFS get -p reservation did not return 0" - fi - - reserve=`zfs get -H reservation $FS | awk '{print $3}'` - if [[ $reserve != "none" ]]; then - log_fail "ZFS get reservation did not return 'none'" - fi + log_must [ $(zfs get -pHo value reservation $FS) -eq 0 ] + log_must [ $(zfs get -Ho value reservation $FS) = none ] done log_pass "Successfully set reservation to 0 and 'none'" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh index b1bc054776b8..bb7cd4cccc39 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @@ -77,9 +77,7 @@ function cleanup if datasetexists $ds; then mntp=$(get_prop mountpoint $ds) destroy_dataset $ds - if [[ -d $mntp ]]; then - rm -fr $mntp - fi + [ -d $mntp ] && rm -fr $mntp fi snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ @@ -91,9 +89,7 @@ function cleanup zfs unmount -a > /dev/null 2>&1 log_must zfs mount -a - if [[ -d $tmpmnt ]]; then - rm -fr $tmpmnt - fi + [ -d $tmpmnt ] && rm -fr $tmpmnt } log_assert "Setting canmount=noauto to file system, it must be successful." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh index 083a6b1f464f..29a709397422 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh @@ -57,22 +57,12 @@ function verify_snapdir_visible # $1 dataset, $2 hidden|visible typeset dataset=$1 typeset value=$2 typeset mtpt=$(get_prop mountpoint $dataset) - typeset name - - for name in `ls -a $mtpt`; do - if [[ $name == ".zfs" ]]; then - if [[ $value == "visible" ]]; then - return 0 - else - return 1 - fi - fi - done - if [[ $value == "visible" ]]; then - return 1 + # $mtpt/.zfs always actually exists so [ -d $mtpt/.zfs ] is always true + if ls -a $mtpt | grep -xFq .zfs; then + [ $value = "visible" ] else - return 0 + [ $value != "visible" ] fi } @@ -95,15 +85,14 @@ log_assert "Setting a valid snapdir property on a dataset succeeds." for dataset in $all_datasets; do for value in hidden visible; do - if [[ $dataset == "$TESTPOOL/$TESTVOL" ]] ; then + if [ "$dataset" = "$TESTPOOL/$TESTVOL" ]; then set_n_check_prop "$value" "snapdir" \ "$dataset" "false" else set_n_check_prop "$value" "snapdir" \ "$dataset" - verify_snapdir_visible $dataset $value - [[ $? -eq 0 ]] || \ - log_fail "$dataset/.zfs is not $value as expect." + verify_snapdir_visible $dataset $value || + log_fail "$dataset/.zfs is not $value as expected." fi done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh index c9bc7565abd6..5cfaec55e4bc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh @@ -77,9 +77,9 @@ while (( i < ${#dataset[@]} )); do done (( j += 1 )) done - # Additional recordsize - set_n_check_prop "recordsize" "2048K" "${dataset[i]}" false - set_n_check_prop "recordsize" "128B" "${dataset[i]}" false + # Additional recordsize + set_n_check_prop "2048K" "recordsize" "${dataset[i]}" false + set_n_check_prop "128B" "recordsize" "${dataset[i]}" false (( i += 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib index 7e34341d8526..04886e38c2d3 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib @@ -73,17 +73,17 @@ function set_n_check_prop reservation|reserv|quota ) if [[ $expect_value == "none" ]]; then [[ $cur_value != "0" ]] && \ - log_fail "The '$dataset' '$prop' value \ - '$cur_value' is not expected." + log_fail "The '$dataset' '$prop' value" \ + "'$cur_value' is not expected." elif [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; * ) if [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; esac @@ -244,11 +244,7 @@ function check_user_prop typeset expect_value="$3" typeset value=$(zfs get -p -H -o value "$user_prop" $dtst 2>&1) - if [[ "$expect_value" == "$value" ]]; then - return 0 - else - return 1 - fi + [ "$expect_value" = "$value" ] } # @@ -315,15 +311,8 @@ function check_prop_inherit typeset value=$(get_prop "$prop" "$checked_dtst") typeset source=$(get_source "$prop" "$checked_dtst") - if [[ "$value" != "$inherited_value" || \ - "$source" != "inherited from $inherited_dtst" ]] - then - log_note "expected (value '$inherited_value', source 'inherited from $inherited_dtst')," \ - "got (value '$value', source '$source')" - return 1 - else - return 0 - fi + [ "$value" = "$inherited_value" ] && + [ "$source" = "inherited from $inherited_dtst" ] } # @@ -346,12 +335,7 @@ function check_prop_received log_fail "Unable to get $prop received value for dataset" \ "$dataset" fi - if [[ "$received" == "$value" ]] - then - return 0 - else - return 1 - fi + if [ "$received" = "$value" ] } # @@ -371,10 +355,5 @@ function check_prop_missing if (($? != 0)); then log_fail "Unable to get $prop value for dataset $dataset" fi - if [[ "-" == "$value" ]] - then - return 0 - else - return 1 - fi + [ "$value" = "-" ] } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh index 131b039e1cd2..efd7a2d0c7bd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh @@ -67,20 +67,14 @@ typeset origdir=$PWD # unmount fails will not unshare the shared filesystem log_must zfs set sharenfs=on $TESTPOOL/$TESTFS log_must is_shared $TESTDIR -if cd $TESTDIR ; then - log_mustnot zfs umount $TESTPOOL/$TESTFS -else - log_fail "cd $TESTDIR fails" -fi +log_must cd $TESTDIR +log_mustnot zfs umount $TESTPOOL/$TESTFS log_must is_shared $TESTDIR # destroy fails will not unshare the shared filesystem log_must zfs create $TESTPOOL/$TESTFS/fs2 -if cd $TESTDIR/fs2 ; then - log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 -else - log_fail "cd $TESTDIR/fs2 fails" -fi +log_must cd $TESTDIR/fs2 +log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 log_must is_shared $TESTDIR/fs2 log_pass "Verify that umount and destroy fail, and do not unshare the shared" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh index e26ca5c2aa89..2fb8ae7814ea 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh @@ -91,7 +91,7 @@ function test_legacy_unshare # log_fail "'zfs set sharenfs=off' fails to make ZFS " \ "filesystem $filesystem unshared." - log_must eval "share_nfs $mntp" + log_must share_nfs $mntp is_shared $mntp || \ log_fail "'share' command fails to share ZFS file system." # diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh index 7023c49e51f2..142ebacd4558 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh @@ -103,7 +103,7 @@ function do_dup_test # Read the file a few times to generate some # duplicate errors of the same blocks for _ in {1..15}; do - dd if=$FILEPATH of=/dev/null bs=128K > /dev/null 2>&1 + dd if=$FILEPATH of=/dev/null bs=128K 2>/dev/null done log_must zinject -c all fi @@ -140,4 +140,3 @@ if $duplicates; then else log_pass "Duplicate I/O ereport errors are not posted" fi - 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 6369a297c17d..77fe116983df 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 @@ -79,7 +79,7 @@ function cleanup cleanup_filesystem $TESTPOOL1 $TESTFS - destroy_pool $TESTPOOL1 + destroy_pool $TESTPOOL1 [[ -d $ALTER_ROOT ]] && \ log_must rm -rf $ALTER_ROOT diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh index a199c2a7fb9d..e450d9a6222c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh @@ -43,18 +43,16 @@ POOL_FILE=missing_ivset.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" - log_must bzcat \ + log_must eval bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ - > /$TESTPOOL/$POOL_FILE - return 0 + "> /$TESTPOOL/$POOL_FILE" } function cleanup { log_must set_tunable32 DISABLE_IVSET_GUID_CHECK 0 poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME - [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE - return 0 + log_must rm -rf /$TESTPOOL/$POOL_FILE } log_onexit cleanup @@ -65,11 +63,7 @@ function has_ivset_guid # dataset ds="$1" ivset_guid=$(get_prop ivsetguid $ds) - if [ "$ivset_guid" == "-" ]; then - return 1 - else - return 0 - fi + [ "$ivset_guid" != "-" ] } # 1. Import a pre-packaged pool with Errata #4 and verify its state @@ -78,9 +72,7 @@ log_must zpool import -d /$TESTPOOL/ $POOL_NAME log_must eval "zpool status $POOL_NAME | grep -q 'Errata #4'" log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER" bm2_value=$(zpool get -H -o value feature@bookmark_v2 $POOL_NAME) -if [ "$bm2_value" != "disabled" ]; then - log_fail "initial pool's bookmark_v2 feature is not disabled" -fi +log_must [ "$bm2_value" = "disabled" ] log_mustnot has_ivset_guid $POOL_NAME/testfs@snap1 log_mustnot has_ivset_guid $POOL_NAME/testfs@snap2 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 9d4629a77912..bcb795b19f83 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 @@ -107,7 +107,7 @@ function verify function cleanup { - cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" + log_must cd $DEVICE_DIR for pool in $TESTPOOL1 $TESTPOOL2; do if poolexists "$pool" ; then @@ -136,7 +136,7 @@ function cleanup_all done log_must rm -f $DEVICE_DIR/$DEVICE_ARCHIVE - cd $CWD || log_fail "Unable change directory to $CWD" + log_must cd $CWD } @@ -146,7 +146,7 @@ log_assert "Verify that import could handle device overlapped." CWD=$PWD -cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" +log_must cd $DEVICE_DIR log_must tar cf $DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}* checksum1=$(sum $MYTESTFILE | awk '{print $1}') diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh index 14c35b3da664..0d15c0c8e5ae 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh @@ -41,7 +41,6 @@ # 1. Attempt to share a dataset # 2. Verify the dataset was not shared. # -# verify_runnable "global" @@ -51,17 +50,11 @@ fi log_assert "zfs share returns an error when run as a user" -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was incorrectly shared initially!" -fi +log_mustnot is_shared $TESTDIR/unshared log_mustnot zfs share $TESTPOOL/$TESTFS/unshared # Now verify that the above command didn't actually do anything -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was actually shared!" -fi +log_mustnot is_shared $TESTDIR/unshared log_pass "zfs share returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh index 7ae86fc4ec76..62b5bf39f43c 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh @@ -52,17 +52,13 @@ fi log_assert "zfs unshare returns an error when run as a user" # verify that the filesystem was shared initially -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" log_mustnot zfs unshare $TESTPOOL/$TESTFS/shared # now verify that the above command didn't do anything -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" log_pass "zfs unshare returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh b/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh index 1e0ed80d3203..22e52ccc90b7 100755 --- a/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh @@ -57,7 +57,7 @@ function cleanup restore_root_datasets } -log_assert "everyone' is interpreted as a keyword even if a user " \ +log_assert "'everyone' is interpreted as a keyword even if a user " \ "or group named 'everyone' exists." log_onexit cleanup @@ -79,9 +79,7 @@ if [[ $user_added == "TRUE" ]]; then fi log_note "Created a group called 'everyone'." -if ! cat /etc/group | awk -F: '{print $1}' | \ - grep -w 'everyone' > /dev/null 2>&1 -then +if ! grep -q '^everyone:' /etc/group; then group_added="TRUE" log_must add_group everyone fi diff --git a/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh b/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh index 4229537b3953..1cfa84a930bc 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh @@ -70,10 +70,7 @@ FAIL_FILEDEVPOOL2="$TEST_BASE_DIR/file-fail-dev2" SPARE_FILEDEV="$TEST_BASE_DIR/file-spare-dev" SPARE_DISKDEV="$(get_debug_device)" -for vdev in $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 \ - $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV; do - log_must truncate -s $MINVDEVSIZE $vdev -done +log_must truncate -s $MINVDEVSIZE $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV for spare in $SPARE_FILEDEV $SPARE_DISKDEV; do # 1. Create two pools diff --git a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh index 8e174dcb7ebf..26f728bb1779 100755 --- a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh @@ -55,8 +55,7 @@ log_assert "Pool history records all recursive operations." log_onexit cleanup root_testfs=$TESTPOOL/$TESTFS -fs1=$root_testfs/fs1; fs2=$root_testfs/fs2; fs3=$root_testfs/fs3 -for fs in $fs1 $fs2 $fs3; do +for fs in $root_testfs/fs{1..3}; do log_must zfs create $fs done diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh index b8220791f1d4..4f151ef15c1d 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh @@ -60,10 +60,10 @@ function cleanup log_onexit cleanup -log_assert "Verify that to set a reservation on a filesystem or volume must " \ +log_assert "Verify that to set a reservation on a filesystem or volume must" \ "use value smaller than space available property of pool" -space_avail=`get_prop available $TESTPOOL` +space_avail=$(get_prop available $TESTPOOL) if ! is_global_zone ; then OBJ_LIST="" @@ -103,7 +103,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zfs set reservation=$resv_size_set $obj - resv_size_get=`get_prop reservation $obj` + resv_size_get=$(get_prop reservation $obj) if [[ $resv_size_set != $resv_size_get ]]; then log_fail "Reservation not the expected value " \ "($resv_size_set != $resv_size_get)" @@ -111,7 +111,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zero_reservation $obj - new_space_avail=`get_prop available $obj` + new_space_avail=$(get_prop available $obj) # # Due to the way space is consumed and released by metadata we diff --git a/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh b/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh index 32bacf753a0e..0d592ad33e58 100755 --- a/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh @@ -54,7 +54,7 @@ typeset tmpfile="$TEST_BASE_DIR/mounted-datasets.$$" # damage done by the attempted pool destroy. The destroy itself should fail, # but some filesystems can become unmounted in the process, and aren't # automatically remounted. -mount -p | awk '{if ($4 == "zfs") print $1}' > $tmpfile +mount -p | awk '$4 == "zfs" {print $1}' > $tmpfile log_mustnot zpool destroy $rootpool diff --git a/tests/zfs-tests/tests/functional/rootpool/setup.ksh b/tests/zfs-tests/tests/functional/rootpool/setup.ksh index 8d8097108190..d81b3dfbdd40 100755 --- a/tests/zfs-tests/tests/functional/rootpool/setup.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/setup.ksh @@ -35,7 +35,7 @@ verify_runnable "global" # # This functionality is supported under Linux, but these test cases -# are disabled by default since they manipulate the systems root pool. +# are disabled by default since they manipulate the system's root pool. # if is_linux || is_freebsd; then log_unsupported "Supported but disabled by default" diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh index 056fc2cc2584..5d308d8f6574 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh @@ -40,19 +40,11 @@ function get_estimated_size { typeset cmd=$1 typeset ds=${cmd##* } - if is_freebsd; then - mkdir -p $BACKDIR - typeset tmpfile=$(TMPDIR=$BACKDIR mktemp) - else - typeset tmpfile=$(mktemp -p $BACKDIR) - fi - - eval "$cmd >$tmpfile" - [[ $? -eq 0 ]] || log_fail "get_estimated_size: $cmd" - typeset size=$(eval "awk '\$2 == \"$ds\" {print \$3}' $tmpfile") - rm -f $tmpfile + typeset tmpfile=$(mktemp $BACKDIR/size_estimate.XXXXXXXX) - echo $size + eval "$cmd >$tmpfile" || log_fail "$cmd: $?" + awk -v ds="$ds" '$2 == ds {print $3}' $tmpfile + rm -f $tmpfile } log_assert "Verify the stream size given by -P accounts for compressed send." @@ -75,23 +67,19 @@ for compress in "${compress_prop_vals[@]}"; do typeset ds_size=$(get_estimated_size "zfs send -nP $send_ds@snap") typeset ds_lrefer=$(get_prop lrefer $send_ds) - within_percent $ds_size $ds_lrefer 90 || log_fail \ - "$ds_size and $ds_lrefer differed by too much" + log_must within_percent $ds_size $ds_lrefer 90 typeset vol_size=$(get_estimated_size "zfs send -nP $send_vol@snap") typeset vol_lrefer=$(get_prop lrefer $send_vol) - within_percent $vol_size $vol_lrefer 90 || log_fail \ - "$vol_size and $vol_lrefer differed by too much" + log_must within_percent $vol_size $vol_lrefer 90 typeset ds_csize=$(get_estimated_size "zfs send -nP -c $send_ds@snap") typeset ds_refer=$(get_prop refer $send_ds) - within_percent $ds_csize $ds_refer 90 || log_fail \ - "$ds_csize and $ds_refer differed by too much" + log_must within_percent $ds_csize $ds_refer 90 typeset vol_csize=$(get_estimated_size "zfs send -nP -c $send_vol@snap") typeset vol_refer=$(get_prop refer $send_vol) - within_percent $vol_csize $vol_refer 90 || log_fail \ - "$vol_csize and $vol_refer differed by too much" + log_must within_percent $vol_csize $vol_refer 90 done log_pass "The stream size given by -P accounts for compressed send." diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh index 693ca0a634d5..f5c0ab0c22d0 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh @@ -52,19 +52,6 @@ function cleanup { fi } -function get_pool_size { - poolname=$1 - psize=$(zpool list -H -o allocated $poolname) - if [[ $psize == *[mM] ]] - then - returnvalue=$(echo $psize | sed -e 's/m//g' -e 's/M//g') - returnvalue=$((returnvalue * 1024)) - else - returnvalue=$(echo $psize | sed -e 's/k//g' -e 's/K//g') - fi - echo $returnvalue -} - log_assert "xattr file sizes count towards normal disk usage" log_onexit cleanup @@ -77,10 +64,10 @@ if is_global_zone then # get pool and filesystem sizes. Since we're starting with an empty # pool, the usage should be small - a few k. - POOL_SIZE=$(get_pool_size $TESTPOOL) + POOL_SIZE=$(get_pool_prop allocated $TESTPOOL) fi -FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) +FS_SIZE=$(get_prop used $TESTPOOL/$TESTFS) if is_freebsd; then # FreeBSD setextattr has awful scaling with respect to input size. @@ -106,7 +93,7 @@ sync_pool # now check to see if our pool disk usage has increased if is_global_zone then - NEW_POOL_SIZE=$(get_pool_size $TESTPOOL) + NEW_POOL_SIZE=$(get_pool_prop allocated $TESTPOOL) (($NEW_POOL_SIZE <= $POOL_SIZE)) && \ log_fail "The new pool size $NEW_POOL_SIZE was less \ than or equal to the old pool size $POOL_SIZE." @@ -114,7 +101,7 @@ then fi # also make sure our filesystem usage has increased -NEW_FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) +NEW_FS_SIZE=$(get_prop used $TESTPOOL/$TESTFS) (($NEW_FS_SIZE <= $FS_SIZE)) && \ log_fail "The new filesystem size $NEW_FS_SIZE was less \ than or equal to the old filesystem size $FS_SIZE." diff --git a/tests/zfs-tests/tests/perf/perf.shlib b/tests/zfs-tests/tests/perf/perf.shlib index 5a404df083e4..27f56676db8b 100644 --- a/tests/zfs-tests/tests/perf/perf.shlib +++ b/tests/zfs-tests/tests/perf/perf.shlib @@ -265,7 +265,7 @@ function apply_zinject_delays typeset idx=0 while [[ $idx -lt "${#ZINJECT_DELAYS[@]}" ]]; do [[ -n ${ZINJECT_DELAYS[$idx]} ]] || \ - log_must "No zinject delay found at index: $idx" + log_fail "No zinject delay found at index: $idx" for disk in $DISKS; do log_must zinject \ From 10ba242060b829751ea8226d6e84609ab2caed99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 8 Mar 2022 13:36:03 +0100 Subject: [PATCH 10/63] tests: don't fail if no fio or python3.sysctl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/libtest.shlib | 1 + .../zfs-tests/tests/functional/arc/setup.ksh | 2 ++ .../tests/functional/cache/cache_012_pos.ksh | 2 ++ .../cli_user/misc/arc_summary_001_pos.ksh | 27 +++---------------- .../cli_user/misc/arc_summary_002_neg.ksh | 4 +-- .../cli_user/misc/arcstat_001_pos.ksh | 5 ++-- .../compression/l2arc_compressed_arc.ksh | 2 ++ .../l2arc_compressed_arc_disabled.ksh | 2 ++ .../compression/l2arc_encrypted.ksh | 2 ++ .../l2arc_encrypted_no_compressed_arc.ksh | 2 ++ .../tests/functional/io/io_uring.ksh | 2 +- .../zfs-tests/tests/functional/io/libaio.ksh | 2 ++ tests/zfs-tests/tests/functional/io/mmap.ksh | 2 +- .../tests/functional/io/posixaio.ksh | 2 ++ tests/zfs-tests/tests/functional/io/psync.ksh | 2 ++ tests/zfs-tests/tests/functional/io/sync.ksh | 2 ++ .../functional/l2arc/l2arc_arcstats_pos.ksh | 2 ++ .../functional/l2arc/l2arc_l2miss_pos.ksh | 2 ++ .../functional/l2arc/l2arc_mfuonly_pos.ksh | 2 ++ .../l2arc/persist_l2arc_001_pos.ksh | 2 ++ .../l2arc/persist_l2arc_002_pos.ksh | 2 ++ .../l2arc/persist_l2arc_003_neg.ksh | 2 ++ .../l2arc/persist_l2arc_004_pos.ksh | 2 ++ .../l2arc/persist_l2arc_005_pos.ksh | 2 ++ .../tests/functional/no_space/enospc_rm.ksh | 2 ++ .../removal/remove_attach_mirror.ksh | 2 ++ .../tests/functional/slog/slog_015_neg.ksh | 2 ++ .../tests/functional/trim/trim_l2arc.ksh | 2 ++ .../tests/perf/regression/random_reads.ksh | 2 ++ .../perf/regression/random_readwrite.ksh | 2 ++ .../regression/random_readwrite_fixed.ksh | 2 ++ .../tests/perf/regression/random_writes.ksh | 2 ++ .../perf/regression/random_writes_zil.ksh | 2 ++ .../sequential_reads_arc_cached.ksh | 2 ++ .../sequential_reads_arc_cached_clone.ksh | 2 ++ .../sequential_reads_dbuf_cached.ksh | 2 ++ .../perf/regression/sequential_writes.ksh | 2 ++ 37 files changed, 74 insertions(+), 29 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index ad2c26976d14..828b842a655f 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3376,6 +3376,7 @@ function write_compressible done done else + command -v fio > /dev/null || log_unsupported "fio missing" log_must eval fio \ --name=job \ --fallocate=0 \ diff --git a/tests/zfs-tests/tests/functional/arc/setup.ksh b/tests/zfs-tests/tests/functional/arc/setup.ksh index 37b8f352cc64..60699d365eb5 100755 --- a/tests/zfs-tests/tests/functional/arc/setup.ksh +++ b/tests/zfs-tests/tests/functional/arc/setup.ksh @@ -26,5 +26,7 @@ . $STF_SUITE/include/libtest.shlib +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" + DISK=${DISKS%% *} default_setup $DISK diff --git a/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh b/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh index edefe9c1bf68..be250158bf7e 100755 --- a/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh @@ -44,6 +44,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Looping around a cache device succeeds." function cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh index befbea986e1b..5c3d06f228ce 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh @@ -27,34 +27,15 @@ . $STF_SUITE/include/libtest.shlib -log_assert "arc_summary generates output and doesn't return an error code" +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" -# Depending on which version of arc_summary is installed some command -# line options may not be available. The python3 version includes -# several additional flags. -python3 -V 2>&1 > /dev/null -if (( $? )); then - # Some systems have Python 3 installed, but only older versions - # that don't have the subprocess.run() functionality. We catch - # these with a separate test. Remove this when all systems have - # reached 3.5 or greater - VERSIONPYTEST=$(python3 -V) - if [[ ${VERSIONPYTEST:9:1} -lt 5 ]]; then - set -A args "" "-a" "-d" "-p 1" - else - set -A args "" "-a" "-d" "-p 1" "-g" "-s arc" "-r" - fi -else - set -A args "" "-a" "-d" "-p 1" -fi +log_assert "arc_summary generates output and doesn't return an error code" # Without this, the below checks aren't going to work the way we hope... set -o pipefail -typeset -i i=0 -while [[ $i -lt ${#args[*]} ]]; do - log_must eval "arc_summary ${args[i]} > /dev/null" - ((i = i + 1)) +for arg in "" "-a" "-d" "-p 1" "-g" "-s arc" "-r"; do + log_must eval "arc_summary $arg > /dev/null" done log_must eval "arc_summary | head > /dev/null" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh index de747fba89d1..59fe057e8ca6 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh @@ -27,11 +27,11 @@ . $STF_SUITE/include/libtest.shlib -typeset args=("-x" "-5" "-p 7" "--err" "-@") +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" log_assert "arc_summary generates an error code with invalid options" -for arg in "${args[@]}"; do +for arg in "-x" "-5" "-p 7" "--err" "-@"; do log_mustnot eval "arc_summary $arg > /dev/null" done diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh index ab574731fed9..af301829c196 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh @@ -1,4 +1,4 @@ -#! /bin/ksh -p +#!/bin/ksh -p # # CDDL HEADER START # @@ -27,6 +27,8 @@ . $STF_SUITE/include/libtest.shlib +is_freebsd && ! python3 -c 'import sysctl' 2>/dev/null && log_unsupported "python3 sysctl module missing" + set -A args "" "-s \",\"" "-x" "-v" \ "-f time,hit%,dh%,ph%,mh%" @@ -38,4 +40,3 @@ while [[ $i -lt ${#args[*]} ]]; do ((i = i + 1)) done log_pass "arcstat generates output and doesn't return an error code" - diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh index 5980ce156934..57f6b6a0242b 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh @@ -52,6 +52,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc enabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh index 4c3b6a61c25f..c8f4111744eb 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh @@ -52,6 +52,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc disabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh index fb460daf6837..f7b8a4b950d5 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh @@ -53,6 +53,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with encryption enabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh index 45ef489c3145..0838b2c93e68 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh @@ -53,6 +53,8 @@ export DIRECT=1 verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC with compressed_arc disabled succeeds." origin_carc_setting=$(get_tunable COMPRESSED_ARC_ENABLED) diff --git a/tests/zfs-tests/tests/functional/io/io_uring.ksh b/tests/zfs-tests/tests/functional/io/io_uring.ksh index 2d2b18f8bb5b..1ee5cee52227 100755 --- a/tests/zfs-tests/tests/functional/io/io_uring.ksh +++ b/tests/zfs-tests/tests/functional/io/io_uring.ksh @@ -44,7 +44,7 @@ if [[ $(linux_version) -lt $(linux_version "5.1") ]]; then log_unsupported "Requires io_uring support" fi -fio --ioengine=io_uring --parse-only || log_unsupported "io_uring support required" +fio --ioengine=io_uring --parse-only || log_unsupported "fio io_uring support required" function cleanup { diff --git a/tests/zfs-tests/tests/functional/io/libaio.ksh b/tests/zfs-tests/tests/functional/io/libaio.ksh index c434ad90ddd7..ef100209beac 100755 --- a/tests/zfs-tests/tests/functional/io/libaio.ksh +++ b/tests/zfs-tests/tests/functional/io/libaio.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/tests/zfs-tests/tests/functional/io/mmap.ksh b/tests/zfs-tests/tests/functional/io/mmap.ksh index e9600787a8bc..742c1f08f1c7 100755 --- a/tests/zfs-tests/tests/functional/io/mmap.ksh +++ b/tests/zfs-tests/tests/functional/io/mmap.ksh @@ -37,7 +37,7 @@ # 2. Repeat the test with additional fio(1) options. # -if ! compare_version_gte $(fio --version) "fio-2.3"; then +if ! compare_version_gte "$(fio --version)" "fio-2.3"; then log_unsupported "Requires fio-2.3 or newer" fi diff --git a/tests/zfs-tests/tests/functional/io/posixaio.ksh b/tests/zfs-tests/tests/functional/io/posixaio.ksh index 0758164c1673..c720aef9535f 100755 --- a/tests/zfs-tests/tests/functional/io/posixaio.ksh +++ b/tests/zfs-tests/tests/functional/io/posixaio.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/tests/zfs-tests/tests/functional/io/psync.ksh b/tests/zfs-tests/tests/functional/io/psync.ksh index efeb1103d8bb..8feb87d93a7c 100755 --- a/tests/zfs-tests/tests/functional/io/psync.ksh +++ b/tests/zfs-tests/tests/functional/io/psync.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "/$TESTPOOL/rw*" diff --git a/tests/zfs-tests/tests/functional/io/sync.ksh b/tests/zfs-tests/tests/functional/io/sync.ksh index 83f346c6972a..aaaa126efb1f 100755 --- a/tests/zfs-tests/tests/functional/io/sync.ksh +++ b/tests/zfs-tests/tests/functional/io/sync.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { log_must rm -f "$mntpnt/rw*" diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh index 3e76347b029a..69d60ab8bb90 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh @@ -40,6 +40,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "L2ARC MFU/MRU arcstats do not leak." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh index 783484f52c13..c9d5d7ffe1f1 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh @@ -38,6 +38,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "l2arc_misses does not increment upon reads from a pool without l2arc." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh index 5d0198c90c16..f2bada0ebbec 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "l2arc_mfuonly does not cache MRU buffers." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh index 0a9049490c71..95efa3f2d802 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh @@ -49,6 +49,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC with an unencrypted ZFS file system succeeds." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh index 93982e6c605b..bc6d71b7c459 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh @@ -52,6 +52,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC with an encrypted ZFS file system succeeds." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh index fe35c8fc4500..f8dc2b108f0d 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh @@ -38,6 +38,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Persistent L2ARC fails as expected when L2ARC_REBUILD_ENABLED = 0." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh index b40703180687..99cd3a2fc1d4 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh @@ -40,6 +40,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev not present." function cleanup diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh index 8ad648519f5c..ae0167eb49c5 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh @@ -39,6 +39,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Off/onlining an L2ARC device results in rebuilding L2ARC, vdev present." function cleanup diff --git a/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh b/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh index 065abc75977e..d0f4ff4a08fe 100755 --- a/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh +++ b/tests/zfs-tests/tests/functional/no_space/enospc_rm.ksh @@ -30,6 +30,8 @@ verify_runnable "both" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { destroy_pool $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh b/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh index 9bbb07cd9419..cdbd962025cf 100755 --- a/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh +++ b/tests/zfs-tests/tests/functional/removal/remove_attach_mirror.ksh @@ -32,6 +32,8 @@ # 4. Reattach it to make a mirror # +command -v fio > /dev/null || log_unsupported "fio missing" + TMPDIR=${TMPDIR:-$TEST_BASE_DIR} DISK1="$TMPDIR/dsk1" diff --git a/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh b/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh index 04fb225ed4ae..464be019dac3 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_015_neg.ksh @@ -31,6 +31,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # diff --git a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh index ecf9f3424eb5..bd2710c6ffc2 100755 --- a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh +++ b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh @@ -36,6 +36,8 @@ verify_runnable "global" +command -v fio > /dev/null || log_unsupported "fio missing" + log_assert "Trim of L2ARC succeeds." function cleanup diff --git a/tests/zfs-tests/tests/perf/regression/random_reads.ksh b/tests/zfs-tests/tests/perf/regression/random_reads.ksh index 70e273166161..0c73df67935c 100755 --- a/tests/zfs-tests/tests/perf/regression/random_reads.ksh +++ b/tests/zfs-tests/tests/perf/regression/random_reads.ksh @@ -38,6 +38,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/random_readwrite.ksh b/tests/zfs-tests/tests/perf/regression/random_readwrite.ksh index 4dc1e3ddba9a..3a358774f565 100755 --- a/tests/zfs-tests/tests/perf/regression/random_readwrite.ksh +++ b/tests/zfs-tests/tests/perf/regression/random_readwrite.ksh @@ -38,6 +38,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/random_readwrite_fixed.ksh b/tests/zfs-tests/tests/perf/regression/random_readwrite_fixed.ksh index cdf15c701277..afaffb9e648f 100755 --- a/tests/zfs-tests/tests/perf/regression/random_readwrite_fixed.ksh +++ b/tests/zfs-tests/tests/perf/regression/random_readwrite_fixed.ksh @@ -28,6 +28,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/random_writes.ksh b/tests/zfs-tests/tests/perf/regression/random_writes.ksh index 30db7564c2dc..06061a9b7462 100755 --- a/tests/zfs-tests/tests/perf/regression/random_writes.ksh +++ b/tests/zfs-tests/tests/perf/regression/random_writes.ksh @@ -37,6 +37,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/random_writes_zil.ksh b/tests/zfs-tests/tests/perf/regression/random_writes_zil.ksh index ff6d465bb722..7e5a741137d6 100755 --- a/tests/zfs-tests/tests/perf/regression/random_writes_zil.ksh +++ b/tests/zfs-tests/tests/perf/regression/random_writes_zil.ksh @@ -18,6 +18,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached.ksh b/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached.ksh index d885d0b7f992..ee14f2ce7807 100755 --- a/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached.ksh +++ b/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached.ksh @@ -28,6 +28,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached_clone.ksh b/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached_clone.ksh index 80081a098e8f..2cc81d5cd341 100755 --- a/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached_clone.ksh +++ b/tests/zfs-tests/tests/perf/regression/sequential_reads_arc_cached_clone.ksh @@ -34,6 +34,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/sequential_reads_dbuf_cached.ksh b/tests/zfs-tests/tests/perf/regression/sequential_reads_dbuf_cached.ksh index 0402b48a3e9c..9a244324a751 100755 --- a/tests/zfs-tests/tests/perf/regression/sequential_reads_dbuf_cached.ksh +++ b/tests/zfs-tests/tests/perf/regression/sequential_reads_dbuf_cached.ksh @@ -32,6 +32,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat diff --git a/tests/zfs-tests/tests/perf/regression/sequential_writes.ksh b/tests/zfs-tests/tests/perf/regression/sequential_writes.ksh index 7850bc0375df..a51655cc3719 100755 --- a/tests/zfs-tests/tests/perf/regression/sequential_writes.ksh +++ b/tests/zfs-tests/tests/perf/regression/sequential_writes.ksh @@ -37,6 +37,8 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/perf/perf.shlib +command -v fio > /dev/null || log_unsupported "fio missing" + function cleanup { # kill fio and iostat From 9077b633c89638c48532ff7f3c6734b0e962bc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 00:16:55 +0100 Subject: [PATCH 11/63] tests: mixed_create_failure: undefined log_err -> log_fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: #13215 Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/casenorm/mixed_create_failure.ksh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh b/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh index 51b5bb3f6584..7d22fc914453 100755 --- a/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh +++ b/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh @@ -100,7 +100,7 @@ function test_ops save_name="$test_path/$name" break; else - log_err "$cmd failed with unexpected error : $out" + log_fail "$cmd failed: $out" fi fi done @@ -111,7 +111,7 @@ function test_ops out=$($cmd 2>&1) ret=$? if (($ret != 0)); then - log_err "cmd:$cmd failed out:$out" + log_fail "$cmd failed: $out" fi # Now, try to rename the tmp_obj to the name which we failed to add earlier. @@ -120,9 +120,9 @@ function test_ops ret=$? if (($ret != 0)); then if [[ $out = *@(No space left on device)* ]]; then - log_note "$cmd failed as expected : $out" + log_note "$cmd failed as expected: $out" else - log_err "$cmd failed with : $out" + log_fail "$cmd failed: $out" fi fi } From 8e95600429ef932070314d9bec52de8c640ef501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 00:18:26 +0100 Subject: [PATCH 12/63] tests: zfs_create_nomount: undefined local -> typeset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh index e1fbbe63ad31..5b0478e855cf 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_nomount.ksh @@ -30,7 +30,7 @@ verify_runnable "both" function cleanup { - local ds + typeset ds for ds in "$fs" "$vol"; do datasetexists "$ds" && destroy_dataset "$ds" From 2ce5d74e60fef4f9504a0e30bdbd747efc60b098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 00:30:52 +0100 Subject: [PATCH 13/63] tests: snapshot_00[15]_pos: use cksum instead of sum -r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This only worked by accident on FreeBSD, where sum doesn't take flags POSIX guarantees us cksum (Ethernet CRC) ‒ use that instead Signed-off-by: Ahelenia Ziemiańska --- .../functional/snapshot/snapshot_001_pos.ksh | 19 ++++++------------- .../functional/snapshot/snapshot_005_pos.ksh | 8 ++++---- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh index 8b8c118d9dfb..6a55a902fb20 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh index c1917dff1299..9cff0decc698 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh @@ -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 From bdb0ca61ab06fc57d6c11bb93cc96fc4443b55f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 00:51:07 +0100 Subject: [PATCH 14/63] tests: replace sum(1) with cksum(1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/commands.cfg | 1 - .../zfs-tests/tests/functional/acl/acl_common.kshlib | 12 +++++------- .../tests/functional/cli_root/cli_common.kshlib | 2 +- .../cli_root/zfs_rollback/zfs_rollback_common.kshlib | 6 +++--- .../cli_root/zpool_import/zpool_import_001_pos.ksh | 7 +++---- .../cli_root/zpool_import/zpool_import_002_pos.ksh | 7 +++---- .../zpool_import/zpool_import_all_001_pos.ksh | 7 +++---- .../zpool_import/zpool_import_missing_001_pos.ksh | 8 +++----- .../zpool_import/zpool_import_missing_003_pos.ksh | 7 +++---- .../zpool_import/zpool_import_rename_001_pos.ksh | 7 +++---- .../tests/functional/migration/migration.cfg | 5 ++--- .../tests/functional/migration/migration.kshlib | 8 ++------ 12 files changed, 31 insertions(+), 46 deletions(-) diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index b247a67ff669..50449633ac72 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 ba08bcb48bef..1e9d736fdfdb 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 # 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 4788de598663..2b84f6a9c1cd 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 # } # -# Compare the check sum of target files with the original file +# Compare the checksum of target files with the original file # function compare_cksum # ... 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 2eadb68c372d..04a886773270 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 77fe116983df..e159c1a04195 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 898f93cc9062..95ebe0ae294d 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 b384ec9b1fce..4ebe6b59141d 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 3b5167ff0374..22cec24ff457 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 bcb795b19f83..ac76f879c2e8 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 bb6bf86d7881..4e49e8d01d88 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 12a5a7799b7a..a8a24e0a3b51 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 a2b4ed99b11e..2b1955fe93f1 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" From fa07bcb3b7bbd0773eeb0793daffca0658a11c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 00:56:32 +0100 Subject: [PATCH 15/63] tests: redacted_send: explicitly assume instant /dev on non-Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The users spew udevadm ENOENTs on FreeBSD Signed-off-by: Ahelenia Ziemiańska --- .../zfs-tests/tests/functional/redacted_send/redacted.kshlib | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib index 30101939db64..6ad2e47018c8 100644 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib @@ -29,6 +29,10 @@ . $STF_SUITE/tests/functional/rsend/rsend.kshlib . $STF_SUITE/tests/functional/redacted_send/redacted.cfg +if ! is_linux; then + alias udevadm=: +fi + function setup_dataset { typeset ds_name=$1 From 278f1da441b261c2cf3e109d08696a8933e35f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 12:48:23 +0100 Subject: [PATCH 16/63] tests: vdev_zaps_007: log_must with > must eval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh index 1f71b11ee562..e04681e67f7d 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh @@ -49,7 +49,7 @@ assert_zap_common $TESTPOOL ${DISK_ARR[1]} "leaf" $orig_leaf1 log_must zpool split $TESTPOOL $POOL2 ${DISK_ARR[1]} # Make sure old pool's ZAPs are consistent. -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" new_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf) new_top_s0=$(get_top_vd_zap ${DISK_ARR[0]} $conf) @@ -62,7 +62,7 @@ log_assert "Per-vdev ZAPs persist on the new pool after import." # Import the split pool. log_must zpool import $POOL2 -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" new_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf) new_top_s1=$(get_top_vd_zap ${DISK_ARR[1]} $conf) From c0529391a3015781eb5ba93343bdaba7ea6dfcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 13:39:34 +0100 Subject: [PATCH 17/63] tests: don't >-redirect without eval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/libtest.shlib | 36 ++++++++------ .../functional/cli_root/zdb/zdb_recover_2.ksh | 2 +- .../cli_root/zfs_mount/zfs_multi_mount.ksh | 4 +- .../zfs_receive/zfs_receive_010_pos.ksh | 13 +++-- .../zfs_receive/zfs_receive_new_props.ksh | 4 +- .../cli_root/zfs_send/zfs_send_007_pos.ksh | 2 +- .../cli_root/zfs_share/zfs_share_013_pos.ksh | 24 ++++----- .../zpool_expand/zpool_expand_003_neg.ksh | 27 +++------- .../cli_root/zpool_import/zpool_import.kshlib | 2 +- .../zpool_import/zpool_import_errata3.ksh | 8 ++- .../zpool_upgrade/zpool_upgrade_008_pos.ksh | 2 +- .../large_dnode/large_dnode_005_pos.ksh | 4 +- .../large_dnode/large_dnode_009_pos.ksh | 2 +- .../functional/history/history_005_neg.ksh | 8 +-- .../functional/history/history_006_neg.ksh | 6 +-- .../tests/functional/inuse/inuse_001_pos.ksh | 8 +-- .../tests/functional/inuse/inuse_003_pos.ksh | 12 ++--- .../zfs-tests/tests/functional/mmp/mmp.kshlib | 6 +-- .../tests/functional/mmp/mmp_on_off.ksh | 6 +-- .../tests/functional/mmp/mmp_on_thread.ksh | 4 +- .../functional/no_space/enospc_002_pos.ksh | 4 +- .../procfs/procfs_list_stale_read.ksh | 4 +- .../redundancy/redundancy_draid.ksh | 4 +- .../redundancy/redundancy_raidz.ksh | 4 +- .../replacement/resilver_restart_001.ksh | 2 +- .../replacement/resilver_restart_002.ksh | 2 +- .../tests/functional/rsend/rsend.kshlib | 17 ++----- .../functional/snapshot/clone_001_pos.ksh | 3 +- .../functional/snapshot/rollback_001_pos.ksh | 6 +-- .../functional/snapshot/rollback_002_pos.ksh | 9 ++-- .../functional/snapshot/rollback_003_pos.ksh | 4 +- .../functional/snapshot/snapshot_001_pos.ksh | 2 +- .../functional/snapshot/snapshot_002_pos.ksh | 49 +++++++------------ .../functional/snapshot/snapshot_003_pos.ksh | 19 +++---- .../functional/snapshot/snapshot_004_pos.ksh | 10 ++-- .../functional/snapshot/snapshot_005_pos.ksh | 13 ++--- .../functional/snapshot/snapshot_006_pos.ksh | 40 +++++++-------- .../functional/snapshot/snapshot_007_pos.ksh | 25 ++++------ .../functional/snapshot/snapshot_008_pos.ksh | 8 ++- .../functional/snapshot/snapshot_011_pos.ksh | 6 +-- .../functional/snapshot/snapshot_013_pos.ksh | 6 +-- .../functional/snapshot/snapshot_014_pos.ksh | 3 +- .../vdev_zaps/vdev_zaps_001_pos.ksh | 2 +- .../vdev_zaps/vdev_zaps_002_pos.ksh | 2 +- .../vdev_zaps/vdev_zaps_003_pos.ksh | 2 +- .../vdev_zaps/vdev_zaps_004_pos.ksh | 6 +-- .../vdev_zaps/vdev_zaps_005_pos.ksh | 4 +- .../vdev_zaps/vdev_zaps_006_pos.ksh | 2 +- .../vdev_zaps/vdev_zaps_007_pos.ksh | 2 +- .../zpool_influxdb/zpool_influxdb.ksh | 11 ++--- .../functional/zvol/zvol_swap/cleanup.ksh | 4 +- 51 files changed, 190 insertions(+), 265 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 828b842a655f..a78c10ce2ee6 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -657,7 +657,7 @@ function default_container_cleanup destroy_dataset "$TESTPOOL/$TESTCTR" "-Rf" [[ -e $TESTDIR1 ]] && \ - log_must rm -rf $TESTDIR1 > /dev/null 2>&1 + log_must rm -rf $TESTDIR1 default_cleanup } @@ -3680,15 +3680,17 @@ function is_swap_inuse return 1 fi - if is_linux; then - swapon -s | grep -w $(readlink -f $device) > /dev/null 2>&1 - elif is_freebsd; then - swapctl -l | grep -w $device - else - swap -l | grep -w $device > /dev/null 2>&1 - fi - - return $? + case "$(uname)" in + Linux) + swapon -s | grep -wq $(readlink -f $device) + ;; + FreeBSD) + swapctl -l | grep -wq $device + ;; + *) + swap -l | grep -wq $device + ;; + esac } # @@ -3698,14 +3700,18 @@ function swap_setup { typeset swapdev=$1 - if is_linux; then + case "$(uname)" in + Linux) log_must eval "mkswap $swapdev > /dev/null 2>&1" log_must swapon $swapdev - elif is_freebsd; then + ;; + FreeBSD) log_must swapctl -a $swapdev - else - log_must swap -a $swapdev - fi + ;; + *) + log_must swap -a $swapdev + ;; + esac return 0 } diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh index 6470327a1765..d4529ff01105 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_recover_2.ksh @@ -48,7 +48,7 @@ verify_disk_count "$DISKS" 2 default_mirror_setup_noexit $DISKS file_write -o create -w -f $init_data -b $blksize -c $write_count -log_must echo "zfs" >> $init_data +echo "zfs" >> $init_data sync_pool $TESTPOOL output=$(zdb -r $TESTPOOL/$TESTFS file1 $tmpfile) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh index bd86eaa16bb4..c4b4f0773137 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_multi_mount.ksh @@ -56,7 +56,7 @@ log_must zfs create $TESTDS MNTPFS="$(get_prop mountpoint $TESTDS)" FILENAME="$MNTPFS/file" log_must mkfile 128k $FILENAME -log_must exec 9<> $FILENAME # open file +log_must eval "exec 9<> $FILENAME" # open file # 3. Lazy umount if is_freebsd; then @@ -74,7 +74,7 @@ log_must zfs mount $TESTDS if [ ! -f $FILENAME ]; then log_fail "Lazy remount failed" fi -log_must exec 9>&- # close fd +log_must eval "exec 9>&-" # close fd # 5. Verify multiple mounts of the same dataset are possible MNTPFS2="$MNTPFS-second" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh index 47e23e6ebca7..c91172ee048e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_010_pos.ksh @@ -134,8 +134,7 @@ dd if=/dev/urandom of=$mntpnt/f18 bs=128k count=64 touch $mntpnt2/f18 # Remove objects that are intended to be missing. -rm $mntpnt/h17 -rm $mntpnt2/h* +rm $mntpnt/h17 $mntpnt2/h* # Add empty objects to $fs to exercise dmu_traverse code for i in {1..100}; do @@ -145,15 +144,15 @@ done log_must zfs snapshot $fs@s1 log_must zfs snapshot $fs2@s1 -log_must zfs send $fs@s1 > $TESTDIR/zr010p -log_must zfs send $fs2@s1 > $TESTDIR/zr010p2 +log_must eval "zfs send $fs@s1 > $TESTDIR/zr010p" +log_must eval "zfs send $fs2@s1 > $TESTDIR/zr010p2" # # Test that, when we receive a full send as a clone of itself, # nop-write saves us all the space used by data blocks. # -cat $TESTDIR/zr010p | log_must zfs receive -o origin=$fs@s1 $rfs +log_must eval "zfs receive -o origin=$fs@s1 $rfs < $TESTDIR/zr010p" size=$(get_prop used $rfs) size2=$(get_prop used $fs) if [[ $size -ge $(($size2 / 10)) ]] then @@ -163,13 +162,13 @@ fi log_must zfs destroy -fr $rfs # Correctness testing: receive each full send as a clone of the other fiesystem. -cat $TESTDIR/zr010p | log_must zfs receive -o origin=$fs2@s1 $rfs +log_must eval "zfs receive -o origin=$fs2@s1 $rfs < $TESTDIR/zr010p" mntpnt_old=$(get_prop mountpoint $fs) mntpnt_new=$(get_prop mountpoint $rfs) log_must directory_diff $mntpnt_old $mntpnt_new log_must zfs destroy -r $rfs -cat $TESTDIR/zr010p2 | log_must zfs receive -o origin=$fs@s1 $rfs +log_must eval "zfs receive -o origin=$fs@s1 $rfs < $TESTDIR/zr010p2" mntpnt_old=$(get_prop mountpoint $fs2) mntpnt_new=$(get_prop mountpoint $rfs) log_must directory_diff $mntpnt_old $mntpnt_new diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh index 54f13355f5e8..ae63f5c6ac1d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_new_props.ksh @@ -70,8 +70,8 @@ log_must zpool set feature@filesystem_limits=enabled "$rpoolname" log_must zfs create -o filesystem_limit=100 "$sendfs" log_must zfs snapshot "$sendfs@a" -log_must zfs send -R "$sendfs@a" >"$streamfile" -log_must eval "zfs recv -svuF $recvfs <$streamfile" +log_must eval "zfs send -R \"$sendfs@a\" >\"$streamfile\"" +log_must eval "zfs recv -svuF \"$recvfs\" <\"$streamfile\"" log_pass "ZFS can handle receiving streams with filesystem limits on \ pools where the feature was recently enabled" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh index 306fabc8cef4..85d076310588 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh @@ -57,7 +57,7 @@ test_pool () POOL=$1 log_must zfs create -o recordsize=512 $POOL/fs mntpnt=$(get_prop mountpoint "$POOL/fs") - log_must dd if=/dev/urandom of=${mntpnt}/file bs=512 count=1 2>/dev/null + log_must eval "dd if=/dev/urandom of=${mntpnt}/file bs=512 count=1 2>/dev/null" object=$(ls -i $mntpnt | awk '{print $1}') log_must zfs snapshot $POOL/fs@a while true; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh index 150eddac0ebb..e9766de49285 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_013_pos.ksh @@ -46,35 +46,35 @@ cleanup log_must zfs set sharenfs="rw=[::1]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" log_must zfs set sharenfs="rw=[2::3]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "2::3(" <<< "$output" > /dev/null +log_must grep -q "2::3(" <<< "$output" log_must zfs set sharenfs="rw=[::1]:[2::3]" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null -log_must grep "2::3(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" +log_must grep -q "2::3(" <<< "$output" log_must zfs set sharenfs="rw=[::1]/64" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1/64(" <<< "$output" > /dev/null +log_must grep -q "::1/64(" <<< "$output" log_must zfs set sharenfs="rw=[2::3]/128" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "2::3/128(" <<< "$output" > /dev/null +log_must grep -q "2::3/128(" <<< "$output" log_must zfs set sharenfs="rw=[::1]/32:[2::3]/128" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1/32(" <<< "$output" > /dev/null -log_must grep "2::3/128(" <<< "$output" > /dev/null +log_must grep -q "::1/32(" <<< "$output" +log_must grep -q "2::3/128(" <<< "$output" log_must zfs set sharenfs="rw=[::1]:[2::3]/64:[2a01:1234:1234:1234:aa34:234:1234:1234]:1.2.3.4/24" $TESTPOOL/$TESTFS output=$(showshares_nfs 2>&1) -log_must grep "::1(" <<< "$output" > /dev/null -log_must grep "2::3/64(" <<< "$output" > /dev/null -log_must grep "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" > /dev/null -log_must grep "1\\.2\\.3\\.4/24(" <<< "$output" > /dev/null +log_must grep -q "::1(" <<< "$output" +log_must grep -q "2::3/64(" <<< "$output" +log_must grep -q "2a01:1234:1234:1234:aa34:234:1234:1234(" <<< "$output" +log_must grep -q "1\\.2\\.3\\.4/24(" <<< "$output" log_pass "NFS share ip address propagated correctly." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh index b3c71b666a59..2681e69f4e72 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh @@ -39,7 +39,6 @@ # Once set zpool autoexpand=off, zpool can *NOT* autoexpand by # Dynamic VDEV Expansion # -# # STRATEGY: # 1) Create three vdevs (loopback, scsi_debug, and file) # 2) Create pool by using the different devices and set autoexpand=off @@ -73,7 +72,7 @@ log_onexit cleanup log_assert "zpool can not expand if set autoexpand=off after vdev expansion" -for type in " " mirror raidz draid; do +for type in "" mirror raidz draid; do log_note "Setting up loopback, scsi_debug, and file vdevs" log_must truncate -s $org_size $FILE_LO DEV1=$(losetup -f) @@ -89,11 +88,7 @@ for type in " " mirror raidz draid; do # The -f is required since we're mixing disk and file vdevs. log_must zpool create -f $TESTPOOL1 $type $DEV1 $DEV2 $DEV3 - typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1) - if [[ $autoexp != "off" ]]; then - log_fail "zpool $TESTPOOL1 autoexpand should be off but is " \ - "$autoexp" - fi + log_must [ "$(get_pool_prop autoexpand $TESTPOOL1)" = "off" ] typeset prev_size=$(get_pool_prop size $TESTPOOL1) @@ -107,8 +102,8 @@ for type in " " mirror raidz draid; do log_must losetup -c $DEV1 sleep 3 - echo "2" > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb - echo "1" > /sys/class/block/$DEV2/device/rescan + log_must eval "echo 2 > /sys/bus/pseudo/drivers/scsi_debug/virtual_gb" + log_must eval "echo 1 > /sys/class/block/$DEV2/device/rescan" block_device_wait sleep 3 @@ -119,18 +114,10 @@ for type in " " mirror raidz draid; do # check for zpool history for the pool size expansion zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | \ - grep "vdev online" >/dev/null 2>&1 - - if [[ $? -eq 0 ]]; then - log_fail "pool $TESTPOOL1 is not autoexpand after vdev " \ - "expansion" - fi - - typeset expand_size=$(get_pool_prop size $TESTPOOL1) + grep "vdev online" && + log_fail "pool $TESTPOOL1 is not autoexpand after vdev expansion" - if [[ "$prev_size" != "$expand_size" ]]; then - log_fail "pool $TESTPOOL1 size changed after vdev expansion" - fi + log_must [ "$(get_pool_prop size $TESTPOOL1)" = "$prev_size" ] cleanup done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 8bbd668a9317..5503d30b5512 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -22,7 +22,7 @@ function cleanup { # clear any remaining zinjections - log_must zinject -c all > /dev/null + log_must eval "zinject -c all > /dev/null" destroy_pool $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh index 40b6ca1c1897..c5e578d79edb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata3.ksh @@ -44,17 +44,15 @@ POOL_FILE=cryptv0.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" - log_must bzcat \ + log_must eval bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ - > /$TESTPOOL/$POOL_FILE - return 0 + "> /$TESTPOOL/$POOL_FILE" } function cleanup { poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME - [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE - return 0 + log_must rm -f /$TESTPOOL/$POOL_FILE } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh index d930919652bf..71d59b93a4ca 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade_008_pos.ksh @@ -71,7 +71,7 @@ for ver_old in $VERSIONS; do typeset -i ver_new=$(random_int_between $ver_old $MAX_VER) create_old_pool $ver_old - log_must zpool upgrade -V $ver_new $pool_name > /dev/null + log_must eval 'zpool upgrade -V $ver_new $pool_name > /dev/null' check_poolversion $pool_name $ver_new destroy_upgraded_pool $ver_old done diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh index 03e2db4b8082..1d167e3ae59f 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_005_pos.ksh @@ -54,11 +54,11 @@ log_assert "zfs send stream with large dnodes accepted by new pool" log_must zfs create -o dnodesize=1k $TEST_SEND_FS log_must touch /$TEST_SEND_FS/$TEST_FILE log_must zfs snap $TEST_SNAP -log_must zfs send $TEST_SNAP > $TEST_STREAM +log_must eval "zfs send $TEST_SNAP > $TEST_STREAM" log_must rm -f /$TEST_SEND_FS/$TEST_FILE log_must touch /$TEST_SEND_FS/$TEST_FILEINCR log_must zfs snap $TEST_SNAPINCR -log_must zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR +log_must eval "zfs send -i $TEST_SNAP $TEST_SNAPINCR > $TEST_STREAMINCR" log_must eval "zfs recv $TEST_RECV_FS < $TEST_STREAM" inode=$(ls -li /$TEST_RECV_FS/$TEST_FILE | awk '{print $1}') diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh index 1e42202069eb..0b61e1df2226 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_009_pos.ksh @@ -66,6 +66,6 @@ log_must wait log_must_busy zpool export $TESTPOOL log_must zpool import $TESTPOOL -log_must ls -lR "/$TEST_FS/" >/dev/null 2>&1 +log_must eval "ls -lR /$TEST_FS/ >/dev/null 2>&1" log_must zdb -d $TESTPOOL log_pass diff --git a/tests/zfs-tests/tests/functional/history/history_005_neg.ksh b/tests/zfs-tests/tests/functional/history/history_005_neg.ksh index 297a701cc567..5038af4a7c79 100755 --- a/tests/zfs-tests/tests/functional/history/history_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/history/history_005_neg.ksh @@ -54,10 +54,10 @@ log_assert "Verify 'zpool get|history|list|status|iostat' will not be logged." # Save initial TESTPOOL history log_must eval "zpool history $TESTPOOL >$OLD_HISTORY" -log_must zpool get all $TESTPOOL >/dev/null -log_must zpool list $TESTPOOL >/dev/null -log_must zpool status $TESTPOOL >/dev/null -log_must zpool iostat $TESTPOOL >/dev/null +log_must eval "zpool get all $TESTPOOL >/dev/null" +log_must eval "zpool list $TESTPOOL >/dev/null" +log_must eval "zpool status $TESTPOOL >/dev/null" +log_must eval "zpool iostat $TESTPOOL >/dev/null" log_must eval "zpool history $TESTPOOL >$NEW_HISTORY" log_must diff $OLD_HISTORY $NEW_HISTORY diff --git a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh index 19b7114faf5b..a1e76e68b802 100755 --- a/tests/zfs-tests/tests/functional/history/history_006_neg.ksh +++ b/tests/zfs-tests/tests/functional/history/history_006_neg.ksh @@ -67,15 +67,15 @@ log_must zfs snapshot $snap2 # Save initial TESTPOOL history log_must eval "zpool history $TESTPOOL > $OLD_HISTORY" -log_must zfs list $fs > /dev/null -log_must zfs get mountpoint $fs > /dev/null +log_must eval "zfs list $fs > /dev/null" +log_must eval "zfs get mountpoint $fs > /dev/null" log_must zfs unmount $fs log_must zfs mount $fs if ! is_linux; then log_must zfs share $fs log_must zfs unshare $fs fi -log_must zfs send -i $snap1 $snap2 > /dev/null +log_must eval "zfs send -i $snap1 $snap2 > /dev/null" log_must zfs holds $snap1 log_must eval "zpool history $TESTPOOL > $NEW_HISTORY" diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh index f824661c0067..25a807025c87 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_001_pos.ksh @@ -49,7 +49,7 @@ function cleanup # Remove dump device. # if [[ -n $PREVDUMPDEV ]]; then - log_must dumpadm -u -d $PREVDUMPDEV > /dev/null + log_must eval "dumpadm -u -d $PREVDUMPDEV > /dev/null" fi destroy_pool $TESTPOOL @@ -61,16 +61,16 @@ log_onexit cleanup typeset dumpdev="" -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` log_note "Zero $FS_DISK0" log_must cleanup_devices $FS_DISK0 log_note "Configuring $rawdisk0 as dump device" -log_must dumpadm -d $rawdisk0 > /dev/null +log_must eval "dumpadm -d $rawdisk0 > /dev/null" log_note "Confirm that dump device has been setup" -dumpdev=`dumpadm | grep "Dump device" | awk '{print $3}'` +dumpdev=`dumpadm | awk '/Dump device/ {print $3}'` [[ -z "$dumpdev" ]] && log_untested "No dump device has been configured" [[ "$dumpdev" != "$rawdisk0" ]] && \ diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh index 07d6ac17557c..24918e217428 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh @@ -58,25 +58,21 @@ function cleanup log_note "Kill off ufsdump process if still running" kill -0 $PIDUFSDUMP > /dev/null 2>&1 && \ - log_must kill -9 $PIDUFSDUMP > /dev/null 2>&1 + log_must eval "kill -9 $PIDUFSDUMP" # # Note: It would appear that ufsdump spawns a number of processes # which are not killed when the $PIDUFSDUMP is whacked. So best bet # is to find the rest of the them and deal with them individually. # - for all in `pgrep ufsdump` - do - kill -9 $all > /dev/null 2>&1 - done + kill -9 `pgrep ufsdump` > /dev/null 2>&1 log_note "Kill off ufsrestore process if still running" kill -0 $PIDUFSRESTORE > /dev/null 2>&1 && \ - log_must kill -9 $PIDUFSRESTORE > /dev/null 2>&1 + log_must eval "kill -9 $PIDUFSRESTORE" ismounted $UFSMP ufs && log_must umount $UFSMP - rm -rf $UFSMP - rm -rf $TESTDIR + rm -rf $UFSMP $TESTDIR # # Tidy up the disks we used. diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 661cbf3a52e7..5fb22bd85c69 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -180,13 +180,11 @@ function seconds_mmp_waits_for_activity typeset mmp_write typeset mmp_delay - log_must zdb -e -p $devpath $pool >$tmpfile 2>/dev/null + log_must eval "zdb -e -p $devpath $pool >$tmpfile 2>/dev/null" mmp_fail=$(awk '/mmp_fail/ {print $NF}' $tmpfile) mmp_write=$(awk '/mmp_write/ {print $NF}' $tmpfile) mmp_delay=$(awk '/mmp_delay/ {print $NF}' $tmpfile) - if [ -f $tmpfile ]; then - rm $tmpfile - fi + rm $tmpfile # In order of preference: if [ -n $mmp_fail -a -n $mmp_write ]; then diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh index 29d771de8f8b..513b7d31f9cd 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_on_off.ksh @@ -60,9 +60,9 @@ log_must mmp_set_hostid $HOSTID1 default_setup_noexit $DISK log_must zpool set multihost=off $TESTPOOL -log_must zdb -u $TESTPOOL > $PREV_UBER +log_must eval "zdb -u $TESTPOOL > $PREV_UBER" log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if ! diff "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp thread has updated an uberblock" @@ -70,7 +70,7 @@ fi log_must zpool set multihost=on $TESTPOOL log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if diff "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp failed to update uberblocks" diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh index 01cca61c3c3e..cd82fa47e23f 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_on_thread.ksh @@ -53,9 +53,9 @@ log_must mmp_set_hostid $HOSTID1 default_setup_noexit $DISK log_must zpool set multihost=on $TESTPOOL -log_must zdb -u $TESTPOOL > $PREV_UBER +log_must eval "zdb -u $TESTPOOL > $PREV_UBER" log_must sleep 5 -log_must zdb -u $TESTPOOL > $CURR_UBER +log_must eval "zdb -u $TESTPOOL > $CURR_UBER" if diff -u "$CURR_UBER" "$PREV_UBER"; then log_fail "mmp failed to update uberblocks" diff --git a/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh b/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh index 2fb3fb46c44c..0aecbea7eb27 100755 --- a/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/no_space/enospc_002_pos.ksh @@ -62,8 +62,8 @@ done log_mustnot_expect space zfs create $TESTPOOL/$TESTFS/subfs log_mustnot_expect space zfs clone $TESTPOOL/$TESTFS@snap $TESTPOOL/clone -log_must zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$ -log_mustnot_expect space zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$ +log_must eval "zfs send $TESTPOOL/$TESTFS@snap > $TEST_BASE_DIR/stream.$$" +log_mustnot_expect space eval "zfs receive $TESTPOOL/$TESTFS/recvd < $TEST_BASE_DIR/stream.$$" log_must rm $TEST_BASE_DIR/stream.$$ log_must zfs rename $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS@snap_newname diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh index b3958b345d2a..dcc71788682d 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh @@ -74,9 +74,9 @@ function do_test # finish reading. # { - log_must dd bs=512 count=4 >/dev/null + log_must eval "dd bs=512 count=4 >/dev/null" log_must eval "$cmd" - cat 2>&1 >/dev/null | log_must grep "Input/output error" + log_must eval 'cat 2>&1 >/dev/null | grep "Input/output error"' } <$TXG_HIST } diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh b/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh index b2721707cb75..285318853a9e 100755 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy_draid.ksh @@ -77,7 +77,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" # @@ -100,7 +100,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" log_must zpool scrub -w $pool diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh b/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh index 7351cfaae5ed..a3ea3e53cb75 100755 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy_raidz.ksh @@ -77,7 +77,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" # @@ -100,7 +100,7 @@ function test_selfheal # log_must zpool import -o cachefile=none -d $dir $pool typeset mntpnt=$(get_prop mountpoint $pool/fs) - log_must find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1 + log_must eval "find $mntpnt -type f -exec cksum {} + >> /dev/null 2>&1" log_must check_pool_status $pool "errors" "No known data errors" log_must zpool scrub -w $pool diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh index 269d31bf8905..937693a67c9e 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh @@ -162,7 +162,7 @@ do # inject read io errors on vdev and verify resilver does not restart log_must zinject -a -d ${VDEV_FILES[2]} -e io -T read -f 0.25 $TESTPOOL1 - log_must cat ${DATAPATHS[1]} > /dev/null + log_must eval "cat ${DATAPATHS[1]} > /dev/null" log_must zinject -c all # there should still be 2 resilver starts w/o defer, 1 with defer diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh index 4f2707693d13..67be04e1e0ed 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh @@ -57,7 +57,7 @@ log_must set_tunable32 SCAN_LEGACY 1 # create the pool and a 32M file (32k blocks) log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[0]} $SPARE_VDEV_FILE log_must zpool create -f -O recordsize=1k $TESTPOOL1 ${VDEV_FILES[0]} -log_must dd if=/dev/urandom of=/$TESTPOOL1/file bs=1M count=32 > /dev/null 2>&1 +log_must eval "dd if=/dev/urandom of=/$TESTPOOL1/file bs=1M count=32 2>/dev/null" # determine objset/object objset=$(zdb -d $TESTPOOL1/ | sed -ne 's/.*ID \([0-9]*\).*/\1/p') diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 8d704ee36876..1df5c3542e7d 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -128,7 +128,7 @@ function cleanup_pool # # https://github.com/openzfs/zfs/issues/6143 # - log_must df >/dev/null + log_must eval "df >/dev/null" log_must_busy zfs destroy -Rf $pool else typeset list=$(zfs list -H -r -t all -o name $pool) @@ -153,8 +153,6 @@ function cleanup_pool if [[ -d $mntpnt ]]; then rm -rf $mntpnt/* fi - - return 0 } function cleanup_pools @@ -655,7 +653,7 @@ function resume_test for ((i=0; i<2; i=i+1)); do mess_send_file /$streamfs/$stream_num - log_mustnot zfs recv -suv $recvfs /dev/null" log_must eval "zfs send -t $token >/$streamfs/$stream_num" - [[ -f /$streamfs/$stream_num ]] || \ - log_fail "NO FILE /$streamfs/$stream_num" done - log_must zfs recv -suv $recvfs /$streamfs/1" mess_send_file /$streamfs/1 - log_mustnot zfs recv -suv $recvfs < /$streamfs/1 2>&1 - token=$(zfs get -Hp -o value receive_resume_token $recvfs) - echo "$token" > /$streamfs/resume_token - - return 0 + log_mustnot eval "zfs recv -suv $recvfs < /$streamfs/1 2>&1" + get_prop receive_resume_token $recvfs > /$streamfs/resume_token } # diff --git a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh index 1c8a3b2a6c20..9a63bf23483e 100755 --- a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh @@ -113,8 +113,7 @@ log_onexit cleanup_all setup_all -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 typeset -i i=0 diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh index 97194f4fe4a0..34e72a70d7d4 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh @@ -55,16 +55,14 @@ function cleanup [[ $? -eq 0 ]] && \ log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that a rollback to a previous snapshot succeeds." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh index c424a69f0a7e..dc375e2224c2 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh @@ -59,16 +59,14 @@ function cleanup [[ $? -eq 0 ]] && \ log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify rollback is with respect to latest snapshot." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -109,8 +107,7 @@ while [[ $i -le $COUNT ]]; do (( i = i + 1 )) done -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/original_file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -f $TESTDIR/original_file* # # Now rollback to latest snapshot diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh index 766de990ecdb..e707640acd14 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_003_pos.ksh @@ -100,7 +100,7 @@ log_must zfs snapshot $SNAPPOOL.1 # # https://github.com/openzfs/zfs/issues/6143 # -log_must df >/dev/null +log_must eval "df >/dev/null" export __ZFS_POOL_RESTRICT="$TESTPOOL" log_must zfs unmount -a @@ -110,6 +110,6 @@ unset __ZFS_POOL_RESTRICT log_must touch /$TESTPOOL/$TESTFILE/$TESTFILE.1 log_must zfs rollback $SNAPPOOL.1 -log_must df >/dev/null +log_must eval "df >/dev/null" log_pass "Rollbacks succeed when nested file systems are present." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh index 6a55a902fb20..9a677b036ead 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_001_pos.ksh @@ -54,7 +54,7 @@ function cleanup log_must zfs destroy $SNAPFS fi - log_must rm -rf $SNAPDIR $TESTDIR/* > /dev/null 2>&1 + log_must rm -rf $SNAPDIR $TESTDIR/* } log_assert "Verify a file system snapshot is identical to original." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh index 42fbbd9a7a2b..a3ed1b548210 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_002_pos.ksh @@ -51,26 +51,13 @@ verify_runnable "both" function cleanup { - if [[ -d $CWD ]]; then - cd $CWD || log_fail "Could not cd $CWD" - fi - - snapexists $SNAPFS - if [[ $? -eq 0 ]]; 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 - - if [[ -d "$SNAPSHOT_TARDIR" ]]; then - log_must rm -rf $SNAPSHOT_TARDIR > /dev/null 2>&1 - fi + [ -d $CWD ] && log_must cd $CWD + + snapexists $SNAPFS && log_must zfs destroy $SNAPFS + + [ -e $SNAPDIR ] && log_must rm -rf $SNAPDIR + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* + [ -d "$SNAPSHOT_TARDIR" ] && log_must rm -rf $SNAPSHOT_TARDIR } log_assert "Verify an archive of a file system is identical to " \ @@ -82,8 +69,7 @@ log_onexit cleanup typeset -i COUNT=21 typeset OP=create -[[ -n $TESTDIR ]] && \ - rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && rm -rf $TESTDIR/* log_note "Create files in the zfs filesystem..." @@ -96,33 +82,32 @@ done log_note "Create a tarball from $TESTDIR contents..." CWD=$PWD -cd $TESTDIR || log_fail "Could not cd $TESTDIR" +log_must cd $TESTDIR log_must tar cf $SNAPSHOT_TARDIR/original.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_note "Create a snapshot and mount it..." log_must zfs snapshot $SNAPFS log_note "Remove all of the original files..." -log_must rm -f $TESTDIR/file* > /dev/null 2>&1 +log_must rm -f $TESTDIR/file* log_note "Create tarball of snapshot..." CWD=$PWD -cd $SNAPDIR || log_fail "Could not cd $SNAPDIR" +log_must cd $SNAPDIR log_must tar cf $SNAPSHOT_TARDIR/snapshot.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD -log_must mkdir $TESTDIR/original -log_must mkdir $TESTDIR/snapshot +log_must mkdir $TESTDIR/original $TESTDIR/snapshot CWD=$PWD -cd $TESTDIR/original || log_fail "Could not cd $TESTDIR/original" +log_must cd $TESTDIR/original log_must tar xf $SNAPSHOT_TARDIR/original.tar -cd $TESTDIR/snapshot || log_fail "Could not cd $TESTDIR/snapshot" +log_must cd $TESTDIR/snapshot log_must tar xf $SNAPSHOT_TARDIR/snapshot.tar -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_must directory_diff $TESTDIR/original $TESTDIR/snapshot log_pass "Directory structures match." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh index 054b58cd5590..8cb7298a4836 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh @@ -49,20 +49,17 @@ function cleanup { typeset -i i=1 while [ $i -lt $COUNT ]; do - snapexists $SNAPFS.$i - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPFS.$i - fi + snapexists $SNAPFS.$i && log_must zfs destroy $SNAPFS.$i - if [[ -e $SNAPDIR.$i ]]; then - log_must rm -rf $SNAPDIR.$i > /dev/null 2>&1 + if [ -e $SNAPDIR.$i ]; then + log_must rm -rf $SNAPDIR.$i fi (( i = i + 1 )) done - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } @@ -70,8 +67,7 @@ log_assert "Verify many snapshots of a file system can be taken." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -86,8 +82,7 @@ while [[ $i -lt $COUNT ]]; do done log_note "Remove all of the original files" -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/file* i=1 while [[ $i -lt $COUNT ]]; do diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh index 9d3b3de1adc0..44fc6ec9e988 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh @@ -48,20 +48,16 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ - log_must zfs destroy $SNAPFS + snapexists $SNAPFS && log_must zfs destroy $SNAPFS - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that a snapshot of an empty file system remains empty." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* log_must zfs snapshot $SNAPFS FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh index 9cff0decc698..a5667badf53a 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_005_pos.ksh @@ -49,17 +49,14 @@ verify_runnable "both" function cleanup { - snapexists $SNAPCTR - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR - fi + snapexists $SNAPCTR && log_must zfs destroy $SNAPCTR - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh index d2a304670981..2130ff8901cd 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_006_pos.ksh @@ -51,24 +51,21 @@ verify_runnable "both" function cleanup { if [[ -d $CWD ]]; then - cd $CWD || log_fail "Could not cd $CWD" + log_must cd $CWD fi - snapexists $SNAPCTR - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR - fi + snapexists $SNAPCTR && log_must zfs destroy $SNAPCTR - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $TESTDIR1 ]]; then - log_must rm -rf $TESTDIR1/* > /dev/null 2>&1 + if [ -e $TESTDIR1 ]; then + log_must rm -rf $TESTDIR1/* fi - if [[ -d "$SNAPSHOT_TARDIR" ]]; then - log_must rm -rf $SNAPSHOT_TARDIR > /dev/null 2>&1 + if [ -d "$SNAPSHOT_TARDIR" ]; then + log_must rm -rf $SNAPSHOT_TARDIR fi } @@ -81,7 +78,7 @@ log_onexit cleanup typeset -i COUNT=21 typeset OP=create -[[ -n $TESTDIR1 ]] && rm -rf $TESTDIR1/* > /dev/null 2>&1 +[ -n $TESTDIR1 ] && rm -rf $TESTDIR1/* log_note "Create files in the zfs dataset ..." @@ -94,33 +91,32 @@ done log_note "Create a tarball from $TESTDIR1 contents..." CWD=$PWD -cd $TESTDIR1 || log_fail "Could not cd $TESTDIR1" +log_must cd $TESTDIR1 log_must tar cf $SNAPSHOT_TARDIR/original.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_note "Create a snapshot and mount it..." log_must zfs snapshot $SNAPCTR log_note "Remove all of the original files..." -log_must rm -f $TESTDIR1/file* > /dev/null 2>&1 +log_must rm -f $TESTDIR1/file* log_note "Create tarball of snapshot..." CWD=$PWD -cd $SNAPDIR1 || log_fail "Could not cd $SNAPDIR1" +log_must cd $SNAPDIR1 log_must tar cf $SNAPSHOT_TARDIR/snapshot.tar . -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD -log_must mkdir $TESTDIR1/original -log_must mkdir $TESTDIR1/snapshot +log_must mkdir $TESTDIR1/original mkdir $TESTDIR1/snapshot CWD=$PWD -cd $TESTDIR1/original || log_fail "Could not cd $TESTDIR1/original" +log_must cd $TESTDIR1/original log_must tar xf $SNAPSHOT_TARDIR/original.tar -cd $TESTDIR1/snapshot || log_fail "Could not cd $TESTDIR1/snapshot" +log_must cd $TESTDIR1/snapshot log_must tar xf $SNAPSHOT_TARDIR/snapshot.tar -cd $CWD || log_fail "Could not cd $CWD" +log_must cd $CWD log_must directory_diff $TESTDIR1/original $TESTDIR1/snapshot log_pass "Directory structures match." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh index 7ed1fdb6e7ad..41d4b468268b 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh @@ -49,24 +49,21 @@ function cleanup { typeset -i i=1 while [ $i -lt $COUNT ]; do - snapexists $SNAPCTR.$i - if [[ $? -eq 0 ]]; then - log_must zfs destroy $SNAPCTR.$i - fi + snapexists $SNAPCTR.$i && log_must zfs destroy $SNAPCTR.$i - if [[ -e $SNAPDIR.$i ]]; then - log_must rm -rf $SNAPDIR1.$i > /dev/null 2>&1 + if [ -e $SNAPDIR.$i ]; then + log_must rm -rf $SNAPDIR1.$i fi (( i = i + 1 )) done - if [[ -e $SNAPDIR1 ]]; then - log_must rm -rf $SNAPDIR1 > /dev/null 2>&1 + if [ -e $SNAPDIR1 ]; then + log_must rm -rf $SNAPDIR1 fi - if [[ -e $TESTDIR ]]; then - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + if [ -e $TESTDIR ]; then + log_must rm -rf $TESTDIR/* fi } @@ -74,8 +71,7 @@ log_assert "Verify that many snapshots can be made on a zfs dataset." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -90,12 +86,11 @@ while [[ $i -lt $COUNT ]]; do done log_note "Remove all of the original files" -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR1/file* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -f $TESTDIR1/file* i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`ls $SNAPDIR1.$i/file* | wc -l` + FILECOUNT=`echo $SNAPDIR1.$i/file* | wc -w` typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR1.$i/file$j $j diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh index d0ecb77fe0a0..d229c1d74be8 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh @@ -55,16 +55,14 @@ function cleanup (( i = i + 1 )) done - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that destroying snapshots returns space to the pool." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 @@ -82,7 +80,7 @@ done typeset -i i=1 while [[ $i -lt $COUNT ]]; do - log_must rm -rf $TESTDIR/file$i > /dev/null 2>&1 + log_must rm -f $TESTDIR/file$i log_must zfs destroy $SNAPFS.$i (( i = i + 1 )) diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh index 7e0a7f4ce1d8..fcf57f65f6dd 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh @@ -53,15 +53,13 @@ function cleanup { snapexists $SNAPPOOL && destroy_dataset $SNAPPOOL -r - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify that rollback to a snapshot created by snapshot -r succeeds." log_onexit cleanup -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh index e02f6eb30042..aee6bb6ceb3f 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh @@ -51,8 +51,7 @@ function cleanup datasetexists $ctrfs && destroy_dataset $ctrfs -r snapexists $snappool && destroy_dataset $snappool -r - [[ -e $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 + [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* } log_assert "Verify snapshots from 'snapshot -r' can be used for zfs send/recv" @@ -67,8 +66,7 @@ snapctrfs=$ctrfs@$TESTSNAP fsdir=/$ctrfs snapdir=$fsdir/.zfs/snapshot/$TESTSNAP -[[ -n $TESTDIR ]] && \ - log_must rm -rf $TESTDIR/* > /dev/null 2>&1 +[ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* typeset -i COUNT=10 diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh index 384377c7f64b..55188960b7e3 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_014_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - [[ -e $TESTDIR1 ]] && \ - log_must rm -rf $TESTDIR1/* > /dev/null 2>&1 + [ -e $TESTDIR1 ] && log_must rm -rf $TESTDIR1/* snapexists $SNAPCTR && destroy_dataset $SNAPCTR diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_001_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_001_pos.ksh index fe7dff6570a1..b67cc6d973e6 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_001_pos.ksh @@ -33,7 +33,7 @@ DISK=${DISKS%% *} log_must zpool create -f $TESTPOOL $DISK conf="$TESTDIR/vz001" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_top_zap $TESTPOOL $DISK "$conf" assert_leaf_zap $TESTPOOL $DISK "$conf" diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_002_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_002_pos.ksh index 01d04ab156db..c571973b080b 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_002_pos.ksh @@ -33,7 +33,7 @@ log_assert "Per-vdev ZAPs are created on pool creation with many disks." log_must zpool create -f $TESTPOOL $DISKS conf="$TESTDIR/vz002" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" for DISK in $DISKS; do diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_003_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_003_pos.ksh index b6d9ffbda15c..015729576a7d 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_003_pos.ksh @@ -34,7 +34,7 @@ log_assert "Per-vdev ZAPs are created on pool creation with multi-level vdev "\ log_must zpool create -f $TESTPOOL mirror $DISKS conf="$TESTDIR/vz003" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" assert_top_zap $TESTPOOL "type: 'mirror'" "$conf" diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh index b7468e4c331b..86dc058ebffe 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh @@ -38,7 +38,7 @@ log_must zpool create -f $TESTPOOL $DISK # Make the pool. conf="$TESTDIR/vz004" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" orig_top=$(get_top_vd_zap $DISK $conf) orig_leaf=$(get_leaf_vd_zap $DISK $conf) @@ -51,7 +51,7 @@ assert_zap_common $TESTPOOL $DISK "top" $orig_top disk2=$(echo $DISKS | awk '{print $2}') log_must zpool attach $TESTPOOL $DISK $disk2 log_must zpool wait -t resilver $TESTPOOL -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" # Ensure top-level ZAP was transferred successfully. new_top=$(get_top_vd_zap "type: 'mirror'" $conf) @@ -80,7 +80,7 @@ dsk2_leaf=$(get_leaf_vd_zap $disk2 $conf) # log_must zpool detach $TESTPOOL $DISK -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" final_top=$(get_top_vd_zap $disk2 $conf) final_leaf=$(get_leaf_vd_zap $disk2 $conf) diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_005_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_005_pos.ksh index 7a40d8f0c565..1d82218bf283 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_005_pos.ksh @@ -35,7 +35,7 @@ log_must zpool create -f $TESTPOOL $DISK # Make the pool. conf="$TESTDIR/vz005" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" orig_top=$(get_top_vd_zap $DISK $conf) orig_leaf=$(get_leaf_vd_zap $DISK $conf) @@ -50,7 +50,7 @@ log_must zpool export $TESTPOOL log_must zpool import $TESTPOOL # Verify that ZAPs persisted. -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" new_top=$(get_top_vd_zap $DISK $conf) new_leaf=$(get_leaf_vd_zap $DISK $conf) diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_006_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_006_pos.ksh index 0476bcda91ff..ce94336c7c5d 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_006_pos.ksh @@ -36,7 +36,7 @@ log_assert "Per-vdev ZAPs are created for added vdevs." log_must zpool add -f $TESTPOOL ${DISK_ARR[1]} conf="$TESTDIR/vz006" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" orig_top=$(get_top_vd_zap ${DISK_ARR[1]} $conf) diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh index e04681e67f7d..fbcb807b5fcf 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh @@ -36,7 +36,7 @@ log_must zpool create -f $TESTPOOL mirror ${DISK_ARR[0]} ${DISK_ARR[1]} log_assert "Per-vdev ZAPs persist correctly on the original pool after split." conf="$TESTDIR/vz007" -log_must zdb -PC $TESTPOOL > $conf +log_must eval "zdb -PC $TESTPOOL > $conf" assert_has_sentinel "$conf" orig_top=$(get_top_vd_zap "type: 'mirror'" $conf) diff --git a/tests/zfs-tests/tests/functional/zpool_influxdb/zpool_influxdb.ksh b/tests/zfs-tests/tests/functional/zpool_influxdb/zpool_influxdb.ksh index 495a4a38b7f5..61a85c50280a 100755 --- a/tests/zfs-tests/tests/functional/zpool_influxdb/zpool_influxdb.ksh +++ b/tests/zfs-tests/tests/functional/zpool_influxdb/zpool_influxdb.ksh @@ -43,14 +43,11 @@ fi function check_for { - grep "^${1}," $tmpfile >/dev/null 2>/dev/null - if [ $? -ne 0 ]; then - log_fail "cannot find stats for $1" - fi + log_must grep -q "^${1}," $tmpfile } # by default, all stats and histograms for all pools -log_must zpool_influxdb > $tmpfile +log_must eval "zpool_influxdb > $tmpfile" STATS=" zpool_io_size @@ -64,8 +61,8 @@ for stat in $STATS; do done # scan stats aren't expected to be there until after a scan has started -zpool scrub $TESTPOOL -zpool_influxdb > $tmpfile +log_must zpool scrub $TESTPOOL +log_must eval "zpool_influxdb > $tmpfile" check_for zpool_scan_stats log_pass "zpool_influxdb gathers statistics" diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/cleanup.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/cleanup.ksh index 70574fcfe705..f1457b72199e 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/cleanup.ksh @@ -46,13 +46,13 @@ fi for swapdev in $SAVESWAPDEVS do if ! is_swap_inuse $swapdev ; then - log_must swap_setup $swapdev >/dev/null 2>&1 + swap_setup $swapdev fi done voldev=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL if is_swap_inuse $voldev ; then - log_must swap_cleanup $voldev + swap_cleanup $voldev fi default_zvol_cleanup From a2e4662be297c7dcef58451db25975e301647cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 13:52:14 +0100 Subject: [PATCH 18/63] tests: get rid of which MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/commands.cfg | 3 +-- tests/zfs-tests/include/libtest.shlib | 2 +- tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh | 4 +--- tests/zfs-tests/tests/functional/pam/setup.ksh | 4 +--- .../tests/functional/user_namespace/user_namespace_001.ksh | 4 ++-- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 50449633ac72..a5ee92071b92 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -109,8 +109,7 @@ export SYSTEM_FILES_COMMON='arp uuidgen vmstat wait - wc - which' + wc' export SYSTEM_FILES_FREEBSD='chflags compress diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index a78c10ce2ee6..f786f05e8af5 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2618,7 +2618,7 @@ function add_user_linux # # Add new users to the same group and the command line utils. # This allows them to be run out of the original users home # directory as long as it permissioned to be group readable. - cmd_group=$(stat --format="%G" $(which zfs)) + cmd_group=$(stat --format="%G" $(command -v zfs)) log_must usermod -a -G $cmd_group $user return 0 diff --git a/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh b/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh index 36a7e76f9f3d..031d90c3838b 100755 --- a/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/mmap/mmap_libaio_001_pos.ksh @@ -42,9 +42,7 @@ verify_runnable "global" log_assert "verify mmap'd pages work with libaio" # mmap_libaio is built when the libaio-devel package is installed. -if ! which mmap_libaio; then - log_unsupported "This test requires mmap_libaio." -fi +command -v mmap_libaio > /dev/null || log_unsupported "This test requires mmap_libaio." log_must chmod 777 $TESTDIR diff --git a/tests/zfs-tests/tests/functional/pam/setup.ksh b/tests/zfs-tests/tests/functional/pam/setup.ksh index 23515a598e72..8ef9fbe0feed 100755 --- a/tests/zfs-tests/tests/functional/pam/setup.ksh +++ b/tests/zfs-tests/tests/functional/pam/setup.ksh @@ -22,9 +22,7 @@ . $STF_SUITE/tests/functional/pam/utilities.kshlib -if ! which pamtester; then - log_unsupported "pam tests require the pamtester utility to be installed" -fi +command -v pamtester > /dev/null || log_unsupported "pam tests require the pamtester utility to be installed" DISK=${DISKS%% *} create_pool $TESTPOOL "$DISK" diff --git a/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh b/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh index 6be30ab4d204..3d19c4273e24 100755 --- a/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh +++ b/tests/zfs-tests/tests/functional/user_namespace/user_namespace_001.ksh @@ -51,8 +51,8 @@ log_onexit cleanup log_assert "Check root in user namespaces" -TOUCH=$(readlink -e $(which touch)) -CHMOD=$(readlink -e $(which chmod)) +TOUCH=$(readlink -f $(command -v touch)) +CHMOD=$(readlink -f $(command -v chmod)) for i in ${files[*]}; do log_must $TOUCH $TESTDIR/$i From 7ec4171439b96c122f3400e06316485ffb727ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 23:54:07 +0100 Subject: [PATCH 19/63] tests: vdev_zaps_007: actually test the new pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh index fbcb807b5fcf..c7f12c633706 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_007_pos.ksh @@ -62,7 +62,7 @@ log_assert "Per-vdev ZAPs persist on the new pool after import." # Import the split pool. log_must zpool import $POOL2 -log_must eval "zdb -PC $TESTPOOL > $conf" +log_must eval "zdb -PC $POOL2 > $conf" new_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf) new_top_s1=$(get_top_vd_zap ${DISK_ARR[1]} $conf) From 78b543f7df602883a8cf325daece8a246feae19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 23:54:26 +0100 Subject: [PATCH 20/63] tests: vdev_zaps: cleanup library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/libtest.shlib | 14 ++---- .../cli_root/zfs_set/canmount_003_pos.ksh | 4 +- .../zpool_import_features_002_neg.ksh | 6 +-- .../functional/vdev_zaps/vdev_zaps.kshlib | 44 ++++--------------- 4 files changed, 17 insertions(+), 51 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index f786f05e8af5..8009299624e0 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -1229,7 +1229,6 @@ function poolexists fi zpool get name "$pool" > /dev/null 2>&1 - return $? } # Return 0 if all the specified datasets exist; $? otherwise @@ -1242,13 +1241,7 @@ function datasetexists return 1 fi - while (($# > 0)); do - zfs get name $1 > /dev/null 2>&1 || \ - return $? - shift - done - - return 0 + zfs get name "$@" > /dev/null 2>&1 } # return 0 if none of the specified datasets exists, otherwise return 1. @@ -1776,7 +1769,7 @@ function create_dataset #dataset dataset_options # $2 - custom arguments for zfs destroy # Destroy dataset with the given parameters. -function destroy_dataset #dataset #args +function destroy_dataset # dataset [args] { typeset dataset=$1 typeset mtpt @@ -1792,8 +1785,7 @@ function destroy_dataset #dataset #args mtpt=$(get_prop mountpoint "$dataset") log_must_busy zfs destroy $args $dataset - [[ -d $mtpt ]] && \ - log_must rm -rf $mtpt + [ -d $mtpt ] && log_must rm -rf $mtpt else log_note "Dataset does not exist. ($dataset)" return 1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh index e4664d03b43c..b370118a7f76 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_003_pos.ksh @@ -97,9 +97,9 @@ while (( i < ${#dataset_pos[*]} )); do done i=0 -while (( i < ${#dataset_pos[*]} )) ; do +while (( i < ${#dataset_pos[*]} )); do dataset=${dataset_pos[i]} - if ismounted $dataset; then + if ismounted $dataset; then log_must cd ${old_mnt[i]} set_n_check_prop "noauto" "canmount" "$dataset" log_must mounted $dataset diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh index d16ef217a444..88fde66adf04 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_features_002_neg.ksh @@ -69,18 +69,18 @@ done log_mustnot zpool import -d $DEVICE_DIR $TESTPOOL1 # error message should not mention "readonly" -log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep readonly" +log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 | grep -q readonly" log_mustnot poolexists $TESTPOOL1 for feature in $active_features; do log_must eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \ - | grep $feature" + | grep -q $feature" log_mustnot poolexists $TESTPOOL1 done for feature in $enabled_features; do log_mustnot eval "zpool import -d $DEVICE_DIR $TESTPOOL1 \ - | grep $feature" + | grep -q $feature" log_mustnot poolexists $TESTPOOL1 done diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps.kshlib b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps.kshlib index aae2ab40ce58..ad5bd9e7f81b 100644 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps.kshlib +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps.kshlib @@ -19,45 +19,25 @@ function get_conf_section # regex conf { - typeset dsk_line next_vd_line conf section typeset regex="$1" typeset conf="$2" - dsk_line=$(grep -n "$regex" "$conf" | awk -F: '{print $1}') - if [[ -z "$dsk_line" ]]; then - return - fi - next_vd_line=$(tail -n +$dsk_line "$conf" | \ - grep -n "children\[" | awk -F: '{print $1}' | head -n 1) - - if [[ -n "$next_vd_line" ]]; then - section=$(cat "$conf" | sed "1,${dsk_line}d" | head -n \ - $(($next_vd_line - 2))) - - else - section=$(tail -n +$dsk_line "$conf") - fi - echo "$section" + awk -v r="$1" '$0 ~ r, 0 {if($0 ~ r) next; if(/children\[/) exit; print}' "$conf" } function get_leaf_vd_zap # dsk conf { - typeset section=$(get_conf_section "$1" "$2") - echo "$section" | egrep \ - "com.delphix:vdev_zap_leaf: [0-9]+" | awk '{print $2}' + get_conf_section "$1" "$2" | awk '/com.delphix:vdev_zap_leaf: [0-9]+/ {print $2}' } function get_top_vd_zap # dsk conf { - typeset section=$(get_conf_section "$1" "$2") - echo "$section" | egrep \ - "com.delphix:vdev_zap_top: [0-9]+" | awk '{print $2}' + get_conf_section "$1" "$2" | awk '/com.delphix:vdev_zap_top: [0-9]+/ {print $2}' } function assert_has_sentinel # conf { - res=$(grep "com.delphix:has_per_vdev_zaps" "$1") - [[ -z "$res" ]] && log_fail "Pool missing ZAP feature sentinel value" + log_must grep -q "com.delphix:has_per_vdev_zaps" "$1" } function assert_zap_common # pool vd lvl zapobj @@ -67,9 +47,9 @@ function assert_zap_common # pool vd lvl zapobj typeset lvl=$3 typeset zapobj=$4 - if [[ -z "$zapobj" ]]; then + if [ -z "$zapobj" ]; then log_fail "$vd on $pool has no $lvl ZAP in config" - elif [[ -z "$(zdb -d $pool $zapobj | grep 'zap')" ]]; then + elif ! zdb -d $pool $zapobj | grep -q 'zap'; then log_fail "$vd on $pool has no $lvl ZAP in MOS" fi } @@ -100,15 +80,9 @@ function assert_leaf_zap # pool vd conf function cleanup { - if datasetexists $TESTPOOL ; then - log_must zpool destroy -f $TESTPOOL - fi - if [[ -e $conf ]]; then - log_must rm -f "$conf" - fi - if [[ -e $POOL2 ]]; then - log_must zpool destroy -f $POOL2 - fi + datasetexists $TESTPOOL && log_must zpool destroy -f $TESTPOOL + [ -e $conf ] && log_must rm -f "$conf" + poolexists $POOL2 && log_must zpool destroy -f $POOL2 } log_onexit cleanup From e85a8277eaf6cccf8232fe3eb07e704a93da8899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 9 Mar 2022 14:17:11 +0100 Subject: [PATCH 21/63] tests: README: note that -d *must* be 777 for the deleg tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs-tests.sh | 2 +- tests/README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index a058eb9c59d1..94c6ab0b111e 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -333,7 +333,7 @@ OPTIONS: -m Enable kmemleak reporting (Linux only) -n NFSFILE Use the nfsfile to determine the NFS configuration -I NUM Number of iterations - -d DIR Use DIR for files and loopback devices + -d DIR Use world-writable DIR for files and loopback devices -s SIZE Use vdevs of SIZE (default: 4G) -r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES}) -t PATH Run single test at PATH relative to test suite diff --git a/tests/README.md b/tests/README.md index a01ffbe12cf7..774bcc4171a3 100644 --- a/tests/README.md +++ b/tests/README.md @@ -88,6 +88,7 @@ The following zfs-tests.sh options are supported: -d DIR Create sparse files for vdevs in the DIR directory. By default these files are created under /var/tmp/. + This directory must be world-writable. -s SIZE Use vdevs of SIZE (default: 4G) From d8374ebb4f0586268da8447bcca6d2945afa6d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 10 Mar 2022 19:40:35 +0100 Subject: [PATCH 22/63] tests: README: note non-default mountd requirement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/README.md b/tests/README.md index 774bcc4171a3..624f5efd16e5 100644 --- a/tests/README.md +++ b/tests/README.md @@ -39,6 +39,9 @@ The pre-requisites for running the ZFS Test Suite are: * The ZFS Test Suite will add users and groups to test machine to verify functionality. Therefore it is strongly advised that a dedicated test machine, which can be a VM, be used for testing. + * On FreeBSD, mountd(8) must use `/etc/zfs/exports` + as one of its export files – by default this can be done by setting + `zfs_enable=yes` in `/etc/rc.conf`. Once the pre-requisites are satisfied simply run the zfs-tests.sh script: From 44ba8ed3797f5176a693bf7f7807dbc6e048ce3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 00:32:13 +0100 Subject: [PATCH 23/63] tests: zfs_rollback_commit: talkative failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../zfs_rollback/zfs_rollback_common.kshlib | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) 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 04a886773270..cc1b24697d21 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 @@ -270,11 +270,7 @@ function check_files typeset sum0=$(getsum $file0) typeset sum1=$(getsum $file1) typeset sum2=$(getsum $file2) - if [[ $sum0 != $origsum || \ - $sum1 != $origsum || sum2 != $origsum ]] - then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum \&\& $sum1 = $origsum \&\& sum2 = $origsum ] ;; $TESTSNAP1) log_must files_exist $file0 $file1 @@ -282,19 +278,14 @@ function check_files typeset sum0=$(getsum $file0) typeset sum1=$(getsum $file1) - if [[ $sum0 != $origsum || $sum1 != $origsum ]] - then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum \&\& $sum1 = $origsum ] ;; $TESTSNAP) log_must files_exist $file0 log_must files_nonexist $file1 $file2 typeset sum0=$(getsum $file0) - if [[ $sum0 != $origsum ]]; then - log_fail "After rollback, file sum is changed." - fi + log_must [ $sum0 = $origsum ] ;; esac } From 43cb8be81174f098663fbd46936284167e4ff15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 11 Mar 2022 23:54:08 +0100 Subject: [PATCH 24/63] tests: review every awk(1) invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../read_dos_attributes/read_dos_attributes.c | 5 +- tests/zfs-tests/include/blkdev.shlib | 18 +- tests/zfs-tests/include/libtest.shlib | 237 +++++------------- tests/zfs-tests/include/zpool_script.shlib | 8 +- .../tests/functional/acl/acl_common.kshlib | 18 +- .../tests/functional/acl/off/dosmode.ksh | 8 +- .../functional/acl/posix/posix_001_pos.ksh | 5 +- .../functional/acl/posix/posix_002_pos.ksh | 5 +- .../alloc_class/alloc_class_005_pos.ksh | 4 +- .../alloc_class/alloc_class_010_pos.ksh | 2 +- .../functional/arc/dbufstats_001_pos.ksh | 3 +- .../functional/bootfs/bootfs_003_pos.ksh | 2 +- .../functional/bootfs/bootfs_006_pos.ksh | 4 +- .../channel_program/lua_core/tst.timeout.ksh | 14 +- .../functional/checksum/filetest_001_pos.ksh | 5 +- .../functional/cli_root/cli_common.kshlib | 12 +- .../functional/cli_root/zdb/zdb_004_pos.ksh | 6 +- .../cli_root/zdb/zdb_decompress.ksh | 16 +- .../cli_root/zdb/zdb_decompress_zstd.ksh | 14 +- .../cli_root/zdb/zdb_display_block.ksh | 4 +- .../cli_root/zdb/zdb_object_range_neg.ksh | 2 +- .../cli_root/zdb/zdb_object_range_pos.ksh | 6 +- .../functional/cli_root/zdb/zdb_objset_id.ksh | 52 ++-- .../cli_root/zfs_clone/zfs_clone_007_pos.ksh | 3 +- .../cli_root/zfs_clone/zfs_clone_010_pos.ksh | 2 +- .../zfs_copies/zfs_copies_002_pos.ksh | 6 +- .../zfs_create/zfs_create_009_neg.ksh | 5 +- .../zfs_create/zfs_create_010_neg.ksh | 5 +- .../zfs_create/zfs_create_012_pos.ksh | 3 +- .../zfs_create/zfs_create_common.kshlib | 13 +- .../zfs_destroy/zfs_destroy_004_pos.ksh | 3 +- .../cli_root/zfs_diff/zfs_diff_changes.ksh | 2 +- .../cli_root/zfs_diff/zfs_diff_timestamp.ksh | 4 +- .../cli_root/zfs_diff/zfs_diff_types.ksh | 2 +- .../cli_root/zfs_get/zfs_get_001_pos.ksh | 7 +- .../cli_root/zfs_get/zfs_get_003_pos.ksh | 5 +- .../cli_root/zfs_get/zfs_get_004_pos.ksh | 9 +- .../cli_root/zfs_load-key/zfs_load-key.ksh | 3 +- .../zfs_load-key/zfs_load-key_all.ksh | 3 +- .../cli_root/zfs_mount/zfs_mount.kshlib | 5 +- .../cli_root/zfs_mount/zfs_mount_007_pos.ksh | 5 +- .../zfs_written_property_001_pos.ksh | 5 +- .../zfs_receive/zfs_receive_003_pos.ksh | 2 +- .../zfs_receive/zfs_receive_006_pos.ksh | 2 +- .../zfs_receive/zfs_receive_007_neg.ksh | 2 +- .../zfs_receive/zfs_receive_008_pos.ksh | 3 - .../zfs_receive/zfs_receive_013_pos.ksh | 2 +- .../zfs_receive/zfs_receive_from_zstd.ksh | 28 +-- .../zfs_rename/zfs_rename_nounmount.ksh | 11 +- .../cli_root/zfs_send/zfs_send_007_pos.ksh | 7 +- .../cli_root/zfs_set/canmount_001_pos.ksh | 10 +- .../cli_root/zfs_set/mountpoint_001_pos.ksh | 4 - .../cli_root/zfs_set/mountpoint_002_pos.ksh | 4 - .../cli_root/zfs_set/mountpoint_003_pos.ksh | 9 +- .../zfs_snapshot/zfs_snapshot_009_pos.ksh | 2 +- .../zfs_unload-key/zfs_unload-key_all.ksh | 3 +- .../zfs_unmount/zfs_unmount_006_pos.ksh | 1 - .../zfs_upgrade/zfs_upgrade_001_pos.ksh | 6 +- .../cli_root/zpool/zpool_colors.ksh | 16 +- .../zpool_add/add_nested_replacing_spare.ksh | 4 +- .../cli_root/zpool_add/zpool_add.kshlib | 12 +- .../cli_root/zpool_add/zpool_add_003_pos.ksh | 6 +- .../zpool_clear/zpool_clear_001_pos.ksh | 99 ++------ .../cli_root/zpool_create/zpool_create.shlib | 7 +- .../zpool_create/zpool_create_005_pos.ksh | 4 +- .../zpool_create/zpool_create_012_neg.ksh | 7 +- .../zpool_create/zpool_create_016_pos.ksh | 4 +- .../zpool_create/zpool_create_tempname.ksh | 6 +- .../zpool_events_clear_retained.ksh | 4 +- .../cli_root/zpool_export/zpool_export.cfg | 6 +- .../cli_root/zpool_get/zpool_get_002_pos.ksh | 2 +- .../cli_root/zpool_get/zpool_get_005_pos.ksh | 9 +- .../cli_root/zpool_import/zpool_import.kshlib | 17 +- .../zpool_import/zpool_import_all_001_pos.ksh | 4 +- .../zpool_initialize_verify_initialized.ksh | 5 +- .../cli_root/zpool_scrub/zpool_scrub.cfg | 4 +- .../zpool_split/zpool_split_props.ksh | 5 +- .../zpool_split/zpool_split_vdevs.ksh | 4 +- .../zpool_upgrade/zpool_upgrade.kshlib | 3 +- .../functional/cli_user/misc/zfs_001_neg.ksh | 2 +- .../cli_user/misc/zpool_001_neg.ksh | 2 +- .../cli_user/misc/zpool_get_001_neg.ksh | 4 +- .../cli_user/misc/zpool_set_001_neg.ksh | 2 +- .../cli_user/zfs_list/zfs_list.kshlib | 2 +- .../compression/compress_001_pos.ksh | 4 +- .../compression/compress_002_pos.ksh | 4 +- .../delegate/delegate_common.kshlib | 10 +- .../tests/functional/events/events.cfg | 2 - .../functional/events/events_002_pos.ksh | 18 +- .../functional/events/events_common.kshlib | 21 +- .../functional/fault/auto_offline_001_pos.ksh | 9 +- .../functional/fault/auto_replace_001_pos.ksh | 4 +- .../functional/fault/zpool_status_-s.ksh | 2 +- .../large_dnode/large_dnode_001_pos.ksh | 2 +- .../functional/history/history_001_pos.ksh | 1 - .../functional/history/history_003_pos.ksh | 9 +- .../functional/history/history_004_pos.ksh | 4 +- .../functional/history/history_common.kshlib | 30 +-- .../tests/functional/inuse/inuse_006_pos.ksh | 2 +- .../tests/functional/inuse/inuse_007_pos.ksh | 2 +- .../l2arc/persist_l2arc_001_pos.ksh | 3 +- .../l2arc/persist_l2arc_002_pos.ksh | 3 +- .../l2arc/persist_l2arc_004_pos.ksh | 3 +- .../l2arc/persist_l2arc_005_pos.ksh | 3 +- .../mount/umount_unlinked_drain.ksh | 4 +- .../tests/functional/mount/umountall_001.ksh | 9 +- .../tests/functional/no_space/enospc_df.ksh | 4 +- .../pool_checkpoint/checkpoint_lun_expsz.ksh | 10 +- .../poolversion/poolversion_001_pos.ksh | 3 +- .../poolversion/poolversion_002_pos.ksh | 4 +- .../tests/functional/procfs/pool_state.ksh | 2 +- .../projectquota/projectspace_004_pos.ksh | 4 +- .../functional/redacted_send/redacted.cfg | 6 +- .../redacted_send/redacted_props.ksh | 4 +- .../redacted_send/redacted_size.ksh | 21 +- .../functional/redundancy/redundancy.kshlib | 11 +- .../removal/remove_mirror_sanity.ksh | 4 +- .../replacement/rebuild_disabled_feature.ksh | 3 +- .../replacement/resilver_restart_002.ksh | 2 +- .../functional/reservation/reservation.shlib | 18 +- .../reservation/reservation_013_pos.ksh | 2 - .../tests/functional/rsend/rsend.cfg | 5 +- .../tests/functional/rsend/rsend.kshlib | 8 +- .../tests/functional/rsend/rsend_012_pos.ksh | 3 +- .../rsend/send_encrypted_truncated_files.ksh | 4 +- .../tests/functional/simd/simd_supported.ksh | 6 +- .../tests/functional/trim/trim.kshlib | 3 +- .../tests/functional/trim/trim_l2arc.ksh | 4 +- .../upgrade/upgrade_projectquota_001_pos.ksh | 2 +- .../vdev_zaps/vdev_zaps_004_pos.ksh | 2 +- .../tests/functional/zvol/zvol_common.shlib | 6 +- .../zvol/zvol_swap/zvol_swap_003_pos.ksh | 2 +- 132 files changed, 404 insertions(+), 764 deletions(-) diff --git a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c b/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c index ed0906c36a6f..36d7b31ba191 100644 --- a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c +++ b/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c @@ -156,12 +156,11 @@ main(int argc, const char * const argv[]) (void) close(fd); - char buffer[BUFFER_SIZE]; - memset(buffer, 0, BUFFER_SIZE); + char buffer[BUFFER_SIZE] = ""; (void) attribute_to_str(dosflags, buffer); - (void) printf("%s\n", buffer); + (void) puts(buffer); return (EXIT_SUCCESS); } diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index 7159b92c080f..6d37494eedbe 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -223,13 +223,11 @@ function set_slice_prefix if is_linux; then while (( i < $DISK_ARRAY_NUM )); do - disk="$(echo $DISKS | nawk '{print $(i + 1)}')" - if ( is_mpath_device $disk ) && [[ -z $(echo $disk | awk 'substr($1,18,1)\ - ~ /^[[:digit:]]+$/') ]] || ( is_real_device $disk ); then + disk="$(echo $DISKS | awk '{print $(i + 1)}')" + if is_mpath_device $disk && ! echo $disk | awk 'substr($1,18,1) ~ /^[[:digit:]]+$/ {exit 1}' || is_real_device $disk; then export SLICE_PREFIX="" return 0 - elif ( is_mpath_device $disk || is_loop_device \ - $disk ); then + elif is_mpath_device $disk || is_loop_device $disk; then export SLICE_PREFIX="p" return 0 else @@ -518,11 +516,11 @@ function get_pool_devices #testpool #devdir typeset devdir=$2 typeset out="" - if is_linux || is_freebsd; then - out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}') - out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ') - fi - echo $out + case $(uname) in + Linux|FreeBSD) + zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}' + ;; + esac } # diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 8009299624e0..60d54428a6dc 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -149,14 +149,11 @@ function ismounted case $fstype in zfs) if [[ "$1" == "/"* ]] ; then - for out in $(zfs mount | awk '{print $2}'); do - [[ $1 == $out ]] && return 0 - done + ! zfs mount | awk -v fs="$1" '$2 == fs {exit 1}' else - for out in $(zfs mount | awk '{print $1}'); do - [[ $1 == $out ]] && return 0 - done + ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}' fi + return $? ;; ufs|nfs) if is_freebsd; then @@ -178,7 +175,7 @@ function ismounted fi ;; ext*) - out=$(df -t $fstype $1 2>/dev/null) + df -t $fstype $1 > /dev/null 2>&1 return $? ;; zvol) @@ -608,10 +605,8 @@ function default_cleanup_noexit log_must zfs set reservation=none $fs log_must zfs set recordsize=128K $fs log_must zfs set mountpoint=/$fs $fs - typeset enc="" - enc=$(get_prop encryption $fs) - if [[ $? -ne 0 ]] || [[ -z "$enc" ]] || \ - [[ "$enc" == "off" ]]; then + typeset enc=$(get_prop encryption $fs) + if [ -z "$enc" ] || [ "$enc" = "off" ]; then log_must zfs set checksum=on $fs fi log_must zfs set compression=off $fs @@ -684,8 +679,6 @@ function destroy_snapshot typeset mtpt="" if ismounted $snap; then mtpt=$(get_prop mountpoint $snap) - (($? != 0)) && \ - log_fail "get_prop mountpoint $snap failed." fi destroy_dataset "$snap" @@ -710,8 +703,6 @@ function destroy_clone typeset mtpt="" if ismounted $clone; then mtpt=$(get_prop mountpoint $clone) - (($? != 0)) && \ - log_fail "get_prop mountpoint $clone failed." fi destroy_dataset "$clone" @@ -743,7 +734,6 @@ function destroy_bookmark function snapexists { zfs list -H -t snapshot "$1" > /dev/null 2>&1 - return $? } # @@ -754,7 +744,6 @@ function snapexists function bkmarkexists { zfs list -H -t bookmark "$1" > /dev/null 2>&1 - return $? } # @@ -765,8 +754,7 @@ function bkmarkexists # function holdexists { - zfs holds "$2" | awk '{ print $2 }' | grep "$1" > /dev/null 2>&1 - return $? + ! zfs holds "$2" | awk -v t="$1" '$2 ~ t { exit 1 }' } # @@ -934,9 +922,8 @@ function set_partition # Determine the cylinder size for the device and using # that calculate the end offset in cylinders. typeset -i cly_size_kb=0 - cly_size_kb=$(parted -m $disk -s -- \ - unit cyl print | head -3 | tail -1 | \ - awk -F '[:k.]' '{print $4}') + cly_size_kb=$(parted -m $disk -s -- unit cyl print | + awk -F '[:k.]' 'NR == 3 {print $4}') ((end = (size_mb * 1024 / cly_size_kb) + start)) parted $disk -s -- \ @@ -1077,15 +1064,14 @@ function get_endslice # typeset -i ratio=0 ratio=$(prtvtoc /dev/rdsk/${disk}s2 | \ - grep "sectors\/cylinder" | \ - awk '{print $2}') + awk '/sectors\/cylinder/ {print $2}') if ((ratio == 0)); then return fi typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 | - nawk -v token="$slice" '{if ($1==token) print $6}') + awk -v token="$slice" '$1 == token {print $6}') ((endcyl = (endcyl + 1) / ratio)) ;; @@ -1163,56 +1149,22 @@ function fill_fs # destdir dirnum filenum bytes num_writes data return 0 } -# -# Simple function to get the specified property. If unable to -# get the property then exits. -# -# Note property is in 'parsable' format (-p) -# +# Get the specified dataset property in parsable format or fail function get_prop # property dataset { - typeset prop_val typeset prop=$1 typeset dataset=$2 - prop_val=$(zfs get -pH -o value $prop $dataset 2>/dev/null) - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for dataset " \ - "$dataset" - return 1 - fi - - echo "$prop_val" - return 0 + zfs get -Hpo value "$prop" "$dataset" || log_fail "zfs get $prop $dataset" } -# -# Simple function to get the specified property of pool. If unable to -# get the property then exits. -# -# Note property is in 'parsable' format (-p) -# +# Get the specified pool property in parsable format or fail function get_pool_prop # property pool { - typeset prop_val typeset prop=$1 typeset pool=$2 - if poolexists $pool ; then - prop_val=$(zpool get -pH $prop $pool 2>/dev/null | tail -1 | \ - awk '{print $3}') - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for pool " \ - "$pool" - return 1 - fi - else - log_note "Pool $pool not exists." - return 1 - fi - - echo "$prop_val" - return 0 + zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool" } # Return 0 if a pool exists; $? otherwise @@ -1988,19 +1940,16 @@ function verify_ashift # device ashift typeset device="$1" typeset ashift="$2" - zdb -e -lll $device | awk -v ashift=$ashift '/ashift: / { - if (ashift != $2) - exit 1; - else - count++; - } END { - if (count != 4) - exit 1; - else - exit 0; + zdb -e -lll $device | awk -v ashift=$ashift ' + /ashift: / { + if (ashift != $2) + exit 1; + else + count++; + } + END { + exit (count != 4); }' - - return $? } # @@ -2375,35 +2324,24 @@ function find_disks swap -l > $sfi dumpadm > $dmpi 2>/dev/null -# write an awk script that can process the output of format -# to produce a list of disks we know about. Note that we have -# to escape "$2" so that the shell doesn't interpret it while -# we're creating the awk script. -# ------------------- - cat > /tmp/find_disks.awk </dev/null | awk ' +BEGIN { FS="."; } - { - if (searchdisks && \$2 !~ "^$"){ - split(\$2,arr," "); - print arr[1]; - } - } +/^Specify disk/{ + searchdisks=0; +} - /^AVAILABLE DISK SELECTIONS:/{ - searchdisks=1; +{ + if (searchdisks && $2 !~ "^$"){ + split($2,arr," "); + print arr[1]; } -EOF -#--------------------- +} - chmod 755 /tmp/find_disks.awk - disks=${@:-$(echo "" | format -e 2>/dev/null | /tmp/find_disks.awk)} - rm /tmp/find_disks.awk +/^AVAILABLE DISK SELECTIONS:/{ + searchdisks=1; +} +')} unused="" for disk in $disks; do @@ -2801,23 +2739,21 @@ function safe_to_destroy_pool { # $1 the pool name # this is a list of the top-level directories in each of the # files that make up the path to the files the pool is based on - FILEPOOL=$(zpool status -v $pool | grep /$1/ | \ - awk '{print $1}') + FILEPOOL=$(zpool status -v $pool | awk -v pool="/$1/" '$0 ~ pool {print $1}') # this is a list of the zvols that make up the pool - ZVOLPOOL=$(zpool status -v $pool | grep "$ZVOL_DEVDIR/$1$" \ - | awk '{print $1}') + ZVOLPOOL=$(zpool status -v $pool | awk -v zvols="$ZVOL_DEVDIR/$1$" '$0 ~ zvols {print $1}') # also want to determine if it's a file-based pool using an # alternate mountpoint... POOL_FILE_DIRS=$(zpool status -v $pool | \ - grep / | awk '{print $1}' | \ - awk -F/ '{print $2}' | grep -v "dev") + awk '/\// {print $1}' | \ + awk -F/ '!/dev/ {print $2}') for pooldir in $POOL_FILE_DIRS do OUTPUT=$(zfs list -H -r -o mountpoint $1 | \ - grep "${pooldir}$" | awk '{print $1}') + awk -v pd="${pooldir}$" '$0 ~ pd {print $1}') ALTMOUNTPOOL="${ALTMOUNTPOOL}${OUTPUT}" done @@ -2935,21 +2871,11 @@ function get_config if ! poolexists "$pool" ; then return 1 fi - alt_root=$(zpool list -H $pool | awk '{print $NF}') - if [[ $alt_root == "-" ]]; then - value=$(zdb -C $pool | grep "$config:" | awk -F: \ - '{print $2}') + if [ "$(get_pool_prop cachefile "$pool")" = "none" ]; then + zdb -e $pool else - value=$(zdb -e $pool | grep "$config:" | awk -F: \ - '{print $2}') - fi - if [[ -n $value ]] ; then - value=${value#'} - value=${value%'} - fi - echo $value - - return 0 + zdb -C $pool + fi | awk -F: -v cfg="$config:" '$0 ~ cfg {sub(/^'\''/, $2); sub(/'\''$/, $2); print $2}' } # @@ -2967,8 +2893,7 @@ function _random_get typeset -i ind ((ind = RANDOM % cnt + 1)) - typeset ret=$(echo "$str" | cut -f $ind -d ' ') - echo $ret + echo "$str" | cut -f $ind -d ' ' } # @@ -3031,20 +2956,7 @@ function datasetcksum typeset cksum sync sync_all_pools - cksum=$(zdb -vvv $1 | grep "^Dataset $1 \[" | grep "cksum" \ - | awk -F= '{print $7}') - echo $cksum -} - -# -# Get cksum of file -# #1 file path -# -function checksum -{ - typeset cksum - cksum=$(cksum $1 | awk '{print $1}') - echo $cksum + zdb -vvv $1 | awk -F= -v ds="^Dataset $1 "'\\[' '$0 ~ ds && /cksum/ {print $7}' } # @@ -3067,27 +2979,6 @@ function get_device_state #pool disk field("", "spares","logs") echo $state } - -# -# print the given directory filesystem type -# -# $1 directory name -# -function get_fstype -{ - typeset dir=$1 - - if [[ -z $dir ]]; then - log_fail "Usage: get_fstype " - fi - - # - # $ df -n / - # / : ufs - # - df -n $dir | awk '{print $3}' -} - # # Given a disk, label it to VTOC regardless what label was on the disk # $1 disk @@ -3141,16 +3032,6 @@ function labelvtoc return 0 } -# -# check if the system was installed as zfsroot or not -# return: 0 if zfsroot, non-zero if not -# -function is_zfsroot -{ - df -n / | grep zfs > /dev/null 2>&1 - return $? -} - # # get the root filesystem name if it's zfsroot system. # @@ -3162,7 +3043,7 @@ function get_rootfs if is_freebsd; then rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') elif ! is_linux; then - rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \ + rootfs=$(awk '$2 == "/" && $3 == "zfs" {print $1}' \ /etc/mnttab) fi if [[ -z "$rootfs" ]]; then @@ -3460,9 +3341,7 @@ function wait_freeing #pool function wait_replacing #pool { typeset pool=${1:-$TESTPOOL} - while true; do - [[ "" == "$(zpool status $pool | - awk '/replacing-[0-9]+/ {print $1}')" ]] && break + while zpool status $pool | grep -qE 'replacing-[0-9]+'; do log_must sleep 1 done } @@ -3910,7 +3789,9 @@ function md5digest md5 -q $file ;; *) - md5sum -b $file | awk '{ print $1 }' + typeset sum _ + read -r sum _ < <(md5sum -b $file) + echo $sum ;; esac } @@ -3928,7 +3809,9 @@ function sha256digest sha256 -q $file ;; *) - sha256sum -b $file | awk '{ print $1 }' + typeset sum _ + read -r sum _ < <(sha256sum -b $file) + echo $sum ;; esac } @@ -4116,9 +3999,7 @@ function kstat # stat flags? sysctl $flags kstat.zfs.misc.$stat ;; Linux) - typeset zfs_kstat="/proc/spl/kstat/zfs/$stat" - [[ -f "$zfs_kstat" ]] || return 1 - cat $zfs_kstat + cat "/proc/spl/kstat/zfs/$stat" 2>/dev/null ;; *) false @@ -4135,7 +4016,7 @@ function get_arcstat # stat kstat arcstats.$stat ;; Linux) - kstat arcstats | awk "/$stat/ { print \$3 }" + kstat arcstats | awk "/$stat/"' { print $3 }' ;; *) false diff --git a/tests/zfs-tests/include/zpool_script.shlib b/tests/zfs-tests/include/zpool_script.shlib index 10bc0cc26128..cbf1e07803d4 100644 --- a/tests/zfs-tests/include/zpool_script.shlib +++ b/tests/zfs-tests/include/zpool_script.shlib @@ -15,7 +15,7 @@ function test_zpool_script { out="$($wholecmd)" # Default number of columns that get printed without -c - if echo "$cmd" | grep -q iostat ; then + if [ "$cmd" != "${cmd/iostat/_/}" ]; then # iostat dcols=7 else @@ -39,9 +39,9 @@ function test_zpool_script { # zpool iostat -v output is 7 columns, so if the script ran correctly # we should see more than that. if ! newcols=$(echo "$out" | \ - awk '/\/dev/{print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \ - head -n 1) ; \ - then + awk '/\/dev/ {print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \ + head -n 1) + then log_fail "'$wholecmd' didn't create a new column value" else log_note "'$wholecmd' passed ($newcols new columns)" diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index 1e9d736fdfdb..c2e09687e43e 100644 --- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -185,9 +185,7 @@ function plus_sign_check_l # return 1 fi - ls -ld $obj | awk '{print $1}' | grep "+$" > /dev/null - - return $? + ! ls -ld $obj | awk '$1 ~ /\+$/ {exit 1}' } # @@ -202,9 +200,7 @@ function plus_sign_check_v # return 1 fi - ls -vd $obj | awk '(NR == 1) {print $1}' | grep "+$" > /dev/null - - return $? + ! ls -vd $obj | awk 'NR == 1 && $1 ~ /\+$ {exit 1}' } # @@ -216,7 +212,6 @@ function plus_sign_check_v # function chgusr_exec # [...] { chg_usr_exec $@ - return $? } # @@ -237,7 +232,6 @@ function set_cur_usr # function usr_exec # [...] { chg_usr_exec "$ZFS_ACL_CUR_USER" $@ - return $? } # @@ -447,12 +441,10 @@ function get_group #node fi if [[ -d $node ]]; then - value=$(ls -dl $node | awk '{print $4}') + ls -dl $node elif [[ -e $node ]]; then - value=$(ls -l $node | awk '{print $4}') - fi - - echo $value + ls -l $node + fi | awk '{print $4}' } diff --git a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh index 585aa025390c..329eaef55dd3 100755 --- a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh +++ b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh @@ -55,12 +55,10 @@ function hasflag typeset path=$2 if is_linux; then - read_dos_attributes $path | awk \ - '{ gsub(",", "\n", $1); print $1 }' | grep -qxF $flag + read_dos_attributes $path else - ls -lo $path | awk '{ gsub(",", "\n", $5); print $5 }' | \ - grep -qxF $flag - fi + ls -lo $path | awk '{ print $5 }' + fi | grep -qwF $flag } log_assert "Verify DOS mode flags function correctly" diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh index d62bf9c346b6..14635b27fe92 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh @@ -70,9 +70,8 @@ if [ "$?" -eq "0" ]; then log_must chmod 700 $TESTDIR/dir.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 # Confirm permissions - ls -l $TESTDIR |grep "dir.0" |grep -q "drwxrw----+" - if [ "$?" -ne "0" ]; then - msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}') + if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwxrw----+"; then + msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}') log_note "expected mask drwxrw----+ but found $msk" log_fail "Expected permissions were not set." fi diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh index d9b5036458f8..bdcc18592f27 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh @@ -53,9 +53,8 @@ log_must mkdir $TESTDIR/dir.0 log_must chmod 700 $TESTDIR/dir.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0 # Confirm permissions -ls -l $TESTDIR |grep "dir.0" |grep -q "drwx-wx---+" -if [ "$?" -ne "0" ]; then - msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}') +if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then + msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}') log_note "expected mask drwx-wx---+ but found $msk" log_fail "Expected permissions were not set." fi diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh index 337114cdb59e..08c703e21acb 100755 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh @@ -42,7 +42,7 @@ do log_must zpool create $TESTPOOL $type $ZPOOL_DISKS fi ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | awk '{print $2}')" + awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "enabled" ]; then log_note "feature@allocation_classes is enabled" else @@ -57,7 +57,7 @@ do $CLASS_DISK0 $CLASS_DISK1 fi ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | awk '{print $2}')" + awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "active" ]; then log_note "feature@allocation_classes is active" else diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh index 2c14c69d8b20..cbf5cbf89bdc 100755 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh @@ -39,7 +39,7 @@ for value in 0 512 1024 2048 4096 8192 16384 32768 65536 131072 do log_must zfs set special_small_blocks=$value $TESTPOOL ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \ - grep special_small_blocks | awk '{print $3}') + awk '/special_small_blocks/ {print $3}') if [ "$ACTUAL" != "$value" ] then log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!" diff --git a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh index 712309eda72f..aaab800b60ab 100755 --- a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh @@ -56,8 +56,7 @@ function testdbufstat # stat_name dbufstat_filter [[ -n "$2" ]] && filter="-F $2" if is_linux; then - from_dbufstat=$(grep -w "$name" "$DBUFSTATS_FILE" | - awk '{ print $3 }') + read -r _ _ from_dbufstat _ < <(grep -w "$name" "$DBUFSTATS_FILE") else from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \ "$DBUFSTATS_FILE") diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh index e719b94e2763..78accbc82da8 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh @@ -74,7 +74,7 @@ do log_must zfs create $POOL/$TESTFS log_must zpool set bootfs=$POOL/$TESTFS $POOL - RES=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + RES=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $RES != "$POOL/$TESTFS" ] then log_fail "Expected $RES == $POOL/$TESTFS" diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh index d29fe7e89c50..c5d7b2e3f4a5 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh @@ -60,7 +60,7 @@ function verify_bootfs { # $POOL log_must zfs create $POOL/$TESTFS log_must zpool set bootfs=$POOL/$TESTFS $POOL - VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $VAL != "$POOL/$TESTFS" ] then log_must zpool status -v $POOL @@ -74,7 +74,7 @@ function verify_no_bootfs { # $POOL POOL=$1 log_must zfs create $POOL/$TESTFS log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL - VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' ) + VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' ) if [ $VAL == "$POOL/$TESTFS" ] then log_must zpool status -v $POOL diff --git a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh index 22ea37548173..905a3c327cce 100755 --- a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh @@ -34,15 +34,11 @@ function test_instr_limit { typeset lim=$1 - error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1) - [[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error" - - instrs_run=$(echo $error | awk -F "chunk" '{print $2}' | awk '{print $1}') - if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then - log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)" - elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then - log_fail "Runtime (${instrs_run} instr) > limit (${lim} + 100 instr)" - fi + log_mustnot eval 'error=$(zfs program -t '$lim' $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)' + + read -r instrs_run _ < <(echo $error | awk -F "chunk" '{print $2}') + log_must [ $instrs_run -ge $(( $lim - 100 )) ] + log_must [ $instrs_run -le $(( $lim + 100 )) ] log_note "With limit $lim the program ended after $instrs_run instructions" } diff --git a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh index 615b41f312b6..c9cefcd43dae 100755 --- a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh @@ -85,7 +85,7 @@ log_must zpool import $TESTPOOL log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL -cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | awk '{print $5}') +cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}') log_assert "Normal file write test saw $cksum checksum errors" log_must [ $cksum -eq 0 ] @@ -105,8 +105,7 @@ while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do log_must zpool scrub $TESTPOOL log_must wait_scrubbed $TESTPOOL - cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | \ - awk '{print $5}') + cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}') log_assert "Checksum '$type' caught $cksum checksum errors" log_must [ $cksum -ne 0 ] 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 2b84f6a9c1cd..1e4917affff7 100644 --- a/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib @@ -30,14 +30,6 @@ . $STF_SUITE/include/libtest.shlib -# -# Get the checksum and size of the file. -# -function get_cksum # -{ - return $(cksum $1 | awk '{print $1 $2}') -} - # # Compare the checksum of target files with the original file # @@ -45,7 +37,7 @@ function get_cksum # function compare_cksum # ... { typeset orig_data=$1 - typeset orig_sum=$(get_cksum $orig_data) + typeset orig_sum=$(cksum < $orig_data) typeset target_sum="" typeset bad_data_list="" typeset -i bad_count=0 @@ -58,7 +50,7 @@ function compare_cksum # ... continue fi - target_sum=$(get_cksum $data) + target_sum=$(cksum < $data) if [[ $target_sum != $orig_sum ]]; then bad_data_list="$bad_data_list $data" (( bad_count +=1 )) diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh index 2c6e6e9be070..52bcc0311375 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh @@ -70,12 +70,14 @@ log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=25 ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ') log_note "vdev 1: ubs $ubs" +set -o pipefail ub_dump_counts=$(zdb -lu ${DISK[1]} | \ awk ' /LABEL/ {label=$NF; blocks[label]=0}; /Uberblock/ {blocks[label]++}; - END {print blocks[0],blocks[1],blocks[2],blocks[3]}') -(( $? != 0)) && log_fail "failed to get ub_dump_counts from DISK[1]" + END {print blocks[0],blocks[1],blocks[2],blocks[3]}') || + log_fail "failed to get ub_dump_counts from DISK[1]" log_note "vdev 1: ub_dump_counts $ub_dump_counts" +set +o pipefail set -A dump_count $ub_dump_counts for label in 0 1 2 3; do diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh index 1ebcbfb44953..f10d13fb5d70 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh @@ -73,7 +73,7 @@ obj=${array[0]} log_note "file $init_data has object number $obj" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + |grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" @@ -81,15 +81,13 @@ log_note "block 0 of $init_data has a DVA of $dva" size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") log_note "block size $size_str" -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +vdev=$(echo "$dva" | cut -d: -f1) +offset=$(echo "$dva" | cut -d: -f2) output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d 2> /dev/null) -echo $output |grep $pattern > /dev/null -(( $? != 0 )) && log_fail "zdb -R :d failed to decompress the data properly" +echo $output | grep -q $pattern || log_fail "zdb -R :d failed to decompress the data properly" output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) -echo $output |grep $four_k > /dev/null -(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly" +echo $output | grep -q $four_k || log_fail "zdb -R :dr failed to decompress the data properly" output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) result=${#output} @@ -97,8 +95,8 @@ result=${#output} "zdb -R failed to decompress the data to the length (${#output} != $size_str)" # decompress using lsize -lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}') -psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') +lsize=$(echo $size_str | cut -d/ -f1) +psize=$(echo $size_str | cut -d/ -f2) output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr 2> /dev/null) result=${#output} (( $result != $blksize)) && log_fail \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh index 238d49560461..9daf61f82f28 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh @@ -76,11 +76,11 @@ log_note "block 0 of $init_data has a DVA of $dva" # use the length reported by zdb -ddddddbbbbbb size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") # convert sizes to decimal -lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}') +lsize=$(echo $size_str | cut -d/ -f 1) lsize_orig=$lsize lsize=${lsize%?} lsize_bytes=$((16#$lsize)) -psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}') +psize=$(echo $size_str | cut -d/ -f 2) psize_orig=$psize psize=${psize%?} psize_bytes=$((16#$psize)) @@ -88,21 +88,21 @@ log_note "block size $size_str" # Get the ZSTD header reported by zdb -Z zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') +zstd_size=$(echo "$zstd_str" | cut -d: -f 1) log_note "ZSTD compressed size $zstd_size" (( $psize_bytes < $zstd_size )) && log_fail \ "zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)" -zstd_version=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') +zstd_version=$(echo "$zstd_str" | cut -d: -f 2) log_note "ZSTD version $zstd_version" -zstd_level=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') +zstd_level=$(echo "$zstd_str" | cut -d: -f 3) log_note "ZSTD level $zstd_level" (( $zstd_level != $random_level )) && log_fail \ "zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)" -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +vdev=$(echo "$dva" | cut -d: -f 1) +offset=$(echo "$dva" | cut -d: -f 2) # Check the first 1024 bytes output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) outsize=$(wc -c <<< "$output") diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh index 5cc4575851f7..ef7eb8fff13e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh @@ -106,8 +106,8 @@ if [ "$output" != "$blk_out1" ]; then log_fail "zdb -R :b80d (block 1 display/decompress) failed" fi -vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}') -offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}') +vdev=$(echo "$dva" | cut -d: -f1) +offset=$(echo "$dva" | cut -d: -f2) output=$(export ZDB_NO_ZLE=\"true\";\ zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) block_cnt=$(echo "$output" | grep 'L0' | wc -l) diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh index e2014405853d..94553290309b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh @@ -65,7 +65,7 @@ done # Specifying a non-existent object identifier returns an error obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | sort -n | tail -n 1 | awk '{print $1}') + egrep "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}') obj_id_invalid=$(( $obj_id_highest + 1 )) log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh index 1e63ac7d2f4e..ff46b0f2f870 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh @@ -42,8 +42,8 @@ function get_object_list_range begin=$2 end=$3 get_object_list $dataset | - while read line; do - obj=$(echo $line | awk '{print $1}') + while read -r line; do + read -r obj _ <<<"$line" if [[ $obj -ge $begin && $obj -le $end ]] ; then echo "$line" elif [[ $obj -gt $end ]] ; then @@ -142,7 +142,7 @@ log_must test "\n$actual\n" == "\n$expected\n" # Specifying individual object IDs works objects="$start1 $end1 $start2 $end2" expected="$objects" -actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{print $1}' | tr '\n' ' ') +actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{printf("%s ", $1)}' | tr '\n' ' ') log_must test "${actual% }" == "$expected" # Get all objects in the meta-objset to test m (spacemap) and z (zap) flags diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh index accb125280f0..c3021d175921 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -68,63 +68,41 @@ log_note "file $init_data has object number $obj" sync_pool $TESTPOOL output=$(zdb -d $TESTPOOL/$TESTFS) -objset_id=$(echo $output | awk '{split($0,array,",")} END{print array[2]}' | - awk '{split($0,array," ")} END{print array[2]}') +objset_id=$(echo $output | cut -d, -f2 | cut -d' ' -f2) objset_hex=$(printf "0x%X" $objset_id) log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" for id in "$objset_id" "$objset_hex" do log_note "zdb -dddddd $TESTPOOL/$id $obj" - output=$(zdb -dddddd $TESTPOOL/$id $obj) - reason="($TESTPOOL/$TESTFS not in zdb output)" - echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$id $obj failed $reason" - reason="(file1 not in zdb output)" - echo $output |grep "file1" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$id $obj failed $reason" - obj=$(printf "0x%X" $obj) + output=$(zdb -dddddd $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" + obj=$(printf "0x%X" $obj) log_note "zdb -NNNNNN $TESTPOOL/$id $obj" output=$(zdb -NNNNNN $TESTPOOL/$id $obj) - reason="($TESTPOOL/$TESTFS not in zdb output)" - echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" - reason="(file1 not in zdb output)" - echo $output |grep "file1" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" done if is_linux; then output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) objset_hex=${output#*-} name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | - grep dataset_name | awk '{split($0,array," ")} END{print array[3]}') + grep dataset_name | cut -d' ' -f3) log_note "checking zdb output for $name_from_proc" - reason="(name $name_from_proc from proc not in zdb output)" - log_note "zdb -dddddd $TESTPOOL/$objset_hex" - output=$(zdb -dddddd $TESTPOOL/$objset_hex) - echo $output |grep "$name_from_proc" > /dev/null - (( $? != 0 )) && log_fail \ - "zdb -dddddd $TESTPOOL/$objset_hex failed $reason" + log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" fi log_must zfs create $hex_ds log_must zfs create $num_ds -output=$(zdb -d $hex_ds) -reason="($TESTPOOL/0x400 not in zdb output)" -echo $output |grep "$hex_ds" > /dev/null -(( $? != 0 )) && log_fail \ - "zdb -d $hex_ds failed $reason" -output=$(zdb -d $num_ds) -reason="($num_ds not in zdb output)" -echo $output |grep "$num_ds" > /dev/null -(( $? != 0 )) && log_fail \ - "zdb -d $num_ds failed $reason" +log_must eval "zdb -d $hex_ds | grep -q \"$hex_ds\"" +log_must eval "zdb -d $num_ds | grep -q \"$num_ds\"" # force numeric interpretation, expect fail log_mustnot zdb -N $hex_ds diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh index 4bfb3d5f78ab..5f42006de289 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh @@ -40,8 +40,7 @@ # 2. Verify it succeed while upgrade, but fails while the version downgraded. # -ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ - | sed -e 's/\.//g') +ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*') verify_runnable "both" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh index 13f5418d4bf5..643bf1cf28e7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh @@ -221,7 +221,7 @@ for (( i = 1; i <= (ZFS_MAXPROPLEN / 200 + 1); i++ )); do log_must zfs clone ${fs}@snap ${fs}/${TESTCLONE}${xs}.${i} done clone_list=$(zfs list -o clones $fs@snap) -char_count=$(echo "$clone_list" | tail -1 | wc | awk '{print $3}') +char_count=$(echo "$clone_list" | tail -1 | wc -c) [[ $char_count -eq $ZFS_MAXPROPLEN ]] || \ log_fail "Clone list not truncated correctly. Unexpected character count" \ "$char_count" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh index 61d7aa28d27c..aa895956c936 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh @@ -94,11 +94,9 @@ done log_note "Verify df(1) can correctly display the space charged." for val in 1 2 3; do if is_freebsd; then - used=`df -m /$TESTPOOL/fs_$val | grep $TESTPOOL/fs_$val \ - | awk -v fs=fs_$val '$4 ~ fs {print $3}'` + used=`df -m /$TESTPOOL/fs_$val | awk -v pa=$TESTPOOL/fs_$val -v fs=fs_$val '$0 ~ pa && $4 ~ fs {print $3}'` else - used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \ - | awk '{print $3}'` + used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | awk -v pa=$TESTPOOL/fs_$val '$0 ~ pa {print $3}'` (( used = used * 1024 )) # kb -> bytes fi check_used $used $val diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh index 63f5e595ea38..6722a659eb65 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh @@ -62,8 +62,7 @@ function cleanup # check to see if there is any new fs created during the test # if so destroy it. # - for dset in $(zfs list -H | \ - awk '{print $1}' | grep / ); do + for dset in $(zfs list -H | awk '$1 ~ /\/ {print $1}'); do found=false i=0 while (( $i < ${#existed_fs[*]} )); do @@ -99,7 +98,7 @@ log_assert "Verify 'zfs create ' fails with bad argumen datasetexists $TESTPOOL/$TESTFS || \ log_must zfs create $TESTPOOL/$TESTFS -set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) +set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}') log_mustnot zfs create $TESTPOOL log_mustnot zfs create $TESTPOOL/$TESTFS diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh index 4b1401d8649b..d4784d6530e5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh @@ -62,8 +62,7 @@ function cleanup # check to see if there is any new fs created during the test # if so destroy it. # - for dset in $(zfs list -H | \ - awk '{print $1}' | grep / ); do + for dset in $(zfs list -H | awk '$1 ~ /\// {print $1}'); do found=false i=0 while (( $i < ${#existed_fs[*]} )); do @@ -108,7 +107,7 @@ set -A options "" "-s" datasetexists $TESTPOOL/$TESTVOL || \ log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL -set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / ) +set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}') log_mustnot zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL log_mustnot zfs create -s -V $VOLSIZE $TESTPOOL/$TESTVOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh index a0b8d52f0c43..2a140d954876 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh @@ -41,8 +41,7 @@ # 2. Verify only the leaf filesystem to be version=1, others use the current version # -ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \ - | sed -e 's/\.//g') +ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*') verify_runnable "both" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib index 4c3f8b908c10..bf8e145e5112 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib @@ -40,15 +40,12 @@ function propertycheck { typeset dtst=$1 typeset propstr=$2 + typeset prop expect_value - typeset prop=$(echo $propstr | awk -F= '{print $1}') - typeset expect_value=$(echo $propstr | awk -F= '{print $2}') - typeset value=$(zfs get -H -p -o value $prop $dtst) + IFS='=' read -r prop expect_value <<<"$propstr" + typeset value=$(get_prop $prop $dtst) - if [[ "$expect_value" == "$value" ]]; then - return 0 - else - return 1 - fi + + [ "$expect_value" = "$value" ] } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh index 9a2ff6bea36d..d618f21e9eb5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh @@ -98,8 +98,7 @@ log_must zfs set mountpoint=$mntp1 $fs1 log_must zfs set mountpoint=$mntp2 $clone for arg in "$fs1 $mntp1" "$clone $mntp2"; do - fs=`echo $arg | awk '{print $1}'` - mntp=`echo $arg | awk '{print $2}'` + read -r fs mntp <<<"$arg" log_note "Verify that 'zfs destroy' fails to" \ "destroy filesystem when it is busy." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh index 51a1b4aa1199..ca8df6dab910 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh @@ -47,7 +47,7 @@ function verify_object_change # change="$2" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" - diffchg="$(awk -v path="$path" '$NF == path { print $1 }' < $FILEDIFF)" + diffchg="$(awk -v path="$path" '$NF == path { print $1 }' $FILEDIFF)" if [[ "$diffchg" != "$change" ]]; then log_fail "Unexpected change for $path ('$diffchg' != '$change')" else diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh index 0d08cf629572..81ee87f8aee9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh @@ -73,10 +73,8 @@ log_must zfs snapshot "$TESTSNAP2" # 3. Verify 'zfs diff -t' correctly display timestamps typeset -i count=0 log_must eval "zfs diff -t $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" -awk '{print substr($1,1,index($1,".")-1)" "$NF}' < "$FILEDIFF" | while read line +awk '{print substr($1,1,index($1,".")-1) " " $NF}' "$FILEDIFF" | while read -r ctime file do - read ctime file <<< "$line" - # If path from 'zfs diff' is not a file (could be xattr object) skip it if [[ ! -f "$file" ]]; then continue; diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh index 8e521b9f5a1e..51f0295cd3c8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh @@ -52,7 +52,7 @@ function verify_object_class # symbol="$2" log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF" - diffsym="$(awk -v path="$path" '$NF == path { print $2 }' < $FILEDIFF)" + diffsym="$(awk -v path="$path" '$NF == path { print $2 }' $FILEDIFF)" if [[ "$diffsym" != "$symbol" ]]; then log_fail "Unexpected type for $path ('$diffsym' != '$symbol')" else diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index 807954a60692..b3286c31e6fa 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -102,16 +102,15 @@ function check_return_value found=0 while read line; do - typeset item - typeset value + typeset item value _ - item=$(echo $line | awk '{print $2}' 2>&1) + read -r _ item _ <<<"$line" if [[ $item == $p ]]; then ((found += 1)) cols=$(echo $line | awk '{print NF}') fi - value=$(echo $line | awk '{print $3}' 2>&1) + read -r _ _ value _ <<<"$line" if [[ $value == $uint64_max ]]; then log_fail "'zfs get $opt $props $dst' return " \ "UINT64_MAX constant." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh index 2ea5aa0cb4cf..e96899118a89 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh @@ -55,9 +55,8 @@ log_onexit cleanup log_must zfs set atime=on $TESTPOOL/$TESTFS log_must zfs mount -o remount,noatime $TESTPOOL/$TESTFS -value1=$(zfs get -H atime $TESTPOOL/$TESTFS | awk '{print $3}') -value2=$(zfs get -H all $TESTPOOL/$TESTFS | awk '{print $2 " " $3}' | \ - grep ^atime | awk '{print $2}') +read -r _ _ value1 _ < <(zfs get -H atime $TESTPOOL/$TESTFS) +read -r _ value2 < <(zfs get -H all $TESTPOOL/$TESTFS | cut -f2,3 | grep ^atime) if [[ $value1 != $value2 ]]; then log_fail "value1($value1) != value2($value2)" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh index 3bc4c6240ed3..de52c586f357 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh @@ -163,15 +163,12 @@ while (( i < ${#opts[*]} )); do log_must eval "zfs get ${opts[i]} all >$propfile" for ds in $allds; do - grep $ds $propfile >/dev/null 2>&1 - (( $? != 0 )) && \ + grep -q $ds $propfile || \ log_fail "There is no property for" \ "dataset $ds in 'get all' output." - propnum=`cat $propfile | awk '{print $1}' | \ - grep "${ds}$" | wc -l` - ds_type=`zfs get -H -o value type $ds` - case $ds_type in + propnum=$(awk -v ds="${ds}$" '$1 ~ ds {print $1}' $propfile | wc -l) + case $(zfs get -H -o value type $ds) in filesystem ) (( propnum < fspropnum )) && \ (( failflag += 1 )) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh index 8af9f80cfbd7..11a97a83e25e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh @@ -70,7 +70,8 @@ log_must key_available $TESTPOOL/$TESTFS1 log_mustnot eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS1" -typeset DISK2="$(echo $DISKS | awk '{ print $2 }')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \ "-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $DISK2" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh index 3c18e4538d34..515753722d20 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh @@ -56,7 +56,8 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \ log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -typeset DISK2="$(echo $DISKS | awk '{ print $2}')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must zpool create -O encryption=on -O keyformat=passphrase \ -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib index 85566e565319..23cab2511a41 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib @@ -35,10 +35,7 @@ function force_unmount #dev { typeset dev=$1 - ismounted $dev - if (( $? == 0 )); then - log_must zfs $unmountforce $dev - fi + ismounted $dev && log_must zfs $unmountforce $dev return 0 } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh index 409dd06d7f88..a11f53d79ba0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh @@ -112,7 +112,7 @@ function get_reverse_option typeset val typeset -i ind=0 - val=$(get_prop $prop $fs) || log_fail "get_prop $prop $fs" + val=$(get_prop $prop $fs) if [[ $val == "on" ]]; then (( ind = i * 2 )) else @@ -127,7 +127,6 @@ cleanup for property in ${properties[@]}; do orig_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" # Set filesystem property temporarily reverse_opt=$(get_reverse_option $fs $property) @@ -135,7 +134,6 @@ for property in ${properties[@]}; do log_must zfs mount -o $reverse_opt $fs cur_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" # In LZ, a user with all zone privileges can never with "devices" if ! is_global_zone && [[ $property == devices ]] ; then @@ -153,7 +151,6 @@ for property in ${properties[@]}; do log_must zfs mount $fs cur_val=$(get_prop $property $fs) - (($? != 0)) && log_fail "get_prop $property $fs" if [[ $orig_val != $cur_val ]]; then log_fail "zfs mount -o $reverse_opt " \ "change the property that is stored on disks" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh index f31ff48099e9..f53a4ac71b68 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh @@ -217,12 +217,11 @@ for ds in $datasets; do sync_pool done recursive_output=$(zfs get -p -r written@current $TESTPOOL | \ - grep -v $TESTFS1@ | grep -v $TESTFS2@ | grep -v $TESTFS3@ | \ - grep -v "VALUE" | grep -v "-") + grep -ve $TESTFS1@ -e $TESTFS2@ -e $TESTFS3@ -e "VALUE" | grep -v "-") expected="$((20 * mb_block))" for ds in $datasets; do writtenat=$(echo "$recursive_output" | grep -v $ds/) - writtenat=$(echo "$writtenat" | grep $ds | awk '{print $3}') + writtenat=$(echo "$writtenat" | awk -v ds="$ds" '$0 ~ ds {print $3}') within_percent $writtenat $expected 99.5 || \ log_fail "Unexpected written@ value on $ds" done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh index cce387615315..48cebc87f039 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh @@ -62,7 +62,7 @@ log_onexit cleanup ibackup=$TEST_BASE_DIR/ibackup.$$ fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2 -mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" +mntpnt=$(get_prop mountpoint $fs) log_must mkfile 10m $mntpnt/file1 log_must zfs snapshot $snap1 log_must mkfile 10m $mntpnt/file2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh index 79f34bd3ff8c..06a0804515a7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh @@ -82,7 +82,7 @@ datasetexists $ancestor_fs || \ log_must zfs create $ancestor_fs log_must zfs create $fs -mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" +mntpnt=$(get_prop mountpoint $fs) log_must mkfile 10m $mntpnt/file1 log_must zfs snapshot $snap1 log_must mkfile 10m $mntpnt/file2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh index fbf0654e4f23..ec2437db929f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh @@ -64,7 +64,7 @@ ibackup=$TEST_BASE_DIR/ibackup.$$ datasetexists $fs || log_must zfs create $fs -mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs" +mntpnt=$(get_prop mountpoint $fs) log_must mkfile 10m $mntpnt/file1 log_must zfs snapshot $snap1 log_must mkfile 10m $mntpnt/file2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh index dc4892b5d50e..f948dfd6690b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh @@ -86,9 +86,6 @@ for orig_fs in $datasets ; do typeset mntpnt mntpnt=$(get_prop mountpoint $orig_fs) - if [[ $? -ne 0 ]] ; then - log_fail "get_prop mountpoint $orig_fs failed" - fi typeset mnt_file=$mntpnt/file1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh index e1e93e9d2a3b..87bb63b36e52 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh @@ -52,7 +52,7 @@ log_onexit cleanup truncate -s 100M $tpoolfile log_must zpool create $temppool $tpoolfile log_must zfs create $src_fs -src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs" +src_mnt=$(get_prop mountpoint $src_fs) echo blah > $src_mnt/blah zfs snapshot $src_fs@base diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh index 72eebb4f9321..05c2ece4654f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh @@ -58,27 +58,22 @@ log_note "Randomly selected ZSTD level: $random_level" log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1 # Make a 5kb compressible file -log_must cat $src_data $src_data $src_data $src_data $src_data \ - > /$TESTPOOL/$TESTFS1/$TESTFILE0 +log_must eval cat $src_data $src_data $src_data $src_data $src_data \ + "> /$TESTPOOL/$TESTFS1/$TESTFILE0" typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0) log_must zfs snapshot $snap # get object number of file -listing=$(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0) log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva" -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') -zstd_version1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') -zstd_level1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') +read -r zstd_size1 zstd_version1 zstd_level1 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output") log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1" log_note "Verify ZFS can receive the ZSTD compressed stream" @@ -89,23 +84,18 @@ typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0) log_fail "Checksums differ ($cksum1 != $checksum)" # get object number of file -listing=$(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0) log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva" -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}') +read -r zstd_size2 zstd_version2 zstd_level2 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output") +log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2" (( $zstd_size2 != $zstd_size1 )) && log_fail \ "ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)" -zstd_version2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}') -zstd_level2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}') -log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2" (( $zstd_level2 != $zstd_level1 )) && log_fail \ "ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh index 1c707762a72c..96826d814f18 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh @@ -39,7 +39,7 @@ function rename_cleanup zfs destroy -fR $TESTPOOL/renamed } -back=$(pwd) +back=$PWD log_onexit rename_cleanup log_must zfs create $TESTPOOL/rename_test @@ -72,14 +72,15 @@ log_must zfs list $TESTPOOL/renamed log_must zfs list $TESTPOOL/renamed/child log_must zfs list $TESTPOOL/renamed/child/grandchild -missing=$(zfs mount | awk -v pat=$TESTPOOL/renamed '$1 ~ pat' | awk \ +missing=$(zfs mount | awk \ + -v genpat=$TESTPOOL/renamed \ -v mntp_p=$mntp_p \ -v mntp_c=$mntp_c \ -v mntp_g=$mntp_g ' BEGIN { p = c = g = 0 } - $2 == mntp_p { p = 1 } - $2 == mntp_c { c = 1 } - $2 == mntp_g { g = 1 } + $1 ~ genpat && $2 == mntp_p { p = 1 } + $1 ~ genpat && $2 == mntp_c { c = 1 } + $1 ~ genpat && $2 == mntp_g { g = 1 } END { if (p != 1) print mntp_p diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh index 85d076310588..15760398127c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh @@ -52,7 +52,7 @@ streamfile=$(mktemp $TESTDIR/file.XXXXXX) vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX) -test_pool () +function test_pool { POOL=$1 log_must zfs create -o recordsize=512 $POOL/fs @@ -67,10 +67,7 @@ test_pool () sync_all_pools # check if we started reusing objects object=$(ls -i $mntpnt | sort -n | awk -v object=$object \ - '{if ($1 <= object) {exit 1}} END {print $1}') - if [[ $? -ne 0 ]]; then - break - fi + '{if ($1 <= object) {exit 1}} END {print $1}') || break done dd if=/dev/urandom of=${mntpnt}/$FILE bs=512 count=1 seek=1 2>/dev/null diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh index ac5fc8188f5a..fe8aa2fd1e07 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh @@ -81,14 +81,8 @@ function cleanup log_assert "Setting a valid property of canmount to file system, it must be successful." log_onexit cleanup -typeset old_fs_canmount="" old_ctr_canmount="" - -old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTFS canmount error." -old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTCTR canmount error." +typeset old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS) +typeset old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR) log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh index 1255ae5f5666..30efef1c383f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh @@ -69,11 +69,7 @@ log_assert "Setting a valid mountpoint to file system, it must be successful." log_onexit cleanup old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTFS mountpoint error." old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Get the $TESTPOOL/$TESTCTR mountpoint error." if [[ ! -d $TESTDIR2 ]]; then log_must mkdir $TESTDIR2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh index 48580cafdb31..603e84dcd07f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh @@ -66,11 +66,7 @@ log_assert "Setting a valid mountpoint for an unmounted file system, \ log_onexit cleanup old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -[[ $? != 0 ]] && \ - log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS" old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR) -[[ $? != 0 ]] && \ - log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR" if [[ ! -d $TESTDIR2 ]]; then log_must mkdir $TESTDIR2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh index 4d86100c03ef..38bbda0d1fae 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh @@ -109,10 +109,8 @@ while ((i < ${#args[@]})); do msg=$(mount | grep "$tmpmnt ") - echo $msg | grep "${args[((i))]}" > /dev/null 2>&1 - if (($? != 0)) ; then - echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1 - if (($? == 0)) ; then + if ! echo $msg | grep -q "${args[((i))]}"; then + if echo $msg | grep -q "${args[((i-1))]}"; then log_fail "Expected option: ${args[((i))]} \n" \ "Real option: $msg" fi @@ -130,8 +128,7 @@ while ((i < ${#args[@]})); do args[((i+1))]="/nodevices/" fi - echo $msg | grep "${args[((i+1))]}" > /dev/null 2>&1 - if (($? != 0)) ; then + if ! echo $msg | grep -q "${args[((i+1))]}"; then log_fail "Expected option: ${args[((i+1))]} \n" \ "Real option: $msg" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh index 4ff539a377d4..407936c7c438 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh @@ -84,7 +84,7 @@ while (( i < ${#invalid_args[*]} )); do ((i = i + 1)) done log_note "verify multiple snapshot transaction group" -txg_group=$(zdb -Pd $TESTPOOL | grep snap | awk '{print $7}') +txg_group=$(zdb -Pd $TESTPOOL | awk '/snap/ {print $7}') for i in 1 2 3; do txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}') [[ $txg_tag != $(echo "$txg_group" | \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh index 55da68262019..6d3d37bd618a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh @@ -54,7 +54,8 @@ log_must zfs create $TESTPOOL/$TESTFS1/child log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \ -o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol -typeset DISK2="$(echo $DISKS | awk '{ print $2}')" +typeset DISK2 _ +read -r _ DISK2 _ <<<"$DISKS" log_must zpool create -O encryption=on -O keyformat=passphrase \ -O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh index 8b70e8868a02..0afb9b6f8501 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh @@ -56,7 +56,6 @@ log_onexit cleanup # Call cleanup to make sure the file system are mounted. cleanup mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS) -(($? != 0)) && log_fail "get_prop mountpoint $TESTPOOL/$TESTFS" typeset -i i=0 while (( i < 10000 )); do diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh index ab76461638b9..3b4451c74884 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh @@ -72,7 +72,7 @@ typeset expect_str3="The following filesystems are out of date, and can be upgra typeset -i COUNT OLDCOUNT zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput -OLDCOUNT=$( wc -l $oldoutput | awk '{print $1}' ) +OLDCOUNT=$(wc -l < $oldoutput) old_datasets="" for version in $ZFS_ALL_VERSIONS ; do @@ -100,7 +100,7 @@ log_must eval 'zfs upgrade > $output 2>&1' # of the current ZFS version. log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output -COUNT=$( wc -l $output | awk '{print $1}' ) +COUNT=$(wc -l < $output) typeset -i i=0 for fs in ${old_datasets}; do @@ -125,7 +125,7 @@ else log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1' fi zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output -COUNT=$( wc -l $output | awk '{print $1}' ) +COUNT=$(wc -l < $output) if (( COUNT != OLDCOUNT )); then cat $output diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh index 8c7f40ba9c0b..b131bc708dbc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh @@ -39,8 +39,7 @@ log_onexit cleanup log_assert "Test colorized zpool status output" -DISK2="$(echo $DISKS | cut -d' ' -f2)" -DISK3="$(echo $DISKS | cut -d' ' -f3)" +read -r _ DISK2 DISK3 _ <<<"$DISKS" log_must dd if=/dev/urandom of=/$TESTDIR/testfile bs=10M count=1 @@ -62,16 +61,15 @@ log_note "$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status)" # Replace the escape codes with "ESC" so they're easier to grep out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status | \ - grep -E 'pool:|DEGRADED' | \ - sed -r 's/[[:space:]]+//g;'$(echo -e 's/\033/ESC/g'))" + sed -E '/pool:|DEGRADED/!d;s/[[:space:]]+//g;'$(printf 's/\033/ESC/g'))" log_note "$(echo $out)" log_note "Look for 'pool:' in bold" -log_must eval "echo \"$out\" | grep -q 'ESC\[1mpool:ESC\[0m' " +log_must grep -q 'ESC\[1mpool:ESC\[0m' <<<"$out" log_note "Look for 'DEGRADED' in yellow" -log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'" +log_must grep -q 'ESC\[0;33mDEGRADEDESC\[0m' <<<"$out" # # The escape code for 'FAULTED' is a little more tricky. The line starts like @@ -83,9 +81,11 @@ log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'" # we can easily remove the vdev field to get what we want. # out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status \ - | awk '/FAULTED/{print $1$3$4}' | sed -r $(echo -e 's/\033/ESC/g'))" + | awk '/FAULTED/ {print $1$3$4}' | sed -E $(printf 's/\033/ESC/g'))" + +log_note "$(echo $out)" log_note "Look for 'FAULTED' in red" -log_must eval "echo \"$out\" | grep -q 'ESC\[0;31mFAULTEDESC\[0m'" +log_must grep -q 'ESC\[0;31mFAULTEDESC\[0m' <<<"$out" log_pass "zpool status displayed colors" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh index 61f5f6d1ceed..677d0762eecb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh @@ -90,10 +90,8 @@ do log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60 zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""} $1 ~ poolname {c=4}; (c && c--) { s=s$1":" } - END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' - if [[ $? -ne 0 ]]; then + END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' || log_fail "Pool does not contain nested replacing/spare vdevs" - fi # 3. Verify 'zpool add' is able to add new devices log_must zpool add $TESTPOOL spare $SPARE_DEV2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib index c64b4a35aa03..e10357340b40 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib @@ -50,9 +50,8 @@ function find_vfstab_dev # function find_mnttab_dev { - typeset mnttabdev + typeset mnttabdev _ typeset mnttabdevs="" - typeset line if is_freebsd; then # FreeBSD doesn't have a mnttab file. @@ -61,21 +60,16 @@ function find_mnttab_dev return 0 elif is_linux; then typeset mnttab="/etc/mtab" - typeset tmpfile="$TEST_BASE_DIR/mtab.tmp" else typeset mnttab="/etc/mnttab" - typeset tmpfile="$TEST_BASE_DIR/mnttab.tmp" fi - cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile - while read -r line + while read -r mnttabdev _ do - mnttabdev=`echo "$line" | awk '{print $1}'` mnttabdev=${mnttabdev%%:} mnttabdevs="$mnttabdev $mnttabdevs" - done <$tmpfile + done < <(grep "^${DEV_DSKDIR}" $mnttab) - rm -f $tmpfile echo $mnttabdevs } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh index a6b03ff3257f..3816444667cf 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh @@ -90,8 +90,8 @@ done log_must zpool add -f $TESTPOOL $config zpool status $TESTPOOL | awk 'NR == 1, /NAME/ { next } /^$/ {exit} {print $1}' > "$TMPFILE_PREFIX-vdevtree" -cat "$TMPFILE_PREFIX-dryrun" | awk 'NR == 1, /would/ {next} - /^$/ {next} {print $1}' > "$TMPFILE_PREFIX-vdevtree-n" -log_must eval "diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree" +awk 'NR == 1, /would/ {next} + /^$/ {next} {print $1}' "$TMPFILE_PREFIX-dryrun" > "$TMPFILE_PREFIX-vdevtree-n" +log_must diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree log_pass "'zpool add -n ...' executes successfully." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh index 1188ca10d14d..f1f926831baa 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh @@ -50,9 +50,7 @@ function cleanup poolexists $TESTPOOL1 && \ log_must zpool destroy -f $TESTPOOL1 - for file in `ls $TEST_BASE_DIR/file.*`; do - log_must rm -f $file - done + log_must rm -f $fbase.{0..2} } @@ -60,14 +58,8 @@ log_assert "Verify 'zpool clear' can clear errors of a storage pool." log_onexit cleanup #make raw files to create various configuration pools -typeset -i i=0 -while (( i < 3 )); do - log_must truncate -s $FILESIZE $TEST_BASE_DIR/file.$i - - (( i = i + 1 )) -done - fbase=$TEST_BASE_DIR/file +log_must truncate -s $FILESIZE $fbase.{0..2} set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \ "raidz1 $fbase.0 $fbase.1 $fbase.2" \ "raidz2 $fbase.0 $fbase.1 $fbase.2" @@ -75,59 +67,24 @@ set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \ function check_err # [] { typeset pool=$1 - shift - if (( $# > 0 )); then - typeset checkvdev=$1 - else - typeset checkvdev="" - fi - typeset -i errnum=0 - typeset c_read=0 - typeset c_write=0 - typeset c_cksum=0 - typeset tmpfile=$TEST_BASE_DIR/file.$$ - typeset healthstr="pool '$pool' is healthy" - typeset output="`zpool status -x $pool`" - - [[ "$output" == "$healthstr" ]] && return $errnum - - zpool status -x $pool | grep -v "^$" | grep -v "pool:" \ - | grep -v "state:" | grep -v "config:" \ - | grep -v "errors:" > $tmpfile - typeset line - typeset -i fetchbegin=1 - while read line; do - if (( $fetchbegin != 0 )); then - echo $line | grep "NAME" >/dev/null 2>&1 - (( $? == 0 )) && (( fetchbegin = 0 )) - continue - fi + typeset checkvdev=$2 - if [[ -n $checkvdev ]]; then - echo $line | grep $checkvdev >/dev/null 2>&1 - (( $? != 0 )) && continue - c_read=`echo $line | awk '{print $3}'` - c_write=`echo $line | awk '{print $4}'` - c_cksum=`echo $line | awk '{print $5}'` - if [ $c_read != 0 ] || [ $c_write != 0 ] || \ - [ $c_cksum != 0 ] - then - (( errnum = errnum + 1 )) - fi - break - fi + [ "$(zpool status -x $pool)" = "pool '$pool' is healthy" ] && return + + typeset -i skipstart=1 + typeset vdev _ c_read c_write c_cksum rest + while read -r vdev _ c_read c_write c_cksum rest; do + if [ $skipstart -ne 0 ]; then + [ "$vdev" = "NAME" ] && skipstart=0 + continue + fi - c_read=`echo $line | awk '{print $3}'` - c_write=`echo $line | awk '{print $4}'` - c_cksum=`echo $line | awk '{print $5}'` - if [ $c_read != 0 ] || [ $c_write != 0 ] || \ - [ $c_cksum != 0 ] - then - (( errnum = errnum + 1 )) + if [ -n "$checkvdev" ]; then + [ "$vdev" = "$checkvdev" ] || continue fi - done <$tmpfile - return $errnum + [ $c_read$c_write$c_cksum = 000 ] || return + done < <(zpool status -x $pool | grep -ve "^$" -e "pool:" -e "state:" -e "config:" -e "errors:") } function do_testing # @@ -137,6 +94,7 @@ function do_testing # typeset type=$1 shift typeset vdev="$@" + (( i = $RANDOM % 3 )) log_must zpool create -f $TESTPOOL1 $vdev log_must zfs create $FS @@ -146,14 +104,13 @@ function do_testing # # avail=$(get_prop available $FS) fill_mb=$(((avail / 1024 / 1024) * 25 / 100)) - log_must dd if=/dev/urandom of=$file.$i bs=$BLOCKSZ count=$fill_mb + log_must dd if=/dev/urandom of=$file bs=$BLOCKSZ count=$fill_mb # # Make errors to the testing pool by overwrite the vdev device with # dd command. We do not want to have a full overwrite. That # may cause the system panic. So, we should skip the vdev label space. # - (( i = $RANDOM % 3 )) typeset -i wcount=0 typeset -i size case $FILESIZE in @@ -173,25 +130,19 @@ function do_testing # (( wcount = FILESIZE/1024 - 512 )) ;; esac - dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc \ - > /dev/null 2>&1 + dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc 2>/dev/null sync_all_pools log_must sync #ensure the vdev files are written out log_must zpool scrub -w $TESTPOOL1 - check_err $TESTPOOL1 && \ - log_fail "No error generated." - if [[ $type == "device" ]]; then - log_must zpool clear $TESTPOOL1 $fbase.$i - ! check_err $TESTPOOL1 $fbase.$i && \ - log_fail "'zpool clear' fails to clear error for $fbase.$i device." + log_mustnot check_err $TESTPOOL1 + typeset dev= + if [ "$type" = "device" ]; then + dev=$fbase.$i fi - if [[ $type == "pool" ]]; then - log_must zpool clear $TESTPOOL1 - ! check_err $TESTPOOL1 && \ - log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1." - fi + log_must zpool clear $TESTPOOL1 $dev + log_must check_err $TESTPOOL1 $dev log_must zpool destroy $TESTPOOL1 } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index 005cf979befa..9954bc23fc9f 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -83,14 +83,9 @@ function find_vfstab_dev # function save_dump_dev { - typeset dumpdev="" - if is_illumos; then - typeset fnd="Dump device" - dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \ - awk '{print $1}'` + dumpadm | grep "Dump device" | cut -f2 -d : | awk '{print $1}' fi - echo $dumpdev } # diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh index e1d8cc474545..98f469108b15 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh @@ -90,8 +90,8 @@ do $file.1 $file.2 $file.3 $file.4 ! poolexists $TESTPOOL && \ log_fail "Creating pool with $opt fails." - mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'` - (( ${#mpt} == 0 )) && \ + mpt=`zfs mount | awk -v pat="^$TESTPOOL[^/]" '$0 ~ pat {print $2}'` + [ -z "$mpt" ] && \ log_fail "$TESTPOOL created with $opt is not mounted." mpt_val=$(get_prop "mountpoint" $TESTPOOL) [[ "$mpt" != "$mpt_val" ]] && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh index 36888e497369..b9274c08b2ab 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh @@ -51,12 +51,11 @@ function cleanup } if is_freebsd; then - typeset swap_disks=$(swapinfo -l | grep "/dev" | awk '{print $1}') + typeset swap_disks=$(swapinfo -l | awk '/\/dev/ {print $1}') elif is_linux; then - typeset swap_disks=`swapon -s | grep "/dev" | awk '{print $1}'` + typeset swap_disks=$(swapon -s | awk '/\/dev/ {print $1}') else - typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \ - awk '{print $1}'` + typeset swap_disks=$(swap -l | awk '/c[0-9].*d[0-9].*s[0-9]/ {print $1}') fi log_assert "'zpool create' should fail with disk slice in swap." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh index 1fa205b0f253..e4543f0df79b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh @@ -67,8 +67,8 @@ function cleanup fi } -typeset swap_disks=$(swap -l | grep -v "swapfile" | awk '{print $1}') -typeset dump_device=$(dumpadm | grep "Dump device" | awk '{print $3}') +typeset swap_disks=$(swap -l | awk '!/swapfile/ {print $1}') +typeset dump_device=$(dumpadm | awk '/Dump device/ {print $3}') log_assert "'zpool create' should success with no device in swap." log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh index 8fd1cea36e28..a75bdecff475 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh @@ -55,11 +55,9 @@ for poolprop in "${poolprops[@]}"; do # 2. Verify the pool is created with the specified temporary name log_must poolexists $TEMPPOOL log_mustnot poolexists $TESTPOOL - propname="$(awk -F= '{print $1}' <<< $fsprop)" - propval="$(awk -F= '{print $2}' <<< $fsprop)" + IFS='=' read -r propname propval <<<"$fsprop" log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval" - propname="$(awk -F= '{print $1}' <<< $poolprop)" - propval="$(awk -F= '{print $2}' <<< $poolprop)" + IFS='=' read -r propname propval <<<"$poolprop" log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval" # Cleanup destroy_pool $TEMPPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh index 22212a8f50a5..76d9c525e443 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh @@ -80,7 +80,7 @@ function damage_and_repair log_must zpool wait -t scrub $POOL log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports" - repaired=$(zpool status $POOL | grep "scan: scrub repaired" | awk '{print $4}') + repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}') if [ "$repaired" == "0B" ]; then log_fail "INVALID TEST -- expected scrub to repair some blocks" else @@ -90,7 +90,7 @@ function damage_and_repair function checksum_error_count { - zpool status -p $POOL | grep $VDEV1 | awk '{print $5}' + zpool status -p $POOL | awk -v dev=$VDEV1 '$0 ~ dev {print $5}' } assertion="Damage to recently repaired blocks should be reported/counted" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg index 8bfb067c7aac..349399263da8 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg @@ -30,9 +30,9 @@ . $STF_SUITE/include/libtest.shlib -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $3}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') +read -r DISK1 _ DISK2 _ <<<"$DISKS" +export DISK1 DISK2 if is_linux; then set_slice_prefix diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh index ba83fadb06f1..b695b7188cb7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh @@ -88,7 +88,7 @@ done # increment the counter to include the header line i=$(( $i + 1 )) -COUNT=$(wc $values | awk '{print $1}') +COUNT=$(wc -l < $values) if [ $i -ne $COUNT ] then log_fail "Found zpool features not in the zpool_get test config $i/$COUNT." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh index ad27d180fdb1..4481dab69f7b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh @@ -50,14 +50,9 @@ typeset -i i=0 while [[ $i -lt "${#properties[@]}" ]]; do log_note "Checking for parsable ${properties[$i]} property" log_must eval "zpool get -p ${properties[$i]} $TESTPOOL >/tmp/value.$$" - grep "${properties[$i]}" /tmp/value.$$ >/dev/null 2>&1 - if [[ $? -ne 0 ]]; then - log_fail "${properties[$i]} not seen in output" - fi - - typeset v=$(grep "${properties[$i]}" /tmp/value.$$ | awk '{print $3}') + log_must grep -q "${properties[$i]}" /tmp/value.$$ - log_note "${properties[$i]} has a value of $v" + typeset v=$(awk -v p="${properties[$i]}" '$0 ~ p {print $3}' /tmp/value.$$) # Determine if this value is a valid number, result in return code log_must test -n "$v" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 5503d30b5512..37f7acfbf198 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -143,13 +143,12 @@ function verify_data_md5sums return 1 fi - cat $md5file | \ - while read digest file; do + while read -r digest file; do typeset digest1=$(md5digest $file) if [[ "$digest1" != "$digest" ]]; then return 1 fi - done + done < $md5file return 0 } @@ -227,8 +226,7 @@ function check_pool_config typeset actual="" typeset began=false - printf "$status\n" | while read line; do - typeset vdev=$(echo "$line" | awk '{printf $1}') + while read -r vdev _; do if ( ! $began ) && [[ $vdev == NAME ]]; then began=true continue @@ -240,7 +238,7 @@ function check_pool_config vdev=$(_translate_vdev $vdev) actual="$actual $vdev" fi - done + done <<<"$status" expected="$poolname $expected" @@ -295,8 +293,7 @@ function check_pool_healthy return 1 fi - status=$(echo "$status" | grep "$pool" | grep -v "pool:" | \ - awk '{print $2}') + status=$(echo "$status" | awk -v p="$pool" '!/pool:/ && $0 ~ p {print $2}') if [[ $status != "ONLINE" ]]; then log_note "Invalid zpool status for '$pool': '$status'" \ @@ -314,9 +311,7 @@ function pool_is_replacing { typeset pool=$1 - zpool status $pool | grep "replacing" | grep "ONLINE" > /dev/null - - return $? + zpool status $pool | grep "replacing" | grep -q "ONLINE" } function set_vdev_validate_skip 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 4ebe6b59141d..9f5503454d95 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 @@ -76,11 +76,11 @@ function cleanup_all # # Try import individually if 'import -a' failed. # - for pool in `zpool import | grep "pool:" | awk '{print $2}'`; do + for pool in $(zpool import | awk '/pool:/ {print $2}'); do zpool import -f $pool done - for pool in `zpool import -d $DEVICE_DIR | grep "pool:" | awk '{print $2}'`; do + for pool in $(zpool import -d $DEVICE_DIR | awk '/pool:/ {print $2}'); do log_must zpool import -d $DEVICE_DIR -f $pool done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh index f774970a71be..083b7e55a0a8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh @@ -65,10 +65,7 @@ log_must zpool export $TESTPOOL metaslabs=0 bs=512 zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' | -while read -r offset_size; do - typeset offset=$(echo $offset_size | cut -d ' ' -f1) - typeset size=$(echo $offset_size | cut -d ' ' -f2) - +while read -r offset size; do log_note "offset: '$offset'" log_note "size: '$size'" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg index fdf2f428477f..f98b1c0613f6 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg @@ -28,8 +28,8 @@ # Copyright (c) 2012, 2016 by Delphix. All rights reserved. # -export DISK1=${DISKS%% *} -export DISK2=$(echo $DISKS | awk '{print $2}') +read -r DISK1 DISK2 _ <<<"$DISKS" +export DISK1 DISK2 export ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024)) export ZFS_SCAN_VDEV_LIMIT_DEFAULT=$((4*1024*1024)) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh index 1aff8d31d91c..39ae1c9d56f9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh @@ -71,12 +71,11 @@ fi # Verify we can set a combination of valid property values on the new pool for prop in "${good_props[@]}" do - propname="$(awk -F= '{print $1}' <<< $prop)" - propval="$(awk -F= '{print $2}' <<< $prop)" + IFS='=' read -r propname propval <<<"$prop" setup_mirror log_must zpool split -o $prop $TESTPOOL $TESTPOOL2 log_must zpool import -N -d $TEST_BASE_DIR $TESTPOOL2 - log_must test "$(get_pool_prop $propname $TESTPOOL2)" == "$propval" + log_must test "$(get_pool_prop $propname $TESTPOOL2)" = "$propval" destroy_pool $TESTPOOL destroy_pool $TESTPOOL2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh index 9866cf7a5a58..d2be9b65cceb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh @@ -122,7 +122,7 @@ typeset altroot="$TESTDIR/altroot-$TESTPOOL2" for config in "${goodconfs[@]}" do create_config="${config%% *}" - add_config="$(awk '{$1= "";print $0}' <<< $config)" + add_config="$(awk '{$1=""; print $0}' <<< $config)" log_must zpool create $TESTPOOL $(pool_config $create_config) for vdev in $add_config; do log_must zpool add -f $TESTPOOL $(pool_config $vdev) @@ -137,7 +137,7 @@ done for config in "${badconfs[@]}" do create_config="${config%% *}" - add_config="$(awk '{$1= "";print $0}' <<< $config)" + add_config="$(awk '{$1=""; print $0}' <<< $config)" log_must zpool create $TESTPOOL $(pool_config $create_config) for vdev in $add_config; do log_must zpool add -f $TESTPOOL $(pool_config $vdev) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib index 783ae54e717b..0bc2cfab0470 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib @@ -132,8 +132,7 @@ function check_poolversion fi # check version using zpool upgrade - actual=$(zpool upgrade | grep $pool$ | \ - awk '{print $1}' | sed -e 's/ //g') + actual=$(zpool upgrade | awk -v p="$pool$" '$0 ~ p {gsub(/ /, "", $1); print $1}') if [[ $actual != $vers ]] ; then log_fail "$pool: zpool reported version $actual, expected $vers" fi diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh index bfe8cf4bb29a..9188e4ba6350 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh @@ -55,6 +55,6 @@ TEMPFILE="$TEST_BASE_DIR/zfs_001_neg.$$.txt" zfs > $TEMPFILE 2>&1 log_must grep "usage: zfs command args" "$TEMPFILE" -log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" +log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE log_pass "zfs shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh index 0fddc08b25db..00a86eebafe6 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh @@ -59,6 +59,6 @@ log_assert "zpool shows a usage message when run as a user" eval "zpool > $TEMPFILE 2>&1" log_must grep "usage: zpool command args" "$TEMPFILE" -log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" +log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE log_pass "zpool shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh index 7415cebf236b..c8abf4da58e6 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh @@ -54,12 +54,12 @@ while [[ $i -lt ${#args[*]} ]] do PROP=${props[$i]} EXPECTED=${prop_vals[$i]} - ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) + ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' ) if [ "$ACTUAL" != "$EXPECTED" ] then log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED" fi - i=$(( $i + 1 )) + i=$(( $i + 1 )) done log_must zpool get all $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh index 941e20c0010e..03d01f20e959 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh @@ -59,7 +59,7 @@ do log_mustnot $POOL set $PROP=$NEW $TESTPOOL # Now verify that the above command did nothing - ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' ) + ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' ) if [ "$ACTUAL" != "$EXPECTED" ] then log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED" diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib index 889ae46fb932..d993c3037444 100644 --- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib @@ -120,7 +120,7 @@ function verify_reverse_sort { # command list name function is_fs_type_zfs { typeset dirname=$1 - typeset fs="$(df $dirname | tail -1 | awk '{print $NF}')" + typeset fs="$(df $dirname | awk 'END {print $NF}')" if is_freebsd; then fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \ diff --git a/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh b/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh index fe3a3acacc04..fb3bae3b6725 100755 --- a/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh @@ -60,8 +60,8 @@ log_must file_write -o $OP -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \ sleep 60 -FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{ print $1}'` -FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{ print $1}'` +FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{print $1}'` +FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{print $1}'` if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ diff --git a/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh b/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh index a07d70824042..e7c6d6c6e57e 100755 --- a/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh @@ -65,8 +65,8 @@ log_must file_write -o $OP -f $TESTDIR1/$TESTFILE1 -b $BLOCKSZ \ sleep 60 -FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{ print $1}'` -FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{ print $1}'` +FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{print $1}'` +FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{print $1}'` if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ diff --git a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib index a78b390aa18e..15adc5a63683 100644 --- a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib +++ b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib @@ -391,12 +391,11 @@ function verify_send user_run $user eval "zfs send $snap > $bak_user" log_must eval "zfs send $snap > $bak_root" - if [[ $(checksum $bak_user) == $(checksum $bak_root) ]]; then + if [ "$(cksum < $bak_user)" = "$(cksum < $bak_root)" ]; then ret=0 fi - rm -rf $bak_user > /dev/null - rm -rf $bak_root > /dev/null + rm -rf $bak_user $bak_root return $ret } @@ -462,12 +461,11 @@ function verify_fs_receive log_must eval "zfs receive $dtst < $bak_root" log_must eval "zfs send $dtstsnap > $bak_root" log_must_busy zfs destroy -rf $dtst - if [[ $(checksum $bak_user) != $(checksum $bak_root) ]]; then + if [ "$(cksum < $bak_user)" != "$(cksum < $bak_root)" ]; then return 1 fi - rm -rf $bak_user > /dev/null - rm -rf $bak_root > /dev/null + rm -rf $bak_user $bak_root done diff --git a/tests/zfs-tests/tests/functional/events/events.cfg b/tests/zfs-tests/tests/functional/events/events.cfg index 1405dab6f989..27046c1b0c6b 100644 --- a/tests/zfs-tests/tests/functional/events/events.cfg +++ b/tests/zfs-tests/tests/functional/events/events.cfg @@ -33,6 +33,4 @@ VDEV4=$TEST_BASE_DIR/vdev4 export TMP_EVENTS=$TEST_BASE_DIR/tmp_events.$$ export TMP_EVENTS_FULL=$TEST_BASE_DIR/tmp_events_full.$$ -export TMP_EVENT_FULL=$TEST_BASE_DIR/tmp_event_full.$$ export TMP_EVENTS_ZED=$TEST_BASE_DIR/tmp_events_zed.$$ -export TMP_EVENT_ZED=$TEST_BASE_DIR/tmp_event_zed.$$ diff --git a/tests/zfs-tests/tests/functional/events/events_002_pos.ksh b/tests/zfs-tests/tests/functional/events/events_002_pos.ksh index 9407656b6e6b..42088fc0905f 100755 --- a/tests/zfs-tests/tests/functional/events/events_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/events/events_002_pos.ksh @@ -42,15 +42,8 @@ verify_runnable "both" function cleanup { - if poolexists $MPOOL; then - destroy_pool $MPOOL - fi - - for file in $VDEV1 $VDEV2; do - [[ -f $file ]] && rm -f $file - done - - log_must rm -f $TMP_EVENTS_ZED + poolexists $MPOOL && log_must destroy_pool $MPOOL + log_must rm -f $VDEV1 $VDEV2 $TMP_EVENTS_ZED log_must zed_stop } @@ -69,10 +62,9 @@ log_must zed_start log_must file_wait_event $ZED_DEBUG_LOG 'sysevent\.fs\.zfs\.config_sync' 150 log_must cp $ZED_DEBUG_LOG $TMP_EVENTS_ZED -awk -v event="sysevent.fs.zfs.pool_create" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_ZED >$TMP_EVENT_ZED -log_must grep -q "^ZEVENT_POOL=$MPOOL" $TMP_EVENT_ZED +log_mustnot awk -v event="sysevent.fs.zfs.pool_create" -v crit="\\nZEVENT_POOL=$MPOOL" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_ZED # 3. Stop the ZED zed_stop diff --git a/tests/zfs-tests/tests/functional/events/events_common.kshlib b/tests/zfs-tests/tests/functional/events/events_common.kshlib index cc600c4ed510..73bf4cf357b5 100644 --- a/tests/zfs-tests/tests/functional/events/events_common.kshlib +++ b/tests/zfs-tests/tests/functional/events/events_common.kshlib @@ -94,7 +94,7 @@ function run_and_verify pool=${pool:-$TESTPOOL} fullcmd="$1" - cmd=$(echo $fullcmd | awk '{print $1}') + read -r cmd _ <<<"$fullcmd" # If we aren't running zpool or zfs, something is wrong [[ $cmd == "zpool" || $cmd == "zfs" ]] || \ @@ -147,23 +147,20 @@ function run_and_verify log_must grep -q "$event" $TMP_EVENTS # Verify the event is in the verbose output with pool name. - awk -v event="$event" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_FULL >$TMP_EVENT_FULL - log_must grep -q "pool = \"$pool\"" $TMP_EVENT_FULL + log_mustnot awk -v event="$event" -v crit="pool = \"$pool\"" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_FULL # all-debug.sh filters history events (seen in ZED_DEBUG_LOG) - if [[ "$event" == "sysevent.fs.zfs.history_event" ]]; then + if [ "$event" = "sysevent.fs.zfs.history_event" ]; then continue fi # Verify the event was received by the ZED and logged. - awk -v event="$event" \ - 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \ - $TMP_EVENTS_ZED >$TMP_EVENT_ZED - log_must grep -q "^ZEVENT_POOL=$pool" $TMP_EVENT_ZED + log_mustnot awk -v event="$event" -v crit="\\nZEVENT_POOL=$pool" \ + 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \ + $TMP_EVENTS_ZED done - rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENT_FULL \ - $TMP_EVENTS_ZED $TMP_EVENT_ZED + rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENTS_ZED } diff --git a/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh index ef2ce24e097b..17bde9a70636 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh @@ -96,8 +96,7 @@ do log_must zpool create -f $TESTPOOL $conf block_device_wait ${DEV_DSKDIR}/${removedev} - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Simulate physical removal of one device remove_disk $removedev @@ -128,8 +127,7 @@ do block_device_wait ${DEV_DSKDIR}/${removedev} log_must zpool add $TESTPOOL spare $sparedev - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Simulate physical removal of one device remove_disk $removedev @@ -161,8 +159,7 @@ do block_device_wait ${DEV_DSKDIR}/${removedev} log_must zpool add $TESTPOOL spare $sparedev - mntpnt=$(get_prop mountpoint /$TESTPOOL) || - log_fail "get_prop mountpoint /$TESTPOOL" + mntpnt=$(get_prop mountpoint /$TESTPOOL) # 2. Fault the spare device making it unavailable log_must zpool offline -f $TESTPOOL $sparedev diff --git a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh index 0302c45373fa..57180cdc1860 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh @@ -72,8 +72,8 @@ echo "alias scsidebug /dev/disk/by-id/$SD_DEVICE_ID" >>$VDEVID_CONF block_device_wait SD_DEVICE=$(udevadm info -q all -n $DEV_DSKDIR/$SD | \ - awk -F'=' '/ID_VDEV=/{print $2; exit}') -[[ -z $SD_DEVICE ]] && log_fail "vdev rule was not registered properly" + awk -F'=' '/ID_VDEV=/ {print $2; exit}') +[ -z $SD_DEVICE ] && log_fail "vdev rule was not registered properly" log_must zpool events -c log_must zpool create -f $TESTPOOL raidz1 $SD_DEVICE $DISK1 $DISK2 $DISK3 diff --git a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh index a290053fd269..5eb4b25c387f 100755 --- a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh +++ b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh @@ -67,7 +67,7 @@ log_must mkfile 1048576 /$TESTPOOL/testfile sync_pool $TESTPOOL log_must zinject -c all -SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}') +SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}') DELAY_EVENTS=$(zpool events | grep delay | wc -l) if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh index cb1e940a7d73..c00b3b6c719a 100755 --- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh @@ -73,7 +73,7 @@ log_must zfs umount $TEST_FS for ((i=0; i < ${#dnsizes[*]}; i++)) ; do dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} | - awk '/ZFS plain file/ {print $6}' | tr K k) + awk '/ZFS plain file/ {gsub(/K/, "k", $6); print $6}') if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})" fi diff --git a/tests/zfs-tests/tests/functional/history/history_001_pos.ksh b/tests/zfs-tests/tests/functional/history/history_001_pos.ksh index f33265185d5c..5b576b8a12aa 100755 --- a/tests/zfs-tests/tests/functional/history/history_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_001_pos.ksh @@ -59,7 +59,6 @@ log_assert "Verify zpool sub-commands which modify state are logged." log_onexit cleanup mntpnt=$(get_prop mountpoint $TESTPOOL) -(( $? != 0)) && log_fail "get_prop($TESTPOOL mountpoint)" VDEV1=$mntpnt/vdev1; VDEV2=$mntpnt/vdev2; VDEV3=$mntpnt/vdev3; VDEV4=$mntpnt/vdev4; diff --git a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh index 46af53f8af90..1bebd4039746 100755 --- a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh @@ -55,7 +55,6 @@ log_assert "zpool history limitation test." log_onexit cleanup mntpnt=$(get_prop mountpoint $TESTPOOL) -(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL" VDEV0=$mntpnt/vdev0 log_must mkfile $MINVDEVSIZE $VDEV0 @@ -79,16 +78,16 @@ done TMPFILE=$TEST_BASE_DIR/spool.$$ zpool history $spool >$TMPFILE -typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}') +typeset -i entry_count=$(wc -l < $TMPFILE) typeset final_md5=$(head -2 $TMPFILE | md5digest) -grep 'zpool create' $TMPFILE >/dev/null 2>&1 || +grep -q 'zpool create' $TMPFILE || log_fail "'zpool create' was not found in pool history" -grep 'zfs create' $TMPFILE >/dev/null 2>&1 && +grep -q 'zfs create' $TMPFILE && log_fail "'zfs create' was found in pool history" -grep 'zfs set compress' $TMPFILE >/dev/null 2>&1 || +grep -q 'zfs set compress' $TMPFILE || log_fail "'zfs set compress' was found in pool history" # Verify that the creation of the pool was preserved in the history. diff --git a/tests/zfs-tests/tests/functional/history/history_004_pos.ksh b/tests/zfs-tests/tests/functional/history/history_004_pos.ksh index 1b8e7dfe02ec..8bdc38f26d67 100755 --- a/tests/zfs-tests/tests/functional/history/history_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_004_pos.ksh @@ -46,7 +46,7 @@ verify_runnable "global" log_assert "'zpool history' can cope with simultaneous commands." -typeset -i orig_count=$(zpool history $spool | wc -l | awk '{print $1}') +typeset -i orig_count=$(zpool history $spool | wc -l) typeset -i i=0 while ((i < 10)); do @@ -90,7 +90,7 @@ while ((i < 10)); do ((i += 1)) done -typeset -i entry_count=$(zpool history $spool | wc -l | awk '{print $1}') +typeset -i entry_count=$(zpool history $spool | wc -l) if ((entry_count - orig_count != 200)); then log_fail "The entries count error: entry_count=$entry_count " \ diff --git a/tests/zfs-tests/tests/functional/history/history_common.kshlib b/tests/zfs-tests/tests/functional/history/history_common.kshlib index ff3260f3c0f2..f441799c89e3 100644 --- a/tests/zfs-tests/tests/functional/history/history_common.kshlib +++ b/tests/zfs-tests/tests/functional/history/history_common.kshlib @@ -52,14 +52,12 @@ function run_and_verify flags="$2" if is_illumos; then - histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g') + histcmd=$(echo $fullcmd | sed 's=/usr/sbin/==g') else - histcmd=$(echo $fullcmd | sed 's/^.*\/\(zpool .*\).*$/\1/') - histcmd=$(echo $histcmd | sed 's/^.*\/\(zfs .*\).*$/\1/') + histcmd=$(echo $fullcmd | sed -E 's=^.*/(zpool|zfs)$=\1=') fi - cmd=$(echo $histcmd | awk '{print $1}') - subcmd=$(echo $histcmd | awk '{print $2}') + read -r cmd subcmd _ <<<"$histcmd" # If we aren't running zpool or zfs, something is wrong [[ $cmd == "zpool" || $cmd == "zfs" ]] || \ @@ -77,11 +75,10 @@ function run_and_verify log_must_busy user_run $user "$fullcmd" fi zpool history $flags $pool > $TMP_HISTORY 2>/dev/null - diff $OLD_HISTORY $TMP_HISTORY | grep "^> " | sed 's/^> //g' \ - > $NEW_HISTORY + diff $OLD_HISTORY $TMP_HISTORY | sed -n 's/^> //gp' > $NEW_HISTORY # Verify what's common to every case, regardless of zpool history flags. - grep "$histcmd" $NEW_HISTORY >/dev/null 2>&1 || \ + grep -q "$histcmd" $NEW_HISTORY || \ log_fail "Didn't find \"$histcmd\" in pool history" # If 'zpool history' was called without any flags, then we're done. @@ -116,8 +113,7 @@ function verify_long suffix=":freebsd" fi - grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY - if [[ $? != 0 ]]; then + if grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then log_note "Couldn't find long information for \"$cmd\"" return 1 fi @@ -133,7 +129,8 @@ function verify_hold [[ $flags =~ "i" ]] || return 1 - typeset tag=$(echo $cmd | awk '{print $4}') + typeset tag _ + read -r _ _ _ tag _ <<<"$cmd" typeset fullname=${cmd##* } typeset dsname=${fullname%%@*} typeset snapname=${fullname##*@} @@ -141,9 +138,7 @@ function verify_hold # This works whether or not the hold was recursive for ds in $(zfs list -r -Ho name -t snapshot $dsname | \ grep "@$snapname"); do - grep "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then log_note "Didn't find hold on $ds with $tag" return 1 fi @@ -231,8 +226,7 @@ function verify_allow # - Whether the operation applies locally or to descendent datasets (or # both) # - echo $cmd | awk '{i = NF - 1; print $i}' | grep '@' >/dev/null \ - 2>&1 && is_set=1 + echo $cmd | awk '$(NF - 1) ~ /@/ {exit 1}' || is_set=1 dsname=${cmd##* } [[ $cmd =~ "-l " ]] && lflag=1 [[ $cmd =~ "-d " ]] && dflag=1 @@ -275,7 +269,7 @@ function verify_allow str="u" [[ -n $is_set ]] && str="U" tmp=${cmd##*-u } - opt=$(echo $tmp | awk '{print $2}') + read -r _ opt _ <<<"$opt" uid=$(id -u ${tmp%% *}) if [[ -n $lflag ]]; then code="${str}l\$$uid $opt" @@ -299,7 +293,7 @@ function verify_allow str="g" [[ -n $is_set ]] && str="G" tmp=${cmd##*-g } - opt=$(echo $tmp | awk '{print $2}') + read -r _ opt _ <<<"$opt" gid=$(awk -F: "/^${tmp%% *}:/ {print \$3}" /etc/group) if [[ -n $lflag ]]; then code="${str}l\$$gid $opt" diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh index 9657322526e7..2222721afd8d 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh @@ -77,7 +77,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2" typeset -i i=0 -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` unset NOINUSE_CHECK while (( i < ${#vdevs[*]} )); do diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh index b96b80890ed8..775f1af63bf1 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh @@ -82,7 +82,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2" typeset -i i=0 -PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'` +PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'` while (( i < ${#vdevs[*]} )); do typeset spare="spare $sdisks" diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh index 95efa3f2d802..6f7b9aff7c38 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh @@ -89,8 +89,7 @@ arcstat_quiescence_noecho l2_size log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh index bc6d71b7c459..3b893d28da6a 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh @@ -92,8 +92,7 @@ arcstat_quiescence_noecho l2_size log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh index 99cd3a2fc1d4..8a572c26469c 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh @@ -80,8 +80,7 @@ log_must zpool export $TESTPOOL arcstat_quiescence_noecho l2_feeds typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') log_must zpool import -d $VDIR $TESTPOOL log_must zpool online $TESTPOOL $VDEV_CACHE diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh index ae0167eb49c5..9663437c6597 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh @@ -77,8 +77,7 @@ log_must zpool offline $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks) -typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \ - awk '{print $2}') +typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}') log_must zpool online $TESTPOOL $VDEV_CACHE arcstat_quiescence_noecho l2_size diff --git a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh index 6130e2c82893..40045a7a96b5 100755 --- a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh +++ b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh @@ -47,8 +47,8 @@ function unlinked_size_is last_usize=0 while [[ $iters -le $MAX_ITERS ]]; do kstat_file=$(grep -nrwl /proc/spl/kstat/zfs/$2/objset-0x* -e $3) - nunlinks=`cat $kstat_file | grep nunlinks | awk '{print $3}'` - nunlinked=`cat $kstat_file | grep nunlinked | awk '{print $3}'` + nunlinks=$(awk '/nunlinks/ {print $3}' $kstat_file) + nunlinked=$(awk '/nunlinked/ {print $3}' $kstat_file) usize=$(($nunlinks - $nunlinked)) if [[ $iters == $MAX_ITERS && $usize == $1 ]]; then return 0 diff --git a/tests/zfs-tests/tests/functional/mount/umountall_001.ksh b/tests/zfs-tests/tests/functional/mount/umountall_001.ksh index 814c831e408c..40c94593ba2d 100755 --- a/tests/zfs-tests/tests/functional/mount/umountall_001.ksh +++ b/tests/zfs-tests/tests/functional/mount/umountall_001.ksh @@ -44,11 +44,11 @@ zfs_list="/ /lib /sbin /tmp /usr /var /var/adm /var/run" # Append our ZFS filesystems to the list, not worrying about duplicates. if is_linux; then - typeset mounts=$(mount | awk '{if ($5 == "zfs") print $3}') + typeset mounts=$(mount | awk '$5 == "zfs" {print $3}') elif is_freebsd; then - typeset mounts=$(mount -p | awk '{if ($3 == "zfs") print $2}') + typeset mounts=$(mount -p | awk '$3 == "zfs" {print $2}') else - typeset mounts=$(mount -p | awk '{if ($4 == "zfs") print $3}') + typeset mounts=$(mount -p | awk '$4 == "zfs" {print $3}') fi for fs in $mounts; do @@ -56,8 +56,7 @@ for fs in $mounts; do done if is_linux; then - mounts=$(umount --fake -av -t zfs 2>&1 | \ - grep "successfully umounted" | awk '{print $1}') + mounts=$(umount --fake -av -t zfs 2>&1 | awk '/successfully umounted/ {print $1}') # Fallback to /proc/mounts for umount(8) (util-linux-ng 2.17.2) if [[ -z $mounts ]]; then mounts=$(awk '/zfs/ { print $2 }' /proc/mounts) diff --git a/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh b/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh index b1eeaf2cc569..cf788ca7fdf0 100755 --- a/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh +++ b/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh @@ -64,8 +64,8 @@ log_must zfs umount $TESTPOOL/$TESTFS log_must eval "df -h | grep $TESTPOOL" # Confirm df size and used are non-zero. -size=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $2}') -used=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $3}') +size=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $2}') +used=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $3}') if [[ "$size" = "0" ]] || [[ "$used" = "0" ]] then log_fail "df failed with size $size and used $used." diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh index a18e634cefa7..7cfc3b1829bc 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh @@ -42,13 +42,13 @@ setup_nested_pools log_onexit cleanup_nested_pools populate_nested_pool -INITSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') +INITSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') log_must zpool checkpoint $NESTEDPOOL log_must truncate -s $EXPSZ $FILEDISK1 log_must zpool online -e $NESTEDPOOL $FILEDISK1 -NEWSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') -DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}') +NEWSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') +DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}') nested_change_state_after_checkpoint log_mustnot [ "$INITSZ" = "$NEWSZ" ] log_must [ "$DEXPSZ" = "-" ] @@ -57,8 +57,8 @@ log_must zpool export $NESTEDPOOL log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL nested_verify_pre_checkpoint_state -FINSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}') -DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}') +FINSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}') +DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}') log_must [ "$EXPSZ" = "$FINSZ" ] log_must [ "$DEXPSZ" != "-" ] diff --git a/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh b/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh index 048cb29e3217..1f4780ccd387 100755 --- a/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh @@ -47,8 +47,7 @@ log_assert "zpool set version can upgrade a pool" for version in 1 2 3 4 5 6 7 8 do log_must zpool set version=$version $TESTPOOL - ACTUAL=$(zpool get version $TESTPOOL | grep version \ - | awk '{print $3}') + ACTUAL=$(get_pool_prop version $TESTPOOL) if [ "$ACTUAL" != "$version" ] then log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $version!" diff --git a/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh b/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh index 69586473eaab..15cd446b6ea6 100755 --- a/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh @@ -50,7 +50,7 @@ log_must zpool set version=6 $TESTPOOL2 # verify it's actually that version - by checking the version property # and also by trying to set bootfs (which should fail if it is not version 6) -VERSION=$(zpool get version $TESTPOOL2| grep version | awk '{print $3}') +VERSION=$(get_pool_prop version $TESTPOOL2) if [ "$VERSION" != "6" ] then log_fail "Version $VERSION set for $TESTPOOL2 expected version 6!" @@ -62,7 +62,7 @@ log_mustnot zpool set version=5 $TESTPOOL2 log_mustnot zpool set version=-1 $TESTPOOL2 # verify the version is still 6 -VERSION=$(zpool get version $TESTPOOL2 | grep version | awk '{print $3}') +VERSION=$(get_pool_prop version $TESTPOOL2) if [ "$VERSION" != "6" ] then log_fail "Version $VERSION set for $TESTPOOL2, expected version 6!" diff --git a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh index 080fdddb2d8f..d29bfd806913 100755 --- a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh +++ b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh @@ -106,7 +106,7 @@ log_assert "Testing /proc/spl/kstat/zfs//state kstat" check_all $TESTPOOL "ONLINE" # Fault one of the disks, and check that pool is degraded -DISK1=$(echo "$DISKS" | awk '{print $2}') +read -r DISK1 _ <<<"$DISKS" log_must zpool offline -tf $TESTPOOL $DISK1 check_all $TESTPOOL "DEGRADED" log_must zpool online $TESTPOOL $DISK1 diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh index fc4a93f04463..51e790348ca6 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh @@ -65,10 +65,10 @@ log_must chattr +P -p $PRJID1 $PRJDIR log_must user_run $PUSER mkfile 50m $PRJDIR/qf sync_pool -total=$(df $PRJDIR | tail -n 1 | awk '{ print $2 }') +total=$(df $PRJDIR | awk 'END { print $2 }') [[ $total -eq 102400 ]] || log_fail "expect '102400' resource, but got '$total'" -used=$(df -i $PRJDIR | tail -n 1 | awk '{ print $5 }') +used=$(df -i $PRJDIR | awk 'END { print $5 }') [[ "$used" == "2%" ]] || log_fail "expect '2%' used, but got '$used'" log_pass "'df' on the directory with inherit project ID flag pass as expect" diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg b/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg index f964b37bad3b..3b9e1714dfe9 100644 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg @@ -23,8 +23,8 @@ # Copyright (c) 2018 by Delphix. All rights reserved. # -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $2}') +read -r DISK1 DISK2 _ <<<"$DISKS" +export DISK1 DISK2 export POOL=$TESTPOOL export POOL2=$TESTPOOL2 @@ -83,4 +83,4 @@ typeset RANGE12="0,2097152" typeset RANGE13="0,16384" typeset RANGE14="" typeset RANGE15="0,4194304" -typeset RANGE16="0,6291456" \ No newline at end of file +typeset RANGE16="0,6291456" diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh index e4163c4ef8da..74b71cdf6954 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh @@ -66,8 +66,8 @@ get_guid_list $tmpdir/prop_list $sendfs#book1 get_guid_list $tmpdir/zdb_list $sendfs#book1 true get_guid_list $tmpdir/recvd_prop_list $recvfs@snap -count=$(wc -l $tmpdir/prop_list | awk '{print $1}') -[[ $count -eq 16 ]] || log_fail "Found incorrect number of redaction snapshots." +count=$(wc -l < $tmpdir/prop_list) +[ $count -eq 16 ] || log_fail "Found incorrect number of redaction snapshots." diff $tmpdir/prop_list $tmpdir/zdb_list || \ log_fail "Property list differed from zdb output" diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh index 7456084b04bc..1634ffe06463 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh @@ -43,22 +43,19 @@ typeset clone_mnt="$(get_prop mountpoint $clone)" log_must rm -rf $clone_mnt/* log_must zfs snapshot $clone@snap log_must zfs redact $sendfs@snap book $clone@snap -log_must eval "zfs send -nvP --redact book $sendfs@snap | \ - grep '^size' | awk '{print \$2}' >$size" -log_must eval "zfs send --redact book $sendfs@snap | wc -c \ - >$size2" -bytes1=$(cat $size | tr -d '[[:space:]]') -bytes2=$(cat $size2 | tr -d '[[:space:]]') -[[ "$bytes1" -eq "$bytes2" ]] || \ +log_must eval "zfs send -nvP --redact book $sendfs@snap | awk '/^size/ {print \$2}' >$size" +log_must eval "zfs send --redact book $sendfs@snap | wc -c >$size2" +read -r bytes1 < $size +read -r bytes2 < $size2 +[ "$bytes1" -eq "$bytes2" ] || \ log_fail "Full sizes differ: estimate $bytes1 and actual $bytes2" log_must zfs snapshot $sendfs@snap2 -log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | \ - grep '^size' | awk '{print \$2}' >$size" +log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | awk '/^size/ {print \$2}' >$size" log_must eval "zfs send -i $sendfs#book $sendfs@snap2 | wc -c >$size2" -bytes1=$(cat $size | tr -d '[[:space:]]') -bytes2=$(cat $size2 | tr -d '[[:space:]]') -[[ "$bytes1" -eq "$bytes2" ]] || \ +read -r bytes1 < $size +read -r bytes2 < $size2 +[ "$bytes1" -eq "$bytes2" ] || \ log_fail "Incremental sizes differ: estimate $bytes1 and actual $bytes2" log_pass "Size estimates of redacted sends estimate accurately." diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib index 55816b451612..28b115fd73ce 100644 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib @@ -200,10 +200,10 @@ function is_healthy ret=$? (( $ret == 0 )) && return 1 typeset l_scan - typeset errnum + typeset errnum _ l_scan=$(zpool status -x $pool | grep "scan:") l_scan=${l_scan##*"with"} - errnum=$(echo $l_scan | awk '{print $1}') + read -r errnum _ <<<"$l_scan" return $errnum fi @@ -243,12 +243,13 @@ function get_vdevs #pool cnt typeset -i cnt=$2 typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \ - egrep -v "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \ - egrep -v "/old$|^$pool$") + egrep -ve "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \ + -e "/old$|^$pool$") typeset -i i=0 typeset vdevs while ((i < cnt)); do - typeset dev=$(echo $all_devs | awk '{print $1}') + typeset dev _ + read -r dev _ <<<"$all_devs" eval all_devs=\${all_devs##*$dev} vdevs="$dev $vdevs" diff --git a/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh b/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh index 4473771521ba..21af3965ae79 100755 --- a/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh +++ b/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh @@ -21,9 +21,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/removal/removal.kshlib -DISK1=$(echo $DISKS | awk '{print $1}') -DISK2=$(echo $DISKS | awk '{print $2}') -DISK3=$(echo $DISKS | awk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" DISKS="$DISK1 $DISK2 $DISK3" log_must default_setup_noexit "$DISK1 mirror $DISK2 $DISK3" diff --git a/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh b/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh index d17d83b78333..5e86a8ccb8ac 100755 --- a/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh +++ b/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh @@ -45,8 +45,7 @@ function check_feature_flag pool=$2 expected_value=$3 - value="$(zpool get -H -o property,value all $pool | \ - egrep "$feature" | awk '{print $2}')" + value="$(zpool get -H -o property,value all $pool | awk -v f="$feature" '$0 ~ f {print $2}')" if [ "$value" = "$expected_value" ]; then log_note "$feature verified to be $value" else diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh index 67be04e1e0ed..b5b0ace59980 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh @@ -74,7 +74,7 @@ log_note "waiting for read errors to start showing up" for iter in {0..59} do sync_pool $TESTPOOL1 - err=$(zpool status $TESTPOOL1 | grep ${VDEV_FILES[0]} | awk '{print $3}') + err=$(zpool status $TESTPOOL1 | awk -v dev=${VDEV_FILES[0]} '$0 ~ dev {print $3}') (( $err > 0 )) && break sleep 1 done diff --git a/tests/zfs-tests/tests/functional/reservation/reservation.shlib b/tests/zfs-tests/tests/functional/reservation/reservation.shlib index 47bd70f7cbcc..9bac794a9784 100644 --- a/tests/zfs-tests/tests/functional/reservation/reservation.shlib +++ b/tests/zfs-tests/tests/functional/reservation/reservation.shlib @@ -38,25 +38,15 @@ # function zero_reservation { - typeset resv_val dataset=$1 log_must zfs set reservation=none $dataset - resv_val=`zfs get -H reservation $dataset | awk '{print $3}'` - if [[ $? -ne 0 ]]; then - log_fail "Unable to get reservation prop on $dataset" - elif [[ $resv_val != "none" ]]; then - log_fail "Reservation not 'none' ($resv_val) as expected" - fi - + log_must eval 'resv_val="$(zfs get -Ho value reservation $dataset)"' + log_must [ $resv_val = "none" ] - resv_val=`zfs get -pH reservation $dataset | awk '{print $3}'` - if [[ $? -ne 0 ]]; then - log_fail "Unable to get reservation prop on $dataset" - elif [[ $resv_val -ne 0 ]]; then - log_fail "Reservation not 0 ($resv_val) as expected" - fi + log_must eval 'resv_val="$(zfs get -pHo value reservation $dataset)"' + log_must [ $resv_val -eq 0 ] return 0 } diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh index bf0955223490..786d5d4d3008 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh @@ -72,8 +72,6 @@ log_must zfs create $TESTPOOL/$TESTFS1 log_must zfs create $TESTPOOL/$TESTFS1/$TESTFS2 space_avail=$(get_prop available $TESTPOOL) -[[ $? -ne 0 ]] && \ - log_fail "Unable to get space available property for $TESTPOOL" typeset -il resv_set=space_avail/5 resv_set=$(floor_volsize $resv_set) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.cfg b/tests/zfs-tests/tests/functional/rsend/rsend.cfg index 8400ecfe35b4..99e87d9369ed 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.cfg +++ b/tests/zfs-tests/tests/functional/rsend/rsend.cfg @@ -29,9 +29,8 @@ export BACKDIR=${TEST_BASE_DIR%%/}/backdir-rsend -export DISK1=$(echo $DISKS | awk '{print $1}') -export DISK2=$(echo $DISKS | awk '{print $2}') -export DISK3=$(echo $DISKS | awk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 export POOL=$TESTPOOL export POOL2=$TESTPOOL2 diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 1df5c3542e7d..ea63defdce12 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -293,7 +293,6 @@ function snapshot_tree typeset -i ret=0 if [[ $type == "filesystem" ]]; then typeset mntpnt=$(get_prop mountpoint $ds) - ((ret |= $?)) if ((ret == 0)) ; then eval random_tree $mntpnt/${snap##$ds} @@ -364,8 +363,7 @@ function fs_inherit_prop fi else fs_prop=$(zfs inherit 2>&1 | \ - awk '$2=="YES" && $3=="YES" {print $1}'| - egrep -v "devices|mlslabel|sharenfs|sharesmb|zoned") + awk '$2=="YES" && $3=="YES" && !/devices|mlslabel|sharenfs|sharesmb|zoned/ {print $1}') fi echo $fs_prop @@ -595,8 +593,8 @@ function mess_send_file # We use zstream dump to verify there is an intact DRR_BEGIN record. offset=$(((($RANDOM * $RANDOM) % ($filesize - $minsize)) + $minsize)) nr_begins=$(head -c $offset $file | zstream dump | \ - grep DRR_BEGIN | awk '{ print $5 }') - log_must test "$nr_begins" -eq 1 + awk '/DRR_BEGIN/ { print $5 }') + log_must [ "$nr_begins" -eq 1 ] if (($RANDOM % 7 <= 1)); then # diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index 694dd15b44f6..61d5e12cba3f 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -51,8 +51,7 @@ function edited_prop case $behaviour in "get") typeset props=$(zfs inherit 2>&1 | \ - awk '$2=="YES" {print $1}' | \ - grep -Ev "^vol|\.\.\.$") + awk '$2=="YES" && $1 !~ /^vol|\.\.\.$/ {print $1}') for item in $props ; do if [[ $item == "mlslabel" ]] && \ ! is_te_enabled ; then diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh index aa19847e0695..aff54e3a7d69 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh @@ -54,11 +54,11 @@ function recursive_cksum { case "$(uname)" in FreeBSD) - find $1 -type f -exec sha256 -q {} \; | \ + find $1 -type f -exec sha256 -q {} + | \ sort | sha256digest ;; *) - find $1 -type f -exec sha256sum {} \; | \ + find $1 -type f -exec sha256sum {} + | \ sort -k 2 | awk '{ print $1 }' | sha256digest ;; esac diff --git a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh index d88bc582bf08..8b45e51bc257 100755 --- a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh +++ b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh @@ -38,14 +38,14 @@ log_note "Testing if we support SIMD instructions (Linux x86 only)" -if !is_linux; then +if ! is_linux; then log_unsupported "Not a Linux System" fi case "$(uname -m)" in -i386|i686|x86_64) +i?86|x86_64) typeset -R modparam="/sys/module/zcommon/parameters/zfs_fletcher_4_impl" - if cat /proc/cpuinfo | awk '/^flags/ {print; exit;}' | grep -q sse; then + if awk '/^flags/ {exit !/sse/}' /proc/cpuinfo; then log_must grep -q sse "$modparam" log_pass "SIMD instructions supported" else diff --git a/tests/zfs-tests/tests/functional/trim/trim.kshlib b/tests/zfs-tests/tests/functional/trim/trim.kshlib index dc1a60a5ee9d..fad15582b188 100644 --- a/tests/zfs-tests/tests/functional/trim/trim.kshlib +++ b/tests/zfs-tests/tests/functional/trim/trim.kshlib @@ -22,8 +22,7 @@ # function get_size_mb { - typeset rval=$(du --block-size 1048576 -s "$1" | awk '{print $1}') - echo -n "$rval" + du --block-size 1048576 -s "$1" | awk '{printf("%s", $1)}' } # diff --git a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh index bd2710c6ffc2..0bbd08acdd3f 100755 --- a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh +++ b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh @@ -97,8 +97,8 @@ done verify_trim_io $TESTPOOL "ind" 5 $TRIM_VDEV2 -typeset cache_size=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $2}') -typeset cache_alloc=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $3}') +typeset cache_size cache_alloc _ +read -r _ cache_size cache_alloc _ < <(zpool list -vp | grep $TRIM_VDEV2) log_must test $cache_alloc -lt $cache_size diff --git a/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh b/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh index 364f67e34584..88d09759bfee 100755 --- a/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh @@ -109,7 +109,7 @@ log_must chattr -p 100 $TESTDIR/fs3/dir log_must sleep 5 # upgrade done in the background so let's wait for a while zfs projectspace -o used $TESTPOOL/fs3 | grep -q "USED" || log_fail "project quota should be enabled for $TESTPOOL/fs3" -cnt=$(zfs get -H projectobjused@100 $TESTPOOL/fs3 | awk '{print $3}') +cnt=$(get_prop projectobjused@100 $TESTPOOL/fs3) # if 'xattr=on', then 'cnt = 2' [[ $cnt -ne 1 ]] && [[ $cnt -ne 2 ]] && log_fail "projectquota accounting failed $cnt" diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh index 86dc058ebffe..3d0f55d5a9a7 100755 --- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh @@ -48,7 +48,7 @@ assert_zap_common $TESTPOOL $DISK "top" $orig_top # Attach a disk. # -disk2=$(echo $DISKS | awk '{print $2}') +read -r _ disk2 _ <<<"$DISKS" log_must zpool attach $TESTPOOL $DISK $disk2 log_must zpool wait -t resilver $TESTPOOL log_must eval "zdb -PC $TESTPOOL > $conf" diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib index 4f74c9b92613..aa47f6c0fdb5 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib +++ b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib @@ -71,8 +71,7 @@ function default_zvol_cleanup function get_dumpdevice { - typeset ret=$(dumpadm | grep "Dump device:" | awk '{print $3}') - echo $ret + dumpadm | awk '/Dump device:/ {print $3}' } function set_dumpsize @@ -86,8 +85,7 @@ function set_dumpsize log_must zfs set volsize=64m $volume - output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | \ - tail -1 | awk '{print $3}') + output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | awk 'END {print $3}') if [[ -n $output ]]; then (( output = output / 1024 / 1024 )) diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh index aafdb7a49fac..588663dba278 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh @@ -74,7 +74,7 @@ PREV_VFSTAB_FILE=$TEST_BASE_DIR/zvol_vfstab.PREV.$$ [[ -f $NEW_VFSTAB_FILE ]] && cp /dev/null $NEW_VFSTAB_FILE -awk '{if ($4 != "swap") print $1}' /etc/vfstab > $NEW_VFSTAB_FILE +awk '$4 != "swap" {print $1}' /etc/vfstab > $NEW_VFSTAB_FILE echo "$voldev\t-\t-\tswap\t-\tno\t-" >> $NEW_VFSTAB_FILE # Copy off the original vfstab, and run swapadd on the newly constructed one. From 7c6730e410db85134623745d1465f66df374c300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 00:13:19 +0100 Subject: [PATCH 25/63] tests: nawk -> awk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs-tests.sh | 1 - tests/zfs-tests/include/blkdev.shlib | 48 +++++++------------ tests/zfs-tests/include/libtest.shlib | 25 ++++------ .../tests/functional/acl/acl_common.kshlib | 6 +-- .../alloc_class/alloc_class_004_pos.ksh | 3 +- .../tests/functional/cache/cache.kshlib | 2 +- .../tests/functional/cachefile/cachefile.cfg | 2 +- .../cli_root/zfs_send/zfs_send_006_pos.ksh | 4 +- .../zfs_snapshot/zfs_snapshot_009_pos.ksh | 4 +- .../zfs_upgrade/zfs_upgrade_001_pos.ksh | 14 +++--- .../zfs_upgrade/zfs_upgrade_002_pos.ksh | 6 +-- .../cli_root/zpool_destroy/zpool_destroy.cfg | 2 +- .../cli_root/zpool_reopen/zpool_reopen.cfg | 7 ++- .../zpool_resilver/zpool_resilver.cfg | 5 +- .../cli_root/zpool_split/zpool_split.cfg | 2 +- .../tests/functional/fault/fault.cfg | 7 ++- .../tests/functional/migration/migration.cfg | 2 +- .../zfs-tests/tests/functional/mmp/mmp.kshlib | 6 +-- .../tests/functional/mv_files/mv_files.cfg | 2 +- .../online_offline/online_offline.cfg | 2 +- .../tests/functional/slog/slog.kshlib | 2 +- .../tests/functional/sparse/sparse.cfg | 2 +- .../tests/functional/truncate/truncate.cfg | 2 +- .../zvol/zvol_ENOSPC/zvol_ENOSPC.cfg | 2 +- .../functional/zvol/zvol_cli/zvol_cli.cfg | 2 +- .../functional/zvol/zvol_swap/zvol_swap.cfg | 6 +-- 26 files changed, 68 insertions(+), 98 deletions(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index 94c6ab0b111e..6e9589e59308 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -297,7 +297,6 @@ constrain_path() { create_links "$SYSTEM_DIRS" "$SYSTEM_FILES" # Exceptions - ln -fs "$STF_PATH/awk" "$STF_PATH/nawk" if [ "$UNAME" = "Linux" ] ; then ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck" ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index 6d37494eedbe..f776caa3be3d 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -253,7 +253,7 @@ function set_device_dir if is_linux; then while (( i < $DISK_ARRAY_NUM )); do - disk="$(echo $DISKS | nawk '{print $(i + 1)}')" + disk="$(echo $DISKS | awk '{print $(i + 1)}')" if is_mpath_device $disk; then export DEV_DSKDIR=$DEV_MPATHDIR return 0 @@ -294,20 +294,15 @@ function get_device_dir #device function get_persistent_disk_name #device { typeset device=$1 - typeset dev_id if is_linux; then if is_real_device $device; then - dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \ - | egrep disk/by-id | nawk '{print $2; exit}' \ - | nawk -F / '{print $3}')" - echo $dev_id + udevadm info -q all -n $DEV_DSKDIR/$device \ + | awk '/disk\/by-id/ {print $2; exit}' | cut -d/ -f3 elif is_mpath_device $device; then - dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \ - | egrep disk/by-id/dm-uuid \ - | nawk '{print $2; exit}' \ - | nawk -F / '{print $3}')" - echo $dev_id + udevadm info -q all -n $DEV_DSKDIR/$device \ + | awk '/disk\/by-id\/dm-uuid/ {print $2; exit}' \ + | cut -d/ -f3 else echo $device fi @@ -334,28 +329,22 @@ function on_off_disk # disk state{online,offline} host if is_linux; then if [[ $state == "offline" ]] && ( is_mpath_device $disk ); then - dm_name="$(readlink $DEV_DSKDIR/$disk \ - | nawk -F / '{print $2}')" - dep="$(ls /sys/block/${dm_name}/slaves \ - | nawk '{print $1}')" + dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" + dep="$(ls /sys/block/${dm_name}/slaves | awk '{print $1}')" while [[ -n $dep ]]; do #check if disk is online - lsscsi | egrep $dep > /dev/null - if (($? == 0)); then + if lsscsi | egrep -q $dep; then dep_dir="/sys/block/${dm_name}" dep_dir+="/slaves/${dep}/device" ss="${dep_dir}/state" sd="${dep_dir}/delete" log_must eval "echo 'offline' > ${ss}" log_must eval "echo '1' > ${sd}" - lsscsi | egrep $dep > /dev/null - if (($? == 0)); then - log_fail "Offlining" \ - "$disk failed" - fi + if lsscsi | egrep -q $dep; then + log_fail "Offlining $disk failed" + fi fi - dep="$(ls /sys/block/$dm_name/slaves \ - 2>/dev/null | nawk '{print $1}')" + dep="$(ls /sys/block/$dm_name/slaves 2>/dev/null | awk '{print $1}')" done elif [[ $state == "offline" ]] && ( is_real_device $disk ); then #check if disk is online @@ -378,12 +367,9 @@ function on_off_disk # disk state{online,offline} host scan_scsi_hosts $host block_device_wait if is_mpath_device $disk; then - dm_name="$(readlink $DEV_DSKDIR/$disk \ - | nawk -F / '{print $2}')" - dep="$(ls /sys/block/$dm_name/slaves \ - | nawk '{print $1}')" - lsscsi | egrep $dep > /dev/null - if (($? != 0)); then + dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" + dep="$(ls /sys/block/$dm_name/slaves | awk '{print $1}')" + if lsscsi | egrep -q $dep; then log_fail "Onlining $disk failed" fi elif is_real_device $disk; then @@ -496,7 +482,7 @@ function unload_scsi_debug function get_debug_device { for i in {1..10} ; do - val=$(lsscsi | nawk '/scsi_debug/ {print $6; exit}' | cut -d / -f3) + val=$(lsscsi | awk '/scsi_debug/ {print $6; exit}' | cut -d/ -f3) # lsscsi can take time to settle if [ "$val" != "-" ] ; then diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 60d54428a6dc..58e992698545 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2018,13 +2018,8 @@ function verify_pool # function get_disklist # pool { - typeset disklist="" - - disklist=$(zpool iostat -v $1 | nawk '(NR >4) {print $1}' | \ - grep -v "\-\-\-\-\-" | \ - egrep -v -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$") - - echo $disklist + zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ + egrep -v -e '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$" } # @@ -2033,8 +2028,7 @@ function get_disklist # pool # function get_disklist_fullpath # pool { - args="-P $1" - get_disklist $args + get_disklist "-P $1" } @@ -2183,14 +2177,12 @@ function check_pool_status # pool token keyword typeset keyword=$3 typeset verbose=${4:-false} - scan=$(zpool status -v "$pool" 2>/dev/null | nawk -v token="$token:" ' + scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" ' ($1==token) {print $0}') if [[ $verbose == true ]]; then log_note $scan fi - echo $scan | egrep -i "$keyword" > /dev/null 2>&1 - - return $? + echo $scan | egrep -qi "$keyword" } # @@ -2968,15 +2960,14 @@ function get_device_state #pool disk field("", "spares","logs") typeset disk=${2#$DEV_DSKDIR/} typeset field=${3:-$pool} - state=$(zpool status -v "$pool" 2>/dev/null | \ - nawk -v device=$disk -v pool=$pool -v field=$field \ + zpool status -v "$pool" 2>/dev/null | \ + awk -v device=$disk -v pool=$pool -v field=$field \ 'BEGIN {startconfig=0; startfield=0; } /config:/ {startconfig=1} (startconfig==1) && ($1==field) {startfield=1; next;} (startfield==1) && ($1==device) {print $2; exit;} (startfield==1) && - ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}') - echo $state + ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}' } # diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index c2e09687e43e..bfae8ec722ef 100644 --- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -58,7 +58,7 @@ function get_acl # return 1 fi - ls -vd $obj | nawk '(NR != 1) {print $0}' + ls -vd $obj | awk '(NR != 1) {print $0}' } # @@ -73,7 +73,7 @@ function get_compact_acl # return 1 fi - ls -Vd $obj | nawk '(NR != 1) {print $0}' + ls -Vd $obj | awk '(NR != 1) {print $0}' } # @@ -246,7 +246,7 @@ function count_ACE # return 1 fi - ls -vd $1 | nawk 'BEGIN {count=0} + ls -vd $1 | awk 'BEGIN {count=0} (NR != 1)&&(/[0-9]:/) {count++} END {print count}' diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh index 79ac9364c257..04ce486adb83 100755 --- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh @@ -52,8 +52,7 @@ do log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \ special $stype $sdisks - ac_value="$(zpool get -H -o property,value all | \ - egrep allocation_classes | nawk '{print $2}')" + ac_value="$(zpool get -H -o property,value all | awk '/allocation_classes/ {print $2}')" if [ "$ac_value" = "active" ]; then log_note "feature@allocation_classes is active" else diff --git a/tests/zfs-tests/tests/functional/cache/cache.kshlib b/tests/zfs-tests/tests/functional/cache/cache.kshlib index 2e258e22cd39..58e2385ea0c9 100644 --- a/tests/zfs-tests/tests/functional/cache/cache.kshlib +++ b/tests/zfs-tests/tests/functional/cache/cache.kshlib @@ -94,7 +94,7 @@ function verify_cache_device # # mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE # - set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \ + set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \ /\tcache/ {start=1} /\tmirror/ || /\tspares/ || /^$/ {start=0} (start==1) && /\t (\/|[a-zA-Z])/ \ diff --git a/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg b/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg index d93ec3ed6f3b..bd48cfdf2f87 100644 --- a/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg +++ b/tests/zfs-tests/tests/functional/cachefile/cachefile.cfg @@ -33,5 +33,5 @@ export CPATH1=$TEST_BASE_DIR/cachefile.1.$$ export CPATH2=$TEST_BASE_DIR/cachefile.2.$$ export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh index 42628a0512e9..c5dfb89394f4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_006_pos.ksh @@ -76,10 +76,10 @@ function verify_size_estimates typeset file_size=$2 typeset refer_diff=$(echo "$refer_size - $estimate_size" | bc) refer_diff=$(echo "$refer_diff / 1" | bc) - refer_diff=$(echo "$refer_diff" | nawk '{print ($1 < 0) ? ($1 * -1): $1'}) + refer_diff=$(echo "$refer_diff" | awk '{print ($1 < 0) ? ($1 * -1): $1'}) typeset file_diff=$(echo "$file_size - $estimate_size" | bc) file_diff=$(echo "$file_diff / 1" | bc) - file_diff=$(echo "$file_diff" | nawk '{print ($1 < 0) ? ($1 * -1):$1'}) + file_diff=$(echo "$file_diff" | awk '{print ($1 < 0) ? ($1 * -1):$1'}) typeset expected_diff=$(cal_percentage $refer_size) [[ -z $refer_diff && -z $file_diff && -z $expected_diff ]] && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh index 407936c7c438..407c8f291122 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh @@ -86,9 +86,9 @@ done log_note "verify multiple snapshot transaction group" txg_group=$(zdb -Pd $TESTPOOL | awk '/snap/ {print $7}') for i in 1 2 3; do - txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}') + txg_tag=$(echo "$txg_group" | awk -v j=$i 'FNR == j {print}') [[ $txg_tag != $(echo "$txg_group" | \ - nawk -v j=$i 'FNR == j {print}') ]] \ + awk -v j=$i 'FNR == j {print}') ]] \ && log_fail "snapshots belong to different transaction groups" done log_note "verify snapshot contents" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh index 3b4451c74884..db8b96f50568 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh @@ -71,7 +71,7 @@ typeset expect_str2="All filesystems are formatted with the current version" typeset expect_str3="The following filesystems are out of date, and can be upgraded" typeset -i COUNT OLDCOUNT -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput OLDCOUNT=$(wc -l < $oldoutput) old_datasets="" @@ -98,8 +98,8 @@ log_must eval 'zfs upgrade > $output 2>&1' # we also check that the usage message contains at least a description # of the current ZFS version. -log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output +log_must grep -q "${expect_str1} $ZFS_VERSION" $output +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output COUNT=$(wc -l < $output) typeset -i i=0 @@ -118,13 +118,13 @@ for fs in $old_datasets ; do done log_must eval 'zfs upgrade > $output 2>&1' -log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1' +log_must grep -q "${expect_str1} $ZFS_VERSION" $output if (( OLDCOUNT == 0 )); then - log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1' + log_must grep -q "${expect_str2}" $output else - log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1' + log_must grep -q "${expect_str3}" $output fi -zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output +zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output COUNT=$(wc -l < $output) if (( COUNT != OLDCOUNT )); then diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh index ba6e7c483edd..994ee2b3475a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_002_pos.ksh @@ -60,8 +60,8 @@ typeset expect_str2="Enhanced directory entries" log_must eval 'zfs upgrade -v > /dev/null 2>&1' -zfs upgrade -v | nawk '$1 ~ "^[0-9]+$" {print $0}'> $output -log_must eval 'grep "${expect_str1}" $output > /dev/null 2>&1' -log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1' +zfs upgrade -v | awk '$1 ~ "^[0-9]+$" {print $0}'> $output +log_must grep -q "${expect_str1}" $output +log_must grep -q "${expect_str2}" $output log_pass "Executing 'zfs upgrade -v' command succeeds." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg index bf6026747f9a..906cba700573 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy.cfg @@ -28,7 +28,7 @@ # Copyright (c) 2012 by Delphix. All rights reserved. # -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS echo $DISKS | read DISK0 DISK1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg index 7451ffd8c53f..35beb568cb40 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.cfg @@ -18,7 +18,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS export SMALL_FILE_SIZE=10 export LARGE_FILE_SIZE=80 @@ -29,9 +29,8 @@ export SDHOSTS=1 export SDTGTS=1 export SDLUNS=1 -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 if is_linux; then set_slice_prefix diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg index 2a942d69f6d0..2b8c9e954ad7 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver.cfg @@ -23,8 +23,7 @@ # Copyright (c) 2018 by Datto. All rights reserved. # -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 export MAXTIMEOUT=300 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg index 5833a420c87c..a441a7dff0d6 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split.cfg @@ -14,5 +14,5 @@ # export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/tests/zfs-tests/tests/functional/fault/fault.cfg b/tests/zfs-tests/tests/functional/fault/fault.cfg index 839330ed47dd..108406e3e171 100644 --- a/tests/zfs-tests/tests/functional/fault/fault.cfg +++ b/tests/zfs-tests/tests/functional/fault/fault.cfg @@ -26,7 +26,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS export FSIZE=10M export MAXTIMEOUT=30 @@ -36,9 +36,8 @@ export SDHOSTS=1 export SDTGTS=1 export SDLUNS=1 -export DISK1=$(echo $DISKS | nawk '{print $1}') -export DISK2=$(echo $DISKS | nawk '{print $2}') -export DISK3=$(echo $DISKS | nawk '{print $3}') +read -r DISK1 DISK2 DISK3 _ <<<"$DISKS" +export DISK1 DISK2 DISK3 if is_linux; then set_slice_prefix diff --git a/tests/zfs-tests/tests/functional/migration/migration.cfg b/tests/zfs-tests/tests/functional/migration/migration.cfg index a8a24e0a3b51..308891b86d01 100644 --- a/tests/zfs-tests/tests/functional/migration/migration.cfg +++ b/tests/zfs-tests/tests/functional/migration/migration.cfg @@ -31,7 +31,7 @@ . $STF_SUITE/include/libtest.shlib export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set -A disk_array $(find_disks $DISKS) case "${#disk_array[*]}" in 0) diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 5fb22bd85c69..7ff2636e1f32 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -36,10 +36,8 @@ function check_pool_import # pool opts token keyword typeset keyword=$4 zpool import $opts 2>&1 | \ - nawk -v token="$token:" '($1==token) {print $0}' | \ - grep -i "$keyword" > /dev/null 2>&1 - - return $? + awk -v token="$token:" '($1==token) {print}' | \ + grep -iq "$keyword" } function is_pool_imported # pool opts diff --git a/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg b/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg index ed28ff1efd27..fbab8f6dad7b 100644 --- a/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg +++ b/tests/zfs-tests/tests/functional/mv_files/mv_files.cfg @@ -30,7 +30,7 @@ export DISK=${DISKS%% *} export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir export TESTFILE=testfile diff --git a/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg b/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg index ae4cb69adcb0..6f1121c5e99e 100644 --- a/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg +++ b/tests/zfs-tests/tests/functional/online_offline/online_offline.cfg @@ -38,5 +38,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export STF_TIMEOUT=3600 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/tests/zfs-tests/tests/functional/slog/slog.kshlib b/tests/zfs-tests/tests/functional/slog/slog.kshlib index 75cfec2d832d..8bc34d0dac32 100644 --- a/tests/zfs-tests/tests/functional/slog/slog.kshlib +++ b/tests/zfs-tests/tests/functional/slog/slog.kshlib @@ -101,7 +101,7 @@ function verify_slog_device # # mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE # - set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \ + set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \ /\tlogs/ {start=1} /\tmirror/ || /\tspares/ || /^$/ {start=0} (start==1) && /\t (\/|[a-zA-Z])/ \ diff --git a/tests/zfs-tests/tests/functional/sparse/sparse.cfg b/tests/zfs-tests/tests/functional/sparse/sparse.cfg index 0fc669148aa1..b7e403bce5f1 100644 --- a/tests/zfs-tests/tests/functional/sparse/sparse.cfg +++ b/tests/zfs-tests/tests/functional/sparse/sparse.cfg @@ -39,5 +39,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export STF_TIMEOUT=3600 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/tests/zfs-tests/tests/functional/truncate/truncate.cfg b/tests/zfs-tests/tests/functional/truncate/truncate.cfg index 13cdafab133b..d852ee63abb5 100644 --- a/tests/zfs-tests/tests/functional/truncate/truncate.cfg +++ b/tests/zfs-tests/tests/functional/truncate/truncate.cfg @@ -34,6 +34,6 @@ export TRUNC_FILEOFFSET=${TRUNC_FILEOFFSET-""} export TRUNC_COUNT=${TRUNC_COUNT-"16384"} # FILESIZE/BLKSIZE/8 export DISKSARRAY=$DISKS -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') set_device_dir diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/zvol_ENOSPC.cfg b/tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/zvol_ENOSPC.cfg index 8a99225ba9ec..92650c5e050e 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/zvol_ENOSPC.cfg +++ b/tests/zfs-tests/tests/functional/zvol/zvol_ENOSPC/zvol_ENOSPC.cfg @@ -32,7 +32,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS if is_linux; then diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli.cfg b/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli.cfg index 8a99225ba9ec..92650c5e050e 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli.cfg +++ b/tests/zfs-tests/tests/functional/zvol/zvol_cli/zvol_cli.cfg @@ -32,7 +32,7 @@ verify_runnable "global" -export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}') +export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}') export DISKSARRAY=$DISKS if is_linux; then diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap.cfg b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap.cfg index 54ecc18b5585..b6501da9c5c7 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap.cfg +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap.cfg @@ -34,11 +34,11 @@ # Remember swap devices # if is_linux; then - SAVESWAPDEVS=$(swapon -s | nawk '(NR != 1) {print $1}') + SAVESWAPDEVS=$(swapon -s | awk '(NR != 1) {print $1}') elif is_freebsd; then - SAVESWAPDEVS=$(swapctl -l | nawk '(NR != 1) {print $1}') + SAVESWAPDEVS=$(swapctl -l | awk '(NR != 1) {print $1}') else - SAVESWAPDEVS=$(swap -l | nawk '(NR != 1) {print $1}') + SAVESWAPDEVS=$(swap -l | awk '(NR != 1) {print $1}') fi export BLOCKSZ=$(( 1024 * 1024 )) From 0c205ecf574fccc4fb736a72c1d5eaaff1aad9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 00:25:47 +0100 Subject: [PATCH 26/63] egrep -> grep -E MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- config/kernel-global_page_state.m4 | 2 +- tests/test-runner/include/logapi.shlib | 15 ++----- tests/zfs-tests/include/blkdev.shlib | 42 +++++++------------ tests/zfs-tests/include/commands.cfg | 1 - tests/zfs-tests/include/libtest.shlib | 6 +-- .../tests/functional/acl/acl_common.kshlib | 3 +- .../functional/acl/posix/posix_001_pos.ksh | 4 +- .../functional/acl/posix/posix_002_pos.ksh | 2 +- .../functional/acl/posix/posix_003_pos.ksh | 12 +++--- .../cli_root/zdb/zdb_block_size_histogram.ksh | 3 +- .../cli_root/zdb/zdb_object_range_neg.ksh | 2 +- .../cli_root/zdb/zdb_object_range_pos.ksh | 3 +- .../cli_root/zfs_get/zfs_get_009_pos.ksh | 4 +- .../cli_root/zpool_import/zpool_import.kshlib | 2 +- .../zpool_initialize_verify_initialized.ksh | 2 +- .../cli_user/zfs_list/zfs_list_007_pos.ksh | 9 ++-- .../functional/fault/auto_online_001_pos.ksh | 5 +-- .../functional/redundancy/redundancy.kshlib | 6 +-- 18 files changed, 48 insertions(+), 75 deletions(-) diff --git a/config/kernel-global_page_state.m4 b/config/kernel-global_page_state.m4 index badb5e5d2e23..76f2bba202a1 100644 --- a/config/kernel-global_page_state.m4 +++ b/config/kernel-global_page_state.m4 @@ -55,7 +55,7 @@ dnl # AC_DEFUN([ZFS_AC_KERNEL_ENUM_MEMBER], [ AC_MSG_CHECKING([whether enum $2 contains $1]) AS_IF([AC_TRY_COMMAND( - "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | egrep -qx $1)],[ + "${srcdir}/scripts/enum-extract.pl" "$2" "$3" | grep -Eqx $1)],[ AC_MSG_RESULT([yes]) AC_DEFINE(m4_join([_], [ZFS_ENUM], m4_toupper($2), $1), 1, [enum $2 contains $1]) diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib index 33423a7e3c65..59ac4c2c30b4 100644 --- a/tests/test-runner/include/logapi.shlib +++ b/tests/test-runner/include/logapi.shlib @@ -103,10 +103,7 @@ function log_must_retry out="cat $logfile" if (( $status == 0 )); then - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or" \ " assertion failure exited $status" @@ -228,10 +225,7 @@ function log_neg_expect print -u2 $($out) _printerror "$@" "unexpectedly exited $status (SEGV)" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if (( $? == 0 )); then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" @@ -279,10 +273,7 @@ function log_pos print -u2 $($out) _printerror "$@" "exited $status" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index f776caa3be3d..a97d1582d45c 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -115,21 +115,18 @@ function is_physical_device #device if is_linux; then is_disk_device "$DEV_DSKDIR/$device" && \ - [[ -f /sys/module/loop/parameters/max_part ]] - return $? + [ -f /sys/module/loop/parameters/max_part ] elif is_freebsd; then is_disk_device "$DEV_DSKDIR/$device" && \ - echo $device | egrep -q \ + echo $device | grep -qE \ -e '^a?da[0-9]+$' \ -e '^md[0-9]+$' \ -e '^mfid[0-9]+$' \ -e '^nda[0-9]+$' \ -e '^nvd[0-9]+$' \ -e '^vtbd[0-9]+$' - return $? else - echo $device | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1 - return $? + echo $device | grep -qE "^c[0-F]+([td][0-F]+)+$" fi } @@ -143,8 +140,7 @@ function is_real_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep disk >/dev/null - return $? + grep -q disk fi } @@ -158,8 +154,7 @@ function is_loop_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep loop >/dev/null - return $? + grep -q loop fi } @@ -182,7 +177,7 @@ function is_mpath_device #disk if is_linux; then lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ - egrep mpath >/dev/null + grep -q mpath if (($? == 0)); then readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1 return $? @@ -333,14 +328,14 @@ function on_off_disk # disk state{online,offline} host dep="$(ls /sys/block/${dm_name}/slaves | awk '{print $1}')" while [[ -n $dep ]]; do #check if disk is online - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then dep_dir="/sys/block/${dm_name}" dep_dir+="/slaves/${dep}/device" ss="${dep_dir}/state" sd="${dep_dir}/delete" log_must eval "echo 'offline' > ${ss}" log_must eval "echo '1' > ${sd}" - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then log_fail "Offlining $disk failed" fi fi @@ -348,17 +343,14 @@ function on_off_disk # disk state{online,offline} host done elif [[ $state == "offline" ]] && ( is_real_device $disk ); then #check if disk is online - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then + if lsscsi | grep -qF $disk; then dev_state="/sys/block/$disk/device/state" dev_delete="/sys/block/$disk/device/delete" log_must eval "echo 'offline' > ${dev_state}" log_must eval "echo '1' > ${dev_delete}" - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then - log_fail "Offlining $disk" \ - "failed" - fi + if lsscsi | grep -qF $disk; then + log_fail "Offlining $disk failed" + fi else log_note "$disk is already offline" fi @@ -369,13 +361,13 @@ function on_off_disk # disk state{online,offline} host if is_mpath_device $disk; then dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" dep="$(ls /sys/block/$dm_name/slaves | awk '{print $1}')" - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then log_fail "Onlining $disk failed" fi elif is_real_device $disk; then block_device_wait typeset -i retries=0 - while ! lsscsi | egrep -q $disk; do + while ! lsscsi | grep -qF $disk; do if (( $retries > 2 )); then log_fail "Onlining $disk failed" break @@ -451,16 +443,14 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz log_unsupported "Platform does not have scsi_debug" "module" fi - lsmod | egrep scsi_debug > /dev/null - if (($? == 0)); then + if lsmod | grep -q scsi_debug; then log_fail "scsi_debug module already installed" else log_must modprobe scsi_debug dev_size_mb=$devsize \ add_host=$hosts num_tgts=$tgts max_luns=$luns \ sector_size=$sector physblk_exp=$blkexp block_device_wait - lsscsi | egrep scsi_debug > /dev/null - if (($? == 1)); then + if ! lsscsi | grep -q scsi_debug; then log_fail "scsi_debug module install failed" fi fi diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index a5ee92071b92..fcde48adc66a 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -32,7 +32,6 @@ export SYSTEM_FILES_COMMON='arp dmesg du echo - egrep env expr false diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 58e992698545..88390456a119 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2018,8 +2018,8 @@ function verify_pool # function get_disklist # pool { - zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ - egrep -v -e '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$" + echo $(zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ + grep -vEe '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$") } # @@ -2182,7 +2182,7 @@ function check_pool_status # pool token keyword if [[ $verbose == true ]]; then log_note $scan fi - echo $scan | egrep -qi "$keyword" + echo $scan | grep -qi "$keyword" } # diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index bfae8ec722ef..1450f7b660f9 100644 --- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -403,8 +403,7 @@ function get_xattr # return 1 fi - for xattr in `runat $obj ls | \ - grep -E -v -e SUNWattr_ro -e SUNWattr_rw` ; do + for xattr in $(runat $obj ls | grep -v 'SUNWattr_r[ow]'); do runat $obj cksum $xattr done } diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh index 14635b27fe92..d88217e5cad7 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh @@ -57,7 +57,7 @@ log_onexit cleanup log_note "Testing access to FILE" log_must touch $TESTDIR/file.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/file.0 -getfacl $TESTDIR/file.0 2> /dev/null | egrep -q \ +getfacl $TESTDIR/file.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:rw-$" if [ "$?" -eq "0" ]; then # Should be able to write to file @@ -75,7 +75,7 @@ if [ "$?" -eq "0" ]; then log_note "expected mask drwxrw----+ but found $msk" log_fail "Expected permissions were not set." fi - getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ + getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:rw-$" if [ "$?" -ne "0" ]; then acl=$(getfacl $TESTDIR/dir.0 2> /dev/null) diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh index bdcc18592f27..8764dd5a21c4 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh @@ -58,7 +58,7 @@ if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then log_note "expected mask drwx-wx---+ but found $msk" log_fail "Expected permissions were not set." fi -getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ +getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:-wx$" if [ "$?" -eq "0" ]; then # Should be able to create file in directory diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh index 1b04a024f2ad..bdd77bd37603 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh @@ -43,16 +43,14 @@ log_note "Testing access to DIRECTORY" log_must mkdir $ACLDIR log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR log_must setfacl -d -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR -getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str1" -if [ "$?" -eq "0" ]; then - getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str2" -fi -if [ "$?" -eq "0" ]; then +if getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str1" && + getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str2" +then log_must zfs unmount $TESTPOOL/$TESTFS log_must zfs mount $TESTPOOL/$TESTFS - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str1\"" - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str2\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str1\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str2\"" log_pass "POSIX ACLs survive remount" else log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rwx'" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh index 6ad93d87ca9a..75f15f6a88e3 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh @@ -115,8 +115,7 @@ function histo_populate_test_pool of=/${pool}/B_${this_rs}/file_${filenum} \ bs=${this_rs} count=${thiscount} \ iflag=fullblock 2>&1 | \ - egrep -v -e "records in" -e "records out" \ - -e "bytes.*copied" + grep -ve "records in" -e "records out" -e "bytes.*copied" ((filenum+=1)) done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh index 94553290309b..e4664b52eb94 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh @@ -65,7 +65,7 @@ done # Specifying a non-existent object identifier returns an error obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}') + grep -E "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}') obj_id_invalid=$(( $obj_id_highest + 1 )) log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh index ff46b0f2f870..2c85e6e932a6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh @@ -60,8 +60,7 @@ function get_object_list_range function get_object_list { zdb -P -dd $@ 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | - sed 's/^[[:space:]]*//' | + sed -E '/^ +-?([0-9]+ +){7}/!d;s/^[[:space:]]*//' | sort -n } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh index 7fd6918b43db..2580070e670c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh @@ -39,7 +39,7 @@ # STRATEGY: # 1. Create a multiple depth filesystem. # 2. 'zfs get -d ' to get the output. -# 3. 'zfs get -r|egrep' to get the expected output. +# 3. 'zfs get -r|grep' to get the expected output. # 4. Compare the two outputs, they should be same. # @@ -86,7 +86,7 @@ for dp in ${depth_array[@]}; do done for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do log_must eval "zfs get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs get -rH -o name $prop $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs get -rH -o name $prop $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT done (( old_val=dp )) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index 37f7acfbf198..b91b496ee3ba 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -180,7 +180,7 @@ function _translate_vdev # typeset keywords="mirror replacing raidz1 raidz2 raidz3 indirect draid1 draid2 draid3" for word in $keywords; do - echo $vdev | egrep -qE \ + echo $vdev | grep -qE \ "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" if [[ $? -eq 0 ]]; then vdev=$word diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh index 083b7e55a0a8..5e40eee4b83e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh @@ -76,7 +76,7 @@ while read -r offset size; do # Note we use '-t x4' instead of '-t x8' here because x8 is not # a supported format on FreeBSD. dd if=$SMALLFILE skip=$((offset / bs)) count=$((size / bs)) bs=$bs | - od -t x4 -Ad | egrep -q "deadbeef +deadbeef +deadbeef +deadbeef" || + od -t x4 -Ad | grep -qE "deadbeef +deadbeef +deadbeef +deadbeef" || log_fail "Pattern not found in metaslab free space" done diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh index 8e9009bd5500..0f60113b76fe 100755 --- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh @@ -37,7 +37,7 @@ # # STRATEGY: # 1. 'zfs list -d ' to get the output. -# 2. 'zfs list -r|egrep' to get the expected output. +# 2. 'zfs list -r|grep' to get the expected output. # 3. Compare the two outputs, they should be same. # @@ -50,8 +50,7 @@ fi function cleanup { - log_must rm -f $DEPTH_OUTPUT - log_must rm -f $EXPECT_OUTPUT + log_must rm -f $DEPTH_OUTPUT $EXPECT_OUTPUT } log_onexit cleanup @@ -76,10 +75,10 @@ for dp in ${depth_array[@]}; do log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" [[ -s "$DEPTH_OUTPUT" ]] && \ log_fail "$DEPTH_OUTPUT should be null." - log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' + log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E "$eg_opt" else log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT fi (( fs+=1 )) diff --git a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh index 03fc15a8a7cb..36d30b51e25c 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh @@ -134,9 +134,8 @@ do ((timeout++)) sleep 1 - zpool events $TESTPOOL \ - | egrep sysevent.fs.zfs.resilver_finish > /dev/null - if (($? == 0)); then + if zpool events $TESTPOOL \ + | grep -qF sysevent.fs.zfs.resilver_finish; then log_note "Auto-online of $offline_disk is complete" sleep 1 break diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib index 28b115fd73ce..6399c11ced34 100644 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib @@ -221,7 +221,7 @@ function is_data_valid log_must zpool scrub -w $pool record_data $pool $PST_RECORD_FILE - if ! diff $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null 2>&1; then + if ! cmp $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null; then log_must cat $PRE_RECORD_FILE log_must cat $PST_RECORD_FILE diff -u $PRE_RECORD_FILE $PST_RECORD_FILE @@ -242,8 +242,8 @@ function get_vdevs #pool cnt typeset pool=$1 typeset -i cnt=$2 - typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \ - egrep -ve "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \ + typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}' | \ + grep -vEe "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" \ -e "/old$|^$pool$") typeset -i i=0 typeset vdevs From 7f45f8db4fc59dd7c977f19c3f1584b776152ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 00:26:46 +0100 Subject: [PATCH 27/63] fgrep -> grep -F MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- config/kernel.m4 | 6 +++--- config/zfs-build.m4 | 2 +- .../tests/functional/cli_root/zpool_wait/zpool_wait.kshlib | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/kernel.m4 b/config/kernel.m4 index d1d3dede175b..7af5f327fb0e 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -392,11 +392,11 @@ AC_DEFUN([ZFS_AC_KERNEL], [ utsrelease1=$kernelbuild/include/linux/version.h utsrelease2=$kernelbuild/include/linux/utsrelease.h utsrelease3=$kernelbuild/include/generated/utsrelease.h - AS_IF([test -r $utsrelease1 && fgrep -q UTS_RELEASE $utsrelease1], [ + AS_IF([test -r $utsrelease1 && grep -qF UTS_RELEASE $utsrelease1], [ utsrelease=$utsrelease1 - ], [test -r $utsrelease2 && fgrep -q UTS_RELEASE $utsrelease2], [ + ], [test -r $utsrelease2 && grep -qF UTS_RELEASE $utsrelease2], [ utsrelease=$utsrelease2 - ], [test -r $utsrelease3 && fgrep -q UTS_RELEASE $utsrelease3], [ + ], [test -r $utsrelease3 && grep -qF UTS_RELEASE $utsrelease3], [ utsrelease=$utsrelease3 ]) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index d516f3d2969f..726b4b420c77 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -173,7 +173,7 @@ AC_DEFUN([ZFS_AC_DEBUG_KMEM_TRACKING], [ ]) AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS_DETECT_FREEBSD], [ - AS_IF([sysctl -n kern.conftxt | fgrep -qx $'options\tINVARIANTS'], + AS_IF([sysctl -n kern.conftxt | grep -Fqx $'options\tINVARIANTS'], [enable_invariants="yes"], [enable_invariants="no"]) ]) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib index b413f6e9f98d..ccb97914968a 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib @@ -120,5 +120,5 @@ function check_while_waiting # Whether any vdev in the given pool is initializing function is_vdev_initializing # pool { - zpool status -i "$1" | grep 'initialized, started' >/dev/null + zpool status -i "$1" | grep -q 'initialized, started' } From 09f1df1509c89ebb4bdc14a733d852b02cd1e75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 04:30:22 +0100 Subject: [PATCH 28/63] tests: {read,write}_dos_attributes: despaghettify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also: actually accept all the flags in write_d_a Signed-off-by: Ahelenia Ziemiańska --- configure.ac | 3 +- tests/zfs-tests/cmd/Makefile.am | 3 +- .../.gitignore | 1 + .../Makefile.am | 4 +- .../cmd/linux_dos_attributes/dos_attributes.h | 82 +++++++ .../read_dos_attributes.c | 60 ++++++ .../write_dos_attributes.c | 95 +++++++++ .../cmd/read_dos_attributes/.gitignore | 1 - .../cmd/read_dos_attributes/Makefile.am | 6 - .../read_dos_attributes/read_dos_attributes.c | 166 --------------- .../write_dos_attributes.c | 201 ------------------ 11 files changed, 243 insertions(+), 379 deletions(-) rename tests/zfs-tests/cmd/{write_dos_attributes => linux_dos_attributes}/.gitignore (51%) rename tests/zfs-tests/cmd/{write_dos_attributes => linux_dos_attributes}/Makefile.am (50%) create mode 100644 tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h create mode 100644 tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c create mode 100644 tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c delete mode 100644 tests/zfs-tests/cmd/read_dos_attributes/.gitignore delete mode 100644 tests/zfs-tests/cmd/read_dos_attributes/Makefile.am delete mode 100644 tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c delete mode 100644 tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c diff --git a/configure.ac b/configure.ac index 990958bafa1e..04fbb491adbb 100644 --- a/configure.ac +++ b/configure.ac @@ -226,14 +226,13 @@ AC_CONFIG_FILES([ tests/zfs-tests/cmd/randfree_file/Makefile tests/zfs-tests/cmd/randwritecomp/Makefile tests/zfs-tests/cmd/readmmap/Makefile - tests/zfs-tests/cmd/read_dos_attributes/Makefile + tests/zfs-tests/cmd/linux_dos_attributes/Makefile tests/zfs-tests/cmd/rename_dir/Makefile tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile tests/zfs-tests/cmd/send_doall/Makefile tests/zfs-tests/cmd/stride_dd/Makefile tests/zfs-tests/cmd/threadsappend/Makefile tests/zfs-tests/cmd/user_ns_exec/Makefile - tests/zfs-tests/cmd/write_dos_attributes/Makefile tests/zfs-tests/cmd/xattrtest/Makefile tests/zfs-tests/include/Makefile tests/zfs-tests/tests/Makefile diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index 88d8c8cf08b2..fb49edd3a543 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -34,8 +34,7 @@ if BUILD_LINUX SUBDIRS += \ getversion \ randfree_file \ - read_dos_attributes \ + linux_dos_attributes \ user_ns_exec \ - write_dos_attributes \ xattrtest endif diff --git a/tests/zfs-tests/cmd/write_dos_attributes/.gitignore b/tests/zfs-tests/cmd/linux_dos_attributes/.gitignore similarity index 51% rename from tests/zfs-tests/cmd/write_dos_attributes/.gitignore rename to tests/zfs-tests/cmd/linux_dos_attributes/.gitignore index f3949ac82822..14a62551da93 100644 --- a/tests/zfs-tests/cmd/write_dos_attributes/.gitignore +++ b/tests/zfs-tests/cmd/linux_dos_attributes/.gitignore @@ -1 +1,2 @@ +/read_dos_attributes /write_dos_attributes diff --git a/tests/zfs-tests/cmd/write_dos_attributes/Makefile.am b/tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am similarity index 50% rename from tests/zfs-tests/cmd/write_dos_attributes/Makefile.am rename to tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am index c297fd49e0e9..2e383e94f200 100644 --- a/tests/zfs-tests/cmd/write_dos_attributes/Makefile.am +++ b/tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am @@ -2,5 +2,7 @@ include $(top_srcdir)/config/Rules.am pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin -pkgexec_PROGRAMS = write_dos_attributes +EXTRA_DIST = dos_attributes.h +pkgexec_PROGRAMS = read_dos_attributes write_dos_attributes +read_dos_attributes_SOURCES = read_dos_attributes.c write_dos_attributes_SOURCES = write_dos_attributes.c diff --git a/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h b/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h new file mode 100644 index 000000000000..dd3a820ff20c --- /dev/null +++ b/tests/zfs-tests/cmd/linux_dos_attributes/dos_attributes.h @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: 0BSD + +#include + + +#define U_APPEND_SHORT "uappnd" +#define U_APPEND_FULL "uappend" +#define SU_APPEND_SHORT "sappnd" +#define SU_APPEND_FULL "sappend" + +#define U_ARCH_SHORT "uarch" +#define U_ARCH_FULL "uarchive" +#define SU_ARCH_SHORT "arch" +#define SU_ARCH_FULL "archived" + +#define U_HIDDEN_SHORT "hidden" +#define U_HIDDEN_FULL "uhidden" + +#define SU_IMMUTABLE_FULL "simmutable" +#define SU_IMMUTABLE_SHORT "schange" +#define SU_IMMUTABLE "schg" +#define U_IMMUTABLE_FULL "uimmutable" +#define U_IMMUTABLE_SHORT "uchange" +#define U_IMMUTABLE "uchg" + +#define SU_NODUMP "nodump" +#define UNSET_NODUMP "dump" + +#define U_UNLINK_SHORT "uunlnk" +#define U_UNLINK_FULL "uunlink" +#define SU_UNLINK_SHORT "sunlnk" +#define SU_UNLINK_FULL "sunlink" + +#define U_OFFLINE_SHORT "offline" +#define U_OFFLINE_FULL "uoffline" + +#define U_RDONLY "rdonly" +#define U_RDONLY_SHORT "urdonly" +#define U_RDONLY_FULL "readonly" + +#define U_REPARSE_SHORT "reparse" +#define U_REPARSE_FULL "ureparse" + +#define U_SPARSE_SHORT "sparse" +#define U_SPARSE_FULL "usparse" + +#define U_SYSTEM_SHORT "system" +#define U_SYSTEM_FULL "usystem" + + +static const uint64_t all_dos_attributes[] = { + ZFS_ARCHIVE, + ZFS_APPENDONLY, + ZFS_IMMUTABLE, + ZFS_NOUNLINK, + ZFS_NODUMP, + ZFS_HIDDEN, + ZFS_OFFLINE, + ZFS_READONLY, + ZFS_SPARSE, + ZFS_SYSTEM, + ZFS_REPARSE, +}; + +static const char *const all_dos_attribute_names[][7] = { + {U_ARCH_SHORT, U_ARCH_FULL, SU_ARCH_SHORT, SU_ARCH_FULL}, + {U_APPEND_SHORT, U_APPEND_FULL, SU_APPEND_SHORT, SU_APPEND_FULL}, + {SU_IMMUTABLE_FULL, SU_IMMUTABLE_SHORT, SU_IMMUTABLE, + U_IMMUTABLE_FULL, U_IMMUTABLE_SHORT, U_IMMUTABLE}, + {U_UNLINK_SHORT, U_UNLINK_FULL, SU_UNLINK_FULL, SU_UNLINK_SHORT}, + {SU_NODUMP, /* UNSET_NODUMP */}, + {U_HIDDEN_SHORT, U_HIDDEN_FULL}, + {U_OFFLINE_SHORT, U_OFFLINE_FULL}, + {U_RDONLY, U_RDONLY_SHORT, U_RDONLY_FULL}, + {U_SPARSE_SHORT, U_SPARSE_FULL}, + {U_SYSTEM_SHORT, U_SYSTEM_FULL}, + {U_REPARSE_SHORT, U_REPARSE_FULL}, +}; + +_Static_assert( + ARRAY_SIZE(all_dos_attributes) == ARRAY_SIZE(all_dos_attribute_names), + "attribute list length mismatch"); diff --git a/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c b/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c new file mode 100644 index 000000000000..07821140512e --- /dev/null +++ b/tests/zfs-tests/cmd/linux_dos_attributes/read_dos_attributes.c @@ -0,0 +1,60 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 iXsystems, Inc. + */ + +/* + * FreeBSD exposes additional file attributes via ls -o and chflags. + * Under Linux, we provide ZFS_IOC_[GS]ETDOSFLAGS ioctl()s. + * + * This application is the equivalent to FreeBSD ls -lo $1 | awk '{print $5}'. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dos_attributes.h" + +int +main(int argc, const char *const *argv) +{ + if (argc != 2) + errx(EXIT_FAILURE, "usage: %s file", argv[0]); + + int fd = open(argv[1], O_RDONLY | O_CLOEXEC); + if (fd == -1) + err(EXIT_FAILURE, "%s", argv[1]); + + uint64_t flags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS"); + + bool any = false; + for (size_t i = 0; i < ARRAY_SIZE(all_dos_attributes); ++i) + if (flags & all_dos_attributes[i]) { + if (any) + putchar(','); + (void) fputs(*all_dos_attribute_names[i], stdout); + any = true; + } + if (any) + (void) putchar('\n'); + else + (void) puts("-"); +} diff --git a/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c b/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c new file mode 100644 index 000000000000..3cea7d4b1c7d --- /dev/null +++ b/tests/zfs-tests/cmd/linux_dos_attributes/write_dos_attributes.c @@ -0,0 +1,95 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 iXsystems, Inc. + */ + +/* + * FreeBSD exposes additional file attributes via ls -o and chflags. + * Under Linux, we provide ZFS_IOC_[GS]ETDOSFLAGS ioctl()s. + * + * This application is equivalent to FreeBSD chflags. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dos_attributes.h" + +int +main(int argc, const char *const *argv) +{ + if (argc != 3) + errx(EXIT_FAILURE, "usage: %s flag file", argv[0]); + + bool unset = false; + uint64_t attr = 0; + const char *flag = argv[1]; + if (strcmp(flag, "0") == 0) + ; + else if (strcmp(flag, SU_NODUMP) == 0) + attr = ZFS_NODUMP; + else if (strcmp(flag, UNSET_NODUMP) == 0) { + attr = ZFS_NODUMP; + unset = true; + } else { + if (strncmp(flag, "no", 2) == 0) { + unset = true; + flag += 2; + } + for (size_t i = 0; i < ARRAY_SIZE(all_dos_attribute_names); ++i) + for (const char *const *nm = all_dos_attribute_names[i]; + *nm; ++nm) + if (strcmp(flag, *nm) == 0) { + attr = all_dos_attributes[i]; + goto found; + } + + errx(EXIT_FAILURE, "%s: unknown flag", argv[1]); +found:; + } + + int fd = open(argv[2], O_RDWR | O_APPEND | O_CLOEXEC); + if (fd == -1) + err(EXIT_FAILURE, "%s", argv[2]); + + uint64_t flags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS"); + + if (attr == 0) + flags = 0; + else if (unset) + flags &= ~attr; + else + flags |= attr; + + if (ioctl(fd, ZFS_IOC_SETDOSFLAGS, &flags) == -1) + err(EXIT_FAILURE, "ZFS_IOC_SETDOSFLAGS"); + + uint64_t newflags; + if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &newflags) == -1) + err(EXIT_FAILURE, "second ZFS_IOC_GETDOSFLAGS"); + + if (newflags != flags) + errx(EXIT_FAILURE, "expecting %#" PRIx64 ", got %#" PRIx64 + "; %ssetting %#" PRIx64 "", + flags, newflags, unset ? "un" : "", attr); + + (void) printf("%#" PRIx64 "\n", flags); +} diff --git a/tests/zfs-tests/cmd/read_dos_attributes/.gitignore b/tests/zfs-tests/cmd/read_dos_attributes/.gitignore deleted file mode 100644 index 52584e4a738b..000000000000 --- a/tests/zfs-tests/cmd/read_dos_attributes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/read_dos_attributes diff --git a/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am b/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am deleted file mode 100644 index 69412f05f650..000000000000 --- a/tests/zfs-tests/cmd/read_dos_attributes/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = read_dos_attributes -read_dos_attributes_SOURCES = read_dos_attributes.c diff --git a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c b/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c deleted file mode 100644 index 36d7b31ba191..000000000000 --- a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - */ - -/* - * Copyright 2022 iXsystems, Inc. - */ - -/* - * FreeBSD allows to update and retreive additional file level attributes. - * For Linux, two IOCTLs have been added to update and retrieve additional - * level attributes. - * - * This application reads additional file level attributes on a given - * file and prints FreeBSD keywords that map to respective attributes. - * - * Usage: 'read_dos_attributes filepath' - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SU_ARCH_SHORT "arch" -#define SU_ARCH_FULL "archived" -#define SU_NODUMP "nodump" -#define SU_APPEND_SHORT "sappnd" -#define SU_APPEND_FULL "sappend" -#define SU_IMMUTABLE "schg" -#define SU_IMMUTABLE_SHORT "schange" -#define SU_IMMUTABLE_FULL "simmutable" -#define SU_UNLINK_SHORT "sunlnk" -#define SU_UNLINK_FULL "sunlink" -#define U_APPEND_SHORT "uappnd" -#define U_APPEND_FULL "uappend" -#define U_ARCH_SHORT "uarch" -#define U_ARCH_FULL "uarchive" -#define U_IMMUTABLE "uchg" -#define U_IMMUTABLE_SHORT "uchange" -#define U_IMMUTABLE_FULL "uimmutable" -#define U_HIDDEN_SHORT "hidden" -#define U_HIDDEN_FULL "uhidden" -#define U_OFFLINE_SHORT "offline" -#define U_OFFLINE_FULL "uoffline" -#define U_RDONLY "rdonly" -#define U_RDONLY_SHORT "urdonly" -#define U_RDONLY_FULL "readonly" -#define U_SPARSE_SHORT "sparse" -#define U_SPARSE_FULL "usparse" -#define U_SYSTEM_SHORT "system" -#define U_SYSTEM_FULL "usystem" -#define U_REPARSE_SHORT "reparse" -#define U_REPARSE_FULL "ureparse" -#define U_UNLINK_SHORT "uunlnk" -#define U_UNLINK_FULL "uunlink" -#define UNSET_NODUMP "dump" - -#define NO_ATTRIBUTE "-" - -#define SEPARATOR "," - -#define BUFFER_SIZE 0x200 - -void attribute_to_str(uint64_t attributes, char *buff); - -void -attribute_to_str(uint64_t attributes, char *buff) -{ - if (attributes & ZFS_ARCHIVE) { - strcat(buff, U_ARCH_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_APPENDONLY) { - strcat(buff, U_APPEND_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_IMMUTABLE) { - strcat(buff, U_IMMUTABLE_FULL); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_NOUNLINK) { - strcat(buff, U_UNLINK_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_NODUMP) { - strcat(buff, SU_NODUMP); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_HIDDEN) { - strcat(buff, U_HIDDEN_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_OFFLINE) { - strcat(buff, U_OFFLINE_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_READONLY) { - strcat(buff, U_RDONLY); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_SPARSE) { - strcat(buff, U_SPARSE_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_SYSTEM) { - strcat(buff, U_SYSTEM_SHORT); - strcat(buff, SEPARATOR); - } - - if (attributes & ZFS_REPARSE) { - strcat(buff, U_REPARSE_SHORT); - strcat(buff, SEPARATOR); - } - - if (buff[0] == '\0') - strcat(buff, NO_ATTRIBUTE); - else - buff[strlen(buff) - 1] = '\0'; -} - -int -main(int argc, const char * const argv[]) -{ - if (argc != 2) - errx(EXIT_FAILURE, "Usage: %s filepath", argv[0]); - - int fd = open(argv[1], O_RDWR | O_APPEND); - if (fd < 0) - err(EXIT_FAILURE, "Failed to open %s", argv[1]); - - uint64_t dosflags = 0; - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - (void) close(fd); - - char buffer[BUFFER_SIZE] = ""; - - (void) attribute_to_str(dosflags, buffer); - - (void) puts(buffer); - - return (EXIT_SUCCESS); -} diff --git a/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c b/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c deleted file mode 100644 index c373d3b15318..000000000000 --- a/tests/zfs-tests/cmd/write_dos_attributes/write_dos_attributes.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file and its contents are supplied under the terms of the - * Common Development and Distribution License ("CDDL"), version 1.0. - * You may only use this file in accordance with the terms of version - * 1.0 of the CDDL. - * - * A full copy of the text of the CDDL should have accompanied this - * source. A copy of the CDDL is also available via the Internet at - * http://www.illumos.org/license/CDDL. - */ - -/* - * Copyright 2022 iXsystems, Inc. - */ - -/* - * FreeBSD allows to update and retreive additional file level attributes. - * For Linux, two IOCTLs have been added to update and retrieve additional - * level attributes. - * - * This application updates additional file level attributes on a given - * file. FreeBSD keywords can be used to specify the flag. - * - * Usage: 'write_dos_attributes flag filepath' - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SU_ARCH_SHORT "arch" -#define SU_ARCH_FULL "archived" -#define SU_NODUMP "nodump" -#define SU_APPEND_SHORT "sappnd" -#define SU_APPEND_FULL "sappend" -#define SU_IMMUTABLE "schg" -#define SU_IMMUTABLE_SHORT "schange" -#define SU_IMMUTABLE_FULL "simmutable" -#define SU_UNLINK_SHORT "sunlnk" -#define SU_UNLINK_FULL "sunlink" -#define U_APPEND_SHORT "uappnd" -#define U_APPEND_FULL "uappend" -#define U_ARCH_SHORT "uarch" -#define U_ARCH_FULL "uarchive" -#define U_IMMUTABLE "uchg" -#define U_IMMUTABLE_SHORT "uchange" -#define U_IMMUTABLE_FULL "uimmutable" -#define U_HIDDEN_SHORT "hidden" -#define U_HIDDEN_FULL "uhidden" -#define U_OFFLINE_SHORT "offline" -#define U_OFFLINE_FULL "uoffline" -#define U_RDONLY "rdonly" -#define U_RDONLY_SHORT "urdonly" -#define U_RDONLY_FULL "readonly" -#define U_SPARSE_SHORT "sparse" -#define U_SPARSE_FULL "usparse" -#define U_SYSTEM_SHORT "system" -#define U_SYSTEM_FULL "usystem" -#define U_REPARSE_SHORT "reparse" -#define U_REPARSE_FULL "ureparse" -#define U_UNLINK_SHORT "uunlnk" -#define U_UNLINK_FULL "uunlink" -#define UNSET_NODUMP "dump" - -#define IS_NO(s) (s[0] == 'n' && s[1] == 'o') - -uint64_t str_to_attribute(char *str); - -uint64_t -str_to_attribute(char *str) -{ - if ((strcmp(str, SU_ARCH_SHORT) == 0) || - (strcmp(str, SU_ARCH_FULL) == 0) || - (strcmp(str, U_ARCH_SHORT) == 0) || - (strcmp(str, U_ARCH_FULL) == 0)) - return (ZFS_ARCHIVE); - - else if ((strcmp(str, SU_APPEND_SHORT) == 0) || - (strcmp(str, SU_APPEND_FULL) == 0) || - (strcmp(str, U_APPEND_SHORT) == 0) || - (strcmp(str, U_APPEND_FULL) == 0)) - return (ZFS_APPENDONLY); - - else if ((strcmp(str, SU_IMMUTABLE) == 0) || - (strcmp(str, SU_IMMUTABLE_SHORT) == 0) || - (strcmp(str, SU_IMMUTABLE_FULL) == 0)) - return (ZFS_IMMUTABLE); - - else if ((strcmp(str, SU_UNLINK_SHORT) == 0) || - (strcmp(str, SU_UNLINK_FULL) == 0) || - (strcmp(str, U_UNLINK_SHORT) == 0) || - (strcmp(str, SU_UNLINK_FULL) == 0)) - return (ZFS_NOUNLINK); - - else if ((strcmp(str, U_HIDDEN_SHORT) == 0) || - (strcmp(str, U_HIDDEN_FULL) == 0)) - return (ZFS_HIDDEN); - - else if ((strcmp(str, U_OFFLINE_SHORT) == 0) || - (strcmp(str, U_OFFLINE_FULL) == 0)) - return (ZFS_OFFLINE); - - else if ((strcmp(str, U_RDONLY) == 0) || - (strcmp(str, U_RDONLY_SHORT) == 0) || - (strcmp(str, U_RDONLY_FULL) == 0)) - return (ZFS_READONLY); - - else if ((strcmp(str, U_SPARSE_SHORT) == 0) || - (strcmp(str, U_SPARSE_FULL) == 0)) - return (ZFS_SPARSE); - - else if ((strcmp(str, U_SYSTEM_SHORT) == 0) || - (strcmp(str, U_SYSTEM_FULL) == 0)) - return (ZFS_SYSTEM); - - else if ((strcmp(str, U_REPARSE_SHORT) == 0) || - (strcmp(str, U_REPARSE_FULL) == 0)) - return (ZFS_REPARSE); - - return (-1); -} - -int -main(int argc, const char * const argv[]) -{ - if (argc != 3) - errx(EXIT_FAILURE, "Usage: %s flag filepath", argv[0]); - - uint8_t unset, unset_all; - uint64_t attribute, dosflags; - char *flag = strdup(argv[1]); - unset = unset_all = 0; - attribute = dosflags = 0; - - // convert the flag to lower case - for (int i = 0; i < strlen(argv[1]); ++i) - flag[i] = tolower((unsigned char) flag[i]); - - // check if flag starts with 'no' - if (IS_NO(flag)) { - if (strcmp(flag, SU_NODUMP) == 0) { - attribute = ZFS_NODUMP; - } else { - attribute = str_to_attribute(flag + 2); - unset = 1; - } - } - // check if '0' was passed - else if (strcmp(flag, "0") == 0) { - unset_all = 1; - } - // check if the flag is 'dump' - else if (strcmp(flag, UNSET_NODUMP) == 0) { - attribute = ZFS_NODUMP; - unset = 1; - } else { - attribute = str_to_attribute(flag); - } - - if (attribute == -1) - errx(EXIT_FAILURE, "Invalid Flag %s", argv[1]); - - int fd = open(argv[2], O_RDWR | O_APPEND); - if (fd < 0) - err(EXIT_FAILURE, "Failed to open %s", argv[2]); - - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - if (unset == 0 && attribute != 0) - attribute |= dosflags; - else if (unset == 1 && attribute != 0) - attribute = dosflags & (~attribute); - else if (unset_all == 1) - attribute = 0; - - // set the attribute/s - if (ioctl(fd, ZFS_IOC_SETDOSFLAGS, &attribute) == -1) - err(EXIT_FAILURE, "ZFS_IOC_SETDOSFLAGS failed"); - - // get the attributes to confirm - dosflags = -1; - if (ioctl(fd, ZFS_IOC_GETDOSFLAGS, &dosflags) == -1) - err(EXIT_FAILURE, "ZFS_IOC_GETDOSFLAGS failed"); - - (void) close(fd); - - if (dosflags != attribute) - errx(EXIT_FAILURE, "Could not set %s attribute", argv[1]); - - (void) printf("New Dos Flags: 0x%llx\n", (u_longlong_t)dosflags); - - return (EXIT_SUCCESS); -} From 6eb2c40ec358b01cb5acc9fd294da1847527088e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 22 Mar 2022 20:09:47 +0100 Subject: [PATCH 29/63] tests: cmd: don't recurse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This confers an >10x speedup on t/z-t/cmd builds (12s -> 1.1s), gets rid of 23 redundant identical automake specs and gitignores, and groups the binaries with their common headers Signed-off-by: Ahelenia Ziemiańska --- configure.ac | 33 ---- tests/zfs-tests/cmd/.gitignore | 34 ++++ tests/zfs-tests/cmd/Makefile.am | 179 ++++++++++++++---- tests/zfs-tests/cmd/{badsend => }/badsend.c | 0 tests/zfs-tests/cmd/badsend/.gitignore | 1 - tests/zfs-tests/cmd/badsend/Makefile.am | 11 -- .../cmd/{btree_test => }/btree_test.c | 0 tests/zfs-tests/cmd/btree_test/.gitignore | 1 - tests/zfs-tests/cmd/btree_test/Makefile.am | 32 ---- .../cmd/{chg_usr_exec => }/chg_usr_exec.c | 0 tests/zfs-tests/cmd/chg_usr_exec/.gitignore | 1 - tests/zfs-tests/cmd/chg_usr_exec/Makefile.am | 6 - .../cmd/{devname2devid => }/devname2devid.c | 0 tests/zfs-tests/cmd/devname2devid/.gitignore | 1 - tests/zfs-tests/cmd/devname2devid/Makefile.am | 10 - .../cmd/{dir_rd_update => }/dir_rd_update.c | 0 tests/zfs-tests/cmd/dir_rd_update/.gitignore | 1 - tests/zfs-tests/cmd/dir_rd_update/Makefile.am | 6 - tests/zfs-tests/cmd/{draid => }/draid.c | 0 tests/zfs-tests/cmd/draid/.gitignore | 1 - tests/zfs-tests/cmd/draid/Makefile.am | 15 -- .../cmd/{file_check => file}/file_check.c | 2 +- tests/zfs-tests/cmd/{ => file}/file_common.h | 0 .../cmd/{file_trunc => file}/file_trunc.c | 0 .../cmd/{file_write => file}/file_write.c | 2 +- .../cmd/{largest_file => file}/largest_file.c | 2 +- .../{randfree_file => file}/randfree_file.c | 2 +- .../{randwritecomp => file}/randwritecomp.c | 2 +- tests/zfs-tests/cmd/file_check/.gitignore | 1 - tests/zfs-tests/cmd/file_check/Makefile.am | 6 - tests/zfs-tests/cmd/file_trunc/.gitignore | 1 - tests/zfs-tests/cmd/file_trunc/Makefile.am | 6 - tests/zfs-tests/cmd/file_write/.gitignore | 1 - tests/zfs-tests/cmd/file_write/Makefile.am | 6 - tests/zfs-tests/cmd/{get_diff => }/get_diff.c | 0 tests/zfs-tests/cmd/get_diff/.gitignore | 1 - tests/zfs-tests/cmd/get_diff/Makefile.am | 6 - .../cmd/{getversion => }/getversion.c | 0 tests/zfs-tests/cmd/getversion/.gitignore | 1 - tests/zfs-tests/cmd/getversion/Makefile.am | 6 - tests/zfs-tests/cmd/largest_file/.gitignore | 1 - tests/zfs-tests/cmd/largest_file/Makefile.am | 6 - .../libzfs_input_check.c | 0 .../cmd/libzfs_input_check/.gitignore | 1 - .../cmd/libzfs_input_check/Makefile.am | 17 -- .../cmd/linux_dos_attributes/.gitignore | 2 - .../cmd/linux_dos_attributes/Makefile.am | 8 - tests/zfs-tests/cmd/{mkbusy => }/mkbusy.c | 0 tests/zfs-tests/cmd/mkbusy/.gitignore | 1 - tests/zfs-tests/cmd/mkbusy/Makefile.am | 6 - tests/zfs-tests/cmd/{mkfile => }/mkfile.c | 0 tests/zfs-tests/cmd/mkfile/.gitignore | 1 - tests/zfs-tests/cmd/mkfile/Makefile.am | 8 - tests/zfs-tests/cmd/{mkfiles => }/mkfiles.c | 0 tests/zfs-tests/cmd/mkfiles/.gitignore | 1 - tests/zfs-tests/cmd/mkfiles/Makefile.am | 6 - tests/zfs-tests/cmd/{mktree => }/mktree.c | 0 tests/zfs-tests/cmd/mktree/.gitignore | 1 - tests/zfs-tests/cmd/mktree/Makefile.am | 6 - .../zfs-tests/cmd/{mmap_exec => }/mmap_exec.c | 0 tests/zfs-tests/cmd/mmap_exec/.gitignore | 1 - tests/zfs-tests/cmd/mmap_exec/Makefile.am | 6 - .../cmd/{mmap_libaio => }/mmap_libaio.c | 0 tests/zfs-tests/cmd/mmap_libaio/.gitignore | 1 - tests/zfs-tests/cmd/mmap_libaio/Makefile.am | 10 - .../zfs-tests/cmd/{mmap_seek => }/mmap_seek.c | 0 tests/zfs-tests/cmd/mmap_seek/.gitignore | 1 - tests/zfs-tests/cmd/mmap_seek/Makefile.am | 6 - .../zfs-tests/cmd/{mmapwrite => }/mmapwrite.c | 0 tests/zfs-tests/cmd/mmapwrite/.gitignore | 1 - tests/zfs-tests/cmd/mmapwrite/Makefile.am | 7 - .../cmd/{nvlist_to_lua => }/nvlist_to_lua.c | 0 tests/zfs-tests/cmd/nvlist_to_lua/.gitignore | 1 - tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am | 10 - tests/zfs-tests/cmd/randfree_file/.gitignore | 1 - tests/zfs-tests/cmd/randfree_file/Makefile.am | 6 - tests/zfs-tests/cmd/randwritecomp/.gitignore | 1 - tests/zfs-tests/cmd/randwritecomp/Makefile.am | 9 - tests/zfs-tests/cmd/{readmmap => }/readmmap.c | 0 tests/zfs-tests/cmd/readmmap/.gitignore | 1 - tests/zfs-tests/cmd/readmmap/Makefile.am | 6 - .../cmd/{rename_dir => }/rename_dir.c | 0 tests/zfs-tests/cmd/rename_dir/.gitignore | 1 - tests/zfs-tests/cmd/rename_dir/Makefile.am | 6 - .../rm_lnkcnt_zero_file.c | 0 .../cmd/rm_lnkcnt_zero_file/.gitignore | 1 - .../cmd/rm_lnkcnt_zero_file/Makefile.am | 7 - .../cmd/{send_doall => }/send_doall.c | 0 tests/zfs-tests/cmd/send_doall/.gitignore | 1 - tests/zfs-tests/cmd/send_doall/Makefile.am | 11 -- .../zfs-tests/cmd/{stride_dd => }/stride_dd.c | 0 tests/zfs-tests/cmd/stride_dd/.gitignore | 1 - tests/zfs-tests/cmd/stride_dd/Makefile.am | 7 - .../cmd/{threadsappend => }/threadsappend.c | 0 tests/zfs-tests/cmd/threadsappend/.gitignore | 1 - tests/zfs-tests/cmd/threadsappend/Makefile.am | 7 - .../cmd/{user_ns_exec => }/user_ns_exec.c | 0 tests/zfs-tests/cmd/user_ns_exec/.gitignore | 1 - tests/zfs-tests/cmd/user_ns_exec/Makefile.am | 6 - .../zfs-tests/cmd/{xattrtest => }/xattrtest.c | 0 tests/zfs-tests/cmd/xattrtest/.gitignore | 1 - tests/zfs-tests/cmd/xattrtest/Makefile.am | 6 - 102 files changed, 181 insertions(+), 386 deletions(-) create mode 100644 tests/zfs-tests/cmd/.gitignore rename tests/zfs-tests/cmd/{badsend => }/badsend.c (100%) delete mode 100644 tests/zfs-tests/cmd/badsend/.gitignore delete mode 100644 tests/zfs-tests/cmd/badsend/Makefile.am rename tests/zfs-tests/cmd/{btree_test => }/btree_test.c (100%) delete mode 100644 tests/zfs-tests/cmd/btree_test/.gitignore delete mode 100644 tests/zfs-tests/cmd/btree_test/Makefile.am rename tests/zfs-tests/cmd/{chg_usr_exec => }/chg_usr_exec.c (100%) delete mode 100644 tests/zfs-tests/cmd/chg_usr_exec/.gitignore delete mode 100644 tests/zfs-tests/cmd/chg_usr_exec/Makefile.am rename tests/zfs-tests/cmd/{devname2devid => }/devname2devid.c (100%) delete mode 100644 tests/zfs-tests/cmd/devname2devid/.gitignore delete mode 100644 tests/zfs-tests/cmd/devname2devid/Makefile.am rename tests/zfs-tests/cmd/{dir_rd_update => }/dir_rd_update.c (100%) delete mode 100644 tests/zfs-tests/cmd/dir_rd_update/.gitignore delete mode 100644 tests/zfs-tests/cmd/dir_rd_update/Makefile.am rename tests/zfs-tests/cmd/{draid => }/draid.c (100%) delete mode 100644 tests/zfs-tests/cmd/draid/.gitignore delete mode 100644 tests/zfs-tests/cmd/draid/Makefile.am rename tests/zfs-tests/cmd/{file_check => file}/file_check.c (98%) rename tests/zfs-tests/cmd/{ => file}/file_common.h (100%) rename tests/zfs-tests/cmd/{file_trunc => file}/file_trunc.c (100%) rename tests/zfs-tests/cmd/{file_write => file}/file_write.c (99%) rename tests/zfs-tests/cmd/{largest_file => file}/largest_file.c (99%) rename tests/zfs-tests/cmd/{randfree_file => file}/randfree_file.c (99%) rename tests/zfs-tests/cmd/{randwritecomp => file}/randwritecomp.c (99%) delete mode 100644 tests/zfs-tests/cmd/file_check/.gitignore delete mode 100644 tests/zfs-tests/cmd/file_check/Makefile.am delete mode 100644 tests/zfs-tests/cmd/file_trunc/.gitignore delete mode 100644 tests/zfs-tests/cmd/file_trunc/Makefile.am delete mode 100644 tests/zfs-tests/cmd/file_write/.gitignore delete mode 100644 tests/zfs-tests/cmd/file_write/Makefile.am rename tests/zfs-tests/cmd/{get_diff => }/get_diff.c (100%) delete mode 100644 tests/zfs-tests/cmd/get_diff/.gitignore delete mode 100644 tests/zfs-tests/cmd/get_diff/Makefile.am rename tests/zfs-tests/cmd/{getversion => }/getversion.c (100%) delete mode 100644 tests/zfs-tests/cmd/getversion/.gitignore delete mode 100644 tests/zfs-tests/cmd/getversion/Makefile.am delete mode 100644 tests/zfs-tests/cmd/largest_file/.gitignore delete mode 100644 tests/zfs-tests/cmd/largest_file/Makefile.am rename tests/zfs-tests/cmd/{libzfs_input_check => }/libzfs_input_check.c (100%) delete mode 100644 tests/zfs-tests/cmd/libzfs_input_check/.gitignore delete mode 100644 tests/zfs-tests/cmd/libzfs_input_check/Makefile.am delete mode 100644 tests/zfs-tests/cmd/linux_dos_attributes/.gitignore delete mode 100644 tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am rename tests/zfs-tests/cmd/{mkbusy => }/mkbusy.c (100%) delete mode 100644 tests/zfs-tests/cmd/mkbusy/.gitignore delete mode 100644 tests/zfs-tests/cmd/mkbusy/Makefile.am rename tests/zfs-tests/cmd/{mkfile => }/mkfile.c (100%) delete mode 100644 tests/zfs-tests/cmd/mkfile/.gitignore delete mode 100644 tests/zfs-tests/cmd/mkfile/Makefile.am rename tests/zfs-tests/cmd/{mkfiles => }/mkfiles.c (100%) delete mode 100644 tests/zfs-tests/cmd/mkfiles/.gitignore delete mode 100644 tests/zfs-tests/cmd/mkfiles/Makefile.am rename tests/zfs-tests/cmd/{mktree => }/mktree.c (100%) delete mode 100644 tests/zfs-tests/cmd/mktree/.gitignore delete mode 100644 tests/zfs-tests/cmd/mktree/Makefile.am rename tests/zfs-tests/cmd/{mmap_exec => }/mmap_exec.c (100%) delete mode 100644 tests/zfs-tests/cmd/mmap_exec/.gitignore delete mode 100644 tests/zfs-tests/cmd/mmap_exec/Makefile.am rename tests/zfs-tests/cmd/{mmap_libaio => }/mmap_libaio.c (100%) delete mode 100644 tests/zfs-tests/cmd/mmap_libaio/.gitignore delete mode 100644 tests/zfs-tests/cmd/mmap_libaio/Makefile.am rename tests/zfs-tests/cmd/{mmap_seek => }/mmap_seek.c (100%) delete mode 100644 tests/zfs-tests/cmd/mmap_seek/.gitignore delete mode 100644 tests/zfs-tests/cmd/mmap_seek/Makefile.am rename tests/zfs-tests/cmd/{mmapwrite => }/mmapwrite.c (100%) delete mode 100644 tests/zfs-tests/cmd/mmapwrite/.gitignore delete mode 100644 tests/zfs-tests/cmd/mmapwrite/Makefile.am rename tests/zfs-tests/cmd/{nvlist_to_lua => }/nvlist_to_lua.c (100%) delete mode 100644 tests/zfs-tests/cmd/nvlist_to_lua/.gitignore delete mode 100644 tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am delete mode 100644 tests/zfs-tests/cmd/randfree_file/.gitignore delete mode 100644 tests/zfs-tests/cmd/randfree_file/Makefile.am delete mode 100644 tests/zfs-tests/cmd/randwritecomp/.gitignore delete mode 100644 tests/zfs-tests/cmd/randwritecomp/Makefile.am rename tests/zfs-tests/cmd/{readmmap => }/readmmap.c (100%) delete mode 100644 tests/zfs-tests/cmd/readmmap/.gitignore delete mode 100644 tests/zfs-tests/cmd/readmmap/Makefile.am rename tests/zfs-tests/cmd/{rename_dir => }/rename_dir.c (100%) delete mode 100644 tests/zfs-tests/cmd/rename_dir/.gitignore delete mode 100644 tests/zfs-tests/cmd/rename_dir/Makefile.am rename tests/zfs-tests/cmd/{rm_lnkcnt_zero_file => }/rm_lnkcnt_zero_file.c (100%) delete mode 100644 tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore delete mode 100644 tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am rename tests/zfs-tests/cmd/{send_doall => }/send_doall.c (100%) delete mode 100644 tests/zfs-tests/cmd/send_doall/.gitignore delete mode 100644 tests/zfs-tests/cmd/send_doall/Makefile.am rename tests/zfs-tests/cmd/{stride_dd => }/stride_dd.c (100%) delete mode 100644 tests/zfs-tests/cmd/stride_dd/.gitignore delete mode 100644 tests/zfs-tests/cmd/stride_dd/Makefile.am rename tests/zfs-tests/cmd/{threadsappend => }/threadsappend.c (100%) delete mode 100644 tests/zfs-tests/cmd/threadsappend/.gitignore delete mode 100644 tests/zfs-tests/cmd/threadsappend/Makefile.am rename tests/zfs-tests/cmd/{user_ns_exec => }/user_ns_exec.c (100%) delete mode 100644 tests/zfs-tests/cmd/user_ns_exec/.gitignore delete mode 100644 tests/zfs-tests/cmd/user_ns_exec/Makefile.am rename tests/zfs-tests/cmd/{xattrtest => }/xattrtest.c (100%) delete mode 100644 tests/zfs-tests/cmd/xattrtest/.gitignore delete mode 100644 tests/zfs-tests/cmd/xattrtest/Makefile.am diff --git a/configure.ac b/configure.ac index 04fbb491adbb..380b97d62460 100644 --- a/configure.ac +++ b/configure.ac @@ -201,39 +201,6 @@ AC_CONFIG_FILES([ tests/zfs-tests/Makefile tests/zfs-tests/callbacks/Makefile tests/zfs-tests/cmd/Makefile - tests/zfs-tests/cmd/badsend/Makefile - tests/zfs-tests/cmd/btree_test/Makefile - tests/zfs-tests/cmd/chg_usr_exec/Makefile - tests/zfs-tests/cmd/devname2devid/Makefile - tests/zfs-tests/cmd/draid/Makefile - tests/zfs-tests/cmd/dir_rd_update/Makefile - tests/zfs-tests/cmd/file_check/Makefile - tests/zfs-tests/cmd/file_trunc/Makefile - tests/zfs-tests/cmd/file_write/Makefile - tests/zfs-tests/cmd/get_diff/Makefile - tests/zfs-tests/cmd/getversion/Makefile - tests/zfs-tests/cmd/largest_file/Makefile - tests/zfs-tests/cmd/libzfs_input_check/Makefile - tests/zfs-tests/cmd/mkbusy/Makefile - tests/zfs-tests/cmd/mkfile/Makefile - tests/zfs-tests/cmd/mkfiles/Makefile - tests/zfs-tests/cmd/mktree/Makefile - tests/zfs-tests/cmd/mmap_exec/Makefile - tests/zfs-tests/cmd/mmap_libaio/Makefile - tests/zfs-tests/cmd/mmap_seek/Makefile - tests/zfs-tests/cmd/mmapwrite/Makefile - tests/zfs-tests/cmd/nvlist_to_lua/Makefile - tests/zfs-tests/cmd/randfree_file/Makefile - tests/zfs-tests/cmd/randwritecomp/Makefile - tests/zfs-tests/cmd/readmmap/Makefile - tests/zfs-tests/cmd/linux_dos_attributes/Makefile - tests/zfs-tests/cmd/rename_dir/Makefile - tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile - tests/zfs-tests/cmd/send_doall/Makefile - tests/zfs-tests/cmd/stride_dd/Makefile - tests/zfs-tests/cmd/threadsappend/Makefile - tests/zfs-tests/cmd/user_ns_exec/Makefile - tests/zfs-tests/cmd/xattrtest/Makefile tests/zfs-tests/include/Makefile tests/zfs-tests/tests/Makefile tests/zfs-tests/tests/functional/Makefile diff --git a/tests/zfs-tests/cmd/.gitignore b/tests/zfs-tests/cmd/.gitignore new file mode 100644 index 000000000000..ea4d2613c578 --- /dev/null +++ b/tests/zfs-tests/cmd/.gitignore @@ -0,0 +1,34 @@ +/badsend +/btree_test +/chg_usr_exec +/devname2devid +/dir_rd_update +/draid +/file_check +/file_trunc +/file_write +/get_diff +/getversion +/largest_file +/libzfs_input_check +/mkbusy +/mkfile +/mkfiles +/mktree +/mmap_exec +/mmap_libaio +/mmap_seek +/mmapwrite +/nvlist_to_lua +/randfree_file +/randwritecomp +/read_dos_attributes +/readmmap +/rename_dir +/rm_lnkcnt_zero_file +/send_doall +/stride_dd +/threadsappend +/user_ns_exec +/write_dos_attributes +/xattrtest diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index fb49edd3a543..ca3befb277c0 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -1,40 +1,145 @@ -EXTRA_DIST = file_common.h - -SUBDIRS = \ - badsend \ - btree_test \ - chg_usr_exec \ - devname2devid \ - dir_rd_update \ - draid \ - file_check \ - file_trunc \ - file_write \ - get_diff \ - largest_file \ - libzfs_input_check \ - mkbusy \ - mkfile \ - mkfiles \ - mktree \ - mmap_exec \ - mmap_libaio \ - mmap_seek \ - mmapwrite \ - nvlist_to_lua \ - randwritecomp \ - readmmap \ - rename_dir \ - rm_lnkcnt_zero_file \ - send_doall \ - stride_dd \ - threadsappend +include $(top_srcdir)/config/Rules.am +pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin + + +pkgexec_PROGRAMS = badsend +badsend_SOURCES = badsend.c +badsend_LDADD = \ + $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(abs_top_builddir)/lib/libzfs/libzfs.la \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la + + +pkgexec_PROGRAMS += btree_test +btree_test_SOURCES = btree_test.c +# Unconditionally enable ASSERTs +btree_test_CPPFLAGS = $(AM_CPPFLAGS) -DDEBUG -UNDEBUG -DZFS_DEBUG +btree_test_LDADD = \ + $(abs_top_builddir)/lib/libzpool/libzpool.la \ + $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la + + +pkgexec_PROGRAMS += chg_usr_exec +chg_usr_exec_SOURCES = chg_usr_exec.c + + +if WANT_DEVNAME2DEVID +pkgexec_PROGRAMS += devname2devid +devname2devid_SOURCES = devname2devid.c +devname2devid_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) +devname2devid_LDADD = $(LIBUDEV_LIBS) +endif + + +pkgexec_PROGRAMS += dir_rd_update +dir_rd_update_SOURCES = dir_rd_update.c + + +pkgexec_PROGRAMS += draid +draid_CFLAGS = $(AM_CFLAGS) $(ZLIB_CFLAGS) +draid_SOURCES = draid.c +draid_LDADD = \ + $(abs_top_builddir)/lib/libzpool/libzpool.la \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la +draid_LDADD += $(ZLIB_LIBS) + + +EXTRA_DIST = file/file_common.h +pkgexec_PROGRAMS += file_check file_trunc file_write largest_file randwritecomp +file_check_SOURCES = file/file_check.c +file_trunc_SOURCES = file/file_trunc.c +file_write_SOURCES = file/file_write.c +largest_file_SOURCES = file/largest_file.c +randwritecomp_SOURCES = file/randwritecomp.c + + +pkgexec_PROGRAMS += get_diff +get_diff_SOURCES = get_diff.c + + +pkgexec_PROGRAMS += libzfs_input_check +libzfs_input_check_SOURCES = libzfs_input_check.c +if BUILD_FREEBSD +libzfs_input_check_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include/os/freebsd/zfs +endif if BUILD_LINUX -SUBDIRS += \ - getversion \ - randfree_file \ - linux_dos_attributes \ - user_ns_exec \ - xattrtest +libzfs_input_check_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/include/os/linux/zfs +endif +libzfs_input_check_LDADD = \ + $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la + + + +pkgexec_PROGRAMS += mkbusy mkfile mkfiles mktree +mkbusy_SOURCES = mkbusy.c +mkfile_SOURCES = mkfile.c +mkfile_LDADD = $(LTLIBINTL) +mkfiles_SOURCES = mkfiles.c +mktree_SOURCES = mktree.c + + +pkgexec_PROGRAMS += mmap_exec mmap_seek mmapwrite readmmap +mmap_exec_SOURCES = mmap_exec.c +mmap_seek_SOURCES = mmap_seek.c +mmapwrite_SOURCES = mmapwrite.c +mmapwrite_LDADD = -lpthread +readmmap_SOURCES = readmmap.c + +if WANT_MMAP_LIBAIO +pkgexec_PROGRAMS += mmap_libaio +mmap_libaio_SOURCES = mmap_libaio.c +mmap_libaio_CFLAGS = $(AM_CFLAGS) $(LIBAIO_CFLAGS) +mmap_libaio_LDADD = $(LIBAIO_LIBS) +endif + + +pkgexec_PROGRAMS += nvlist_to_lua +nvlist_to_lua_SOURCES = nvlist_to_lua.c +nvlist_to_lua_LDADD = \ + $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la + + +pkgexec_PROGRAMS += rename_dir +rename_dir_SOURCES = rename_dir.c + +pkgexec_PROGRAMS += rm_lnkcnt_zero_file +rm_lnkcnt_zero_file_SOURCES = rm_lnkcnt_zero_file.c +rm_lnkcnt_zero_file_LDADD = -lpthread + +pkgexec_PROGRAMS += send_doall +send_doall_SOURCES = send_doall.c +send_doall_LDADD = \ + $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(abs_top_builddir)/lib/libzfs/libzfs.la \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la + +pkgexec_PROGRAMS += stride_dd +stride_dd_SOURCES = stride_dd.c +stride_dd_LDADD = -lrt + +pkgexec_PROGRAMS += threadsappend +threadsappend_SOURCES = threadsappend.c +threadsappend_LDADD = -lpthread + + +if BUILD_LINUX +pkgexec_PROGRAMS += getversion +getversion_SOURCES = getversion.c + +EXTRA_DIST += linux_dos_attributes/dos_attributes.h +pkgexec_PROGRAMS += read_dos_attributes write_dos_attributes +read_dos_attributes_SOURCES = linux_dos_attributes/read_dos_attributes.c +write_dos_attributes_SOURCES = linux_dos_attributes/write_dos_attributes.c + +pkgexec_PROGRAMS += randfree_file +randfree_file_SOURCES = file/randfree_file.c + +pkgexec_PROGRAMS += user_ns_exec +user_ns_exec_SOURCES = user_ns_exec.c + +pkgexec_PROGRAMS += xattrtest +xattrtest_SOURCES = xattrtest.c endif diff --git a/tests/zfs-tests/cmd/badsend/badsend.c b/tests/zfs-tests/cmd/badsend.c similarity index 100% rename from tests/zfs-tests/cmd/badsend/badsend.c rename to tests/zfs-tests/cmd/badsend.c diff --git a/tests/zfs-tests/cmd/badsend/.gitignore b/tests/zfs-tests/cmd/badsend/.gitignore deleted file mode 100644 index d2efa627aa29..000000000000 --- a/tests/zfs-tests/cmd/badsend/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/badsend diff --git a/tests/zfs-tests/cmd/badsend/Makefile.am b/tests/zfs-tests/cmd/badsend/Makefile.am deleted file mode 100644 index 5a8946f0d4bf..000000000000 --- a/tests/zfs-tests/cmd/badsend/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = badsend - -badsend_SOURCES = badsend.c -badsend_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/tests/zfs-tests/cmd/btree_test/btree_test.c b/tests/zfs-tests/cmd/btree_test.c similarity index 100% rename from tests/zfs-tests/cmd/btree_test/btree_test.c rename to tests/zfs-tests/cmd/btree_test.c diff --git a/tests/zfs-tests/cmd/btree_test/.gitignore b/tests/zfs-tests/cmd/btree_test/.gitignore deleted file mode 100644 index 73777c4c1f4b..000000000000 --- a/tests/zfs-tests/cmd/btree_test/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/btree_test diff --git a/tests/zfs-tests/cmd/btree_test/Makefile.am b/tests/zfs-tests/cmd/btree_test/Makefile.am deleted file mode 100644 index 4c9a1a4cc296..000000000000 --- a/tests/zfs-tests/cmd/btree_test/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2019 by Delphix. All rights reserved. -# - -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/lib/libspl/include - -# Unconditionally enable ASSERTs -AM_CPPFLAGS += -DDEBUG -UNDEBUG -DZFS_DEBUG - -pkgexec_PROGRAMS = btree_test -btree_test_SOURCES = btree_test.c - -btree_test_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la diff --git a/tests/zfs-tests/cmd/chg_usr_exec/chg_usr_exec.c b/tests/zfs-tests/cmd/chg_usr_exec.c similarity index 100% rename from tests/zfs-tests/cmd/chg_usr_exec/chg_usr_exec.c rename to tests/zfs-tests/cmd/chg_usr_exec.c diff --git a/tests/zfs-tests/cmd/chg_usr_exec/.gitignore b/tests/zfs-tests/cmd/chg_usr_exec/.gitignore deleted file mode 100644 index a8b44df7c5bf..000000000000 --- a/tests/zfs-tests/cmd/chg_usr_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/chg_usr_exec diff --git a/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am b/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am deleted file mode 100644 index 6f2968f1fac4..000000000000 --- a/tests/zfs-tests/cmd/chg_usr_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = chg_usr_exec -chg_usr_exec_SOURCES = chg_usr_exec.c diff --git a/tests/zfs-tests/cmd/devname2devid/devname2devid.c b/tests/zfs-tests/cmd/devname2devid.c similarity index 100% rename from tests/zfs-tests/cmd/devname2devid/devname2devid.c rename to tests/zfs-tests/cmd/devname2devid.c diff --git a/tests/zfs-tests/cmd/devname2devid/.gitignore b/tests/zfs-tests/cmd/devname2devid/.gitignore deleted file mode 100644 index fa9fb6c509a7..000000000000 --- a/tests/zfs-tests/cmd/devname2devid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/devname2devid diff --git a/tests/zfs-tests/cmd/devname2devid/Makefile.am b/tests/zfs-tests/cmd/devname2devid/Makefile.am deleted file mode 100644 index b8b630dc2dd4..000000000000 --- a/tests/zfs-tests/cmd/devname2devid/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -if WANT_DEVNAME2DEVID -pkgexec_PROGRAMS = devname2devid -devname2devid_SOURCES = devname2devid.c -devname2devid_CFLAGS = $(AM_CFLAGS) $(LIBUDEV_CFLAGS) -devname2devid_LDADD = $(LIBUDEV_LIBS) -endif diff --git a/tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c b/tests/zfs-tests/cmd/dir_rd_update.c similarity index 100% rename from tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c rename to tests/zfs-tests/cmd/dir_rd_update.c diff --git a/tests/zfs-tests/cmd/dir_rd_update/.gitignore b/tests/zfs-tests/cmd/dir_rd_update/.gitignore deleted file mode 100644 index ec9a15f17a1d..000000000000 --- a/tests/zfs-tests/cmd/dir_rd_update/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/dir_rd_update diff --git a/tests/zfs-tests/cmd/dir_rd_update/Makefile.am b/tests/zfs-tests/cmd/dir_rd_update/Makefile.am deleted file mode 100644 index 27cc9e97e0e9..000000000000 --- a/tests/zfs-tests/cmd/dir_rd_update/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = dir_rd_update -dir_rd_update_SOURCES = dir_rd_update.c diff --git a/tests/zfs-tests/cmd/draid/draid.c b/tests/zfs-tests/cmd/draid.c similarity index 100% rename from tests/zfs-tests/cmd/draid/draid.c rename to tests/zfs-tests/cmd/draid.c diff --git a/tests/zfs-tests/cmd/draid/.gitignore b/tests/zfs-tests/cmd/draid/.gitignore deleted file mode 100644 index 911b9f07785a..000000000000 --- a/tests/zfs-tests/cmd/draid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/draid diff --git a/tests/zfs-tests/cmd/draid/Makefile.am b/tests/zfs-tests/cmd/draid/Makefile.am deleted file mode 100644 index 69fed7a6bea4..000000000000 --- a/tests/zfs-tests/cmd/draid/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -AM_CFLAGS += $(ZLIB_CFLAGS) - -pkgexec_PROGRAMS = draid - -draid_SOURCES = draid.c - -draid_LDADD = \ - $(abs_top_builddir)/lib/libzpool/libzpool.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la - -draid_LDADD += $(ZLIB_LIBS) diff --git a/tests/zfs-tests/cmd/file_check/file_check.c b/tests/zfs-tests/cmd/file/file_check.c similarity index 98% rename from tests/zfs-tests/cmd/file_check/file_check.c rename to tests/zfs-tests/cmd/file/file_check.c index 3d3db753f3d7..c93b56f45bba 100644 --- a/tests/zfs-tests/cmd/file_check/file_check.c +++ b/tests/zfs-tests/cmd/file/file_check.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#include "../file_common.h" +#include "file_common.h" static unsigned char bigbuffer[BIGBUFFERSIZE]; diff --git a/tests/zfs-tests/cmd/file_common.h b/tests/zfs-tests/cmd/file/file_common.h similarity index 100% rename from tests/zfs-tests/cmd/file_common.h rename to tests/zfs-tests/cmd/file/file_common.h diff --git a/tests/zfs-tests/cmd/file_trunc/file_trunc.c b/tests/zfs-tests/cmd/file/file_trunc.c similarity index 100% rename from tests/zfs-tests/cmd/file_trunc/file_trunc.c rename to tests/zfs-tests/cmd/file/file_trunc.c diff --git a/tests/zfs-tests/cmd/file_write/file_write.c b/tests/zfs-tests/cmd/file/file_write.c similarity index 99% rename from tests/zfs-tests/cmd/file_write/file_write.c rename to tests/zfs-tests/cmd/file/file_write.c index 60893c34fbc9..61101b7b0653 100644 --- a/tests/zfs-tests/cmd/file_write/file_write.c +++ b/tests/zfs-tests/cmd/file/file_write.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include diff --git a/tests/zfs-tests/cmd/largest_file/largest_file.c b/tests/zfs-tests/cmd/file/largest_file.c similarity index 99% rename from tests/zfs-tests/cmd/largest_file/largest_file.c rename to tests/zfs-tests/cmd/file/largest_file.c index 912607640965..5acb5f1db87d 100644 --- a/tests/zfs-tests/cmd/largest_file/largest_file.c +++ b/tests/zfs-tests/cmd/file/largest_file.c @@ -28,7 +28,7 @@ * Copyright (c) 2012 by Delphix. All rights reserved. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include diff --git a/tests/zfs-tests/cmd/randfree_file/randfree_file.c b/tests/zfs-tests/cmd/file/randfree_file.c similarity index 99% rename from tests/zfs-tests/cmd/randfree_file/randfree_file.c rename to tests/zfs-tests/cmd/file/randfree_file.c index c708d647e8b9..e00780cd2e81 100644 --- a/tests/zfs-tests/cmd/randfree_file/randfree_file.c +++ b/tests/zfs-tests/cmd/file/randfree_file.c @@ -28,7 +28,7 @@ * Copyright (c) 2012 by Delphix. All rights reserved. */ -#include "../file_common.h" +#include "file_common.h" #include #include #include diff --git a/tests/zfs-tests/cmd/randwritecomp/randwritecomp.c b/tests/zfs-tests/cmd/file/randwritecomp.c similarity index 99% rename from tests/zfs-tests/cmd/randwritecomp/randwritecomp.c rename to tests/zfs-tests/cmd/file/randwritecomp.c index 3cff7fd0a01e..cc70d1212f84 100644 --- a/tests/zfs-tests/cmd/randwritecomp/randwritecomp.c +++ b/tests/zfs-tests/cmd/file/randwritecomp.c @@ -15,7 +15,7 @@ #include #include -#include "../file_common.h" +#include "file_common.h" /* * The following sample was derived from real-world data diff --git a/tests/zfs-tests/cmd/file_check/.gitignore b/tests/zfs-tests/cmd/file_check/.gitignore deleted file mode 100644 index 24fe113221d2..000000000000 --- a/tests/zfs-tests/cmd/file_check/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_check diff --git a/tests/zfs-tests/cmd/file_check/Makefile.am b/tests/zfs-tests/cmd/file_check/Makefile.am deleted file mode 100644 index 13027ef5bd02..000000000000 --- a/tests/zfs-tests/cmd/file_check/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_check -file_check_SOURCES = file_check.c diff --git a/tests/zfs-tests/cmd/file_trunc/.gitignore b/tests/zfs-tests/cmd/file_trunc/.gitignore deleted file mode 100644 index 90b149ff51c3..000000000000 --- a/tests/zfs-tests/cmd/file_trunc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_trunc diff --git a/tests/zfs-tests/cmd/file_trunc/Makefile.am b/tests/zfs-tests/cmd/file_trunc/Makefile.am deleted file mode 100644 index 0455eb4a4633..000000000000 --- a/tests/zfs-tests/cmd/file_trunc/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_trunc -file_trunc_SOURCES = file_trunc.c diff --git a/tests/zfs-tests/cmd/file_write/.gitignore b/tests/zfs-tests/cmd/file_write/.gitignore deleted file mode 100644 index 9f691d580a57..000000000000 --- a/tests/zfs-tests/cmd/file_write/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_write diff --git a/tests/zfs-tests/cmd/file_write/Makefile.am b/tests/zfs-tests/cmd/file_write/Makefile.am deleted file mode 100644 index 60895711e7dc..000000000000 --- a/tests/zfs-tests/cmd/file_write/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = file_write -file_write_SOURCES = file_write.c diff --git a/tests/zfs-tests/cmd/get_diff/get_diff.c b/tests/zfs-tests/cmd/get_diff.c similarity index 100% rename from tests/zfs-tests/cmd/get_diff/get_diff.c rename to tests/zfs-tests/cmd/get_diff.c diff --git a/tests/zfs-tests/cmd/get_diff/.gitignore b/tests/zfs-tests/cmd/get_diff/.gitignore deleted file mode 100644 index f5fc360a6839..000000000000 --- a/tests/zfs-tests/cmd/get_diff/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/get_diff diff --git a/tests/zfs-tests/cmd/get_diff/Makefile.am b/tests/zfs-tests/cmd/get_diff/Makefile.am deleted file mode 100644 index 06c39ddd81ce..000000000000 --- a/tests/zfs-tests/cmd/get_diff/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = get_diff -get_diff_SOURCES = get_diff.c diff --git a/tests/zfs-tests/cmd/getversion/getversion.c b/tests/zfs-tests/cmd/getversion.c similarity index 100% rename from tests/zfs-tests/cmd/getversion/getversion.c rename to tests/zfs-tests/cmd/getversion.c diff --git a/tests/zfs-tests/cmd/getversion/.gitignore b/tests/zfs-tests/cmd/getversion/.gitignore deleted file mode 100644 index b347c417aa13..000000000000 --- a/tests/zfs-tests/cmd/getversion/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/getversion diff --git a/tests/zfs-tests/cmd/getversion/Makefile.am b/tests/zfs-tests/cmd/getversion/Makefile.am deleted file mode 100644 index d6b5e84082b2..000000000000 --- a/tests/zfs-tests/cmd/getversion/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = getversion -getversion_SOURCES = getversion.c diff --git a/tests/zfs-tests/cmd/largest_file/.gitignore b/tests/zfs-tests/cmd/largest_file/.gitignore deleted file mode 100644 index f8f480d06542..000000000000 --- a/tests/zfs-tests/cmd/largest_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/largest_file diff --git a/tests/zfs-tests/cmd/largest_file/Makefile.am b/tests/zfs-tests/cmd/largest_file/Makefile.am deleted file mode 100644 index a3e4e9337cf0..000000000000 --- a/tests/zfs-tests/cmd/largest_file/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = largest_file -largest_file_SOURCES = largest_file.c diff --git a/tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c b/tests/zfs-tests/cmd/libzfs_input_check.c similarity index 100% rename from tests/zfs-tests/cmd/libzfs_input_check/libzfs_input_check.c rename to tests/zfs-tests/cmd/libzfs_input_check.c diff --git a/tests/zfs-tests/cmd/libzfs_input_check/.gitignore b/tests/zfs-tests/cmd/libzfs_input_check/.gitignore deleted file mode 100644 index c8796008483f..000000000000 --- a/tests/zfs-tests/cmd/libzfs_input_check/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/libzfs_input_check diff --git a/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am b/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am deleted file mode 100644 index cd462208957c..000000000000 --- a/tests/zfs-tests/cmd/libzfs_input_check/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = libzfs_input_check - -if BUILD_FREEBSD -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/freebsd/zfs -endif -if BUILD_LINUX -DEFAULT_INCLUDES += -I$(top_srcdir)/include/os/linux/zfs -endif - -libzfs_input_check_SOURCES = libzfs_input_check.c -libzfs_input_check_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/tests/zfs-tests/cmd/linux_dos_attributes/.gitignore b/tests/zfs-tests/cmd/linux_dos_attributes/.gitignore deleted file mode 100644 index 14a62551da93..000000000000 --- a/tests/zfs-tests/cmd/linux_dos_attributes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/read_dos_attributes -/write_dos_attributes diff --git a/tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am b/tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am deleted file mode 100644 index 2e383e94f200..000000000000 --- a/tests/zfs-tests/cmd/linux_dos_attributes/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -EXTRA_DIST = dos_attributes.h -pkgexec_PROGRAMS = read_dos_attributes write_dos_attributes -read_dos_attributes_SOURCES = read_dos_attributes.c -write_dos_attributes_SOURCES = write_dos_attributes.c diff --git a/tests/zfs-tests/cmd/mkbusy/mkbusy.c b/tests/zfs-tests/cmd/mkbusy.c similarity index 100% rename from tests/zfs-tests/cmd/mkbusy/mkbusy.c rename to tests/zfs-tests/cmd/mkbusy.c diff --git a/tests/zfs-tests/cmd/mkbusy/.gitignore b/tests/zfs-tests/cmd/mkbusy/.gitignore deleted file mode 100644 index 18d099c08eec..000000000000 --- a/tests/zfs-tests/cmd/mkbusy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkbusy diff --git a/tests/zfs-tests/cmd/mkbusy/Makefile.am b/tests/zfs-tests/cmd/mkbusy/Makefile.am deleted file mode 100644 index abae69dea8c7..000000000000 --- a/tests/zfs-tests/cmd/mkbusy/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkbusy -mkbusy_SOURCES = mkbusy.c diff --git a/tests/zfs-tests/cmd/mkfile/mkfile.c b/tests/zfs-tests/cmd/mkfile.c similarity index 100% rename from tests/zfs-tests/cmd/mkfile/mkfile.c rename to tests/zfs-tests/cmd/mkfile.c diff --git a/tests/zfs-tests/cmd/mkfile/.gitignore b/tests/zfs-tests/cmd/mkfile/.gitignore deleted file mode 100644 index 93e9a8a6ded4..000000000000 --- a/tests/zfs-tests/cmd/mkfile/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkfile diff --git a/tests/zfs-tests/cmd/mkfile/Makefile.am b/tests/zfs-tests/cmd/mkfile/Makefile.am deleted file mode 100644 index 5f0e2e03efd9..000000000000 --- a/tests/zfs-tests/cmd/mkfile/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkfile -mkfile_SOURCES = mkfile.c - -mkfile_LDADD = $(LTLIBINTL) diff --git a/tests/zfs-tests/cmd/mkfiles/mkfiles.c b/tests/zfs-tests/cmd/mkfiles.c similarity index 100% rename from tests/zfs-tests/cmd/mkfiles/mkfiles.c rename to tests/zfs-tests/cmd/mkfiles.c diff --git a/tests/zfs-tests/cmd/mkfiles/.gitignore b/tests/zfs-tests/cmd/mkfiles/.gitignore deleted file mode 100644 index cee4858b701b..000000000000 --- a/tests/zfs-tests/cmd/mkfiles/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mkfiles diff --git a/tests/zfs-tests/cmd/mkfiles/Makefile.am b/tests/zfs-tests/cmd/mkfiles/Makefile.am deleted file mode 100644 index 54c21597f3eb..000000000000 --- a/tests/zfs-tests/cmd/mkfiles/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mkfiles -mkfiles_SOURCES = mkfiles.c diff --git a/tests/zfs-tests/cmd/mktree/mktree.c b/tests/zfs-tests/cmd/mktree.c similarity index 100% rename from tests/zfs-tests/cmd/mktree/mktree.c rename to tests/zfs-tests/cmd/mktree.c diff --git a/tests/zfs-tests/cmd/mktree/.gitignore b/tests/zfs-tests/cmd/mktree/.gitignore deleted file mode 100644 index 588bc6d1cce6..000000000000 --- a/tests/zfs-tests/cmd/mktree/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mktree diff --git a/tests/zfs-tests/cmd/mktree/Makefile.am b/tests/zfs-tests/cmd/mktree/Makefile.am deleted file mode 100644 index 88c74ae0a346..000000000000 --- a/tests/zfs-tests/cmd/mktree/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mktree -mktree_SOURCES = mktree.c diff --git a/tests/zfs-tests/cmd/mmap_exec/mmap_exec.c b/tests/zfs-tests/cmd/mmap_exec.c similarity index 100% rename from tests/zfs-tests/cmd/mmap_exec/mmap_exec.c rename to tests/zfs-tests/cmd/mmap_exec.c diff --git a/tests/zfs-tests/cmd/mmap_exec/.gitignore b/tests/zfs-tests/cmd/mmap_exec/.gitignore deleted file mode 100644 index 63a68bbc681e..000000000000 --- a/tests/zfs-tests/cmd/mmap_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_exec diff --git a/tests/zfs-tests/cmd/mmap_exec/Makefile.am b/tests/zfs-tests/cmd/mmap_exec/Makefile.am deleted file mode 100644 index ab9f81be9463..000000000000 --- a/tests/zfs-tests/cmd/mmap_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mmap_exec -mmap_exec_SOURCES = mmap_exec.c diff --git a/tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c b/tests/zfs-tests/cmd/mmap_libaio.c similarity index 100% rename from tests/zfs-tests/cmd/mmap_libaio/mmap_libaio.c rename to tests/zfs-tests/cmd/mmap_libaio.c diff --git a/tests/zfs-tests/cmd/mmap_libaio/.gitignore b/tests/zfs-tests/cmd/mmap_libaio/.gitignore deleted file mode 100644 index 792c8d3400b0..000000000000 --- a/tests/zfs-tests/cmd/mmap_libaio/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_libaio diff --git a/tests/zfs-tests/cmd/mmap_libaio/Makefile.am b/tests/zfs-tests/cmd/mmap_libaio/Makefile.am deleted file mode 100644 index 25f9dda2b623..000000000000 --- a/tests/zfs-tests/cmd/mmap_libaio/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -if WANT_MMAP_LIBAIO -pkgexec_PROGRAMS = mmap_libaio -mmap_libaio_SOURCES = mmap_libaio.c -mmap_libaio_CFLAGS = $(AM_CFLAGS) $(LIBAIO_CFLAGS) -mmap_libaio_LDADD = $(LIBAIO_LIBS) -endif diff --git a/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c b/tests/zfs-tests/cmd/mmap_seek.c similarity index 100% rename from tests/zfs-tests/cmd/mmap_seek/mmap_seek.c rename to tests/zfs-tests/cmd/mmap_seek.c diff --git a/tests/zfs-tests/cmd/mmap_seek/.gitignore b/tests/zfs-tests/cmd/mmap_seek/.gitignore deleted file mode 100644 index 6b05a7917500..000000000000 --- a/tests/zfs-tests/cmd/mmap_seek/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmap_seek diff --git a/tests/zfs-tests/cmd/mmap_seek/Makefile.am b/tests/zfs-tests/cmd/mmap_seek/Makefile.am deleted file mode 100644 index b938931125f5..000000000000 --- a/tests/zfs-tests/cmd/mmap_seek/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mmap_seek -mmap_seek_SOURCES = mmap_seek.c diff --git a/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c b/tests/zfs-tests/cmd/mmapwrite.c similarity index 100% rename from tests/zfs-tests/cmd/mmapwrite/mmapwrite.c rename to tests/zfs-tests/cmd/mmapwrite.c diff --git a/tests/zfs-tests/cmd/mmapwrite/.gitignore b/tests/zfs-tests/cmd/mmapwrite/.gitignore deleted file mode 100644 index 4e7043bbfd58..000000000000 --- a/tests/zfs-tests/cmd/mmapwrite/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/mmapwrite diff --git a/tests/zfs-tests/cmd/mmapwrite/Makefile.am b/tests/zfs-tests/cmd/mmapwrite/Makefile.am deleted file mode 100644 index b21b9e779bf2..000000000000 --- a/tests/zfs-tests/cmd/mmapwrite/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = mmapwrite -mmapwrite_SOURCES = mmapwrite.c -mmapwrite_LDADD = -lpthread diff --git a/tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c b/tests/zfs-tests/cmd/nvlist_to_lua.c similarity index 100% rename from tests/zfs-tests/cmd/nvlist_to_lua/nvlist_to_lua.c rename to tests/zfs-tests/cmd/nvlist_to_lua.c diff --git a/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore b/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore deleted file mode 100644 index b31db6454dce..000000000000 --- a/tests/zfs-tests/cmd/nvlist_to_lua/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/nvlist_to_lua diff --git a/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am b/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am deleted file mode 100644 index 511b6c6913bb..000000000000 --- a/tests/zfs-tests/cmd/nvlist_to_lua/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = nvlist_to_lua - -nvlist_to_lua_SOURCES = nvlist_to_lua.c -nvlist_to_lua_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/tests/zfs-tests/cmd/randfree_file/.gitignore b/tests/zfs-tests/cmd/randfree_file/.gitignore deleted file mode 100644 index 0f5b394c5fbd..000000000000 --- a/tests/zfs-tests/cmd/randfree_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/randfree_file diff --git a/tests/zfs-tests/cmd/randfree_file/Makefile.am b/tests/zfs-tests/cmd/randfree_file/Makefile.am deleted file mode 100644 index 6306e0e75740..000000000000 --- a/tests/zfs-tests/cmd/randfree_file/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = randfree_file -randfree_file_SOURCES = randfree_file.c diff --git a/tests/zfs-tests/cmd/randwritecomp/.gitignore b/tests/zfs-tests/cmd/randwritecomp/.gitignore deleted file mode 100644 index fb231c678cb2..000000000000 --- a/tests/zfs-tests/cmd/randwritecomp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/randwritecomp diff --git a/tests/zfs-tests/cmd/randwritecomp/Makefile.am b/tests/zfs-tests/cmd/randwritecomp/Makefile.am deleted file mode 100644 index 0002291fa7bf..000000000000 --- a/tests/zfs-tests/cmd/randwritecomp/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -DEFAULT_INCLUDES += \ - -I$(top_srcdir)/include - -pkgexec_PROGRAMS = randwritecomp -randwritecomp_SOURCES = randwritecomp.c diff --git a/tests/zfs-tests/cmd/readmmap/readmmap.c b/tests/zfs-tests/cmd/readmmap.c similarity index 100% rename from tests/zfs-tests/cmd/readmmap/readmmap.c rename to tests/zfs-tests/cmd/readmmap.c diff --git a/tests/zfs-tests/cmd/readmmap/.gitignore b/tests/zfs-tests/cmd/readmmap/.gitignore deleted file mode 100644 index 3799193a92be..000000000000 --- a/tests/zfs-tests/cmd/readmmap/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/readmmap diff --git a/tests/zfs-tests/cmd/readmmap/Makefile.am b/tests/zfs-tests/cmd/readmmap/Makefile.am deleted file mode 100644 index 9b735c287e69..000000000000 --- a/tests/zfs-tests/cmd/readmmap/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = readmmap -readmmap_SOURCES = readmmap.c diff --git a/tests/zfs-tests/cmd/rename_dir/rename_dir.c b/tests/zfs-tests/cmd/rename_dir.c similarity index 100% rename from tests/zfs-tests/cmd/rename_dir/rename_dir.c rename to tests/zfs-tests/cmd/rename_dir.c diff --git a/tests/zfs-tests/cmd/rename_dir/.gitignore b/tests/zfs-tests/cmd/rename_dir/.gitignore deleted file mode 100644 index 39a0cb222ad1..000000000000 --- a/tests/zfs-tests/cmd/rename_dir/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/rename_dir diff --git a/tests/zfs-tests/cmd/rename_dir/Makefile.am b/tests/zfs-tests/cmd/rename_dir/Makefile.am deleted file mode 100644 index 21971cd888fb..000000000000 --- a/tests/zfs-tests/cmd/rename_dir/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = rename_dir -rename_dir_SOURCES = rename_dir.c diff --git a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file.c similarity index 100% rename from tests/zfs-tests/cmd/rm_lnkcnt_zero_file/rm_lnkcnt_zero_file.c rename to tests/zfs-tests/cmd/rm_lnkcnt_zero_file.c diff --git a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore deleted file mode 100644 index fc6323fb3ff3..000000000000 --- a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/rm_lnkcnt_zero_file diff --git a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am b/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am deleted file mode 100644 index 90fc8d0541b6..000000000000 --- a/tests/zfs-tests/cmd/rm_lnkcnt_zero_file/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = rm_lnkcnt_zero_file -rm_lnkcnt_zero_file_SOURCES = rm_lnkcnt_zero_file.c -rm_lnkcnt_zero_file_LDADD = -lpthread diff --git a/tests/zfs-tests/cmd/send_doall/send_doall.c b/tests/zfs-tests/cmd/send_doall.c similarity index 100% rename from tests/zfs-tests/cmd/send_doall/send_doall.c rename to tests/zfs-tests/cmd/send_doall.c diff --git a/tests/zfs-tests/cmd/send_doall/.gitignore b/tests/zfs-tests/cmd/send_doall/.gitignore deleted file mode 100644 index 6ba2e603f744..000000000000 --- a/tests/zfs-tests/cmd/send_doall/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/send_doall diff --git a/tests/zfs-tests/cmd/send_doall/Makefile.am b/tests/zfs-tests/cmd/send_doall/Makefile.am deleted file mode 100644 index 33a6b83122b8..000000000000 --- a/tests/zfs-tests/cmd/send_doall/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = send_doall - -send_doall_SOURCES = send_doall.c -send_doall_LDADD = \ - $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la diff --git a/tests/zfs-tests/cmd/stride_dd/stride_dd.c b/tests/zfs-tests/cmd/stride_dd.c similarity index 100% rename from tests/zfs-tests/cmd/stride_dd/stride_dd.c rename to tests/zfs-tests/cmd/stride_dd.c diff --git a/tests/zfs-tests/cmd/stride_dd/.gitignore b/tests/zfs-tests/cmd/stride_dd/.gitignore deleted file mode 100644 index 7c072ee0dec6..000000000000 --- a/tests/zfs-tests/cmd/stride_dd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/stride_dd diff --git a/tests/zfs-tests/cmd/stride_dd/Makefile.am b/tests/zfs-tests/cmd/stride_dd/Makefile.am deleted file mode 100644 index d6f1adbac2b7..000000000000 --- a/tests/zfs-tests/cmd/stride_dd/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = stride_dd -stride_dd_SOURCES = stride_dd.c -stride_dd_LDADD = -lrt diff --git a/tests/zfs-tests/cmd/threadsappend/threadsappend.c b/tests/zfs-tests/cmd/threadsappend.c similarity index 100% rename from tests/zfs-tests/cmd/threadsappend/threadsappend.c rename to tests/zfs-tests/cmd/threadsappend.c diff --git a/tests/zfs-tests/cmd/threadsappend/.gitignore b/tests/zfs-tests/cmd/threadsappend/.gitignore deleted file mode 100644 index 4c8c8cdf34c1..000000000000 --- a/tests/zfs-tests/cmd/threadsappend/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/threadsappend diff --git a/tests/zfs-tests/cmd/threadsappend/Makefile.am b/tests/zfs-tests/cmd/threadsappend/Makefile.am deleted file mode 100644 index f030b42d50fe..000000000000 --- a/tests/zfs-tests/cmd/threadsappend/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = threadsappend -threadsappend_SOURCES = threadsappend.c -threadsappend_LDADD = -lpthread diff --git a/tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c b/tests/zfs-tests/cmd/user_ns_exec.c similarity index 100% rename from tests/zfs-tests/cmd/user_ns_exec/user_ns_exec.c rename to tests/zfs-tests/cmd/user_ns_exec.c diff --git a/tests/zfs-tests/cmd/user_ns_exec/.gitignore b/tests/zfs-tests/cmd/user_ns_exec/.gitignore deleted file mode 100644 index 655867a640a3..000000000000 --- a/tests/zfs-tests/cmd/user_ns_exec/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/user_ns_exec diff --git a/tests/zfs-tests/cmd/user_ns_exec/Makefile.am b/tests/zfs-tests/cmd/user_ns_exec/Makefile.am deleted file mode 100644 index 5b4bc9aaa683..000000000000 --- a/tests/zfs-tests/cmd/user_ns_exec/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = user_ns_exec -user_ns_exec_SOURCES = user_ns_exec.c diff --git a/tests/zfs-tests/cmd/xattrtest/xattrtest.c b/tests/zfs-tests/cmd/xattrtest.c similarity index 100% rename from tests/zfs-tests/cmd/xattrtest/xattrtest.c rename to tests/zfs-tests/cmd/xattrtest.c diff --git a/tests/zfs-tests/cmd/xattrtest/.gitignore b/tests/zfs-tests/cmd/xattrtest/.gitignore deleted file mode 100644 index 7d2128383639..000000000000 --- a/tests/zfs-tests/cmd/xattrtest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/xattrtest diff --git a/tests/zfs-tests/cmd/xattrtest/Makefile.am b/tests/zfs-tests/cmd/xattrtest/Makefile.am deleted file mode 100644 index 7398ae634629..000000000000 --- a/tests/zfs-tests/cmd/xattrtest/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -include $(top_srcdir)/config/Rules.am - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin - -pkgexec_PROGRAMS = xattrtest -xattrtest_SOURCES = xattrtest.c From 1873fcdb827643eba6b7ae0b0097c05db3f2131f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 12 Mar 2022 17:52:38 +0100 Subject: [PATCH 30/63] tests: logapi: don't cat excessively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also fixes line welding in test error output Signed-off-by: Ahelenia Ziemiańska --- tests/test-runner/include/logapi.shlib | 57 +++++++++++--------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib index 59ac4c2c30b4..765194cb9e55 100644 --- a/tests/test-runner/include/logapi.shlib +++ b/tests/test-runner/include/logapi.shlib @@ -54,7 +54,7 @@ function log_note function log_neg { - log_neg_expect "" "$@" + log_neg_expect "" "$@" } # Execute a positive test and exit $STF_FAIL is test fails @@ -85,7 +85,6 @@ function log_must_nostderr # function log_must_retry { - typeset out="" typeset logfile="/tmp/log.$$" typeset status=1 typeset expect=$1 @@ -100,11 +99,10 @@ function log_must_retry while (( $retry > 0 )); do "$@" 2>$logfile status=$? - out="cat $logfile" if (( $status == 0 )); then - if $out | grep -qEi "internal error|assertion failed"; then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or" \ " assertion failure exited $status" status=1 @@ -114,9 +112,8 @@ function log_must_retry fi break else - $out | grep -i "$expect" > /dev/null 2>&1 - if (( $? == 0 )); then - print -u2 $($out) + if grep -qi "$expect" $logfile; then + cat $logfile >&2 _printerror "$@" "Retry in $delay seconds" sleep $delay @@ -129,7 +126,7 @@ function log_must_retry done if (( $status != 0 )) ; then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "exited $status" fi @@ -194,7 +191,6 @@ EXIT_SIGSEGV=$((EXIT_SIGNAL + SIGSEGV)) function log_neg_expect { - typeset out="" typeset logfile="/tmp/log.$$" typeset ret=1 typeset expect=$1 @@ -206,35 +202,33 @@ function log_neg_expect "$@" 2>$logfile typeset status=$? - out="cat $logfile" # unexpected status if (( $status == EXIT_SUCCESS )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status" # missing binary elif (( $status == EXIT_NOTFOUND )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (File not found)" # bus error - core dump elif (( $status == EXIT_SIGBUS )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (Bus Error)" # segmentation violation - core dump elif (( $status == EXIT_SIGSEGV )); then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status (SEGV)" else - if $out | grep -qEi "internal error|assertion failed"; then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or assertion failure" \ " exited $status" elif [[ -n $expect ]] ; then - $out | grep -i "$expect" > /dev/null 2>&1 - if (( $? == 0 )); then + if grep -qi "$expect" $logfile; then ret=0 else - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "unexpectedly exited $status" fi else @@ -258,7 +252,6 @@ function log_neg_expect function log_pos { - typeset out="" typeset logfile="/tmp/log.$$" while [[ -e $logfile ]]; do @@ -267,14 +260,13 @@ function log_pos "$@" 2>$logfile typeset status=$? - out="cat $logfile" if (( $status != 0 )) ; then - print -u2 $($out) + cat $logfile >&2 _printerror "$@" "exited $status" else - if $out | grep -qEi "internal error|assertion failed"; then - print -u2 $($out) + if grep -qEi "internal error|assertion failed" $logfile; then + cat $logfile >&2 _printerror "$@" "internal error or assertion failure" \ " exited $status" status=1 @@ -297,7 +289,6 @@ function log_pos function log_pos_nostderr { - typeset out="" typeset logfile="/tmp/log.$$" while [[ -e $logfile ]]; do @@ -306,15 +297,13 @@ function log_pos_nostderr "$@" 2>$logfile typeset status=$? - out="cat $logfile" - typeset out_msg=$($out) if (( $status != 0 )) ; then - print -u2 $out_msg + cat $logfile >&2 _printerror "$@" "exited $status" else - if [[ ! -z "$out_msg" ]]; then - print -u2 $out_msg + if [ -s "$logfile" ]; then + cat $logfile >&2 _printerror "$@" "message in stderr" \ " exited $status" status=1 @@ -472,12 +461,12 @@ function _execute_testfail_callbacks { typeset callback - print "$TESTFAIL_CALLBACKS:" | while read -d ":" callback; do + while read -d ":" callback; do if [[ -n "$callback" ]] ; then log_note "Performing test-fail callback ($callback)" $callback fi - done + done <<<"$TESTFAIL_CALLBACKS:" } # Perform cleanup and exit @@ -525,7 +514,7 @@ function _endlog function _printline { - print "$@" + echo "$@" } # Output an error message From a867ede84722e230ef0545ddd4d67e8f9914e2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 22 Mar 2022 22:26:00 +0100 Subject: [PATCH 31/63] tests: mixed_create_failure: explicitly note the error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: #13215 Signed-off-by: Ahelenia Ziemiańska --- .../functional/casenorm/mixed_create_failure.ksh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh b/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh index 7d22fc914453..208be91dea42 100755 --- a/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh +++ b/tests/zfs-tests/tests/functional/casenorm/mixed_create_failure.ksh @@ -70,6 +70,7 @@ function test_ops { typeset obj_type=$1 typeset testdir=$2 + typeset save_name= target_obj='target-file' @@ -83,7 +84,7 @@ function test_ops log_note "Created test dir $test_path" if [[ $obj_type = "symlink" || $obj_type = "hardlink" ]]; then - touch $test_path/$target_obj + > $test_path/$target_obj log_note "Created target: $test_path/$target_obj" op="$op $test_path/$target_obj" fi @@ -104,21 +105,16 @@ function test_ops fi fi done + [ -n "$save_name" ] || log_fail "Didn't ENOSPC!" - log_note 'Test rename \"sample_name\" rename' + log_note 'Test rename "sample_name" rename' TMP_OBJ="$test_path/tmp_obj" cmd="$op $TMP_OBJ" - out=$($cmd 2>&1) - ret=$? - if (($ret != 0)); then - log_fail "$cmd failed: $out" - fi + log_must $cmd # Now, try to rename the tmp_obj to the name which we failed to add earlier. # This should fail as well. - out=$(mv $TMP_OBJ $save_name 2>&1) - ret=$? - if (($ret != 0)); then + if ! out=$(mv $TMP_OBJ $save_name 2>&1); then if [[ $out = *@(No space left on device)* ]]; then log_note "$cmd failed as expected: $out" else From 50638af0f1ce3190cacecd13e2b4c6b25042cc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 14 Mar 2022 01:39:03 +0100 Subject: [PATCH 32/63] scripts: zfs-tests.sh: cleanup, optimise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The single-stage losetup doesn't work on busybox, but then most of the testsuite doesn't Signed-off-by: Ahelenia Ziemiańska --- scripts/zfs-tests.sh | 92 +++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index 6e9589e59308..35d8eb001416 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -29,9 +29,9 @@ BASE_DIR=$(dirname "$0") SCRIPT_COMMON=common.sh if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then -. "${BASE_DIR}/${SCRIPT_COMMON}" + . "${BASE_DIR}/${SCRIPT_COMMON}" else -echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 + echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 fi PROG=zfs-tests.sh @@ -100,7 +100,7 @@ cleanup_linux_loopback() { for TEST_LOOPBACK in ${LOOPBACKS}; do LOOP_DEV="${TEST_LOOPBACK##*/}" DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \ - grep "${LOOP_DEV}" | cut -f1) + awk -v l="${LOOP_DEV}" '$0 ~ l {print $1}') if [ -n "$DM_DEV" ]; then sudo "${DMSETUP}" remove "${DM_DEV}" || @@ -133,9 +133,8 @@ cleanup() { fi fi - for TEST_FILE in ${FILES}; do - rm -f "${TEST_FILE}" >/dev/null 2>&1 - done + # shellcheck disable=SC2086 + rm -f ${FILES} >/dev/null 2>&1 if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then rm -Rf "$STF_PATH" @@ -150,28 +149,30 @@ trap cleanup EXIT # be dangerous and should only be used in a dedicated test environment. # cleanup_all() { - TEST_POOLS=$(sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -H -o name | grep testpool) + TEST_POOLS=$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | grep testpool) if [ "$UNAME" = "FreeBSD" ] ; then TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l) else - TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:) + TEST_LOOPBACKS=$("${LOSETUP}" -a | awk -F: '/file-vdev/ {print $1}') fi - TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null) + TEST_FILES=$(ls "${FILEDIR}"/file-vdev* /var/tmp/file-vdev* 2>/dev/null) msg msg "--- Cleanup ---" - msg "Removing pool(s): $(echo "${TEST_POOLS}" | tr '\n' ' ')" + # shellcheck disable=2116,2086 + msg "Removing pool(s): $(echo ${TEST_POOLS})" for TEST_POOL in $TEST_POOLS; do sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" destroy "${TEST_POOL}" done if [ "$UNAME" != "FreeBSD" ] ; then - msg "Removing dm(s): $(sudo "${DMSETUP}" ls | + msg "Removing all dm(s): $(sudo "${DMSETUP}" ls | grep loop | tr '\n' ' ')" sudo "${DMSETUP}" remove_all fi - msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')" + # shellcheck disable=2116,2086 + msg "Removing loopback(s): $(echo ${TEST_LOOPBACKS})" for TEST_LOOPBACK in $TEST_LOOPBACKS; do if [ "$UNAME" = "FreeBSD" ] ; then sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" @@ -180,10 +181,10 @@ cleanup_all() { fi done - msg "Removing files(s): $(echo "${TEST_FILES}" | tr '\n' ' ')" - for TEST_FILE in $TEST_FILES; do - sudo rm -f "${TEST_FILE}" - done + # shellcheck disable=2116,2086 + msg "Removing files(s): $(echo ${TEST_FILES})" + # shellcheck disable=2086 + sudo rm -f ${TEST_FILES} } # @@ -197,19 +198,18 @@ cleanup_all() { # find_runfile() { NAME=$1 - RESULT="" if [ -f "$RUNFILE_DIR/$NAME" ]; then - RESULT="$RUNFILE_DIR/$NAME" + echo "$RUNFILE_DIR/$NAME" elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then - RESULT="$RUNFILE_DIR/$NAME.run" + echo "$RUNFILE_DIR/$NAME.run" elif [ -f "$NAME" ]; then - RESULT="$NAME" + echo "$NAME" elif [ -f "$NAME.run" ]; then - RESULT="$NAME.run" + echo "$NAME.run" + else + return 1 fi - - echo "$RESULT" } # @@ -340,7 +340,7 @@ OPTIONS: -u USER Run single test as USER (default: root) EXAMPLES: -# Run the default (linux) suite of tests and output the configuration used. +# Run the default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and output the configuration used. $0 -v # Run a smaller suite of tests designed to run more quickly. @@ -350,7 +350,7 @@ $0 -r linux-fast $0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh # Cleanup a previous run of the test suite prior to testing, run the -# default (linux) suite of tests and perform no cleanup on exit. +# default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and perform no cleanup on exit. $0 -x EOF @@ -463,8 +463,8 @@ post_user = root post = outputdir = /var/tmp/test_results EOF - SINGLETESTDIR=$(dirname "$SINGLETEST") - SINGLETESTFILE=$(basename "$SINGLETEST") + SINGLETESTDIR="${SINGLETEST%/*}" + SINGLETESTFILE="${SINGLETEST##*/}" SETUPSCRIPT= CLEANUPSCRIPT= @@ -499,8 +499,8 @@ IFS=, for RUNFILE in $RUNFILES; do if [ -n "$RUNFILE" ]; then SAVED_RUNFILE="$RUNFILE" - RUNFILE=$(find_runfile "$RUNFILE") - [ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE" + RUNFILE=$(find_runfile "$RUNFILE") || + fail "Cannot find runfile: $SAVED_RUNFILE" R="$R,$RUNFILE" fi @@ -520,7 +520,7 @@ if [ "$(id -u)" = "0" ]; then fail "This script must not be run as root." fi -if [ "$(sudo whoami)" != "root" ]; then +if [ "$(sudo id -un)" != "root" ]; then fail "Passwordless sudo access required." fi @@ -557,16 +557,14 @@ fi # # By default preserve any existing pools -# NOTE: Since 'zpool list' outputs a newline-delimited list convert $KEEP from -# space-delimited to newline-delimited. # if [ -z "${KEEP}" ]; then - KEEP="$(sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -H -o name)" + KEEP="$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | tr -s '[:space:]' ' ')" if [ -z "${KEEP}" ]; then KEEP="rpool" fi else - KEEP="$(echo "$KEEP" | tr '[:blank:]' '\n')" + KEEP="$(echo "$KEEP" | tr -s '[:space:]' ' ')" fi # @@ -578,11 +576,7 @@ fi # # See libzfs/libzfs_config.c for more information. # -if [ "$UNAME" = "FreeBSD" ] ; then - __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | tr -s '\n' ' ')" -else - __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')" -fi +__ZFS_POOL_EXCLUDE="$KEEP" . "$STF_SUITE/include/default.cfg" @@ -622,8 +616,7 @@ if [ -z "${DISKS}" ]; then DISKS="$DISKS $MDDEVICE" LOOPBACKS="$LOOPBACKS $MDDEVICE" else - TEST_LOOPBACK=$(sudo "${LOSETUP}" -f) - sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" || + TEST_LOOPBACK=$(sudo "${LOSETUP}" --show -f "${TEST_FILE}") || fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}" BASELOOPBACK="${TEST_LOOPBACK##*/}" DISKS="$DISKS $BASELOOPBACK" @@ -649,7 +642,7 @@ fi # # Disable SELinux until the ZFS Test Suite has been updated accordingly. # -if [ -x "$STF_PATH/setenforce" ]; then +if command -v setenforce >/dev/null; then sudo setenforce permissive >/dev/null 2>&1 fi @@ -657,8 +650,8 @@ fi # Enable internal ZFS debug log and clear it. # if [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then - sudo /bin/sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" - sudo /bin/sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" + sudo sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" + sudo sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" fi msg @@ -688,7 +681,6 @@ export FILEDIR export KEEP export __ZFS_POOL_EXCLUDE export TESTFAIL_CALLBACKS -export PATH=$STF_PATH mktemp_file() { if [ "$UNAME" = "FreeBSD" ]; then @@ -712,7 +704,8 @@ msg "${TEST_RUNNER}" \ "-T \"${TAGS}\"" \ "-i \"${STF_SUITE}\"" \ "-I \"${ITERATIONS}\"" -{ ${TEST_RUNNER} \ +{ PATH=$STF_PATH \ + ${TEST_RUNNER} \ ${QUIET:+-q} \ ${KMEMLEAK:+-m} \ ${KMSG:+-K} \ @@ -737,9 +730,10 @@ if [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then for test_name in $MAYBES; do grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST" done - { ${TEST_RUNNER} \ - ${QUIET:+-q} \ - ${KMEMLEAK:+-m} \ + { PATH=$STF_PATH \ + ${TEST_RUNNER} \ + ${QUIET:+-q} \ + ${KMEMLEAK:+-m} \ -c "${RUNFILES}" \ -T "${TAGS}" \ -i "${STF_SUITE}" \ From 4a460ddf4db56e379c8991f7f628cbf1110d3098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 20 Mar 2022 02:22:00 +0100 Subject: [PATCH 33/63] zed: lets: all-debug: printenv -> env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- cmd/zed/zed.d/all-debug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zed/zed.d/all-debug.sh b/cmd/zed/zed.d/all-debug.sh index ba19b96b082f..9794cf26ce76 100755 --- a/cmd/zed/zed.d/all-debug.sh +++ b/cmd/zed/zed.d/all-debug.sh @@ -15,7 +15,7 @@ zed_exit_if_ignoring_this_event zed_lock "${ZED_DEBUG_LOG}" { - printenv | sort + env | sort echo } 1>&"${ZED_FLOCK_FD}" zed_unlock "${ZED_DEBUG_LOG}" From f75c7afffd94b425b23273019ca3e763efed311e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sun, 20 Mar 2022 02:22:43 +0100 Subject: [PATCH 34/63] zed: functions: zed_log_err: forward to zed_log_msg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- cmd/zed/zed.d/zed-functions.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh index e6d3ce9ecc49..70a7113c6580 100644 --- a/cmd/zed/zed.d/zed-functions.sh +++ b/cmd/zed/zed.d/zed-functions.sh @@ -76,8 +76,7 @@ zed_log_msg() # zed_log_err() { - logger -p "${ZED_SYSLOG_PRIORITY}" -t "${ZED_SYSLOG_TAG}" -- "error:" \ - "${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" + zed_log_msg "error: ${0##*/}:""${ZEVENT_EID:+" eid=${ZEVENT_EID}:"}" "$@" } From 6bfce0052101009cb46c99cf8f059945b9ce3bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 14 Mar 2022 01:41:03 +0100 Subject: [PATCH 35/63] tests: clean out unused/single-use/useless commands from the list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/test-runner/bin/test-runner.py.in | 6 +- tests/zfs-tests/include/commands.cfg | 26 ++------ tests/zfs-tests/include/libtest.shlib | 64 ++----------------- .../cli_root/zdb/zdb_block_size_histogram.ksh | 3 - .../cli_root/zfs_diff/zfs_diff_types.ksh | 6 +- .../zpool_create/zpool_create_024_pos.ksh | 8 +-- .../cli_user/misc/zfs_allow_001_neg.ksh | 11 +--- .../functional/cp_files/cp_files_001_pos.ksh | 2 +- .../zfs-tests/tests/functional/mmp/mmp.kshlib | 8 +-- .../tests/functional/xattr/xattr_003_neg.ksh | 4 +- .../tests/functional/xattr/xattr_010_neg.ksh | 2 +- tests/zfs-tests/tests/perf/perf.shlib | 4 +- .../tests/perf/scripts/prefetch_io.sh | 40 +++--------- 13 files changed, 35 insertions(+), 149 deletions(-) diff --git a/tests/test-runner/bin/test-runner.py.in b/tests/test-runner/bin/test-runner.py.in index 5c868d945a8c..cb453b266f3c 100755 --- a/tests/test-runner/bin/test-runner.py.in +++ b/tests/test-runner/bin/test-runner.py.in @@ -291,7 +291,7 @@ User: %s self.result.starttime = monotonic_time() if kmemleak: - cmd = f'echo clear | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} sh -c "echo clear > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) proc = Popen(privcmd, stdout=PIPE, stderr=PIPE) @@ -305,7 +305,7 @@ User: %s self.result.stdout, self.result.stderr = self.collect_output(proc) if kmemleak: - cmd = f'echo scan | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} sh -c "echo scan > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) cmd = f'{SUDO} cat {KMEMLEAK_FILE}' self.result.kmemleak = check_output(cmd, shell=True) @@ -880,7 +880,7 @@ class TestRun(object): self.outputdir, LOG_ERR) if options.kmemleak: - cmd = f'echo scan=0 | {SUDO} tee {KMEMLEAK_FILE}' + cmd = f'{SUDO} -c "echo scan=0 > {KMEMLEAK_FILE}"' check_output(cmd, shell=True) iteration = 0 diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index fcde48adc66a..0951f719b95c 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -8,9 +8,7 @@ # Please keep the contents of each variable sorted for ease of reading # and maintenance. # -export SYSTEM_FILES_COMMON='arp - awk - base64 +export SYSTEM_FILES_COMMON='awk basename bc bunzip2 @@ -52,10 +50,10 @@ export SYSTEM_FILES_COMMON='arp ksh ldd ln - logname ls mkdir mknod + mkfifo mktemp mount mv @@ -67,12 +65,9 @@ export SYSTEM_FILES_COMMON='arp pgrep ping pkill - printenv printf ps - pwd python3 - quotaon readlink rm rmdir @@ -88,32 +83,26 @@ export SYSTEM_FILES_COMMON='arp ssh stat strings - su sudo swapoff swapon sync tail tar - tee timeout touch tr true truncate - umask umount uname uniq - uuidgen vmstat - wait wc' export SYSTEM_FILES_FREEBSD='chflags compress diskinfo - dumpon fsck getextattr gpart @@ -123,7 +112,6 @@ export SYSTEM_FILES_FREEBSD='chflags lsextattr md5 mdconfig - mkfifo newfs pw rmextattr @@ -135,14 +123,11 @@ export SYSTEM_FILES_FREEBSD='chflags uncompress' export SYSTEM_FILES_LINUX='attr - bash blkid blockdev chattr - dmidecode exportfs fallocate - fdisk free getfattr groupadd @@ -159,16 +144,17 @@ export SYSTEM_FILES_LINUX='attr mkswap modprobe mpstat - nproc parted perf - setenforce setfattr sha256sum udevadm useradd userdel - usermod' + usermod + + flock + logger' export ZFS_FILES='zdb zfs diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 88390456a119..5f0f2d56acf4 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2970,59 +2970,6 @@ function get_device_state #pool disk field("", "spares","logs") ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}' } -# -# Given a disk, label it to VTOC regardless what label was on the disk -# $1 disk -# -function labelvtoc -{ - typeset disk=$1 - if [[ -z $disk ]]; then - log_fail "The disk name is unspecified." - fi - typeset label_file=/var/tmp/labelvtoc.$$ - typeset arch=$(uname -p) - - if is_linux || is_freebsd; then - log_note "Currently unsupported by the test framework" - return 1 - fi - - if [[ $arch == "i386" ]]; then - echo "label" > $label_file - echo "0" >> $label_file - echo "" >> $label_file - echo "q" >> $label_file - echo "q" >> $label_file - - fdisk -B $disk >/dev/null 2>&1 - # wait a while for fdisk finishes - sleep 60 - elif [[ $arch == "sparc" ]]; then - echo "label" > $label_file - echo "0" >> $label_file - echo "" >> $label_file - echo "" >> $label_file - echo "" >> $label_file - echo "q" >> $label_file - else - log_fail "unknown arch type" - fi - - format -e -s -d $disk -f $label_file - typeset -i ret_val=$? - rm -f $label_file - # - # wait the format to finish - # - sleep 60 - if ((ret_val != 0)); then - log_fail "unable to label $disk as VTOC." - fi - - return 0 -} - # # get the root filesystem name if it's zfsroot system. # @@ -3077,22 +3024,19 @@ function verify_disk_count function ds_is_volume { typeset type=$(get_prop type $1) - [[ $type = "volume" ]] && return 0 - return 1 + [ $type = "volume" ] } function ds_is_filesystem { typeset type=$(get_prop type $1) - [[ $type = "filesystem" ]] && return 0 - return 1 + [ $type = "filesystem" ] } function ds_is_snapshot { typeset type=$(get_prop type $1) - [[ $type = "snapshot" ]] && return 0 - return 1 + [ $type = "snapshot" ] } # @@ -3108,7 +3052,7 @@ function is_mp { case $(uname) in Linux) - (($(nproc) > 1)) + (($(grep -c '^processor' /proc/cpuinfo) > 1)) ;; FreeBSD) sysctl -n kern.smp.cpus diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh index 75f15f6a88e3..9a960cecc38b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh @@ -145,7 +145,6 @@ function histo_check_test_pool typeset -i this_rs typeset -i this_ri typeset -i sum_filesizes=0 - typeset dumped typeset stripped let histo_check_pool_size=$(get_pool_prop size ${pool}) @@ -157,11 +156,9 @@ function histo_check_test_pool log_fail "hctp: max_pool_record_size is not numeric ${max_pool_record_size}" fi - dumped="${TEST_BASE_DIR}/${pool}_dump.txt" stripped="${TEST_BASE_DIR}/${pool}_stripped.txt" zdb -Pbbb ${pool} | \ - tee ${dumped} | \ sed -e '1,/^block[ ][ ]*psize[ ][ ]*lsize.*$/d' \ -e '/^size[ ]*Count/d' -e '/^$/,$d' \ > ${stripped} diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh index 51f0295cd3c8..07b14e7aec6b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh @@ -111,11 +111,7 @@ verify_object_class "$MNTPOINT/cdev" "C" # 2. | (Named pipe) log_must zfs snapshot "$TESTSNAP1" -if is_freebsd; then - log_must mkfifo "$MNTPOINT/fifo" -else - log_must mknod "$MNTPOINT/fifo" p -fi +log_must mkfifo "$MNTPOINT/fifo" log_must zfs snapshot "$TESTSNAP2" verify_object_class "$MNTPOINT/fifo" "|" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh index 5b464c3c248b..98d2ee543be4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh @@ -74,7 +74,7 @@ child_pools="" function zpool_stress { - typeset pool=$1 + typeset pool="$1-$$" typeset vdev0="$TEST_BASE_DIR/$pool-vdev0.img" typeset vdev1="$TEST_BASE_DIR/$pool-vdev1.img" typeset -i iters=$2 @@ -118,13 +118,11 @@ function zpool_stress # 1. Create 128 process each of which create/destroy a pool 5 times. typeset i=0 while [[ $i -lt 128 ]]; do - typeset uuid=$(uuidgen | cut -c1-13) - - zpool_stress $TESTPOOL-$uuid 5 & + zpool_stress $TESTPOOL-$i 5 & typeset pid=$! child_pids="$child_pids $pid" - child_pools="$child_pools $TESTPOOL-$uuid" + child_pools="$child_pools $TESTPOOL-$i-$pid" ((i = i + 1)) done diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh index 56a74e4ae427..ce474657b42c 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh @@ -44,22 +44,15 @@ # # -# check to see if we have zfs allow -zfs 2>&1 | grep "allow" > /dev/null -if (($? != 0)) then - log_unsupported "ZFS allow not supported on this machine." -fi - log_assert "zfs allow returns an error when run as a user" log_must zfs allow $TESTPOOL/$TESTFS -log_mustnot zfs allow $(logname) create $TESTPOOL/$TESTFS +log_mustnot zfs allow $(id -un) create $TESTPOOL/$TESTFS # now verify that the above command actually did nothing by # checking for any allow output. ( if no allows are granted, # nothing should be output ) -OUTPUT=$(zfs allow $TESTPOOL/$TESTFS | grep "Local+Descendent" ) -if [ -n "$OUTPUT" ] +if zfs allow $TESTPOOL/$TESTFS | grep -q "Local+Descendent" then log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS" fi diff --git a/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh b/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh index 3e138cfc9f72..208ecfeed334 100755 --- a/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh @@ -58,7 +58,7 @@ BATCH=1000 log_must mkdir $TESTDIR/src log_must mkdir $TESTDIR/dst -WD=$(pwd) +WD=$PWD cd $TESTDIR/src # create NR_FILES in BATCH at a time to prevent overflowing argument buffer for i in $(seq $(($NR_FILES/$BATCH))); do touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH))); done diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 7ff2636e1f32..636d2fa68650 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -69,8 +69,6 @@ function try_pool_import # pool opts message typeset msg=$3 zpool import $opts $pool 2>&1 | grep -i "$msg" - - return $? } function mmp_set_hostid @@ -79,11 +77,7 @@ function mmp_set_hostid zgenhostid $1 - if [ $(hostid) != "$hostid" ]; then - return 1 - fi - - return 0 + [ $(hostid) = "$hostid" ] } function mmp_clear_hostid diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_003_neg.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_003_neg.ksh index ba27d043b7fe..852bffc7a173 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_003_neg.ksh @@ -59,8 +59,8 @@ create_xattr $testfile passwd /etc/passwd log_must chmod 000 $testfile if is_illumos; then - log_mustnot su $ZFS_USER -c "runat $testfile cat passwd" - log_mustnot su $ZFS_USER -c "runat $testfile cp /etc/passwd ." + log_mustnot user_run $ZFS_USER runat $testfile cat passwd + log_mustnot user_run $ZFS_USER runat $testfile cp /etc/passwd . else log_mustnot user_run $ZFS_USER " . $STF_SUITE/include/libtest.shlib diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_010_neg.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_010_neg.ksh index 43502bfff28b..41c7054f23d7 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_010_neg.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_010_neg.ksh @@ -61,6 +61,6 @@ log_mustnot runat $TESTDIR/myfile.$$ mknod block b 888 888 log_mustnot runat $TESTDIR/myfile.$$ mknod char c -log_mustnot runat $TESTDIR/myfile.$$ mknod fifo p +log_mustnot runat $TESTDIR/myfile.$$ mkfifo fifo log_pass "mkdir, mknod fail" diff --git a/tests/zfs-tests/tests/perf/perf.shlib b/tests/zfs-tests/tests/perf/perf.shlib index 27f56676db8b..c9b4505e23ac 100644 --- a/tests/zfs-tests/tests/perf/perf.shlib +++ b/tests/zfs-tests/tests/perf/perf.shlib @@ -254,7 +254,7 @@ function do_collect_scripts # Find a place to deposit performance data collected while under load. function get_perf_output_dir { - typeset dir="$(pwd)/perf_data" + typeset dir="$PWD/perf_data" [[ -d $dir ]] || mkdir -p $dir echo $dir @@ -467,7 +467,7 @@ function get_system_config echo "{" >>$config if is_linux; then - echo " \"ncpus\": \"$(nproc --all)\"," >>$config + echo " \"ncpus\": \"$(lscpu | awk '/^CPU\(s\)/ {print $2; exit}')\"," >>$config echo " \"physmem\": \"$(free -b | \ awk '$1 == "Mem:" { print $2 }')\"," >>$config echo " \"c_max\": \"$(get_max_arc_size)\"," >>$config diff --git a/tests/zfs-tests/tests/perf/scripts/prefetch_io.sh b/tests/zfs-tests/tests/perf/scripts/prefetch_io.sh index 07688ef21b59..bc2bb11aefa6 100755 --- a/tests/zfs-tests/tests/perf/scripts/prefetch_io.sh +++ b/tests/zfs-tests/tests/perf/scripts/prefetch_io.sh @@ -1,5 +1,4 @@ -#!/usr/bin/env bash -# shellcheck disable=SC1004 +#!/bin/sh # # This file and its contents are supplied under the terms of the @@ -21,33 +20,12 @@ # TBD if we can add additional kstats to achieve the desired results # -zfs_kstats="/proc/spl/kstat/zfs" - -function get_prefetch_ios -{ - typeset -l data_misses="$(awk '$1 == "prefetch_data_misses" \ - { print $3; exit }' "$zfs_kstats/arcstats")" - typeset -l metadata_misses="$(awk '$1 == "prefetch_metadata_misses" \ - { print $3; exit }' "$zfs_kstats/arcstats")" - typeset -l total_misses=$(( data_misses + metadata_misses )) - - echo "$total_misses" -} - -function get_prefetched_demand_reads -{ - typeset -l demand_reads="$(awk '$1 == "demand_hit_predictive_prefetch" \ - { print $3; exit }' "$zfs_kstats/arcstats")" - - echo "$demand_reads" +getstat() { + awk -v c="$1" '$1 == c {print $3; exit}' /proc/spl/kstat/zfs/arcstats } -function get_async_upgrade_sync -{ - typeset -l sync_wait="$(awk '$1 == "async_upgrade_sync" \ - { print $3; exit }' "$zfs_kstats/arcstats")" - - echo "$sync_wait" +get_prefetch_ios() { + echo $(( $(getstat prefetch_data_misses) + $(getstat prefetch_metadata_misses) )) } if [ $# -ne 2 ] @@ -58,8 +36,8 @@ fi interval=$2 prefetch_ios=$(get_prefetch_ios) -prefetched_demand_reads=$(get_prefetched_demand_reads) -async_upgrade_sync=$(get_async_upgrade_sync) +prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch) +async_upgrade_sync=$(getstat async_upgrade_sync) while true do @@ -68,12 +46,12 @@ do $(( new_prefetch_ios - prefetch_ios )) prefetch_ios=$new_prefetch_ios - new_prefetched_demand_reads=$(get_prefetched_demand_reads) + new_prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch) printf '%-24s\t%u\n' "prefetched_demand_reads" \ $(( new_prefetched_demand_reads - prefetched_demand_reads )) prefetched_demand_reads=$new_prefetched_demand_reads - new_async_upgrade_sync=$(get_async_upgrade_sync) + new_async_upgrade_sync=$(getstat async_upgrade_sync) printf '%-24s\t%u\n' "async_upgrade_sync" \ $(( new_async_upgrade_sync - async_upgrade_sync )) async_upgrade_sync=$new_async_upgrade_sync From e37ca2239b27cf15731382085f88f343c0c90c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 17:54:07 +0100 Subject: [PATCH 36/63] tests: include: math: simplify bc conditions, review $? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/math.shlib | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/zfs-tests/include/math.shlib b/tests/zfs-tests/include/math.shlib index 7ac59f279604..38d9fecea7cf 100644 --- a/tests/zfs-tests/include/math.shlib +++ b/tests/zfs-tests/include/math.shlib @@ -30,17 +30,14 @@ function within_percent typeset percent=$3 # Set $a or $b to $2 such that a >= b - [[ '1' = $(echo "if ($2 > $a) 1 else 0" | bc) ]] && a=$2 || b=$2 + [ 1 -eq $(echo "$2 > $a" | bc) ] && a=$2 || b=$2 # Prevent division by 0 [[ $a =~ [1-9] ]] || return 1 typeset p=$(echo "scale=2; $b * 100 / $a" | bc) log_note "Comparing $a and $b given $percent% (calculated: $p%)" - [[ '1' = $(echo "scale=2; if ($p >= $percent) 1 else 0" | bc) ]] && \ - return 0 - - return 1 + [ 1 -eq $(echo "scale=2; $p >= $percent" | bc) ] } # @@ -61,9 +58,7 @@ function within_tolerance #value #target #tolerance typeset diff=$((abs(val - target))) log_note "Checking if $val is within +/-$tol of $target (diff: $diff)" - ((diff <= tol)) && return 0 - - return 1 + ((diff <= tol)) } # From 3ecd385d75afefab342a8b2e9130a86225f68e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 01:52:39 +0100 Subject: [PATCH 37/63] tests: review every instance of $? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/blkdev.shlib | 19 +- tests/zfs-tests/include/libtest.shlib | 199 ++++-------------- .../tests/functional/acl/acl_common.kshlib | 28 ++- .../functional/acl/posix/posix_001_pos.ksh | 67 +++--- .../functional/acl/posix/posix_002_pos.ksh | 6 +- .../functional/bootfs/bootfs_001_pos.ksh | 6 - .../functional/bootfs/bootfs_002_neg.ksh | 6 - .../functional/bootfs/bootfs_003_pos.ksh | 6 - .../functional/bootfs/bootfs_004_neg.ksh | 6 - .../functional/bootfs/bootfs_006_pos.ksh | 6 - .../tests/functional/btree/btree_negative.ksh | 7 +- .../tests/functional/cache/cache.kshlib | 6 - .../tests/functional/casenorm/casenorm.kshlib | 14 +- .../channel_program/channel_common.kshlib | 35 ++- .../tests/functional/chattr/setup.ksh | 4 +- .../functional/cli_root/zdb/zdb_003_pos.ksh | 4 +- .../functional/cli_root/zdb/zdb_checksum.ksh | 6 +- .../cli_root/zdb/zdb_decompress_zstd.ksh | 30 +-- .../zfs_create/zfs_create_002_pos.ksh | 3 +- .../zfs_create/zfs_create_013_pos.ksh | 3 +- .../cli_root/zfs_create/zfs_create_dryrun.ksh | 7 +- .../zfs_create/zfs_create_verbose.ksh | 7 +- .../cli_root/zfs_get/zfs_get_002_pos.ksh | 2 +- .../cli_root/zfs_get/zfs_get_005_neg.ksh | 4 +- .../cli_root/zfs_get/zfs_get_008_pos.ksh | 7 +- .../cli_root/zfs_get/zfs_get_009_pos.ksh | 7 +- .../zfs_inherit/zfs_inherit_001_neg.ksh | 9 +- .../zfs_load-key/zfs_load-key_common.kshlib | 3 +- .../cli_root/zfs_mount/zfs_mount_005_pos.ksh | 11 +- .../zfs_receive/zfs_receive_001_pos.ksh | 5 +- .../zfs_receive/zfs_receive_009_neg.ksh | 7 +- .../cli_root/zfs_rename/cleanup.ksh | 8 +- .../functional/cli_root/zfs_rename/setup.ksh | 9 +- .../cli_root/zfs_rename/zfs_rename.kshlib | 7 +- .../cli_root/zfs_send/zfs_send_001_pos.ksh | 8 +- .../cli_root/zfs_send/zfs_send_002_pos.ksh | 8 +- .../zfs_set/property_alias_001_pos.ksh | 8 +- .../cli_root/zfs_set/reservation_001_neg.ksh | 10 +- .../cli_root/zfs_set/ro_props_001_pos.ksh | 7 +- .../zfs_set/user_property_004_pos.ksh | 23 +- .../cli_root/zfs_set/version_001_neg.ksh | 6 +- .../cli_root/zfs_set/zfs_set_common.kshlib | 32 +-- .../cli_root/zfs_share/zfs_share_005_pos.ksh | 9 +- .../cli_root/zfs_share/zfs_share_007_neg.ksh | 5 +- .../cli_root/zfs_share/zfs_share_009_neg.ksh | 3 +- .../zfs_snapshot/zfs_snapshot_004_neg.ksh | 6 +- .../zfs_snapshot/zfs_snapshot_005_neg.ksh | 4 +- .../zfs_snapshot/zfs_snapshot_007_neg.ksh | 7 +- .../cli_root/zfs_unmount/zfs_unmount.kshlib | 2 +- .../cli_root/zpool_add/add-o_ashift.ksh | 16 +- .../cli_root/zpool_add/add_prop_ashift.ksh | 16 +- .../cli_root/zpool_attach/attach-o_ashift.ksh | 15 +- .../cli_root/zpool_create/create-o_ashift.ksh | 12 +- .../zpool_create/zpool_create_016_pos.ksh | 4 +- .../zpool_create/zpool_create_020_pos.ksh | 15 +- .../zpool_create/zpool_create_024_pos.ksh | 17 +- .../zpool_events/zpool_events_cliargs.ksh | 2 +- .../zpool_events/zpool_events_poolname.ksh | 13 +- .../zpool_expand/zpool_expand_001_pos.ksh | 21 +- .../zpool_expand/zpool_expand_002_pos.ksh | 29 +-- .../zpool_expand/zpool_expand_003_neg.ksh | 2 +- .../zpool_export/zpool_export_002_pos.ksh | 17 +- .../cli_root/zpool_get/zpool_get_002_pos.ksh | 13 +- .../cli_root/zpool_get/zpool_get_003_pos.ksh | 10 +- .../import_cachefile_shared_device.ksh | 8 +- .../import_rewind_config_changed.ksh | 8 +- .../cli_root/zpool_import/zpool_import.kshlib | 42 ++-- .../zpool_import/zpool_import_012_pos.ksh | 7 +- .../zpool_offline/zpool_offline_001_pos.ksh | 25 +-- .../zpool_offline/zpool_offline_003_pos.ksh | 5 +- .../zpool_online/zpool_online_001_pos.ksh | 20 +- .../cli_root/zpool_reopen/zpool_reopen.shlib | 13 +- .../zpool_replace/replace-o_ashift.ksh | 14 +- .../zpool_replace/replace_prop_ashift.ksh | 14 +- .../cli_root/zpool_set/zpool_set_001_pos.ksh | 2 +- .../functional/cli_user/misc/zdb_001_neg.ksh | 12 +- .../cli_user/misc/zfs_unallow_001_neg.ksh | 9 +- .../cli_user/zfs_list/zfs_list_003_pos.ksh | 5 +- .../delegate/delegate_common.kshlib | 61 +----- .../tests/functional/delegate/setup.ksh | 4 +- .../tests/functional/exec/exec_002_neg.ksh | 20 +- .../functional/fault/auto_online_001_pos.ksh | 10 +- .../functional/history/history_007_pos.ksh | 12 +- .../functional/history/history_010_pos.ksh | 6 +- .../functional/history/history_common.kshlib | 60 ++---- .../functional/inheritance/inherit.kshlib | 14 +- .../inheritance/inherit_001_pos.ksh | 10 +- .../tests/functional/inuse/inuse_003_pos.ksh | 12 +- .../tests/functional/inuse/inuse_004_pos.ksh | 18 +- .../largest_pool/largest_pool_001_pos.ksh | 5 +- .../tests/functional/migration/cleanup.ksh | 6 +- .../functional/migration/migration.kshlib | 50 ++--- .../migration/migration_001_pos.ksh | 11 +- .../migration/migration_002_pos.ksh | 19 +- .../migration/migration_003_pos.ksh | 19 +- .../migration/migration_004_pos.ksh | 19 +- .../migration/migration_005_pos.ksh | 27 +-- .../migration/migration_006_pos.ksh | 19 +- .../migration/migration_007_pos.ksh | 11 +- .../migration/migration_008_pos.ksh | 19 +- .../migration/migration_009_pos.ksh | 19 +- .../migration/migration_010_pos.ksh | 11 +- .../migration/migration_011_pos.ksh | 19 +- .../migration/migration_012_pos.ksh | 19 +- .../zfs-tests/tests/functional/mmp/mmp.kshlib | 3 - .../tests/functional/mv_files/cleanup.ksh | 7 +- .../functional/mv_files/mv_files_001_pos.ksh | 6 +- .../functional/mv_files/mv_files_002_pos.ksh | 7 +- .../online_offline/online_offline_001_pos.ksh | 15 +- .../online_offline/online_offline_002_neg.ksh | 6 +- .../pool_checkpoint/checkpoint_zdb.ksh | 42 ++-- .../tests/functional/privilege/setup.ksh | 3 +- .../projectquota/projectquota_003_pos.ksh | 10 +- .../projectquota/projectquota_common.kshlib | 15 -- .../tests/functional/projectquota/setup.ksh | 4 +- .../functional/pyzfs/pyzfs_unittest.ksh.in | 15 +- .../tests/functional/quota/quota.kshlib | 4 +- .../functional/redundancy/redundancy.kshlib | 15 +- .../refreserv/refreserv_002_pos.ksh | 3 +- .../rename_dirs/rename_dirs_001_pos.ksh | 5 +- .../functional/replacement/attach_rebuild.ksh | 10 +- .../replacement/attach_resilver.ksh | 10 +- .../tests/functional/replacement/detach.ksh | 10 +- .../replacement/replace_rebuild.ksh | 5 +- .../replacement/replace_resilver.ksh | 5 +- .../tests/functional/rsend/rsend.kshlib | 65 ++---- .../tests/functional/rsend/rsend_011_pos.ksh | 8 +- .../tests/functional/rsend/rsend_012_pos.ksh | 14 +- .../tests/functional/rsend/send_doall.ksh | 12 +- .../tests/functional/slog/slog_014_pos.ksh | 6 +- .../functional/snapshot/rollback_001_pos.ksh | 3 +- .../functional/snapshot/rollback_002_pos.ksh | 6 +- .../functional/snapshot/snapshot_008_pos.ksh | 3 +- .../tests/functional/userquota/setup.ksh | 4 +- .../userquota/userquota_004_pos.ksh | 10 +- .../userquota/userquota_common.kshlib | 20 -- .../userquota/userspace_encrypted.ksh | 3 +- .../tests/functional/xattr/setup.ksh | 3 +- .../tests/functional/xattr/xattr_011_pos.ksh | 8 +- .../tests/functional/xattr/xattr_013_pos.ksh | 6 - .../tests/functional/zvol/zvol_common.shlib | 3 +- .../zvol/zvol_misc/zvol_misc_002_pos.ksh | 15 +- .../zvol/zvol_misc/zvol_misc_004_pos.ksh | 5 +- .../zvol/zvol_misc/zvol_misc_005_neg.ksh | 5 +- .../zvol/zvol_misc/zvol_misc_common.kshlib | 5 +- .../tests/functional/zvol/zvol_swap/setup.ksh | 4 +- tests/zfs-tests/tests/perf/perf.shlib | 55 ++--- 147 files changed, 558 insertions(+), 1483 deletions(-) diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index a97d1582d45c..3e11d15483cb 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -45,9 +45,7 @@ function scan_scsi_hosts log_must eval "echo '- - -' > $host/scan" done else - log_must eval \ - "echo /sys/class/scsi_host/host$hostnum/scan" \ - > /dev/null + log_note "/sys/class/scsi_host/host$hostnum/scan" log_must eval \ "echo '- - -' > /sys/class/scsi_host/host$hostnum/scan" fi @@ -176,13 +174,11 @@ function is_mpath_device #disk [[ -z $disk ]] && log_fail "No argument for disk given." if is_linux; then - lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ - grep -q mpath - if (($? == 0)); then + if lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ + grep -q mpath; then readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1 - return $? else - return $? + false fi elif is_freebsd; then is_disk_device $DEV_MPATHDIR/$disk @@ -438,11 +434,8 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz esac if is_linux; then - modprobe -n scsi_debug - if (($? != 0)); then - log_unsupported "Platform does not have scsi_debug" - "module" - fi + modprobe -n scsi_debug || + log_unsupported "Platform does not have scsi_debug module" if lsmod | grep -q scsi_debug; then log_fail "scsi_debug module already installed" else diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 5f0f2d56acf4..d4dae8e5931c 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -65,17 +65,16 @@ function linux_version { typeset ver="$1" - [[ -z "$ver" ]] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+") + [ -z "$ver" ] && ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+") - typeset version=$(echo $ver | cut -d '.' -f 1) - typeset major=$(echo $ver | cut -d '.' -f 2) - typeset minor=$(echo $ver | cut -d '.' -f 3) + typeset version major minor _ + IFS='.' read -r version major minor _ <<<"$ver" - [[ -z "$version" ]] && version=0 - [[ -z "$major" ]] && major=0 - [[ -z "$minor" ]] && minor=0 + [ -z "$version" ] && version=0 + [ -z "$major" ] && major=0 + [ -z "$minor" ] && minor=0 - echo $((version * 10000 + major * 100 + minor)) + echo $((version * 100000 + major * 1000 + minor)) } # Determine if this is a Linux test system @@ -144,7 +143,7 @@ function ismounted { typeset fstype=$2 [[ -z $fstype ]] && fstype=zfs - typeset out dir name ret + typeset out dir name case $fstype in zfs) @@ -153,7 +152,6 @@ function ismounted else ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}' fi - return $? ;; ufs|nfs) if is_freebsd; then @@ -161,9 +159,7 @@ function ismounted [[ "$1" == "$dev" || "$1" == "$dir" ]] && return 0 done else - out=$(df -F $fstype $1 2>/dev/null) - ret=$? - (($ret != 0)) && return $ret + out=$(df -F $fstype $1 2>/dev/null) || return dir=${out%%\(*} dir=${dir%% *} @@ -176,7 +172,6 @@ function ismounted ;; ext*) df -t $fstype $1 > /dev/null 2>&1 - return $? ;; zvol) if [[ -L "$ZVOL_DEVDIR/$1" ]]; then @@ -186,9 +181,10 @@ function ismounted return 0 fi ;; + *) + false + ;; esac - - return 1 } # Return 0 if a dataset is mounted; 1 otherwise @@ -199,8 +195,6 @@ function ismounted function mounted { ismounted $1 $2 - (($? == 0)) && return 0 - return 1 } # Return 0 if a dataset is unmounted; 1 otherwise @@ -210,9 +204,7 @@ function mounted function unmounted { - ismounted $1 $2 - (($? == 1)) && return 0 - return 1 + ! ismounted $1 $2 } function default_setup @@ -644,8 +636,7 @@ function default_container_cleanup reexport_pool fi - ismounted $TESTPOOL/$TESTCTR/$TESTFS1 - [[ $? -eq 0 ]] && \ + ismounted $TESTPOOL/$TESTCTR/$TESTFS1 && log_must zfs unmount $TESTPOOL/$TESTCTR/$TESTFS1 destroy_dataset "$TESTPOOL/$TESTCTR/$TESTFS1" "-R" @@ -907,8 +898,7 @@ function set_partition parted $disk -s -- print 1 >/dev/null typeset ret_val=$? if [[ $slicenum -eq 0 || $ret_val -ne 0 ]]; then - parted $disk -s -- mklabel gpt - if [[ $? -ne 0 ]]; then + if ! parted $disk -s -- mklabel gpt; then log_note "Failed to create GPT partition table on $disk" return 1 fi @@ -945,8 +935,7 @@ function set_partition if [[ $slicenum -eq 0 ]] || ! gpart show $disk >/dev/null 2>&1; then gpart destroy -F $disk >/dev/null 2>&1 - gpart create -s GPT $disk - if [[ $? -ne 0 ]]; then + if ! gpart create -s GPT $disk; then log_note "Failed to create GPT partition table on $disk" return 1 fi @@ -1144,9 +1133,8 @@ function fill_fs # destdir dirnum filenum bytes num_writes data mkdir -p $destdir/{1..$dirnum} for f in $destdir/{1..$dirnum}/$TESTFILE{1..$filenum}; do file_write -o create -f $f -b $bytes -c $num_writes -d $data \ - || return $? + || return done - return 0 } # Get the specified dataset property in parsable format or fail @@ -1835,8 +1823,7 @@ function zfs_zones_setup #zone_name zone_root zone_ip log_must rm -f $zone_conf # Install the zone - zoneadm -z $zone_name install - if (($? == 0)); then + if zoneadm -z $zone_name install; then log_note "SUCCESS: zoneadm -z $zone_name install" else log_fail "FAIL: zoneadm -z $zone_name install" @@ -1899,14 +1886,10 @@ function check_state # pool disk state{online,offline,degraded} if [[ -z $disk ]]; then #check pool state only - zpool get -H -o value health $pool \ - | grep -i "$state" > /dev/null 2>&1 + zpool get -H -o value health $pool | grep -qi "$state" else - zpool status -v $pool | grep "$disk" \ - | grep -i "$state" > /dev/null 2>&1 + zpool status -v $pool | grep "$disk" | grep -qi "$state" fi - - return $? } # @@ -1980,10 +1963,10 @@ function verify_filesys # pool filesystem dir log_must zpool import $search_path $pool - zdb -cudi $filesys > $zdbout 2>&1 - if [[ $? != 0 ]]; then + if ! zdb -cudi $filesys > $zdbout 2>&1; then log_note "Output: zdb -cudi $filesys" cat $zdbout + rm -f $zdbout log_fail "zdb detected errors with: '$filesys'" fi @@ -2056,10 +2039,8 @@ function stress_timeout log_note "Killing child processes after ${TIMEOUT} stress timeout." typeset pid for pid in $cpids; do - ps -p $pid > /dev/null 2>&1 - if (($? == 0)); then + ps -p $pid > /dev/null 2>&1 && log_must kill -USR1 $pid - fi done } @@ -2201,55 +2182,46 @@ function is_pool_resilvering #pool { check_pool_status "$1" "scan" \ "resilver[ ()0-9A-Za-z:_-]* in progress since" $2 - return $? } function is_pool_resilvered #pool { check_pool_status "$1" "scan" "resilvered " $2 - return $? } function is_pool_scrubbing #pool { check_pool_status "$1" "scan" "scrub in progress since " $2 - return $? } function is_pool_scrubbed #pool { check_pool_status "$1" "scan" "scrub repaired" $2 - return $? } function is_pool_scrub_stopped #pool { check_pool_status "$1" "scan" "scrub canceled" $2 - return $? } function is_pool_scrub_paused #pool { check_pool_status "$1" "scan" "scrub paused since " $2 - return $? } function is_pool_removing #pool { check_pool_status "$1" "remove" "in progress since " - return $? } function is_pool_removed #pool { check_pool_status "$1" "remove" "completed on" - return $? } function is_pool_discarding #pool { check_pool_status "$1" "checkpoint" "discarding" - return $? } function wait_for_degraded @@ -2338,22 +2310,17 @@ BEGIN { FS="."; } unused="" for disk in $disks; do # Check for mounted - grep "${disk}[sp]" /etc/mnttab >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" /etc/mnttab && continue # Check for swap - grep "${disk}[sp]" $sfi >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" $sfi && continue # check for dump device - grep "${disk}[sp]" $dmpi >/dev/null - (($? == 0)) && continue + grep -q "${disk}[sp]" $dmpi && continue # check to see if this disk hasn't been explicitly excluded # by a user-set environment variable - echo "${ZFS_HOST_DEVICES_IGNORE}" | grep "${disk}" > /dev/null - (($? == 0)) && continue + echo "${ZFS_HOST_DEVICES_IGNORE}" | grep -q "${disk}" && continue unused_candidates="$unused_candidates $disk" done - rm $sfi - rm $dmpi + rm $sfi $dmpi # now just check to see if those disks do actually exist # by looking for a device pointing to the first slice in @@ -2386,10 +2353,8 @@ function add_user_freebsd # # Assign 1000 as the base uid typeset -i uid=1000 while true; do - typeset -i ret pw useradd -u $uid -g $group -d $basedir/$user -m -n $user - ret=$? - case $ret in + case $? in 0) break ;; # The uid is not unique 65) ((uid += 1)) ;; @@ -2440,8 +2405,7 @@ function add_group_freebsd # typeset -i gid=1000 while true; do pw groupadd -g $gid -n $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; # The gid is not unique 65) ((gid += 1)) ;; @@ -2463,8 +2427,7 @@ function del_group_freebsd # typeset group=$1 pw groupdel -n $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist, or was deleted successfully. 0|6|65) return 0 ;; # Name already exists as a group name @@ -2504,8 +2467,7 @@ function add_group_illumos # typeset -i gid=100 while true; do groupadd -g $gid $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; # The gid is not unique 4) ((gid += 1)) ;; @@ -2519,8 +2481,7 @@ function del_group_illumos # typeset group=$1 groupmod -n $grp $grp > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist. 6) return 0 ;; # Name already exists as a group name @@ -2553,8 +2514,6 @@ function del_user_linux # if id $user > /dev/null 2>&1; then log_must_retry "currently used" 6 userdel $user fi - - return 0 } function add_group_linux # @@ -2565,8 +2524,7 @@ function add_group_linux # # Linux because for many distributions 1000 and under are reserved. while true; do groupadd $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in 0) return 0 ;; *) return 1 ;; esac @@ -2578,8 +2536,7 @@ function del_group_linux # typeset group=$1 getent group $group > /dev/null 2>&1 - typeset -i ret=$? - case $ret in + case $? in # Group does not exist. 2) return 0 ;; # Name already exists as a group name @@ -2858,7 +2815,6 @@ function get_config { typeset pool=$1 typeset config=$2 - typeset alt_root if ! poolexists "$pool" ; then return 1 @@ -2987,8 +2943,7 @@ function get_rootfs if [[ -z "$rootfs" ]]; then log_fail "Can not get rootfs" fi - zfs list $rootfs > /dev/null 2>&1 - if (($? == 0)); then + if datasetexists $rootfs; then echo $rootfs else log_fail "This is not a zfsroot system." @@ -3119,14 +3074,12 @@ function vdevs_in_pool # therefore we use the 'zpool status' output. typeset tmpfile=$(mktemp) zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile - for vdev in $@; do - grep -w ${vdev##*/} $tmpfile >/dev/null 2>&1 - [[ $? -ne 0 ]] && return 1 + for vdev in "$@"; do + grep -wq ${vdev##*/} $tmpfile || && return 1 done rm -f $tmpfile - - return 0; + return 0 } function get_max @@ -3385,9 +3338,7 @@ function zed_check return fi zedpids="$(pgrep -x zed)" -# ret1=$? zedpids2="$(pgrep -x lt-zed)" -# ret2=$? echo ${zedpids} ${zedpids2} } @@ -3589,18 +3540,14 @@ function set_tunable_impl case "$(uname)" in Linux) typeset zfs_tunables="/sys/module/$module/parameters" - [[ -w "$zfs_tunables/$tunable" ]] || return 1 - cat >"$zfs_tunables/$tunable" <<<"$value" - return $? + echo "$value" >"$zfs_tunables/$tunable" ;; FreeBSD) sysctl vfs.zfs.$tunable=$value - return "$?" ;; SunOS) [[ "$module" -eq "zfs" ]] || return 1 echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw - return $? ;; esac } @@ -3635,9 +3582,7 @@ function get_tunable_impl case "$(uname)" in Linux) typeset zfs_tunables="/sys/module/$module/parameters" - [[ -f "$zfs_tunables/$tunable" ]] || return 1 cat $zfs_tunables/$tunable - return $? ;; FreeBSD) sysctl -n vfs.zfs.$tunable @@ -3646,69 +3591,6 @@ function get_tunable_impl [[ "$module" -eq "zfs" ]] || return 1 ;; esac - - return 1 -} - -# -# Prints the current time in seconds since UNIX Epoch. -# -function current_epoch -{ - printf '%(%s)T' -} - -# -# Get decimal value of global uint32_t variable using mdb. -# -function mdb_get_uint32 -{ - typeset variable=$1 - typeset value - - value=$(mdb -k -e "$variable/X | ::eval .=U") - if [[ $? -ne 0 ]]; then - log_fail "Failed to get value of '$variable' from mdb." - return 1 - fi - - echo $value - return 0 -} - -# -# Set global uint32_t variable to a decimal value using mdb. -# -function mdb_set_uint32 -{ - typeset variable=$1 - typeset value=$2 - - mdb -kw -e "$variable/W 0t$value" > /dev/null - if [[ $? -ne 0 ]]; then - echo "Failed to set '$variable' to '$value' in mdb." - return 1 - fi - - return 0 -} - -# -# Set global scalar integer variable to a hex value using mdb. -# Note: Target should have CTF data loaded. -# -function mdb_ctf_set_int -{ - typeset variable=$1 - typeset value=$2 - - mdb -kw -e "$variable/z $value" > /dev/null - if [[ $? -ne 0 ]]; then - echo "Failed to set '$variable' to '$value' in mdb." - return 1 - fi - - return 0 } # @@ -4117,5 +3999,4 @@ function directory_diff # dir_a dir_b function replay_directory_diff # dir_a dir_b { LIBTEST_DIFF_ZIL_REPLAY=1 directory_diff "$@" - return $? } diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index 1450f7b660f9..e0d40f3d2de8 100644 --- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -98,7 +98,7 @@ function compare_acls # get_acl $src > $tmpsrc get_acl $tgt > $tmptgt typeset -i ret=0 - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt @@ -108,7 +108,7 @@ function compare_acls # get_compact_acl $src > $tmpsrc get_compact_acl $tgt > $tmptgt - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt @@ -166,7 +166,7 @@ function compare_xattrs # get_xattr $src > $tmpsrc get_xattr $tgt > $tmptgt typeset -i ret=0 - diff $tmpsrc $tmptgt > /dev/null 2>&1 + cmp $tmpsrc $tmptgt > /dev/null ret=$? rm -f $tmpsrc $tmptgt @@ -284,8 +284,7 @@ function get_ACE # ;; esac - ls $args $file > $tmpfile - (( $? != 0 )) && log_fail "FAIL: ls $args $file > $tmpfile" + log_must eval "ls $args $file > $tmpfile" while read line; do [[ -z $line ]] && continue if [[ $args == -vd ]]; then @@ -306,8 +305,7 @@ function get_ACE # fi done < $tmpfile - rm -f $tmpfile - (( $? != 0 )) && log_fail "FAIL: rm -f $tmpfile" + log_must rm -f $tmpfile } # @@ -362,30 +360,30 @@ function rwx_node #user node acl_spec|access case $acl_spec in *:read_data:*|read_data) chgusr_exec $user ls -l $node > /dev/null 2>&1 - return $? ;; + ;; *:write_data:*|write_data) if [[ -f ${node}/tmpfile ]]; then log_must rm -f ${node}/tmpfile fi chgusr_exec $user touch ${node}/tmpfile > \ /dev/null 2>&1 - return $? ;; + ;; *"execute:"*|execute) chgusr_exec $user find $node > /dev/null 2>&1 - return $? ;; + ;; esac else case $acl_spec in *:read_data:*|read_data) chgusr_exec $user cat $node > /dev/null 2>&1 - return $? ;; + ;; *:write_data:*|write_data) chgusr_exec $user dd if=/usr/bin/ls of=$node > \ /dev/null 2>&1 - return $? ;; + ;; *"execute:"*|execute) ZFS_ACL_ERR_STR=$(chgusr_exec $user $node 2>&1) - return $? ;; + ;; esac fi } @@ -459,9 +457,7 @@ function get_user_group #uid log_fail "UID not defined." fi - value=$(id $uid) - - if [[ $? -eq 0 ]]; then + if value=$(id $uid); then value=${value##*\(} value=${value%%\)*} echo $value diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh index d88217e5cad7..65c15388cf20 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh @@ -57,40 +57,41 @@ log_onexit cleanup log_note "Testing access to FILE" log_must touch $TESTDIR/file.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/file.0 -getfacl $TESTDIR/file.0 2> /dev/null | grep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:rw-$" -if [ "$?" -eq "0" ]; then - # Should be able to write to file - log_must user_run $ZFS_ACL_STAFF1 \ - "echo 'echo test > /dev/null' > $TESTDIR/file.0" +if ! getfacl $TESTDIR/file.0 2> /dev/null | + grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-" +then + log_note "$(getfacl $TESTDIR/file.0 2> /dev/null)" + log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified" +fi - # Since $TESTDIR is 777, create a new dir with controlled permissions - # for testing that creating a new file is not allowed. - log_must mkdir $TESTDIR/dir.0 - log_must chmod 700 $TESTDIR/dir.0 - log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 - # Confirm permissions - if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwxrw----+"; then - msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}') - log_note "expected mask drwxrw----+ but found $msk" - log_fail "Expected permissions were not set." - fi - getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:rw-$" - if [ "$?" -ne "0" ]; then - acl=$(getfacl $TESTDIR/dir.0 2> /dev/null) - log_note $acl - log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set." - fi - # Should NOT be able to create new file - log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1" +# Should be able to write to file +log_must user_run $ZFS_ACL_STAFF1 \ + "echo 'echo test > /dev/null' > $TESTDIR/file.0" - # Root should be able to run file, but not user - chmod +x $TESTDIR/file.0 - log_must $TESTDIR/file.0 - log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0 +# Since $TESTDIR is 777, create a new dir with controlled permissions +# for testing that creating a new file is not allowed. +log_must mkdir $TESTDIR/dir.0 +log_must chmod 700 $TESTDIR/dir.0 +log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0 +# Confirm permissions +msk=$(ls -ld $TESTDIR/dir.0 | awk '{print $1}') +if ! [ "$msk" = "drwxrw----+" ]; then + log_note "expected mask drwxrw----+ but found $msk" + log_fail "Expected permissions were not set." +fi - log_pass "POSIX ACL mode works on files" -else - log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rw' as specified" +if ! getfacl $TESTDIR/dir.0 2> /dev/null | + grep -qFx "group:$ZFS_ACL_STAFF_GROUP:rw-" +then + log_note "$(getfacl $TESTDIR/dir.0 2> /dev/null)" + log_fail "ACL group:$ZFS_ACL_STAFF_GROUP:rw- was not set." fi +# Should NOT be able to create new file +log_mustnot user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.1" + +# Root should be able to run file, but not user +chmod +x $TESTDIR/file.0 +log_must $TESTDIR/file.0 +log_mustnot user_run $ZFS_ACL_STAFF1 $TESTDIR/file.0 + +log_pass "POSIX ACL mode works on files" diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh index 8764dd5a21c4..ac718ec58897 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh @@ -58,9 +58,9 @@ if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then log_note "expected mask drwx-wx---+ but found $msk" log_fail "Expected permissions were not set." fi -getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ - "^group:$ZFS_ACL_STAFF_GROUP:-wx$" -if [ "$?" -eq "0" ]; then +if getfacl $TESTDIR/dir.0 2> /dev/null | + grep -q "^group:$ZFS_ACL_STAFF_GROUP:-wx$" +then # Should be able to create file in directory log_must user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.0" diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh index 3e9357063bed..6f2f54ebdddc 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_001_pos.ksh @@ -59,12 +59,6 @@ function cleanup { fi } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Valid datasets are accepted as bootfs property values" log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh index a5bc7753e96e..172b69400807 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_002_neg.ksh @@ -60,12 +60,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Invalid datasets are rejected as boot property values" log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh index 78accbc82da8..78559dd186c8 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh @@ -54,12 +54,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_onexit cleanup log_assert "Valid pool names are accepted by zpool set bootfs" diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh index 97b456aade3e..5ea0f6c1a95f 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_004_neg.ksh @@ -55,12 +55,6 @@ function cleanup { } -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - log_assert "Invalid pool names are rejected by zpool set bootfs" log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh index c5d7b2e3f4a5..2738d3916e2c 100755 --- a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh @@ -44,12 +44,6 @@ verify_runnable "global" -zpool set 2>&1 | grep bootfs > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "bootfs pool property not supported on this release." -fi - VDEV1=$TESTDIR/bootfs_006_pos_a.$$.dat VDEV2=$TESTDIR/bootfs_006_pos_b.$$.dat VDEV3=$TESTDIR/bootfs_006_pos_c.$$.dat diff --git a/tests/zfs-tests/tests/functional/btree/btree_negative.ksh b/tests/zfs-tests/tests/functional/btree/btree_negative.ksh index cefcbc51e796..667ac87b4fea 100755 --- a/tests/zfs-tests/tests/functional/btree/btree_negative.ksh +++ b/tests/zfs-tests/tests/functional/btree/btree_negative.ksh @@ -29,10 +29,7 @@ # looks for return values that correspond to a core dump and cause a test # failure. -btree_test -n insert_duplicate -[[ $? -eq 0 ]] && log_fail "Failure from insert_duplicate" - -btree_test -n remove_missing -[[ $? -eq 0 ]] && log_fail "Failure from remove_missing" +btree_test -n insert_duplicate && log_fail "Failure from insert_duplicate" +btree_test -n remove_missing && log_fail "Failure from remove_missing" log_pass "Btree negative tests passed" diff --git a/tests/zfs-tests/tests/functional/cache/cache.kshlib b/tests/zfs-tests/tests/functional/cache/cache.kshlib index 58e2385ea0c9..9948c6280185 100644 --- a/tests/zfs-tests/tests/functional/cache/cache.kshlib +++ b/tests/zfs-tests/tests/functional/cache/cache.kshlib @@ -146,9 +146,3 @@ function verify_cache_device log_note "Can not find device: $device" return 1 } - -function verify_cache_support -{ - zpool upgrade -v | grep "Cache devices" > /dev/null 2>&1 - return $? -} diff --git a/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib b/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib index f0fe1bbaa886..ad5b5367ae48 100644 --- a/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib +++ b/tests/zfs-tests/tests/functional/casenorm/casenorm.kshlib @@ -50,13 +50,8 @@ function delete_file { typeset name=$TESTDIR/$1 - rm $name >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - return 1 - fi - - if [[ -f $name ]] ; then + rm $name >/dev/null 2>&1 || return 1 + if [ -f $name ]; then return 2 fi } @@ -86,10 +81,7 @@ function lookup_file_ci function lookup_any { for name in $NAMES_ALL ; do - lookup_file $name - if [[ $? -eq 0 ]] ; then - return 0 - fi + lookup_file $name && return done return 1 diff --git a/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib b/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib index a828ba29065e..c937e90614c8 100644 --- a/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib +++ b/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib @@ -47,9 +47,10 @@ function log_program zfs program $cmdargs >$tmpout 2>$tmperr typeset ret=$? - log_note "input:\n$(cat $tmpin)" - log_note "output:\n$(cat $tmpout)" - log_note "error:\n$(cat $tmperr)" + log_note $'input:\n'"$(<$tmpin)" + log_note $'output:\n'"$(<$tmpout)" + log_note $'error:\n'"$(<$tmperr)" + log_note "ret: $ret" # # Verify correct return value @@ -64,35 +65,29 @@ function log_program # respectively. # if [[ -f "$basename.out" ]] && [[ $expectexit -eq 0 ]]; then - - outdiff=$(diff "$basename.out" "$tmpout") - if [[ $? -ne 0 ]]; then + if ! outdiff=$(diff "$basename.out" "$tmpout"); then output=$(<$tmpout) rm $tmpout $tmperr $tmpin - log_fail "Output mismatch. Expected:\n" \ - "$(<$basename.out)\nBut got:\n$output\n" \ - "Diff:\n$outdiff" + log_fail $'Output mismatch. Expected:\n' \ + "$(<$basename.out)"$'\nBut got:\n'"$output"$'\n' \ + $'Diff:\n'"$outdiff" fi elif [[ -f "$basename.err" ]] && [[ $expectexit -ne 0 ]]; then - - outdiff=$(diff "$basename.err" "$tmperr") - if [[ $? -ne 0 ]]; then + if ! outdiff=$(diff "$basename.err" "$tmperr"); then outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin - log_fail "Error mismatch. Expected:\n" \ - "$(<$basename.err)\nBut got:\n$outputerror\n" \ - "Diff:\n$outdiff" + log_fail $'Error mismatch. Expected:\n' \ + "$(<$basename.err)"$'\nBut got:\n'"$outputerror"$'\n' \ + $'Diff:\n'"$outdiff" fi elif [[ -n $expecterror ]] && [[ $expectexit -ne 0 ]]; then - - grep -q "$expecterror" $tmperr - if [[ $? -ne 0 ]]; then + if ! grep -q "$expecterror" $tmperr; then outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin - log_fail "Error mismatch. Expected to contain:\n" \ - "$expecterror\nBut got:\n$outputerror\n" + log_fail $'Error mismatch. Expected to contain:\n' \ + "$expecterror"$'\nBut got:\n'"$outputerror"$'\n' fi elif [[ $expectexit -ne 0 ]]; then diff --git a/tests/zfs-tests/tests/functional/chattr/setup.ksh b/tests/zfs-tests/tests/functional/chattr/setup.ksh index d4b3cdcaba92..85c9b6ea6351 100755 --- a/tests/zfs-tests/tests/functional/chattr/setup.ksh +++ b/tests/zfs-tests/tests/functional/chattr/setup.ksh @@ -47,10 +47,8 @@ log_must add_user $QGROUP $QUSER2 # # chmod 0750 $HOME # -user_run $QUSER1 zfs list -if [ $? -ne 0 ]; then +user_run $QUSER1 zfs list || log_unsupported "Test user $QUSER1 cannot execute zfs utilities" -fi DISK=${DISKS%% *} default_setup $DISK diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh index 36f1929dd193..0e4dcf8e6f1e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_003_pos.ksh @@ -60,8 +60,8 @@ log_note "$DEVS" log_must dd if=/dev/${DISK[0]} of=/dev/${DISK[1]} bs=1K count=256 conv=notrunc for x in 0 1 ; do - config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) - (( $? != 0)) && log_fail "failed to get config_count from DISK[$x]" + config_count=$(zdb -l $DEV_RDSKDIR/${DISK[$x]} | grep -c features_for_read) || + log_fail "failed to get config_count from DISK[$x]" log_note "vdev $x: message_count $config_count" [ $config_count -ne ${config_count[$x]} ] && \ log_fail "zdb produces an incorrect number of configuration dumps." diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh index 4f661262a72d..d79933fd5b59 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_checksum.ksh @@ -53,13 +53,13 @@ log_note "file $init_data has object number $obj" sync_pool $TESTPOOL output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" cksum_expected=$(sed -Ene 's/^.+ cksum=([a-z0-9:]+)$/\1/p' <<< "$output") log_note "expecting cksum $cksum_expected" output=$(zdb -R $TESTPOOL $dva:c 2> /dev/null) -result=$(grep $cksum_expected <<< "$output") -(( $? != 0 )) && log_fail "zdb -R failed to print the correct checksum" +grep -q $cksum_expected <<<"$output" || + log_fail "zdb -R failed to print the correct checksum" log_pass "zdb -R generates the correct checksum" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh index 9daf61f82f28..c7e10bac4570 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh @@ -63,52 +63,44 @@ done sync_pool $TESTPOOL true # get object number of file -listing=$(ls -i $init_data) -set -A array $listing -obj=${array[0]} +read -r obj _ < <(ls -i $init_data) log_note "file $init_data has object number $obj" output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + | grep -m 1 "L0 DVA") dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output") log_note "block 0 of $init_data has a DVA of $dva" # use the length reported by zdb -ddddddbbbbbb size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output") # convert sizes to decimal -lsize=$(echo $size_str | cut -d/ -f 1) +IFS='/' read -r lsize psize _ <<<"$size_str" lsize_orig=$lsize -lsize=${lsize%?} -lsize_bytes=$((16#$lsize)) -psize=$(echo $size_str | cut -d/ -f 2) psize_orig=$psize +lsize=${lsize%?} psize=${psize%?} +lsize_bytes=$((16#$lsize)) psize_bytes=$((16#$psize)) log_note "block size $size_str" # Get the ZSTD header reported by zdb -Z -zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output") -zstd_size=$(echo "$zstd_str" | cut -d: -f 1) +read -r zstd_size zstd_version zstd_level < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<<"$output") log_note "ZSTD compressed size $zstd_size" (( $psize_bytes < $zstd_size )) && log_fail \ "zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)" -zstd_version=$(echo "$zstd_str" | cut -d: -f 2) log_note "ZSTD version $zstd_version" -zstd_level=$(echo "$zstd_str" | cut -d: -f 3) log_note "ZSTD level $zstd_level" (( $zstd_level != $random_level )) && log_fail \ "zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)" -vdev=$(echo "$dva" | cut -d: -f 1) -offset=$(echo "$dva" | cut -d: -f 2) +IFS=':' read -r vdev offset _ <<<"$dva" # Check the first 1024 bytes output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null) -outsize=$(wc -c <<< "$output") -(( $outsize != $blksize )) && log_fail \ -"zdb -Z failed to decompress the data to the expected length ($outsize != $lsize_bytes)" -cmp $init_data - <<< "$output" -(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly" +(( ${#output} + 1 != $blksize )) && log_fail \ +"zdb -Z failed to decompress the data to the expected length (${#output} != $lsize_bytes)" +cmp $init_data - <<< "$output" || + log_fail "zdb -R :dr failed to decompress the data properly" log_pass "zdb -Z flag (ZSTD compression header) works as expected" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh index 0218e2e16b68..84f758904bd9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_002_pos.ksh @@ -65,8 +65,7 @@ while (( $j < ${#size[*]} )); do typeset cmdline="zfs create -s -V ${size[j]} \ $TESTPOOL/${TESTVOL}${size[j]}" - str=$(eval $cmdline 2>&1) - if (( $? == 0 )); then + if str=$(eval $cmdline 2>&1); then log_note "SUCCESS: $cmdline" log_must datasetexists $TESTPOOL/${TESTVOL}${size[j]} elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh index 993c6436a7b1..d3855cb315c1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_013_pos.ksh @@ -63,8 +63,7 @@ while (( $j < ${#size[*]} )); do typeset cmdline="zfs create -s -V ${size[j]} \ $TESTPOOL/${LONGFSNAME}${size[j]}" - str=$(eval $cmdline 2>&1) - if (( $? == 0 )); then + if str=$(eval $cmdline 2>&1); then log_note "SUCCESS: $cmdline" log_must datasetexists $TESTPOOL/${LONGFSNAME}${size[j]} elif [[ $str == *${VOL_LIMIT_KEYWORD1}* || \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh index 703ae8043d48..1e22da0045c7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_dryrun.ksh @@ -87,12 +87,11 @@ function dry_create_parseable typeset found_create=false log_note "$0: ${cmd[@]}" - out=$("${cmd[@]}") - (( $? == 0 )) || + out=$("${cmd[@]}") || log_fail "unexpected failure getting stdout from '${cmd[@]}'" datasetexists "$TESTPOOL/$TESTFS1" && log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'" - echo "$out" | while IFS=$'\t' read -A toks; do + while IFS=$'\t' read -A toks; do log_note "verifying ${toks[@]}" case ${toks[0]} in create) @@ -118,7 +117,7 @@ function dry_create_parseable log_fail "Unexpected line ${toks[@]}" ;; esac - done + done <<<"$out" log_must test "$found_create" == "yes, I found create" log_must test "extra props: ${!exp[@]}" == "extra props: " diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh index acab500062ca..b18ffa404c42 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_verbose.ksh @@ -58,12 +58,11 @@ function dry_create_parseable done log_note "$0: ${cmd[@]}" - out=$("${cmd[@]}") - (( $? == 0 )) || + out=$("${cmd[@]}") || log_fail "unexpected failure getting stdout from '${cmd[@]}'" datasetexists "$TESTPOOL/$TESTFS1" || log_fail "$TESTPOOL/$TESTFS1 unexpectedly created by '${cmd[@]}'" - echo "$out" | while IFS=$'\t' read -A toks; do + while IFS=$'\t' read -A toks; do log_note "verifying ${toks[@]}" case ${toks[0]} in create_ancestors) @@ -107,7 +106,7 @@ function dry_create_parseable log_fail "Unexpected line ${toks[@]}" ;; esac - done + done <<<"$out" log_must test "$found_create" == "yes, I found create" log_must test "extra props: ${!exp[@]}" == "extra props: " diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh index 88822adfc761..6717787d06e6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh @@ -85,7 +85,7 @@ for dst in ${dataset[@]}; do for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb) do - log_must eval "zfs get $opt $prop $dst > /dev/null" + log_must eval "zfs get $opt $prop $dst > /dev/null 2>&1" done done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh index c527cef087af..13685ef6f4bc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_005_neg.ksh @@ -93,7 +93,7 @@ function test_options for dst in ${dataset[@]}; do for opt in $opts; do for prop in $props; do - log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1" done done done @@ -113,7 +113,7 @@ function test_options_bookmarks for dst in ${bookmark[@]}; do for opt in $opts; do for prop in $props; do - log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null 2>&1" done done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh index 296fe99968c8..9f3dd47cde7d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_008_pos.ksh @@ -53,7 +53,7 @@ set -A options " " "-r" "-H" "-p" "-rHp" "-o name" \ set -A props type used available creation volsize referenced compressratio \ mounted origin recordsize quota reservation mountpoint sharenfs \ checksum compression atime devices exec readonly setuid snapdir \ - aclinherit canmount primarycache secondarycache \ + aclinherit canmount primarycache secondarycache version \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ userquota@root groupquota@root userused@root groupused@root if is_freebsd; then @@ -62,11 +62,6 @@ else set -A props ${props[*]} zoned acltype fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - set -A props ${props[*]} version -fi - set -A dataset $TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh index 2580070e670c..1e80d4d2b7ef 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh @@ -55,7 +55,7 @@ log_onexit depth_fs_cleanup set -A all_props type used available creation volsize referenced \ compressratio mounted origin recordsize quota reservation mountpoint \ sharenfs checksum compression atime devices exec readonly setuid \ - snapdir aclinherit canmount primarycache secondarycache \ + snapdir aclinherit canmount primarycache secondarycache version \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ userquota@root groupquota@root userused@root groupused@root if is_freebsd; then @@ -64,11 +64,6 @@ else set -A all_props ${all_props[*]} zoned acltype fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - set -A all_props ${all_props[*]} version -fi - depth_fs_setup mntpnt=$(get_prop mountpoint $DEPTH_FS) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh index 62f255ca38b7..aba317f54237 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_inherit/zfs_inherit_001_neg.ksh @@ -47,14 +47,7 @@ verify_runnable "both" # Define uninherited properties and their short name. typeset props_str="type used available avail creation referenced refer \ compressratio ratio mounted origin quota reservation \ - reserv volsize volblocksize volblock" - -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - props_str="$props_str version" -fi - -set -A prop $props_str canmount + reserv volsize volblocksize volblock version canmount" log_assert "'zfs inherit' should return an error when attempting to inherit" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib index f7461437c615..4a85999b4ab8 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib @@ -42,8 +42,7 @@ function key_available function key_unavailable { - key_available $1 && return 1 - return 0 + ! key_available $1 } function verify_keyformat diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh index c0cb693f6ce6..b42b2496e4b9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_005_pos.ksh @@ -77,14 +77,13 @@ cd $TESTDIR || \ zfs $mountcmd $TESTPOOL/$TESTFS ret=$? if is_linux || is_freebsd; then - (( ret == 0 )) || \ - log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ - "unexpected return code of $ret." + expected=0 else - (( ret == 1 )) || \ - log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ - "unexpected return code of $ret." + expected=1 fi +(( ret == expected )) || \ + log_fail "'zfs $mountcmd $TESTPOOL/$TESTFS' " \ + "unexpected return code of $ret." log_note "Make sure the filesystem $TESTPOOL/$TESTFS is unmounted" if is_linux || is_freebsd; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh index 8a6cd8c409be..2b4a086965e8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_001_pos.ksh @@ -105,10 +105,7 @@ for orig_fs in $datasets ; do typeset -i i=0 while (( i < ${#orig_snap[*]} )); do - file_write -o create -f ${orig_data[$i]} -b 512 \ - -c 8 >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Writing data into zfs filesystem fails." + log_must eval "file_write -o create -f ${orig_data[$i]} -b 512 -c 8 >/dev/null 2>&1" log_must zfs snapshot ${orig_snap[$i]} if (( i < 1 )); then log_must eval "zfs send ${orig_snap[$i]} > ${bkup[$i]}" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh index 37fe515e23f7..6cda13690cbd 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_009_neg.ksh @@ -92,11 +92,10 @@ typeset -i i=0 while (( i < ${#validopts[*]} )); do log_mustnot eval "zfs recv < $bkup" - echo ${validopts[i]} | grep "d" >/dev/null 2>&1 - if (( $? != 0 )); then - log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup" - else + if echo ${validopts[i]} | grep -q "d"; then log_mustnot eval "zfs recv ${validopts[i]} $ctr1 $ctr2 < $bkup" + else + log_mustnot eval "zfs recv ${validopts[i]} $fs2 $fs3 < $bkup" fi (( i += 1 )) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh index 4638b63d72ea..0a5b6c36111b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/cleanup.ksh @@ -33,11 +33,7 @@ default_cleanup_noexit -if [[ -d $TESTDIR2 ]]; then - rm -rf $TESTDIR2 - if (( $? != 0 )); then - log_unresolved Could not remove $TESTDIR2 - fi -fi +rm -rf $TESTDIR2 || + log_unresolved Could not remove $TESTDIR2 log_pass diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh index 788e093fb2ca..03701d4f5522 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/setup.ksh @@ -36,12 +36,9 @@ DISK=${DISKS%% *} default_setup_noexit "$DISK" "true" "true" -if [[ -d $TESTDIR2 ]]; then - rm -rf $TESTDIR2 - if (( $? != 0 )); then - log_unresolved Could not remove $TESTDIR2 - fi -fi +rm -rf $TESTDIR2 || + log_unresolved Could not remove $TESTDIR2 + log_must zfs set compression=off $TESTPOOL/$TESTFS log_must zfs create -o compression=off $TESTPOOL/$DATAFS log_must zfs set mountpoint=$TESTDIR2 $TESTPOOL/$DATAFS diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib index af1c2f7bedaf..cafffbd85266 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib @@ -92,8 +92,7 @@ function cleanup fi if [[ ${dataset[i]}-new != *@* ]] ; then - zfs rename ${dataset[i]}-new ${dataset[i]} - if [[ $? -ne 0 ]]; then + if ! zfs rename ${dataset[i]}-new ${dataset[i]}; then typeset newfs=${dataset[i]}-new typeset oldfs=${dataset[i]} typeset mntp=$(get_prop mountpoint $newfs) @@ -120,8 +119,6 @@ function cmp_data #<$1 src data, $2 tgt data> typeset src=$1 typeset tgt=$2 - cmp $src $tgt >/dev/null 2>&1 - - return $? + cmp $src $tgt >/dev/null } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh index b18433085ed5..2c7bac851608 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_001_pos.ksh @@ -96,9 +96,7 @@ log_must zfs set mountpoint=$TESTDIR1 $rst_root file_write -o create -f $init_data -b $BLOCK_SIZE -c $WRITE_COUNT log_must zfs snapshot $init_snap -zfs send $init_snap > $full_bkup -(( $? != 0 )) && \ - log_fail "'zfs send' fails to create full send" +log_must eval "zfs send $init_snap > $full_bkup" log_note "Verify the send stream is valid to receive." @@ -111,9 +109,7 @@ log_note "Verify 'zfs send -i' can create incremental send stream." file_write -o create -f $inc_data -b $BLOCK_SIZE -c $WRITE_COUNT -d 0 log_must zfs snapshot $inc_snap -zfs send -i $init_snap $inc_snap > $inc_bkup -(( $? != 0 )) && \ - log_fail "'zfs send -i' fails to create incremental send" +log_must eval "zfs send -i $init_snap $inc_snap > $inc_bkup" log_note "Verify the incremental send stream is valid to receive." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh index 42bdddd2cc18..c55ce08d006e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_002_pos.ksh @@ -66,12 +66,8 @@ function do_testing # log_must zfs set $property=$prop_val $fs file_write -o create -f $origfile -b $BLOCK_SIZE -c $WRITE_COUNT log_must zfs snapshot $snap - zfs send $snap > $stream - (( $? != 0 )) && \ - log_fail "'zfs send' fails to create send streams." - zfs receive -d $ctr <$stream - (( $? != 0 )) && \ - log_fail "'zfs receive' fails to receive send streams." + log_must eval "zfs send $snap > $stream" + log_must eval "zfs receive -d $ctr <$stream" #verify receive result ! datasetexists $rstfs && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh index f1befe60c373..0ddafe178e3a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/property_alias_001_pos.ksh @@ -91,9 +91,7 @@ typeset -i i=0 for ds in $pool $fs $vol; do for propname in ${ro_prop[*]}; do - zfs get -pH -o value $propname $ds >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Get the property $proname of $ds failed." + log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1" done i=0 while (( i < ${#rw_prop[*]} )); do @@ -120,9 +118,7 @@ for ds in $pool $fs $vol; do done if [[ $ds == $vol ]]; then for propname in "volblocksize" "volblock" ; do - zfs get -pH -o value $propname $ds >/dev/null 2>&1 - (( $? != 0 )) && \ - log_fail "Get the property $propname of $ds failed." + log_must eval "zfs get -pH -o value $propname $ds >/dev/null 2>&1" done fi done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh index de6d83d2270c..b929047cf129 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/reservation_001_neg.ksh @@ -70,15 +70,7 @@ function set_n_check # data-set j=0 while (( $j < ${#suffix[*]} )); do - zfs set \ - reservation=${values[$i]}${suffix[$j]} $obj \ - > /dev/null 2>&1 - if [ $? -eq 0 ] - then - log_note "zfs set \ - reservation=${values[$i]}${suffix[$j]} $obj" - log_fail "The above reservation set returned 0!" - fi + log_mustnot zfs set reservation=${values[$i]}${suffix[$j]} $obj new_resv_val=$(get_prop reservation $obj) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh index 7177fac202d0..e24376a2bf74 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/ro_props_001_pos.ksh @@ -55,18 +55,13 @@ typeset ro_props="type used creation referenced refer compressratio \ mounted origin" typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ sharenfs checksum compression compress atime devices exec readonly rdonly \ - setuid" + setuid version" if is_freebsd; then snap_ro_props+=" jailed" else snap_ro_props+=" zoned" fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - snap_ro_props="$snap_ro_props version" -fi - function cleanup { datasetexists $TESTPOOL/$TESTVOL@$TESTSNAP && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh index bd11ea088333..8ab52679eb9a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/user_property_004_pos.ksh @@ -68,32 +68,19 @@ function nonexist_user_prop log_assert "User property has no effect to snapshot until 'Snapshot properties' supported." log_onexit cleanup -typeset snap_property= - -zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1 -if (( $? == 0 )) ; then - snap_property="true" -fi - for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL ; do typeset fssnap=$fs@snap prop_name=$(valid_user_property 10) value=$(user_property_value 16) - log_must eval "zfs set $prop_name='$value' $fs" - log_must eval "check_user_prop $fs $prop_name '$value'" + log_must zfs set $prop_name="$value" $fs + log_must check_user_prop $fs $prop_name "$value" log_must zfs snapshot $fssnap - if [[ -n $snap_property ]] ; then - log_mustnot nonexist_user_prop $prop_name $fssnap + log_mustnot nonexist_user_prop $prop_name $fssnap - log_must eval "zfs set $prop_name='$value' $fssnap" - log_mustnot nonexist_user_prop $prop_name $fssnap - else - log_must nonexist_user_prop $prop_name $fssnap - log_mustnot eval "zfs set $prop_name='$value' $fssnap" - log_must nonexist_user_prop $prop_name $fssnap - fi + log_must zfs set $prop_name="$value" $fssnap + log_mustnot nonexist_user_prop $prop_name $fssnap done log_pass "User properties has effect upon snapshot." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh index cf5ef5116e90..318a9aae6b45 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/version_001_neg.ksh @@ -66,11 +66,7 @@ function set_n_check # data-set orig_val=$(get_prop version $obj) while (($i < ${#values[*]})); do - zfs set version=${values[$i]} $obj > /dev/null 2>&1 - if [[ $? -eq 0 ]]; then - log_note "zfs set version=${values[$i]} $obj" - log_fail "The above version set returned 0!" - fi + log_mustnot eval "zfs set version=${values[$i]} $obj > /dev/null 2>&1" new_val=$(get_prop version $obj) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib index 04886e38c2d3..2858275cf2b9 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib @@ -97,8 +97,8 @@ function set_n_check_prop if [[ "$expect_value" != "" && "$cur_value" != "$old_value" ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - should equal with '$old_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "should equal '$old_value'." fi fi } @@ -119,8 +119,8 @@ function cleanup_user_prop typeset prop for prop in $user_prop; do - zfs inherit $prop $dt - (($? != 0)) && log_must zfs inherit $prop $dt + zfs inherit $prop $dt || + log_must zfs inherit $prop $dt done done } @@ -225,9 +225,7 @@ function user_property_value { typeset -i len=${1:-100} - typeset value=$(random_string ALL_CHAR $len) - - echo "$value" + random_string ALL_CHAR $len } # @@ -254,14 +252,9 @@ function get_source { typeset prop=$1 typeset dataset=$2 - typeset source - source=$(zfs get -H -o source $prop $dataset) - if (($? != 0)); then + zfs get -H -o source $prop $dataset || log_fail "Unable to get $prop source for dataset $dataset" - fi - - echo "$source" } # @@ -330,12 +323,9 @@ function check_prop_received typeset prop="$2" typeset value="$3" - received=$(zfs get -H -o received "$prop" "$dataset") - if (($? != 0)); then - log_fail "Unable to get $prop received value for dataset" \ - "$dataset" - fi - if [ "$received" = "$value" ] + received=$(zfs get -H -o received "$prop" "$dataset") || + log_fail "Unable to get $prop received value for dataset $dataset" + [ "$received" = "$value" ] } # @@ -351,9 +341,7 @@ function check_prop_missing typeset dataset="$1" typeset prop="$2" - value=$(zfs get -H -o value "$prop" "$dataset") - if (($? != 0)); then + value=$(zfs get -H -o value "$prop" "$dataset") || log_fail "Unable to get $prop value for dataset $dataset" - fi [ "$value" = "-" ] } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh index 013e04ba311f..ea9f348e0e5b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_005_pos.ksh @@ -72,20 +72,17 @@ while (( i < ${#shareopts[*]} )) do log_must zfs set sharenfs="${shareopts[i]}" $TESTPOOL/$TESTFS - option=`get_prop sharenfs $TESTPOOL/$TESTFS` + option=$(get_prop sharenfs $TESTPOOL/$TESTFS) if [[ $option != ${shareopts[i]} ]]; then log_fail "get sharenfs failed. ($option != ${shareopts[i]})" fi # Verify the single option after the leading 'ro' or 'rw'. if is_linux; then - option=`echo "$option" | cut -f2 -d','` + IFS=',' read -r _ option _ <<<"$option" fi - showshares_nfs | grep $option > /dev/null 2>&1 - if (( $? != 0 )); then - log_fail "The '$option' option was not found in share output." - fi + log_must eval "showshares_nfs | grep -q $option" ((i = i + 1)) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh index c64157cee601..553605000d1b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_007_neg.ksh @@ -63,10 +63,7 @@ do log_note "Setting sharenfs=${badopts[i]} $i " log_mustnot zfs set sharenfs="${badopts[i]}" $TESTPOOL/$TESTFS - showshares_nfs | grep $option > /dev/null 2>&1 - if (( $? == 0 )); then - log_fail "An invalid setting '$option' was propagated." - fi + log_mustnot eval "showshares_nfs | grep -q ${badopts[i]}" # # To global zone, sharenfs must be set 'off' before malformed testing. diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh index cf8c84cfe301..ddd65e88859b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_009_neg.ksh @@ -63,8 +63,7 @@ if [[ $sharenfs_val == off ]]; then log_must zfs set sharenfs=on $fs fi -showshares_nfs | grep $mpt >/dev/null 2>&1 -if (( $? != 0 )); then +if ! showshares_nfs | grep -q $mpt; then log_must zfs share $fs fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh index 16926a48ddc4..62bf71390c70 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_004_neg.ksh @@ -59,18 +59,18 @@ while ((ret == 0)); do ret=$? if ((ret != 0)); then - len=$(echo $basefs| wc -c) + len=${#basefs} log_note "The deeply-nested filesystem len: $len" # - # Make sure there are at lease 2 characters left + # Make sure there are at least 2 characters left # for snapshot name space, otherwise snapshot name # is incorrect # if ((len >= 255)); then datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} - len=$(echo $basefs| wc -c) + len=${#basefs} fi break fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh index c133403ac84a..be5bbc8346d6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_005_neg.ksh @@ -60,7 +60,7 @@ while ((ret == 0)); do ret=$? if ((ret != 0)); then - len=$(echo $basefs | wc -c) + len=$(( ${#basefs} + 1 )) # +1 for NUL log_note "The deeply-nested filesystem len: $len" # @@ -71,7 +71,7 @@ while ((ret == 0)); do if ((len >= 255)); then datasetexists $basefs && destroy_dataset $basefs -r basefs=${basefs%/*} - len=$(echo $basefs| wc -c) + len=$(( ${#basefs} + 1 )) fi break fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh index 9499dca21e78..40b936dee977 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_007_neg.ksh @@ -72,18 +72,13 @@ typeset ro_props="type used available avail creation referenced refer compressra mounted origin" typeset snap_ro_props="volsize recordsize recsize quota reservation reserv mountpoint \ sharenfs checksum compression compress atime devices exec readonly rdonly \ - setuid" + setuid version" if is_freebsd; then snap_ro_props+=" jailed" else snap_ro_props+=" zoned" fi -zfs upgrade -v > /dev/null 2>&1 -if [[ $? -eq 0 ]]; then - snap_ro_props="$snap_ro_props version" -fi - for fs in $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL $TESTPOOL/$TESTCTR $TESTPOOL ; do typeset fssnap=$fs@snap diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib index 525dfd162957..3fc5509a612e 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount.kshlib @@ -53,7 +53,7 @@ function do_unmount #cmd #opt #mnt #expect zfs $cmd $opt $mnt ret=$? - if (( ret != expect)); then + if (( ret != expect )); then log_fail "'zfs $cmd $opt $mnt' " \ "unexpected return code of $ret." fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh index 89cc4b0d3082..80a2213d9aa8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh @@ -64,12 +64,8 @@ for ashift in ${ashifts[@]} do log_must zpool create $TESTPOOL $disk1 log_must zpool add -o ashift=$ashift $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 @@ -81,12 +77,8 @@ do log_must zpool create $TESTPOOL $disk1 log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $ashift log_must zpool add $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must set_tunable64 VDEV_FILE_PHYSICAL_ASHIFT $orig_ashift log_must zpool destroy $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh index 4637fe0d84a3..df04ecc5b89e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_prop_ashift.ksh @@ -70,12 +70,8 @@ for ashift in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 log_must zpool add $TESTPOOL $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift value to "\ - "$ashift" - fi + log_must verify_ashift $disk2 $ashift + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 @@ -88,12 +84,8 @@ do do log_must zpool create -o ashift=$ashift $TESTPOOL $disk1 log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2 - verify_ashift $disk2 $cmdval - if [[ $? -ne 0 ]] - then - log_fail "Device was added without setting ashift " \ - "value to $cmdval" - fi + log_must verify_ashift $disk2 $cmdval + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh index 618c6992edb4..745f60507bed 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_attach/attach-o_ashift.ksh @@ -69,23 +69,14 @@ do for cmdval in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1 - verify_ashift $disk1 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Pool was created without setting ashift " \ - "value to $ashift" - fi + log_must verify_ashift $disk1 $ashift + # ashift_of(attached_disk) <= ashift_of(existing_vdev) if [[ $cmdval -le $ashift ]] then log_must zpool attach -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was attached without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift else log_mustnot zpool attach -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh index 2c1f6e0ca659..426321db06d6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/create-o_ashift.ksh @@ -59,8 +59,7 @@ function write_device_uberblocks # typeset device=$1 typeset pool=$2 - while [ "$(zdb -quuul $device | grep -c 'invalid')" -ne 0 ] - do + while zdb -quuul $device | grep -q 'invalid'; do sync_pool $pool true done } @@ -89,8 +88,6 @@ function verify_device_uberblocks # exit 1 } }' - - return $? } log_assert "zpool create -o ashift=' works with different ashift values" @@ -114,11 +111,8 @@ do "$ashift (current = $pprop)" fi write_device_uberblocks $disk $TESTPOOL - verify_device_uberblocks $disk ${ubcount[$i]} - if [[ $? -ne 0 ]] - then - log_fail "Pool was created with unexpected number of uberblocks" - fi + log_must verify_device_uberblocks $disk ${ubcount[$i]} + # clean things for the next run log_must zpool destroy $TESTPOOL log_must zpool labelclear $disk diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh index e4543f0df79b..b3dd2cefc76c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh @@ -75,11 +75,9 @@ log_onexit cleanup for sdisk in $swap_disks; do log_note "Executing: swap -d $sdisk" - swap -d $sdisk >/dev/null 2>&1; - if [[ $? != 0 ]]; then + swap -d $sdisk >/dev/null 2>&1 || log_untested "Unable to delete swap device $sdisk because of" \ "insufficient RAM" - fi done log_must zpool create $TESTPOOL $DISK0 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh index 104b5ec9868a..39097df2fb59 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_020_pos.ksh @@ -75,25 +75,16 @@ log_must zpool get all $TESTPOOL zpool get all $TESTPOOL > $values # check for the cachefile property, verifying that it's set to 'none' -grep "$TESTPOOL[ ]*cachefile[ ]*none" $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "zpool property \'cachefile\' was not set to \'none\'." -fi +log_must grep -q "$TESTPOOL[ ]*cachefile[ ]*none" $values # check that the root = /mountpoint property is set correctly -grep "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "zpool property root was not found in pool output." -fi +log_must grep -q "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values rm $values # finally, check that the pool has no reference in /etc/zfs/zpool.cache if [[ -f /etc/zfs/zpool.cache ]] ; then - REF=$(strings /etc/zfs/zpool.cache | grep ${TESTPOOL}) - if [ ! -z "$REF" ] + if strings /etc/zfs/zpool.cache | grep -q ${TESTPOOL} then strings /etc/zfs/zpool.cache log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh index 98d2ee543be4..3e3c9ce942b5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_024_pos.ksh @@ -81,17 +81,13 @@ function zpool_stress typeset retry=10 typeset j=0 - truncate -s $FILESIZE $vdev0 - truncate -s $FILESIZE $vdev1 + truncate -s $FILESIZE $vdev0 $vdev1 while [[ $j -lt $iters ]]; do ((j = j + 1)) sleep 1 - zpool create $pool $vdev0 $vdev1 - if [ $? -ne 0 ]; then - return 1; - fi + zpool create $pool $vdev0 $vdev1 || return 1 # The 'zfs destroy' command is retried because it can # transiently return EBUSY when blkid is concurrently @@ -100,13 +96,8 @@ function zpool_stress while [[ $k -lt $retry ]]; do ((k = k + 1)) - zpool destroy $pool - if [ $? -eq 0 ]; then - break; - elif [ $k -eq $retry ]; then - return 1; - fi - + zpool destroy $pool && break + [ $k -eq $retry ] && return 1 sleep 3 done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh index 1623a18e4740..27e2cf0ba472 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_cliargs.ksh @@ -37,7 +37,7 @@ function log_must_follow # sleep 3 kill $pid if [[ $? -ne 0 ]]; then - log_fail "'$command' does not work as expected." + log_fail "'$command' exited early." else log_note "'$command' works successfully." fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh index 42c46712f3d9..0e3829fcc8d8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_poolname.ksh @@ -50,10 +50,8 @@ log_must zpool create $NEWPOOL $DISK log_must zpool events -c # 3. Generate some ZFS events on both pools -for i in `seq 1 $EVENTS_NUM`; do +for i in {1..$EVENTS_NUM}; do log_must zpool clear $TESTPOOL -done -for i in `seq 1 $EVENTS_NUM`; do log_must zpool clear $NEWPOOL done # wait a bit to allow the kernel module to process new events @@ -61,14 +59,11 @@ zpool_events_settle # 4. Verify 'zpool events poolname' successfully display events zpool events -v $TESTPOOL | - awk -v POOL=$TESTPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' -if [[ $? -ne 0 ]]; then + awk -v POOL=$TESTPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' || log_fail "Unexpected events for pools other than $TESTPOOL" -fi + zpool events -v $NEWPOOL | - awk -v POOL=$NEWPOOL '/pool = / {if ($3 != "\""POOL"\"") exit 1}' -if [[ $? -ne 0 ]]; then + awk -v POOL=$NEWPOOL '/pool = / && $3 != "\""POOL"\"" {exit 1}' || log_fail "Unexpected events for pools other than $NEWPOOL" -fi log_pass "'zpool events poolname' display events only from the chosen pool." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh index 6bbd46289f7c..c49777e6b3c4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh @@ -128,7 +128,7 @@ for type in " " mirror raidz draid:1s; do typeset size_addition=$(zpool history -il $TESTPOOL1 |\ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size}" | wc -l) + grep -c "(+${expansion_size}") if [[ $size_addition -ne 3 ]]; then log_fail "pool $TESTPOOL1 has not expanded, " \ @@ -139,31 +139,22 @@ for type in " " mirror raidz draid:1s; do zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then + grep -q "(+${expansion_size})" || log_fail "pool $TESTPOOL1 has not expanded" - fi elif [[ $type == "draid:1s" ]]; then typeset expansion_size=$((2*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL has not expanded" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL has not expanded" else typeset expansion_size=$((3*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL has not expanded" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL has not expanded" fi else log_fail "pool $TESTPOOL1 is not autoexpanded after vdev " \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh index 62843b062291..ccd266c727be 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_002_pos.ksh @@ -131,7 +131,7 @@ for type in " " mirror raidz draid:1s; do typeset size_addition=$(zpool history -il $TESTPOOL1 \ | grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size}" | wc -l) + grep -c "(+${expansion_size}") if [[ $size_addition -ne $i ]]; then log_fail "pool $TESTPOOL1 has not expanded " \ @@ -143,34 +143,25 @@ for type in " " mirror raidz draid:1s; do zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]]; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" elif [[ $type == "draid:1s" ]]; then typeset expansion_size=$((2*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" else typeset expansion_size=$((3*($exp_size-$org_size))) zpool history -il $TESTPOOL1 | \ grep "pool '$TESTPOOL1' size:" | \ grep "vdev online" | \ - grep "(+${expansion_size})" >/dev/null 2>&1 - - if [[ $? -ne 0 ]] ; then - log_fail "pool $TESTPOOL1 has not expanded " \ - "after zpool online -e" - fi + grep -q "(+${expansion_size})" || + log_fail "pool $TESTPOOL1 has not expanded " \ + "after zpool online -e" fi else log_fail "pool $TESTPOOL1 did not expand after vdev " \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh index 2681e69f4e72..5bd8b56ffd0d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_003_neg.ksh @@ -113,7 +113,7 @@ for type in "" mirror raidz draid; do sleep 5 # check for zpool history for the pool size expansion - zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | \ + zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | grep "vdev online" && log_fail "pool $TESTPOOL1 is not autoexpand after vdev expansion" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh index 8040d12b92d2..913a4cd6a34c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export_002_pos.ksh @@ -45,9 +45,7 @@ verify_runnable "global" function cleanup { - cd $olddir || \ - log_fail "Couldn't cd back to $olddir" - + log_must cd $olddir zpool_export_cleanup } @@ -57,16 +55,9 @@ log_onexit cleanup log_assert "Verify a busy ZPOOL cannot be exported." -ismounted "$TESTPOOL/$TESTFS" -(( $? != 0 )) && \ - log_fail "$TESTDIR not mounted. Unable to continue." - -cd $TESTDIR || \ - log_fail "Couldn't cd to $TESTDIR" - +log_must ismounted "$TESTPOOL/$TESTFS" +log_must cd $TESTDIR log_mustnot zpool export $TESTPOOL - -poolexists $TESTPOOL || \ - log_fail "$TESTPOOL not found in 'zpool list' output." +log_must poolexists $TESTPOOL log_pass "Unable to export a busy ZPOOL as expected." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh index b695b7188cb7..de39aa260f61 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh @@ -66,22 +66,13 @@ log_must zpool get all $TESTPOOL zpool get all $TESTPOOL > $values log_note "Checking zpool get all output for a header." -grep ^"NAME " $values > /dev/null 2>&1 -if [ $? -ne 0 ] -then - log_fail "The header was not printed from zpool get all" -fi +log_must grep -q ^"NAME " $values while [ $i -lt "${#properties[@]}" ] do log_note "Checking for ${properties[$i]} property" - grep "$TESTPOOL *${properties[$i]}" $values > /dev/null 2>&1 - if [ $? -ne 0 ] - then - log_fail "zpool property ${properties[$i]} was not found\ - in pool output." - fi + log_must grep -q "$TESTPOOL *${properties[$i]}" $values i=$(( $i + 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh index 89fca9cbd485..7c2e214b7da0 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_003_pos.ksh @@ -60,14 +60,10 @@ while [ $i -lt "${#properties[@]}" ] do log_note "Checking for ${properties[$i]} property" log_must eval "zpool get ${properties[$i]} $TESTPOOL > $values" - grep "${properties[$i]}" $values > /dev/null 2>&1 - if [ $? -ne 0 ] - then - log_fail "${properties[$i]} not seen in output" - fi - grep "^NAME " $values > /dev/null 2>&1 + log_must grep -q "${properties[$i]}" $values + # only need to check this once. - if [ $i -eq 0 ] && [ $? -ne 0 ] + if [ $i -eq 0 ] && ! grep -q "^NAME " $values then log_fail "Header not seen in zpool get output" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh index 87942b4a52e4..ce9885904b01 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_cachefile_shared_device.ksh @@ -50,14 +50,8 @@ function dev_checksum log_note "Compute checksum of '$dev'" - checksum=$(md5digest $dev) - if [[ $? -ne 0 ]]; then + md5digest $dev || log_fail "Failed to compute checksum of '$dev'" - return 1 - fi - - echo "$checksum" - return 0 } function test_shared_device diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh index d79c757d2406..4b6fcbd80af1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/import_rewind_config_changed.ksh @@ -133,12 +133,8 @@ function test_common log_must zpool export $TESTPOOL1 - zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1 - if (( $? == 0 )); then - verify_data_md5sums $MD5FILE - if (( $? == 0 )); then - retval=0 - fi + if zpool import -d $DEVICE_DIR -T $txg $TESTPOOL1; then + verify_data_md5sums $MD5FILE && retval=0 log_must check_pool_config $TESTPOOL1 "$poolcheck" log_must zpool destroy $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib index b91b496ee3ba..559810ff0e30 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib @@ -64,17 +64,13 @@ function write_some_data typeset files10mb=${2:-10} typeset ds="$pool/fillerds" - zfs create $ds - [[ $? -ne 0 ]] && return 1 + zfs create $ds || return 1 # Create 100 MB of data typeset file="/$ds/fillerfile" for i in {1..$files10mb}; do - dd if=/dev/urandom of=$file.$i bs=128k count=80 - [[ $? -ne 0 ]] && return 1 + dd if=/dev/urandom of=$file.$i bs=128k count=80 || return 1 done - - return 0 } # @@ -180,20 +176,20 @@ function _translate_vdev # typeset keywords="mirror replacing raidz1 raidz2 raidz3 indirect draid1 draid2 draid3" for word in $keywords; do - echo $vdev | grep -qE \ - "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" - if [[ $? -eq 0 ]]; then + if echo $vdev | + grep -qE "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" + then vdev=$word break fi done - [[ $vdev == "logs" ]] && echo "log" && return 0 - [[ $vdev == "raidz1" ]] && echo "raidz" && return 0 - [[ $vdev == "draid1" ]] && echo "draid" && return 0 - - echo $vdev - return 0 + case "$vdev" in + logs) echo "log" ;; + raidz1) echo "raidz" ;; + draid1) echo "draid" ;; + *) echo $vdev ;; + esac } # @@ -216,9 +212,8 @@ function check_pool_config typeset expected=$2 typeset status - status=$(zpool status $poolname 2>&1) - if [[ $? -ne 0 ]]; then - if ( $logfailure ); then + if ! status=$(zpool status $poolname 2>&1); then + if $logfailure; then log_note "zpool status $poolname failed: $status" fi return 1 @@ -243,7 +238,7 @@ function check_pool_config expected="$poolname $expected" if [[ "$actual" != "$expected" ]]; then - if ( $logfailure ); then + if $logfailure; then log_note "expected pool vdevs:" log_note "> '$expected'" log_note "actual pool vdevs:" @@ -270,13 +265,11 @@ function wait_for_pool_config timeout=$(( $timeout + $(date +%s) )) while (( $(date +%s) < $timeout )); do - check_pool_config -q $poolname "$expectedconfig" - [[ $? -eq 0 ]] && return 0 + check_pool_config -q $poolname "$expectedconfig" && return 0 sleep 3 done check_pool_config $poolname "$expectedconfig" - return $? } # @@ -285,10 +278,9 @@ function wait_for_pool_config function check_pool_healthy { typeset pool=$1 - typeset status - status=$(zpool status $pool 2>&1) - if [[ $? -ne 0 ]]; then + + if ! status=$(zpool status $pool 2>&1); then log_note "zpool status $pool failed: $status" return 1 fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh index ec387b225665..a9d5e2b319a4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_012_pos.ksh @@ -165,10 +165,9 @@ for option in "" "-Df"; do fi log_note "Import with $nfs_flag and " \ "$guid_flag" - zpool import $option ${devs[i]} \ - ${options[j]} $target - #import by GUID if import by pool name fails - if [[ $? != 0 ]]; then + if ! zpool import $option ${devs[i]} \ + ${options[j]} $target; then + # import by GUID if import by pool name fails log_note "Possible pool name" \ "duplicates. Try GUID import" target=$guid diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh index 6f4c2e3182d1..4f3c187b91d5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_001_pos.ksh @@ -55,10 +55,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } @@ -79,16 +76,10 @@ for disk in $DISKLIST; do while [[ $i -lt ${#args[*]} ]]; do if (( j < num )) ; then log_must zpool offline ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match offline state" - fi + log_must check_state $TESTPOOL $disk "offline" else log_mustnot zpool offline ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" fi (( i = i + 1 )) @@ -106,19 +97,13 @@ for disk in $DISKLIST; do while [[ $i -lt $iters ]]; do index=`expr $RANDOM % ${#args[*]}` log_must zpool offline ${args[$index]} $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL is not offline." - fi + log_must check_state $TESTPOOL $disk "offline" (( i = i + 1 )) done log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" done log_pass "'zpool offline -f' succeeded" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh index 7b5d21cba208..ceef4cc3161d 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_offline/zpool_offline_003_pos.ksh @@ -54,10 +54,7 @@ function cleanup # Ensure we don't leave disks in the offline state for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh index 8489fddb4109..e104a9323f27 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_online/zpool_online_001_pos.ksh @@ -54,10 +54,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done } @@ -79,16 +76,10 @@ for disk in $DISKLIST; do sync_pool $TESTPOOL log_must zpool offline $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match offline state" - fi + log_must check_state $TESTPOOL $disk "offline" log_must zpool online ${args[$i]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" while [[ $j -lt 20 ]]; do is_pool_resilvered $TESTPOOL && break @@ -112,10 +103,7 @@ for disk in $DISKLIST; do while [[ $i -lt $iters ]]; do index=`expr $RANDOM % ${#args[*]}` log_must zpool online ${args[$index]} $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" (( i = i + 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib index 3d142fdf70ca..9b3bc1432270 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib @@ -20,7 +20,7 @@ function clear_labels #disks { for disk in $@; do - if ( is_loop_device $disk ) || ( is_mpath_device $disk ); then + if is_loop_device $disk || is_mpath_device $disk; then zpool labelclear -f /dev/$disk else zpool labelclear -f /dev/${disk}1 @@ -90,19 +90,16 @@ function wait_for_action #pool timeout function function wait_for_resilver_start #pool timeout { wait_for_action $1 $2 is_pool_resilvering - return $? } function wait_for_resilver_end #pool timeout { wait_for_action $1 $2 is_pool_resilvered - return $? } function wait_for_scrub_end #pool timeout { wait_for_action $1 $2 is_pool_scrubbed - return $? } # @@ -111,14 +108,10 @@ function wait_for_scrub_end #pool timeout function is_scan_restarted #pool { - typeset pool=$1 - zpool history -i $pool | grep -q "scan aborted, restarting" - return $? + zpool history -i $1 | grep -q "scan aborted, restarting" } function is_deferred_scan_started #pool { - typeset pool=$1 - zpool history -i $pool | grep -q "starting deferred resilver" - return $? + zpool history -i $1 | grep -q "starting deferred resilver" } diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh index 1b18b1297a78..f1b957e620c9 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace-o_ashift.ksh @@ -69,23 +69,13 @@ do for cmdval in ${ashifts[@]} do log_must zpool create -o ashift=$ashift $TESTPOOL1 $disk1 - verify_ashift $disk1 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Pool was created without setting ashift " \ - "value to $ashift" - fi + log_must verify_ashift $disk1 $ashift # ashift_of(replacing_disk) <= ashift_of(existing_vdev) if [[ $cmdval -le $ashift ]] then log_must zpool replace -o ashift=$cmdval $TESTPOOL1 \ $disk1 $disk2 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift wait_replacing $TESTPOOL1 else log_mustnot zpool replace -o ashift=$cmdval $TESTPOOL1 \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh index f076f26818eb..a524c4b17ae5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_replace/replace_prop_ashift.ksh @@ -77,12 +77,7 @@ do then log_must zpool replace $TESTPOOL1 $disk1 $disk2 wait_replacing $TESTPOOL1 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift else # cannot replace if pool prop ashift > vdev ashift log_mustnot zpool replace $TESTPOOL1 $disk1 $disk2 @@ -90,12 +85,7 @@ do log_must zpool replace -o ashift=$ashift $TESTPOOL1 \ $disk1 $disk2 wait_replacing $TESTPOOL1 - verify_ashift $disk2 $ashift - if [[ $? -ne 0 ]] - then - log_fail "Device was replaced without " \ - "setting ashift value to $ashift" - fi + log_must verify_ashift $disk2 $ashift fi # clean things for the next run log_must zpool destroy $TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh index f08fdfab7fd6..6e4e6be6a18e 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_001_pos.ksh @@ -51,7 +51,7 @@ then log_fail "\"zpool set\" exit status $RET should be equal to 2." fi -OUTPUT=$(zpool set 2>&1 | grep -i usage) +zpool set 2>&1 | grep -qi usage if [ $? != 0 ] then log_fail "Usage message for zpool set did not contain the word 'usage'." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh index 3adfc59f51ce..490da6c8caa7 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh @@ -44,19 +44,13 @@ function check_zdb { - $@ > $TEST_BASE_DIR/zdb.$$ - grep "Dataset mos" $TEST_BASE_DIR/zdb.$$ - if [ $? -eq 0 ] - then - log_fail "$@ exited 0 when run as a non root user!" - fi - rm $TEST_BASE_DIR/zdb.$$ + log_mustnot eval "$* | grep -q 'Dataset mos'" } function cleanup { - rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt $TEST_BASE_DIR/zdb.$$ + rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt } verify_runnable "global" @@ -66,7 +60,7 @@ log_onexit cleanup log_must eval "zdb > $TEST_BASE_DIR/zdb_001_neg.$$.txt" # verify the output looks okay -log_must grep pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt +log_must grep -q pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt log_must rm $TEST_BASE_DIR/zdb_001_neg.$$.txt # we shouldn't able to run it on any dataset diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh index 98383a08762e..604887f6a2d8 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh @@ -43,19 +43,12 @@ # # -# check to see if we have zfs unallow -zfs 2>&1 | grep "unallow" > /dev/null -if (($? != 0)) then - log_unsupported "ZFS unallow not supported on this machine." -fi - log_assert "zfs unallow returns an error when run as a user" log_mustnot zfs unallow everyone $TESTPOOL/$TESTFS/allowed # now check with zfs allow to see if the permissions are still there -OUTPUT=$(zfs allow $TESTPOOL/$TESTFS/allowed | grep "Local+Descendent" ) -if [ -z "$OUTPUT" ] +if ! zfs allow $TESTPOOL/$TESTFS/allowed | grep -q "Local+Descendent" then log_fail "Error - create permissions were unallowed on \ $TESTPOOL/$TESTFS/allowed" diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh index 43cfd0cf2101..8e3a5680d34d 100755 --- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_003_pos.ksh @@ -66,10 +66,7 @@ cd /tmp for path in $TESTPOOL/$TESTFS $TESTDIR ./../$TESTDIR ; do zfs list -rH -o name $path > $tmpfile for fs in $children ; do - grep "^${fs}$" $tmpfile > /dev/null 2>&1 - if (( $? != 0 )); then - log_fail "$fs not shown in the output list." - fi + log_must grep -qxF "$fs" $tmpfile done done diff --git a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib index 15adc5a63683..90045f0b3e55 100644 --- a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib +++ b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib @@ -161,38 +161,29 @@ function common_perm typeset perm=$2 typeset dtst=$3 - typeset -i ret=1 case $perm in send) verify_send $user $perm $dtst - ret=$? ;; allow) verify_allow $user $perm $dtst - ret=$? ;; userprop) verify_userprop $user $perm $dtst - ret=$? ;; compression|checksum|readonly) verify_ccr $user $perm $dtst - ret=$? ;; copies) verify_copies $user $perm $dtst - ret=$? ;; reservation) verify_reservation $user $perm $dtst - ret=$? ;; *) - ret=1 + return 1 ;; esac - - return $ret } function check_fs_perm @@ -201,99 +192,74 @@ function check_fs_perm typeset perm=$2 typeset fs=$3 - typeset -i ret=1 case $perm in create) verify_fs_create $user $perm $fs - ret=$? ;; destroy) verify_fs_destroy $user $perm $fs - ret=$? ;; snapshot) verify_fs_snapshot $user $perm $fs - ret=$? ;; rollback) verify_fs_rollback $user $perm $fs - ret=$? ;; clone) verify_fs_clone $user $perm $fs - ret=$? ;; rename) verify_fs_rename $user $perm $fs - ret=$? ;; mount) verify_fs_mount $user $perm $fs - ret=$? ;; share) verify_fs_share $user $perm $fs - ret=$? ;; mountpoint) verify_fs_mountpoint $user $perm $fs - ret=$? ;; promote) verify_fs_promote $user $perm $fs - ret=$? ;; canmount) verify_fs_canmount $user $perm $fs - ret=$? ;; dnodesize) verify_fs_dnodesize $user $perm $fs - ret=$? ;; recordsize) verify_fs_recordsize $user $perm $fs - ret=$? ;; quota) verify_fs_quota $user $perm $fs - ret=$? ;; aclmode) verify_fs_aclmode $user $perm $fs - ret=$? ;; aclinherit) verify_fs_aclinherit $user $perm $fs - ret=$? ;; snapdir) verify_fs_snapdir $user $perm $fs - ret=$? ;; atime|exec|devices|setuid|xattr) verify_fs_aedsx $user $perm $fs - ret=$? ;; zoned) verify_fs_zoned $user $perm $fs - ret=$? ;; sharenfs) verify_fs_sharenfs $user $perm $fs - ret=$? ;; receive) verify_fs_receive $user $perm $fs - ret=$? ;; *) common_perm $user $perm $fs - ret=$? ;; esac - - return $ret } function check_vol_perm @@ -302,43 +268,32 @@ function check_vol_perm typeset perm=$2 typeset vol=$3 - typeset -i ret=1 case $perm in destroy) verify_vol_destroy $user $perm $vol - ret=$? ;; snapshot) verify_vol_snapshot $user $perm $vol - ret=$? ;; rollback) verify_vol_rollback $user $perm $vol - ret=$? ;; clone) verify_vol_clone $user $perm $vol - ret=$? ;; rename) verify_vol_rename $user $perm $vol - ret=$? ;; promote) verify_vol_promote $user $perm $vol - ret=$? ;; volsize) verify_vol_volsize $user $perm $vol - ret=$? ;; *) common_perm $user $perm $vol - ret=$? ;; esac - - return $ret } function setup_unallow_testenv @@ -362,8 +317,6 @@ function setup_unallow_testenv log_must verify_perm $SUBFS $LOCAL_DESC_SET $OTHER2 fi done - - return 0 } # @@ -1692,20 +1645,12 @@ function verify_allow typeset -i ret - user_run $user zfs allow $user allow $dtst - ret=$? - if [[ $ret -eq 0 ]]; then - return 1 - fi + user_run $user zfs allow $user allow $dtst && return 1 log_must zfs allow $user copies $dtst user_run $user zfs allow $user copies $dtst ret=$? log_must zfs unallow $user copies $dtst - if [[ $ret -eq 1 ]]; then - return 1 - fi - - return 0 + [ $ret -ne 1 ] } diff --git a/tests/zfs-tests/tests/functional/delegate/setup.ksh b/tests/zfs-tests/tests/functional/delegate/setup.ksh index 2f13da750436..d783b417346a 100755 --- a/tests/zfs-tests/tests/functional/delegate/setup.ksh +++ b/tests/zfs-tests/tests/functional/delegate/setup.ksh @@ -68,10 +68,8 @@ log_must add_user $OTHER_GROUP $OTHER2 # # chmod 0750 $HOME # -user_run $STAFF1 zfs list -if [ $? -ne 0 ]; then +user_run $STAFF1 zfs list || log_unsupported "Test user $STAFF1 cannot execute zfs utilities" -fi DISK=${DISKS%% *} diff --git a/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh b/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh index c11bf8442bcd..2082659a3010 100755 --- a/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/exec/exec_002_neg.ksh @@ -60,18 +60,12 @@ function cleanup function exec_n_check { typeset expect_value=$1 - shift - $@ - ret=$? - if [[ $ret != $expect_value ]]; then - log_fail "Unexpected return code: '$ret'" - fi - - return 0 + "$@" + log_must [ $? = $expect_value ] } -log_assert "Setting exec=off on a filesystem, processes can not be executed " \ +log_assert "Setting exec=off on a filesystem, processes can not be executed" \ "from this file system." log_onexit cleanup @@ -79,11 +73,11 @@ log_must cp $STF_PATH/ls $TESTDIR/myls log_must zfs set exec=off $TESTPOOL/$TESTFS if is_linux; then - log_must exec_n_check 126 $TESTDIR/myls - log_must exec_n_check 1 mmap_exec $TESTDIR/myls # EPERM + exp=1 # EPERM else - log_must exec_n_check 126 $TESTDIR/myls - log_must exec_n_check 13 mmap_exec $TESTDIR/myls # EACCES + exp=13 # EACCES fi +log_must exec_n_check 126 $TESTDIR/myls +log_must exec_n_check $exp mmap_exec $TESTDIR/myls log_pass "Setting exec=off on filesystem testing passed." diff --git a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh index 36d30b51e25c..3a1a610b8daf 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh @@ -114,10 +114,7 @@ do # Reimport pool with drive missing log_must zpool import $TESTPOOL - check_state $TESTPOOL "" "degraded" - if (($? != 0)); then - log_fail "$TESTPOOL is not degraded" - fi + log_must check_state $TESTPOOL "" "degraded" # Clear zpool events log_must zpool events -c @@ -143,10 +140,7 @@ do done # Validate auto-online was successful - check_state $TESTPOOL "" "online" - if (($? != 0)); then - log_fail "$TESTPOOL is not back online" - fi + log_must check_state $TESTPOOL "" "online" sleep 2 done log_must zpool destroy $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/history/history_007_pos.ksh b/tests/zfs-tests/tests/functional/history/history_007_pos.ksh index f187b88f056e..c0ce0aae7482 100755 --- a/tests/zfs-tests/tests/functional/history/history_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_007_pos.ksh @@ -80,7 +80,7 @@ for arch in "i386" "sparc"; do log_must zpool destroy -f $migratedpoolname log_must zpool import -d $import_dir $migratedpoolname - log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^\$" >$migrated_cmds_f" + log_must eval "TZ=$TIMEZONE zpool history $migratedpoolname | grep -v \"^\$\" >$migrated_cmds_f" # The migrated history file should differ with original history file on # two commands -- 'export' and 'import', which are included in migrated @@ -89,20 +89,20 @@ for arch in "i386" "sparc"; do # then compare this filtered file with the original history file. They # should be identical at this time. for subcmd in "export" "import"; do - grep -q "$subcmd" $migrated_cmds_f || \ - log_fail "zpool $subcmd is not logged for" \ - "the imported pool $migratedpoolname." + grep -q "$subcmd" $migrated_cmds_f || + log_fail "zpool $subcmd is not logged for" \ + "the imported pool $migratedpoolname." done tmpfile=$import_dir/cmds_tmp.$$ - linenum=`wc -l < $migrated_cmds_f` + linenum=$(wc -l < $migrated_cmds_f) (( linenum = linenum - 2 )) head -n $linenum $migrated_cmds_f > $tmpfile log_must diff $tmpfile $orig_cmds_f1 # cleanup for next loop testing log_must zpool destroy -f $migratedpoolname - log_must rm -f `ls $import_dir` + log_must rm -f $(ls $import_dir) done log_pass "Verify command history moves with migrated pool." diff --git a/tests/zfs-tests/tests/functional/history/history_010_pos.ksh b/tests/zfs-tests/tests/functional/history/history_010_pos.ksh index 2c32b1b6cefa..57a7cb4466d0 100755 --- a/tests/zfs-tests/tests/functional/history/history_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_010_pos.ksh @@ -66,10 +66,8 @@ add_user $HIST_GROUP $HIST_USER # # chmod 0750 $HOME # -user_run $HIST_USER zfs list -if [ $? -ne 0 ]; then - log_unsupported "Test user $HIST_USER cannot execute zfs utilities" -fi +user_run $HIST_USER zfs list || + log_unsupported "Test user $HIST_USER cannot execute zfs utilities" run_and_verify "zfs create $root_testfs" "-l" run_and_verify "zfs allow $HIST_GROUP snapshot,mount $root_testfs" "-l" diff --git a/tests/zfs-tests/tests/functional/history/history_common.kshlib b/tests/zfs-tests/tests/functional/history/history_common.kshlib index f441799c89e3..95f9441bf692 100644 --- a/tests/zfs-tests/tests/functional/history/history_common.kshlib +++ b/tests/zfs-tests/tests/functional/history/history_common.kshlib @@ -113,7 +113,7 @@ function verify_long suffix=":freebsd" fi - if grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then + if ! grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then log_note "Couldn't find long information for \"$cmd\"" return 1 fi @@ -138,7 +138,7 @@ function verify_hold # This works whether or not the hold was recursive for ds in $(zfs list -r -Ho name -t snapshot $dsname | \ grep "@$snapname"); do - if grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then + if ! grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then log_note "Didn't find hold on $ds with $tag" return 1 fi @@ -167,15 +167,12 @@ function verify_rollback typeset rb_fs=${dsname}/%rollback typeset snapname=${fullname##*@} - grep "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "clone swap $rb_fs ([0-9]*) parent=$parent_fs" $NEW_HISTORY ; then log_note "Didn't find rollback clone swap in pool history" return 1 fi - grep "destroy $rb_fs" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "destroy $rb_fs" $NEW_HISTORY; then log_note "Didn't find rollback destroy in pool history" return 1 fi @@ -196,9 +193,7 @@ function verify_inherit # This works whether or not the inherit was recursive for ds in $(zfs list -r -Ho name -t filesystem $dsname); do - grep "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY >/dev/null \ - 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "$subcmd $ds ([0-9]*) ${prop}=" $NEW_HISTORY; then log_note "Didn't find inherit history for $ds" return 1 fi @@ -248,9 +243,7 @@ function verify_allow [[ -n $is_set ]] && str="S-\$@" tmp=${cmd#*@} code="$str${tmp% *}" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -259,9 +252,7 @@ function verify_allow [[ -n $is_set ]] && str="C-\$" tmp=${cmd#*-c} code="$str${tmp% *}" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -273,18 +264,14 @@ function verify_allow uid=$(id -u ${tmp%% *}) if [[ -n $lflag ]]; then code="${str}l\$$uid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$$uid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY]; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -297,18 +284,14 @@ function verify_allow gid=$(awk -F: "/^${tmp%% *}:/ {print \$3}" /etc/group) if [[ -n $lflag ]]; then code="${str}l\$$gid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$$gid $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -320,18 +303,14 @@ function verify_allow opt=${opt%% *} if [[ -n $lflag ]]; then code="${str}l\$ $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi fi if [[ -n $dflag ]]; then code="${str}d\$ $opt" - grep "permission $subcmd $dsname ([0-9]*) $code" \ - $NEW_HISTORY >/dev/null 2>&1 - if [ $? != 0 ]]; then + if ! grep -q "permission $subcmd $dsname ([0-9]*) $code" $NEW_HISTORY; then log_note "Couldn't find $code in $NEW_HISTORY" return 1 fi @@ -367,16 +346,14 @@ function verify_destroy [[ $dsname =~ "@" ]] && typeset is_snap=1 if [[ -n $is_snap ]]; then - grep "ioctl destroy_snaps" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "ioctl destroy_snaps" $NEW_HISTORY; then log_note "Didn't find ioctl while destroying $dsname" return 1 fi fi # This should be present for datasets and snapshots alike - grep "destroy $dsname" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "destroy $dsname" $NEW_HISTORY; then log_note "Didn't find \"destroy\" for $dsname" return 1 fi @@ -395,9 +372,7 @@ function verify_snapshot typeset dsname=${fullname%%@*} typeset snapname=${fullname##*@} - grep "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY \ - >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "\[txg:[0-9]*\] $subcmd $fullname ([0-9]*)" $NEW_HISTORY; then log_note "Didn't find snapshot command for $fullname" return 1 fi @@ -405,8 +380,7 @@ function verify_snapshot # This works whether or not the snapshot was recursive for ds in $(zfs list -r -Ho name -t snapshot $dsname | \ grep "@$snapname"); do - grep "^[ ]* $ds$" $NEW_HISTORY >/dev/null 2>&1 - if [[ $? != 0 ]]; then + if ! grep -q "^[ ]* $ds$" $NEW_HISTORY; then log_note "Didn't find \"ioctl snapshot\" for $ds" return 1 fi diff --git a/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib b/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib index cd6bd5c027ca..a485d0521d1f 100644 --- a/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib +++ b/tests/zfs-tests/tests/functional/inheritance/inherit.kshlib @@ -34,18 +34,12 @@ # function get_prop_src # property dataset { - typeset prop_val typeset prop=$1 typeset dataset=$2 - prop_val=`zfs get -H -o source $prop $dataset` - - if [[ $? -ne 0 ]]; then - log_fail "Unable to determine the source of $prop " \ + zfs get -H -o source $prop $dataset || + log_fail "Unable to determine the source of $prop" \ "property for dataset $dataset" - else - echo $prop_val - fi } # @@ -63,7 +57,7 @@ function verify_prop_src # child_dataset property expected_src typeset prop=$2 typeset expected=$3 - prop_src=`get_prop_src $prop $target` + prop_src=$(get_prop_src $prop $target) # # Rather than just checking if $prop_src == $expected @@ -105,7 +99,7 @@ function set_n_verify_prop #property value dataset typeset dataset=$3 zfs set $prop=$prop_val $dataset - check_val=`get_prop $prop $dataset` + check_val=$(get_prop $prop $dataset) if [[ $check_val != $prop_val ]]; then log_fail "Property $prop of $dataset has value $check_val"\ diff --git a/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh b/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh index 95dc7359f278..4dfc3a8986a3 100755 --- a/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/inheritance/inherit_001_pos.ksh @@ -337,9 +337,7 @@ function scan_state { #state-file for p in ${prop[i]} ${prop[((i+1))]}; do zfs $op $p $target - ret=$? - check_failure $ret "zfs $op $p \ - $target" + check_failure $? "zfs $op $p $target" done fi for check_obj in $list; do @@ -349,16 +347,14 @@ function scan_state { #state-file # check_failure to keep journal small verify_prop_src $check_obj $p \ $final_src - ret=$? - check_failure $ret "verify" \ + check_failure $? "verify" \ "_prop_src $check_obj $p" \ "$final_src" # Again, to keep journal size down. verify_prop_val $p $check_obj \ $final_src $j - ret=$? - check_failure $ret "verify" \ + check_failure $? "verify" \ "_prop_val $check_obj $p" \ "$final_src" done diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh index 24918e217428..8c984df3089e 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh @@ -92,8 +92,8 @@ typeset -i filenum=0 typeset cwd="" log_note "Make a ufs filesystem on source $rawdisk1" -new_fs $rawdisk1 > /dev/null 2>&1 -(($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1" +new_fs $rawdisk1 > /dev/null 2>&1 || + log_untested "Unable to create ufs filesystem on $rawdisk1" log_must mkdir -p $UFSMP @@ -104,9 +104,9 @@ log_note "Now create some directories and files to be ufsdump'ed" while (($dirnum <= 2)); do log_must mkdir $bigdir${dirnum} while (( $filenum <= 2 )); do - file_write -o create -f $bigdir${dirnum}/file${filenum} \ + if ! file_write -o create -f $bigdir${dirnum}/file${filenum} \ -b $BLOCK_SIZE -c $BLOCK_COUNT - if [[ $? -ne 0 ]]; then + then if [[ $dirnum -lt 3 ]]; then log_fail "file_write only wrote" \ "<(( $dirnum * 3 + $filenum ))>" \ @@ -135,9 +135,7 @@ log_note "Attempt to take the source device in use by ufsdump as spare device" log_mustnot zpool create $TESTPOOL1 "$FS_DISK2" spare "$disk1" log_mustnot poolexists $TESTPOOL1 -wait $PIDUFSDUMP -typeset -i retval=$? -(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val" +wait $PIDUFSDUMP || log_fail "ufsdump failed with error code $?" log_must mount $disk1 $UFSMP diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh index a9725e06dcf0..8e051d8b6f73 100755 --- a/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/inuse/inuse_004_pos.ksh @@ -52,10 +52,10 @@ function cleanup # to work correctly. So its reproduced below. Still need to fully # understand why default_cleanup does not work correctly from here. # - log_must zfs umount $TESTPOOL/$TESTFS + log_must zfs umount $TESTPOOL/$TESTFS - rm -rf $TESTDIR || \ - log_unresolved Could not remove $TESTDIR + rm -rf $TESTDIR || + log_unresolved Could not remove $TESTDIR log_must zfs destroy $TESTPOOL/$TESTFS destroy_pool $TESTPOOL @@ -71,21 +71,11 @@ function mini_format if is_linux; then parted $disk -s -- mklabel gpt - typeset -i retval=$? elif is_freebsd; then gpart create -s gpt $disk - typeset -i retval=$? else - typeset format_file=$TEST_BASE_DIR/format_in.$$.1 - echo "partition" > $format_file - echo "modify" >> $format_file - - format -e -s -d $disk -f $format_file - typeset -i retval=$? - - rm -rf $format_file + format -e -s -d $disk -f <(printf '%s\n' partition modify) fi - return $retval } log_assert "format will disallow modification of a mounted zfs disk partition"\ diff --git a/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh b/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh index 6f6acdafafe5..7955478502d1 100755 --- a/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/largest_pool/largest_pool_001_pos.ksh @@ -117,15 +117,12 @@ log_onexit cleanup # units for 'df'. It must be greater than one. # ----------------------------------------------------------------------- typeset str -typeset -i ret for volsize in $VOLSIZES; do log_note "Create a pool which will contain a volume device" log_must create_pool $TESTPOOL2 "$DISKS" log_note "Create a volume device of desired sizes: $volsize" - str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1) - ret=$? - if (( ret != 0 )); then + if ! str=$(zfs create -sV $volsize $TESTPOOL2/$TESTVOL 2>&1); then if [[ is_32bit && \ $str == *${VOL_LIMIT_KEYWORD1}* || \ $str == *${VOL_LIMIT_KEYWORD2}* || \ diff --git a/tests/zfs-tests/tests/functional/migration/cleanup.ksh b/tests/zfs-tests/tests/functional/migration/cleanup.ksh index 1a1f3f42731e..79676d79e6fd 100755 --- a/tests/zfs-tests/tests/functional/migration/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/migration/cleanup.ksh @@ -34,11 +34,9 @@ verify_runnable "global" -ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS -(( $? == 0 )) && log_must umount -f $NONZFS_TESTDIR +ismounted $NONZFS_TESTDIR $NEWFS_DEFAULT_FS && log_must umount -f $NONZFS_TESTDIR -ismounted $TESTPOOL/$TESTFS -[[ $? == 0 ]] && log_must zfs umount -f $TESTDIR +ismounted $TESTPOOL/$TESTFS && log_must zfs umount -f $TESTDIR destroy_pool $TESTPOOL DISK=${DISKS%% *} diff --git a/tests/zfs-tests/tests/functional/migration/migration.kshlib b/tests/zfs-tests/tests/functional/migration/migration.kshlib index 2b1955fe93f1..0362f0644f6f 100644 --- a/tests/zfs-tests/tests/functional/migration/migration.kshlib +++ b/tests/zfs-tests/tests/functional/migration/migration.kshlib @@ -49,19 +49,11 @@ function prepare #srcdir cmd { typeset srcdir=$1 typeset cmd=$2 - typeset -i retval=0 cwd=$PWD - cd $srcdir - (( $? != 0 )) && return 1 - - $cmd - (( $? != 0 )) && return 1 - - cd $cwd - (( $? != 0 )) && return 1 - - return 0 + cd $srcdir || return 1 + $cmd || return 1 + cd $cwd || return 1 } # @@ -90,30 +82,22 @@ function migrate #destdir oldsuma oldsumb cmd typeset oldsuma=$2 typeset oldsumb=$3 typeset cmd=$4 - typeset -i retval=0 cwd=$PWD - cd $destdir - (( $? != 0 )) && return 1 - - $cmd - (( $? != 0 )) && return 1 - + cd $destdir || return 1 + $cmd || return 1 read -r suma sumb _ < <(cksum ./$BNAME) + cd $cwd || return 1 if (( $oldsuma != $suma )); then log_note "sum values are not the same" - retval=1 + return 1 fi if (( $oldsumb != $sumb )); then log_note "sum values are not the same" - retval=1 + return 1 fi - - cd $cwd - (( $? != 0 )) && return 1 - return $retval } function migrate_cpio @@ -122,28 +106,20 @@ function migrate_cpio typeset archive=$2 typeset oldsuma=$3 typeset oldsumb=$4 - typeset -i retval=0 cwd=$PWD - cd $destdir - (( $? != 0 )) && return 1 - - cpio -iv < $archive - (( $? != 0 )) && return 1 - + cd $destdir || return 1 + cpio -iv < $archive || return 1 read -r suma sumb _ < <(cksum ./$BNAME) + cd $cwd if (( $oldsuma != $suma )); then log_note "sum values are not the same" - retval=1 + return 1 fi if (( $oldsumb != $sumb )); then log_note "sum values are not the same" - retval=1 + return 1 fi - - cd $cwd - (( $? != 0 )) && return 1 - return $retval } diff --git a/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh index 875d2f7c78be..3a4a4b7f8f74 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_001_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/tar$$.tar - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/tar$$.tar $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" +log_must migrate $TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh index 6b97e2a4071b..a522174f11aa 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_002_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using tar. +# Migrating test file from ZFS fs to platform native fs using tar. # # STRATEGY: # 1. Calculate chksum of testfile # 2. Tar up test file and place on a ZFS filesystem -# 3. Extract tar contents to a UFS file system +# 3. Extract tar contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/tar$$.tar - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/tar$$.tar $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using tar" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "tar cf $TESTDIR/tar$$.tar $BNAME" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -migrate $NONZFS_TESTDIR $SUMA $SUMB "tar xf $TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh index dd0baeaa9b78..c83883d356c3 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_003_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using tar. +# Migrating test file from platform native fs to ZFS fs using tar. # # STRATEGY: # 1. Calculate chksum of testfile -# 2. Tar up test file and place on a UFS filesystem +# 2. Tar up test file and place on a platform native filesystem # 3. Extract tar contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/tar$$.tar - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/tar$$.tar $TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using tar" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using tar" log_onexit cleanup -prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "tar cf $NONZFS_TESTDIR/tar$$.tar $BNAME" +log_must migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar" -migrate $TESTDIR $SUMA $SUMB "tar xvf $NONZFS_TESTDIR/tar$$.tar" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "UFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh index 00a6cc172ab6..5a4375410e65 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_004_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cpio$$.cpio - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/cpio$$.cpio $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using cpio" @@ -57,17 +56,9 @@ log_assert "Migrating test file from ZFS fs to ZFS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" - -ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh index 4386596f777d..f282c37b7a1c 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_005_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using cpio +# Migrating test file from ZFS fs to platform native fs using cpio # # STRATEGY: # 1. Calculate chksum of testfile # 2. Cpio up test file and place on a ZFS filesystem -# 3. Extract cpio contents to a UFS file system +# 3. Extract cpio contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,26 +48,17 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cpio$$.cpio - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/cpio$$.cpio $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to uFS fs using cpio" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -ls $BNAME | cpio -oc > $TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $NONZFS_TESTDIR "$TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh index 9b5c9166ed97..a2ebd1f3f2c8 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_006_pos.ksh @@ -48,8 +48,7 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/cpio$$.cpio - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/cpio$$.cpio $TESTDIR/$BNAME } log_assert "Migrating test file from UFS fs to ZFS fs using cpio" @@ -57,17 +56,9 @@ log_assert "Migrating test file from UFS fs to ZFS fs using cpio" log_onexit cleanup cwd=$PWD -cd $DNAME -(( $? != 0 )) && log_untested "Could not change directory to $DNAME" - -ls $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio -(( $? != 0 )) && log_fail "Unable to create cpio archive" - -cd $cwd -(( $? != 0 )) && log_untested "Could not change directory to $cwd" - -migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must cd $DNAME +log_must eval "find $BNAME | cpio -oc > $NONZFS_TESTDIR/cpio$$.cpio" +log_must cd $cwd +log_must migrate_cpio $TESTDIR "$NONZFS_TESTDIR/cpio$$.cpio" $SUMA $SUMB log_pass "Successfully migrated test file from UFS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh index 0d136550f740..40839ecc00a5 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_007_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" +log_must migrate $TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh index f62b1f33a3e5..af60e4bc1f4e 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_008_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using dd. +# Migrating test file from ZFS fs to platform native fs using dd. # # STRATEGY: # 1. Calculate chksum of testfile # 2. Dd up test file and place on a ZFS filesystem -# 3. Extract dd contents to a UFS file system +# 3. Extract dd contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using dd" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$TESTDIR/dd$$.dd" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -migrate $NONZFS_TESTDIR $SUMA $SUMB "dd if=$TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh index 907be39eb4dd..e24cfdc96db1 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_009_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using dd. +# Migrating test file from platform native fs to ZFS fs using dd. # # STRATEGY: # 1. Calculate chksum of testfile -# 2. Dd up test file and place on a UFS filesystem +# 2. Dd up test file and place on a platform native filesystem # 3. Extract dd contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/dd$$.dd - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/dd$$.dd $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using dd" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using dd" log_onexit cleanup -prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "dd if=$BNAME obs=128k of=$NONZFS_TESTDIR/dd$$.dd" +log_must migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME" -migrate $TESTDIR $SUMA $SUMB "dd if=$NONZFS_TESTDIR/dd$$.dd obs=128k of=$BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh index e80dd67cdc21..f090fed3d83c 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_010_pos.ksh @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cp$$.cp - rm -rf $TESTDIR/$BNAME + rm -rf $TESTDIR/cp$$.cp $TESTDIR/$BNAME } log_assert "Migrating test file from ZFS fs to ZFS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" - -migrate $TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to ZFS fs" +log_must prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" +log_must migrate $TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" log_pass "Successfully migrated test file from ZFS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh index 2d7ecb45eadb..4293c8d8bdc2 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_011_pos.ksh @@ -34,12 +34,12 @@ # # DESCRIPTION: -# Migrating test file from ZFS fs to UFS fs using cp +# Migrating test file from ZFS fs to platform native fs using cp # # STRATEGY: # 1. Calculate chksum of testfile # 2. CP up test file and place on a ZFS filesystem -# 3. Extract cp contents to a UFS file system +# 3. Extract cp contents to a platform native file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. # @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $NONZFS_TESTDIR/cp$$.cp - rm -rf $TESTDIR/$BNAME + rm -rf $NONZFS_TESTDIR/cp$$.cp $TESTDIR/$BNAME } -log_assert "Migrating test file from ZFS fs to UFS fs using cp" +log_assert "Migrating test file from ZFS fs to $NEWFS_DEFAULT_FS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_must prepare $DNAME "cp $BNAME $TESTDIR/cp$$.cp" +log_must migrate $NONZFS_TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -migrate $NONZFS_TESTDIR $SUMA $SUMB "cp $TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "ZFS fs to UFS fs" - -log_pass "Successfully migrated test file from ZFS fs to UFS fs". +log_pass "Successfully migrated test file from ZFS fs to $NEWFS_DEFAULT_FS fs". diff --git a/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh b/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh index fd9c4549164a..675b4a159b68 100755 --- a/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/migration/migration_012_pos.ksh @@ -34,11 +34,11 @@ # # DESCRIPTION: -# Migrating test file from UFS fs to ZFS fs using cp +# Migrating test file from platform native fs to ZFS fs using cp # # STRATEGY: # 1. Calculate chksum of testfile -# 2. CP up test file and place on a UFS filesystem +# 2. CP up test file and place on a platform native filesystem # 3. Extract cp contents to a ZFS file system # 4. Calculate chksum of extracted file # 5. Compare old and new chksums. @@ -48,19 +48,14 @@ verify_runnable "both" function cleanup { - rm -rf $TESTDIR/cp$$.cp - rm -rf $NONZFS_TESTDIR/$BNAME + rm -rf $TESTDIR/cp$$.cp $NONZFS_TESTDIR/$BNAME } -log_assert "Migrating test file from UFS fs to ZFS fs using cp" +log_assert "Migrating test file from $NEWFS_DEFAULT_FS fs to ZFS fs using cp" log_onexit cleanup -prepare $DNAME "cp $BNAME $NONZFS_TESTDIR/cp$$.cp" -(( $? != 0 )) && log_fail "Unable to create src archive" +log_mustprepare $DNAME "cp $BNAME $NONZFS_TESTDIR/cp$$.cp" +log_mustmigrate $TESTDIR $SUMA $SUMB "cp $NONZFS_TESTDIR/cp$$.cp $BNAME" -migrate $TESTDIR $SUMA $SUMB "cp $NONZFS_TESTDIR/cp$$.cp $BNAME" -(( $? != 0 )) && log_fail "Unable to successfully migrate test file from" \ - "UFS fs to ZFS fs" - -log_pass "Successfully migrated test file from UFS fs to ZFS fs". +log_pass "Successfully migrated test file from $NEWFS_DEFAULT_FS fs to ZFS fs". diff --git a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib index 636d2fa68650..da681164e1a8 100644 --- a/tests/zfs-tests/tests/functional/mmp/mmp.kshlib +++ b/tests/zfs-tests/tests/functional/mmp/mmp.kshlib @@ -47,7 +47,6 @@ function is_pool_imported # pool opts check_pool_import "$pool" "$opts" "status" \ "The pool is currently imported" - return $? } function wait_pool_imported # pool opts @@ -58,8 +57,6 @@ function wait_pool_imported # pool opts while is_pool_imported "$pool" "$opts"; do log_must sleep 5 done - - return 0 } function try_pool_import # pool opts message diff --git a/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh b/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh index a664433743af..1c170208b574 100755 --- a/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/mv_files/cleanup.ksh @@ -34,13 +34,12 @@ verify_runnable "global" -[[ -f $TEST_BASE_DIR/exitsZero.ksh ]] && \ +[[ -f $TEST_BASE_DIR/exitsZero.ksh ]] && log_must rm -f $TEST_BASE_DIR/exitsZero.ksh -[[ -f $TEST_BASE_DIR/testbackgprocs.ksh ]] && \ +[[ -f $TEST_BASE_DIR/testbackgprocs.ksh ]] && log_must rm -f $TEST_BASE_DIR/testbackgprocs.ksh -ismounted $TESTPOOL/$TESTFS_TGT -(( $? == 0 )) && log_must zfs umount $TESTPOOL/$TESTFS_TGT +ismounted $TESTPOOL/$TESTFS_TGT ||log_must zfs umount $TESTPOOL/$TESTFS_TGT log_must zfs destroy $TESTPOOL/$TESTFS_TGT [[ -d $TESTDIR_TGT ]] && log_must rm -rf $TESTDIR_TGT diff --git a/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh b/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh index c49b19c6c3a3..209c3509a347 100755 --- a/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/mv_files/mv_files_001_pos.ksh @@ -53,8 +53,7 @@ verify_runnable "global" function cleanup { - rm -f $OLDDIR/* >/dev/null 2>&1 - rm -f $NEWDIR_IN_FS/* >/dev/null 2>&1 + rm -f $OLDDIR/* $NEWDIR_IN_FS/* >/dev/null 2>&1 } log_assert "Doing a 'mv' of a large amount of files within a zfs filesystem" \ @@ -62,7 +61,6 @@ log_assert "Doing a 'mv' of a large amount of files within a zfs filesystem" \ log_onexit cleanup -mv_test $OLDDIR $NEWDIR_IN_FS -(($? != 0 )) && log_fail "'mv' test failed to complete." +log_must mv_test $OLDDIR $NEWDIR_IN_FS log_pass diff --git a/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh b/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh index fdadac32d59b..c20831babfab 100755 --- a/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/mv_files/mv_files_002_pos.ksh @@ -54,8 +54,7 @@ verify_runnable "global" function cleanup { - rm -f $OLDDIR/* >/dev/null 2>&1 - rm -f $NEWDIR_ACROSS_FS/* >/dev/null 2>&1 + rm -f $OLDDIR/* $NEWDIR_ACROSS_FS/* >/dev/null 2>&1 } log_assert "Doing a 'mv' of a large amount of files across two zfs filesystems" \ @@ -63,8 +62,6 @@ log_assert "Doing a 'mv' of a large amount of files across two zfs filesystems" log_onexit cleanup -mv_test $OLDDIR $NEWDIR_ACROSS_FS -(($? != 0 )) && \ - log_fail "'mv' test failed to complete." +log_must mv_test $OLDDIR $NEWDIR_ACROSS_FS log_pass diff --git a/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh b/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh index 5050447c000a..1d1b1c944cc0 100755 --- a/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/online_offline/online_offline_001_pos.ksh @@ -54,10 +54,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi + log_must check_state $TESTPOOL $disk "online" done @@ -73,17 +70,11 @@ typeset killpid="$! " for disk in $DISKLIST; do for i in 'do_offline' 'do_offline_while_already_offline'; do log_must zpool offline $TESTPOOL $disk - check_state $TESTPOOL $disk "offline" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL is not offline." - fi + log_must check_state $TESTPOOL $disk "offline" done log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "$disk of $TESTPOOL did not match online state" - fi + log_must check_state $TESTPOOL $disk "online" # Delay for resilver to complete sleep 3 diff --git a/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh b/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh index e66e7e10fedc..a2427f2e1822 100755 --- a/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/online_offline/online_offline_002_neg.ksh @@ -55,11 +55,7 @@ function cleanup # for disk in $DISKLIST; do log_must zpool online $TESTPOOL $disk - check_state $TESTPOOL $disk "online" - if [[ $? != 0 ]]; then - log_fail "Unable to online $disk" - fi - + log_must check_state $TESTPOOL $disk "online" done kill $killpid >/dev/null 2>&1 diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh index fdefc0c3bdbb..18ef2309c605 100755 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_zdb.ksh @@ -47,8 +47,8 @@ verify_runnable "global" # with the current state. The name of this temporary pool is the # name of the actual pool with the suffix below appended to it. # -CHECKPOINT_SUFFIX="_CHECKPOINTED_UNIVERSE" -CHECKPOINTED_FS1=$TESTPOOL$CHECKPOINT_SUFFIX/$TESTFS1 +BOGUS_SUFFIX="_CHECKPOINTED_UNIVERSE" +CHECKPOINTED_FS1=$TESTPOOL$BOGUS_SUFFIX/$TESTFS1 setup_test_pool log_onexit cleanup_test_pool @@ -58,41 +58,23 @@ log_must zpool checkpoint $TESTPOOL test_change_state_after_checkpoint -zdb $TESTPOOL | grep "Checkpointed uberblock found" || \ - log_fail "zdb could not find checkpointed uberblock" - -zdb -k $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock in checkpointed state" - -zdb $TESTPOOL | grep "Dataset $FS1" && \ - log_fail "zdb found destroyed dataset in current state" - -zdb -k $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \ - log_fail "zdb could not find destroyed dataset in checkpoint" +log_must eval "zdb $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k $TESTPOOL | grep -q \"Checkpointed uberblock found\"" +log_mustnot eval "zdb $TESTPOOL | grep \"Dataset $FS1\"" +log_must eval "zdb -k $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" log_must zpool export $TESTPOOL -zdb -e $TESTPOOL | grep "Checkpointed uberblock found" || \ - log_fail "zdb could not find checkpointed uberblock" - -zdb -k -e $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock in checkpointed state" - -zdb -e $TESTPOOL | grep "Dataset $FS1" && \ - log_fail "zdb found destroyed dataset in current state" - -zdb -k -e $TESTPOOL | grep "Dataset $CHECKPOINTED_FS1" || \ - log_fail "zdb could not find destroyed dataset in checkpoint" +log_must eval "zdb -e $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k -e $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -e $TESTPOOL | grep \"Dataset $FS1\"" +log_must eval "zdb -k -e $TESTPOOL | grep \"Dataset $CHECKPOINTED_FS1\"" log_must zpool import $TESTPOOL log_must zpool checkpoint -d $TESTPOOL -zdb $TESTPOOL | grep "Checkpointed uberblock found" && \ - log_fail "zdb found checkpointed uberblock after discarding " \ - "the checkpoint" - -zdb -k $TESTPOOL && \ - log_fail "zdb opened checkpointed state that was discarded" +log_mustnot eval "zdb $TESTPOOL | grep \"Checkpointed uberblock found\"" +log_mustnot eval "zdb -k $TESTPOOL" log_pass "zdb can analyze checkpointed pools." diff --git a/tests/zfs-tests/tests/functional/privilege/setup.ksh b/tests/zfs-tests/tests/functional/privilege/setup.ksh index 4eb069394475..9d48d1961a7b 100755 --- a/tests/zfs-tests/tests/functional/privilege/setup.ksh +++ b/tests/zfs-tests/tests/functional/privilege/setup.ksh @@ -36,8 +36,7 @@ USES_NIS=false # if we're running NIS, turn it off until we clean up # (it can cause useradd to take a long time, hitting our TIMEOUT) -svcs svc:/network/nis/client:default | grep online > /dev/null -if [ $? -eq 0 ] +if svcs svc:/network/nis/client:default | grep -q online then svcadm disable svc:/network/nis/client:default USES_NIS=true diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh index 06f360d30b2b..44a5b09f9001 100755 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_003_pos.ksh @@ -54,7 +54,7 @@ log_onexit cleanup log_assert "Check the basic function of project{obj}used" sync_pool -typeset project_used=$(get_value "projectused@$PRJID1" $QFS) +typeset project_used=$(get_prop "projectused@$PRJID1" $QFS) typeset file_size='10m' if [[ $project_used != 0 ]]; then @@ -66,8 +66,8 @@ log_must user_run $PUSER mkdir $PRJDIR log_must chattr +P -p $PRJID1 $PRJDIR log_must user_run $PUSER mkfile $file_size $PRJDIR/qf sync_pool -project_used=$(get_value "projectused@$PRJID1" $QFS) -# get_value() reads the exact byte value which is slightly more than 10m +project_used=$(get_prop "projectused@$PRJID1" $QFS) +# get_prop() reads the exact byte value which is slightly more than 10m if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then log_note "project $PRJID1 used is $project_used" log_fail "projectused for project $PRJID1 expected to be $file_size, " \ @@ -75,7 +75,7 @@ if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then fi log_must rm -rf $PRJDIR -typeset project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) +typeset project_obj_used=$(get_prop "projectobjused@$PRJID2" $QFS) typeset file_count=100 if [[ $project_obj_used != 0 ]]; then @@ -88,7 +88,7 @@ log_must chattr +P -p $PRJID2 $PRJDIR # $PRJDIR has already used one object with the $PRJID2 log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((file_count - 1)) sync_pool -project_obj_used=$(get_value "projectobjused@$PRJID2" $QFS) +project_obj_used=$(get_prop "projectobjused@$PRJID2" $QFS) if [[ $project_obj_used != $file_count ]]; then log_note "project $PRJID2 used is $project_obj_used" log_fail "projectobjused for project $PRJID2 expected to be " \ diff --git a/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib b/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib index 0582164f9d6c..a90e001b2407 100644 --- a/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib +++ b/tests/zfs-tests/tests/functional/projectquota/projectquota_common.kshlib @@ -75,21 +75,6 @@ function check_quota fi } -function get_value -{ - typeset prop_val - typeset prop=$1 - typeset dataset=$2 - - prop_val=$(zfs get -H -p -o value $prop $dataset 2>/dev/null) - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for dataset $dataset" - return 1 - fi - - echo $prop_val -} - function project_obj_count { typeset fs=$1 diff --git a/tests/zfs-tests/tests/functional/projectquota/setup.ksh b/tests/zfs-tests/tests/functional/projectquota/setup.ksh index 88906d91cdbb..0402d241b100 100755 --- a/tests/zfs-tests/tests/functional/projectquota/setup.ksh +++ b/tests/zfs-tests/tests/functional/projectquota/setup.ksh @@ -45,10 +45,8 @@ log_must add_user $PGROUP $PUSER # # chmod 0750 $HOME # -user_run $PUSER zfs list -if [ $? -ne 0 ]; then +user_run $PUSER zfs list || log_unsupported "Test user $PUSER cannot execute zfs utilities" -fi DISK=${DISKS%% *} default_setup_noexit $DISK diff --git a/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in b/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in index 84e20e2e7eba..d55c4f3270ae 100755 --- a/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in +++ b/tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh.in @@ -32,10 +32,8 @@ fi verify_runnable "global" # Verify that the required dependencies for testing are installed. -@PYTHON@ -c "import cffi" 2>/dev/null -if [ $? -eq 1 ]; then +@PYTHON@ -c "import cffi" 2>/dev/null || log_unsupported "python3-cffi not found by Python" -fi # We don't just try to "import libzfs_core" because we want to skip these tests # only if pyzfs was not installed due to missing, build-time, dependencies; if @@ -43,19 +41,16 @@ fi # mismatch, we want to report it. @PYTHON@ -c ' import pkgutil, sys -sys.exit(pkgutil.find_loader("libzfs_core") is None)' -if [ $? -eq 1 ]; then +sys.exit(pkgutil.find_loader("libzfs_core") is None)' || log_unsupported "libzfs_core not found by Python" -fi log_assert "Verify the nvlist and libzfs_core Python unittest run successfully" -# NOTE: don't use log_must() here because it makes output unreadable +# log_must buffers stderr, which interacts badly with +# no-output timeouts on CI runners @PYTHON@ -m unittest --verbose \ libzfs_core.test.test_nvlist.TestNVList \ - libzfs_core.test.test_libzfs_core.ZFSTest -if [ $? -ne 0 ]; then + libzfs_core.test.test_libzfs_core.ZFSTest || log_fail "Python unittest completed with errors" -fi log_pass "Python unittest completed without errors" diff --git a/tests/zfs-tests/tests/functional/quota/quota.kshlib b/tests/zfs-tests/tests/functional/quota/quota.kshlib index 0ffe6394b54a..12e882d47e34 100644 --- a/tests/zfs-tests/tests/functional/quota/quota.kshlib +++ b/tests/zfs-tests/tests/functional/quota/quota.kshlib @@ -59,8 +59,8 @@ function fill_quota file_write -o create -f $MNTPT/$TESTFILE1 -b $BLOCK_SIZE \ -c $write_size -d 0 zret=$? - [[ $zret -ne $EDQUOT ]] && \ - log_fail "Returned error code: $zret. Expected: $EDQUOT." + [[ $zret -ne $EDQUOT ]] && \ + log_fail "Returned error code: $zret. Expected: $EDQUOT." typeset -i file_size=`ls -lsk $MNTPT/$TESTFILE1 | awk '{ print $1 }'` typeset -i limit=0 diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib index 6399c11ced34..78c33d81db26 100644 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib @@ -142,7 +142,6 @@ function setup_test_env log_must zpool create -O compression=off -f -m $TESTDIR $pool $keyword $vdevs log_note "Filling up the filesystem ..." - typeset -i ret=0 typeset -i i=0 typeset file=$TESTDIR/file typeset -i limit @@ -150,9 +149,7 @@ function setup_test_env while true ; do [[ $(get_prop available $pool) -lt $limit ]] && break - file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES - ret=$? - (( $ret != 0 )) && break + file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES || break (( i = i + 1 )) done @@ -163,16 +160,13 @@ function refill_test_env { log_note "Re-filling the filesystem ..." typeset pool=$1 - typeset -i ret=0 typeset -i i=0 typeset mntpnt mntpnt=$(get_prop mountpoint $pool) typeset file=$mntpnt/file while [[ -e $file.$i ]]; do log_must rm -f $file.$i - file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES - ret=$? - (( $ret != 0 )) && break + file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES || break (( i = i + 1 )) done @@ -195,10 +189,7 @@ function is_healthy return 0 else typeset -i ret - zpool status -x $pool | grep "state:" | \ - grep "FAULTED" >/dev/null 2>&1 - ret=$? - (( $ret == 0 )) && return 1 + zpool status -x $pool | grep "state:" | grep -q "FAULTED" && return 1 typeset l_scan typeset errnum _ l_scan=$(zpool status -x $pool | grep "scan:") diff --git a/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh b/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh index a8f58631f7b6..6b096f5d2010 100755 --- a/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/refreserv/refreserv_002_pos.ksh @@ -68,8 +68,7 @@ function max_refreserv log_must zfs set refreserv=$rr $ds while :; do - zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1 - if [[ $? == 0 ]]; then + if zfs set refreserv=$((rr + incsize)) $ds >/dev/null 2>&1; then ((rr += incsize)) continue else diff --git a/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh b/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh index d7b6de1a2e01..938a7d391ab5 100755 --- a/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/rename_dirs/rename_dirs_001_pos.ksh @@ -61,10 +61,7 @@ mkdir -p 1/2/3/4/5 a/b/c/d/e rename_dir & sleep 10 -typeset -i retval=1 -pgrep -x rename_dir >/dev/null 2>&1 -retval=$? -if (( $retval == 0 )); then +if pgrep -x rename_dir >/dev/null 2>&1; then pkill -9 -x rename_dir >/dev/null 2>&1 fi diff --git a/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh b/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh index 998d3eec7c71..384a588064b1 100755 --- a/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh +++ b/tests/zfs-tests/tests/functional/replacement/attach_rebuild.ksh @@ -142,10 +142,7 @@ for op in "" "-f"; do attach_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done @@ -161,10 +158,7 @@ for type in "" "raidz" "raidz1" "draid" "draid1"; do log_mustnot zpool attach -s "$opt" $TESTDIR/$TESTFILE1.1 \ $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -eq 0 ]]; then - log_fail "$REPLACEFILE should not be present." - fi + log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done diff --git a/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh b/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh index e99d681bb21d..d855ad928b60 100755 --- a/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh +++ b/tests/zfs-tests/tests/functional/replacement/attach_resilver.ksh @@ -141,10 +141,7 @@ for op in "" "-f"; do attach_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done @@ -160,10 +157,7 @@ for type in "" "raidz" "raidz1" "draid"; do log_mustnot zpool attach "$opt" $TESTDIR/$TESTFILE1.1 \ $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -eq 0 ]]; then - log_fail "$REPLACEFILE should not be present." - fi + log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 done diff --git a/tests/zfs-tests/tests/functional/replacement/detach.ksh b/tests/zfs-tests/tests/functional/replacement/detach.ksh index f049c639d8a6..8c8eb1e88331 100755 --- a/tests/zfs-tests/tests/functional/replacement/detach.ksh +++ b/tests/zfs-tests/tests/functional/replacement/detach.ksh @@ -134,10 +134,7 @@ log_must zfs set mountpoint=$TESTDIR1 $TESTPOOL1/$TESTFS1 detach_test $TESTDIR/$TESTFILE1.1 -zpool iostat -v $TESTPOOL1 | grep "$TESTFILE1.1" -if [[ $? -eq 0 ]]; then - log_fail "$TESTFILE1.1 should no longer be present." -fi +log_mustnot eval "zpool iostat -v $TESTPOOL1 | grep \"$TESTFILE1.1\"" destroy_pool $TESTPOOL1 @@ -150,10 +147,7 @@ for type in "" "raidz" "raidz1" "draid"; do log_mustnot zpool detach $TESTDIR/$TESTFILE1.1 - zpool iostat -v $TESTPOOL1 | grep "$TESTFILE1.1" - if [[ $? -ne 0 ]]; then - log_fail "$TESTFILE1.1 is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$TESTFILE1.1\"" destroy_pool $TESTPOOL1 done diff --git a/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh b/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh index b3c7995fd62a..19823de1240d 100755 --- a/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh +++ b/tests/zfs-tests/tests/functional/replacement/replace_rebuild.ksh @@ -145,10 +145,7 @@ for type in "" "mirror" "draid"; do replace_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 log_must rm -rf /$TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh b/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh index 2585397bba88..f25e8f548b72 100755 --- a/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh +++ b/tests/zfs-tests/tests/functional/replacement/replace_resilver.ksh @@ -142,10 +142,7 @@ for type in "" "raidz" "mirror" "draid"; do replace_test "$opt" $TESTDIR/$TESTFILE1.1 $TESTDIR/$REPLACEFILE - zpool iostat -v $TESTPOOL1 | grep "$REPLACEFILE" - if [[ $? -ne 0 ]]; then - log_fail "$REPLACEFILE is not present." - fi + log_must eval "zpool iostat -v $TESTPOOL1 | grep \"$REPLACEFILE\"" destroy_pool $TESTPOOL1 log_must rm -rf /$TESTPOOL1 diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index ea63defdce12..0098f647124c 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -165,9 +165,7 @@ function cmp_md5s { typeset file1=$1 typeset file2=$2 - typeset sum1=$(md5digest $file1) - typeset sum2=$(md5digest $file2) - test "$sum1" = "$sum2" + [ "$(md5digest $file1)" = "$(md5digest $file2)" ] } # @@ -181,18 +179,9 @@ function cmp_ds_subs typeset src_fs=$1 typeset dst_fs=$2 - zfs list -r -H -t all -o name $src_fs > $BACKDIR/src1 - zfs list -r -H -t all -o name $dst_fs > $BACKDIR/dst1 - - eval sed -e 's:^$src_fs:PREFIX:g' < $BACKDIR/src1 > $BACKDIR/src - eval sed -e 's:^$dst_fs:PREFIX:g' < $BACKDIR/dst1 > $BACKDIR/dst - - diff $BACKDIR/src $BACKDIR/dst - typeset -i ret=$? - - rm -f $BACKDIR/src $BACKDIR/dst $BACKDIR/src1 $BACKDIR/dst1 - - return $ret + diff \ + <(zfs list -rHt all -o name $src_fs | sed "s:^$src_fs:PREFIX:g") \ + <(zfs list -rHt all -o name $dst_fs | sed "s:^$dst_fs:PREFIX:g") } # @@ -211,7 +200,6 @@ function cmp_ds_cont dstdir=$(get_prop mountpoint $dst_fs) replay_directory_diff $srcdir $dstdir - return $? } # @@ -224,34 +212,19 @@ function cmp_ds_prop { typeset dtst1=$1 typeset dtst2=$2 - typeset -a props=("type" "origin" "volblocksize" "acltype" "dnodesize" \ - "atime" "canmount" "checksum" "compression" "copies" "devices" \ - "exec" "quota" "readonly" "recordsize" "reservation" "setuid" \ - "snapdir" "version" "volsize" "xattr" "mountpoint"); + typeset props="type,origin,volblocksize,acltype,dnodesize" + props+=",atime,canmount,checksum,compression,copies,devices" + props+=",exec,quota,readonly,recordsize,reservation,setuid" + props+=",snapdir,version,volsize,xattr,mountpoint" if is_freebsd; then - props+=("jailed") + props+=",jailed" else - props+=("zoned") + props+=",zoned" fi - for prop in $props; - do - zfs get -H -o property,value,source $prop $dtst1 >> \ - $BACKDIR/dtst1 - zfs get -H -o property,value,source $prop $dtst2 >> \ - $BACKDIR/dtst2 - done - - eval sed -e 's:$dtst1:PREFIX:g' < $BACKDIR/dtst1 > $BACKDIR/dtst1 - eval sed -e 's:$dtst2:PREFIX:g' < $BACKDIR/dtst2 > $BACKDIR/dtst2 - - diff $BACKDIR/dtst1 $BACKDIR/dtst2 - typeset -i ret=$? - - rm -f $BACKDIR/dtst1 $BACKDIR/dtst2 - - return $ret - + diff \ + <(zfs get -Ho property,value,source $props $dtst1 | sed "s:$dtst1:PREFIX:g") \ + <(zfs get -Ho property,value,source $props $dtst2 | sed "s:$dtst2:PREFIX:g") } # @@ -344,9 +317,7 @@ function getds_with_suffix typeset ds=$1 typeset suffix=$2 - typeset list=$(zfs list -r -H -t all -o name $ds | grep "$suffix$") - - echo $list + zfs list -rHt all -o name $ds | grep "$suffix$" } # @@ -374,7 +345,7 @@ function fs_inherit_prop # function vol_inherit_prop { - echo "checksum readonly" + echo checksum readonly } # @@ -621,13 +592,11 @@ function file_check if [[ -d /$recvfs/.zfs/snapshot/a && -d \ /$sendfs/.zfs/snapshot/a ]]; then - directory_diff /$recvfs/.zfs/snapshot/a /$sendfs/.zfs/snapshot/a - [[ $? -eq 0 ]] || log_fail "Differences found in snap a" + log_must directory_diff /$recvfs/.zfs/snapshot/a /$sendfs/.zfs/snapshot/a fi if [[ -d /$recvfs/.zfs/snapshot/b && -d \ /$sendfs/.zfs/snapshot/b ]]; then - directory_diff /$recvfs/.zfs/snapshot/b /$sendfs/.zfs/snapshot/b - [[ $? -eq 0 ]] || log_fail "Differences found in snap b" + log_must directory_diff /$recvfs/.zfs/snapshot/b /$sendfs/.zfs/snapshot/b fi } diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh index f2df0ed03460..88f79f3e921a 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh @@ -65,13 +65,13 @@ done # # Inherit properties in sub-datasets # -for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do - for prop in $(fs_inherit_prop) ; do +for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone"; do + for prop in $(fs_inherit_prop); do log_must zfs inherit $prop $ds done done -if is_global_zone ; then - for prop in $(vol_inherit_prop) ; do +if is_global_zone; then + for prop in $(vol_inherit_prop); do log_must zfs inherit $prop $POOL/$FS/vol done fi diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index 61d5e12cba3f..6c75172be544 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -159,19 +159,15 @@ set -A pair "$POOL" "$POOL2" \ typeset -i i=0 while ((i < ${#pair[@]})); do log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} - ((i += 2)) done -zpool upgrade -v | grep "Snapshot properties" > /dev/null 2>&1 -if (( $? == 0 )) ; then - i=0 - while ((i < ${#pair[@]})); do - log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final - ((i += 2)) - done -fi +i=0 +while ((i < ${#pair[@]})); do + log_must cmp_ds_prop ${pair[$i]}@final ${pair[((i+1))]}@final + ((i += 2)) +done log_pass "Verify zfs send -R will backup all the filesystem properties " \ "correctly." diff --git a/tests/zfs-tests/tests/functional/rsend/send_doall.ksh b/tests/zfs-tests/tests/functional/rsend/send_doall.ksh index e5c3490b32cd..55b8c002e61a 100755 --- a/tests/zfs-tests/tests/functional/rsend/send_doall.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send_doall.ksh @@ -46,12 +46,7 @@ log_must zfs create $POOL/fs/child # Create 3 files and a snapshot between each file creation. for i in {1..3}; do - file="/$POOL/fs/file$i" - log_must mkfile 16384 $file - - file="/$POOL/fs/child/file$i" - log_must mkfile 16384 $file - + log_must mkfile 16384 "/$POOL/fs/file$i" "/$POOL/fs/child/file$i" log_must zfs snapshot -r $POOL/fs@snap$i done @@ -59,9 +54,6 @@ done log_must eval "send_doall $POOL/fs@snap3 >$BACKDIR/fs@snap3" log_must eval "zfs recv $POOL/newfs < $BACKDIR/fs@snap3" -zfs list $POOL/newfs/child -if [[ $? -eq 0 ]]; then - log_fail "Children dataset should not have been received" -fi +log_mustnot datasetexists $POOL/newfs/child log_pass "Verify send_doall stream is correct" diff --git a/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh b/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh index dbdf1f1ce527..9d9bcf885d50 100755 --- a/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh +++ b/tests/zfs-tests/tests/functional/slog/slog_014_pos.ksh @@ -76,11 +76,7 @@ for type in "mirror" "raidz" "raidz2"; do log_must zpool offline $TESTPOOL $VDIR/a log_must wait_for_degraded $TESTPOOL - zpool status -v $TESTPOOL | grep logs | \ - grep "DEGRADED" 2>&1 >/dev/null - if (( $? == 0 )); then - log_fail "log device should display correct status" - fi + log_mustnot eval "zpool status -v $TESTPOOL | grep logs | grep -q \"DEGRADED\"" log_must zpool online $TESTPOOL $VDIR/a log_must zpool destroy -f $TESTPOOL diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh index 34e72a70d7d4..b64c026eebe7 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh @@ -51,8 +51,7 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS && log_must zfs destroy $SNAPFS [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh index dc375e2224c2..6e562e6c90ff 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh @@ -51,12 +51,10 @@ verify_runnable "both" function cleanup { - snapexists $SNAPFS.1 - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS.1 && log_must zfs destroy $SNAPFS.1 - snapexists $SNAPFS - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS && log_must zfs destroy $SNAPFS [ -e $TESTDIR ] && log_must rm -rf $TESTDIR/* diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh index d229c1d74be8..560e846cee9d 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_008_pos.ksh @@ -48,8 +48,7 @@ function cleanup { typeset -i i=1 while [[ $i -lt $COUNT ]]; do - snapexists $SNAPFS.$i - [[ $? -eq 0 ]] && \ + snapexists $SNAPFS.$i && log_must zfs destroy $SNAPFS.$i (( i = i + 1 )) diff --git a/tests/zfs-tests/tests/functional/userquota/setup.ksh b/tests/zfs-tests/tests/functional/userquota/setup.ksh index 2c609c9eb5e2..29cbbeb660d0 100755 --- a/tests/zfs-tests/tests/functional/userquota/setup.ksh +++ b/tests/zfs-tests/tests/functional/userquota/setup.ksh @@ -47,10 +47,8 @@ log_must add_user $QGROUP $QUSER2 # # chmod 0750 $HOME # -user_run $QUSER1 zfs list -if [ $? -ne 0 ]; then +user_run $QUSER1 zfs list || log_unsupported "Test user $QUSER1 cannot execute zfs utilities" -fi DISK=${DISKS%% *} default_setup_noexit $DISK diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_004_pos.ksh b/tests/zfs-tests/tests/functional/userquota/userquota_004_pos.ksh index ae748e2c63d4..896645f7ca0d 100755 --- a/tests/zfs-tests/tests/functional/userquota/userquota_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userquota_004_pos.ksh @@ -51,8 +51,8 @@ log_onexit cleanup log_assert "Check the basic function of {user|group} used" sync_pool -typeset user_used=$(get_value "userused@$QUSER1" $QFS) -typeset group_used=$(get_value "groupused@$QGROUP" $QFS) +typeset user_used=$(get_prop "userused@$QUSER1" $QFS) +typeset group_used=$(get_prop "groupused@$QGROUP" $QFS) typeset file_size='100m' if [[ $user_used != 0 ]]; then @@ -66,10 +66,10 @@ mkmount_writable $QFS log_must user_run $QUSER1 mkfile $file_size $QFILE sync_pool -user_used=$(get_value "userused@$QUSER1" $QFS) -group_used=$(get_value "groupused@$QGROUP" $QFS) +user_used=$(get_prop "userused@$QUSER1" $QFS) +group_used=$(get_prop "groupused@$QGROUP" $QFS) -# get_value() reads the exact byte value which is slightly more than 100m +# get_prop() reads the exact byte value which is slightly more than 100m if [[ "$(($user_used/1024/1024))m" != "$file_size" ]]; then log_note "user $QUSER1 used is $user_used" log_fail "userused for user $QUSER1 expected to be $file_size, " \ diff --git a/tests/zfs-tests/tests/functional/userquota/userquota_common.kshlib b/tests/zfs-tests/tests/functional/userquota/userquota_common.kshlib index cee3c6fb3269..40f9184c5254 100644 --- a/tests/zfs-tests/tests/functional/userquota/userquota_common.kshlib +++ b/tests/zfs-tests/tests/functional/userquota/userquota_common.kshlib @@ -101,23 +101,3 @@ function check_quota return 1 fi } - -# -# zfs get prop, which return raw value not -p value. -# -function get_value # property dataset -{ - typeset prop_val - typeset prop=$1 - typeset dataset=$2 - - prop_val=$(zfs get -H -p -o value $prop $dataset 2>/dev/null) - if [[ $? -ne 0 ]]; then - log_note "Unable to get $prop property for dataset " \ - "$dataset" - return 1 - fi - - echo $prop_val - return 0 -} diff --git a/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh b/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh index 429b16e04e44..e55902237897 100755 --- a/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/userquota/userspace_encrypted.ksh @@ -36,8 +36,7 @@ function cleanup function log_must_unsupported { - log_must_retry "unsupported" 3 "$@" - (( $? != 0 )) && log_fail + log_must_retry "unsupported" 3 "$@" || log_fail } log_onexit cleanup diff --git a/tests/zfs-tests/tests/functional/xattr/setup.ksh b/tests/zfs-tests/tests/functional/xattr/setup.ksh index 7ad36a714365..4f0fb1abf493 100755 --- a/tests/zfs-tests/tests/functional/xattr/setup.ksh +++ b/tests/zfs-tests/tests/functional/xattr/setup.ksh @@ -34,8 +34,7 @@ # (it can cause useradd to take a long time, hitting our TIMEOUT) if is_illumos; then USES_NIS=false - svcs svc:/network/nis/client:default | grep online > /dev/null - if [ $? -eq 0 ] + if svcs svc:/network/nis/client:default | grep -q online then svcadm disable -t svc:/network/nis/client:default USES_NIS=true diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh index fdfefbf674e9..7d7827e135ea 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh @@ -126,12 +126,8 @@ if is_illumos; then log_must mkdir $TESTDIR/noxattrs log_must touch $TESTDIR/noxattrs/no-xattr - find $TESTDIR -xattr | grep myfile.$$ - [[ $? -ne 0 ]] && \ - log_fail "find -xattr didn't find our file that had an xattr." - find $TESTDIR -xattr | grep no-xattr - [[ $? -eq 0 ]] && \ - log_fail "find -xattr found a file that didn't have an xattr." + log_must eval "find $TESTDIR -xattr | grep -q myfile.$$" + log_mustnot eval "find $TESTDIR -xattr | grep -q no-xattr" log_must rm -rf $TESTDIR/noxattrs else log_note "Checking find - unsupported" diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_013_pos.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_013_pos.ksh index efa9faab96f5..a5a43ff1083c 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_013_pos.ksh @@ -52,12 +52,6 @@ function cleanup { log_assert "The noxattr mount option functions as expected" log_onexit cleanup -zfs set 2>&1 | grep xattr > /dev/null -if [ $? -ne 0 ] -then - log_unsupported "noxattr mount option not supported on this release." -fi - log_must touch $TESTDIR/myfile.$$ create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib index aa47f6c0fdb5..c0fd90f58eaf 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib +++ b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib @@ -126,6 +126,5 @@ function is_zvol_dumpified return 1 fi - zdb -dddd $volume 2 | grep "dumpsize" > /dev/null 2>&1 - return $? + zdb -dddd $volume 2 | grep -q "dumpsize" } diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh index 297ad242fe25..16ff1f5f87db 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_002_pos.ksh @@ -48,11 +48,11 @@ volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL) function cleanup { - snapexists $TESTPOOL/$TESTVOL@snap && \ + snapexists $TESTPOOL/$TESTVOL@snap && destroy_dataset $TESTPOOL/$TESTVOL@snap - ismounted $TESTDIR $NEWFS_DEFAULT_FS - (( $? == 0 )) && log_must umount $TESTDIR + ismounted $TESTDIR $NEWFS_DEFAULT_FS && + log_must umount $TESTDIR zfs set volsize=$volsize $TESTPOOL/$TESTVOL } @@ -73,13 +73,8 @@ log_must mount ${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL $TESTDIR typeset -i fn=0 typeset -i retval=0 -while (( 1 )); do - file_write -o create -f $TESTDIR/testfile$$.$fn \ - -b $BLOCKSZ -c $NUM_WRITES - retval=$? - if (( $retval != 0 )); then - break - fi +while file_write -o create -f $TESTDIR/testfile$$.$fn \ + -b $BLOCKSZ -c $NUM_WRITES; do (( fn = fn + 1 )) done diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh index e0dce0c2c34a..0f8dbb1bcfff 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_004_pos.ksh @@ -58,10 +58,7 @@ function cleanup safe_dumpadm $savedumpdev fi - swap -l | grep -w $voldev > /dev/null 2>&1 - if (( $? == 0 )); then - log_must swap -d $voldev - fi + swap -l | grep -qw $voldev && log_must swap -d $voldev typeset snap for snap in snap0 snap1 ; do diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg.ksh index 48dfe6d9386c..b4a6f1248579 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg.ksh @@ -53,10 +53,7 @@ volsize=$(zfs get -H -o value volsize $TESTPOOL/$TESTVOL) function cleanup { - swap -l | grep $voldev > /dev/null 2>&1 - if (( $? == 0 )) ; then - log_must swap -d $voldev - fi + swap -l | grep -qF $voldev && log_must swap -d $voldev typeset dumpdev=$(get_dumpdevice) if [[ $dumpdev != $savedumpdev ]] ; then diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib index b69d2ce02913..da8a494b4a64 100644 --- a/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib +++ b/tests/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_common.kshlib @@ -134,9 +134,8 @@ function verify_partition # device # verify we can access the partition on the device devname="$(readlink -f "$device")" if is_linux || is_freebsd; then - is_disk_device "$devname""p1" + is_disk_device "${devname}p1" else - is_disk_device "$devname""s0" + is_disk_device "${devname}s0" fi - return $? } diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/setup.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/setup.ksh index 2ec8c72c67de..6c6ca2b3b6f8 100755 --- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/setup.ksh +++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/setup.ksh @@ -37,11 +37,9 @@ verify_runnable "global" for i in $SAVESWAPDEVS ; do log_note "Executing: swap_cleanup $i" - swap_cleanup $i >/dev/null 2>&1 - if [[ $? != 0 ]]; then + swap_cleanup $i >/dev/null 2>&1 || log_untested "Unable to delete swap device $i because of" \ "insufficient RAM" - fi done default_zvol_setup $DISK $VOLSIZE diff --git a/tests/zfs-tests/tests/perf/perf.shlib b/tests/zfs-tests/tests/perf/perf.shlib index c9b4505e23ac..83e1da2542d5 100644 --- a/tests/zfs-tests/tests/perf/perf.shlib +++ b/tests/zfs-tests/tests/perf/perf.shlib @@ -380,65 +380,44 @@ function get_directory function get_min_arc_size { - typeset -l min_arc_size - if is_freebsd; then - min_arc_size=$(sysctl -n kstat.zfs.misc.arcstats.c_min) + sysctl -n kstat.zfs.misc.arcstats.c_min elif is_illumos; then - min_arc_size=$(dtrace -qn 'BEGIN { + dtrace -qn 'BEGIN { printf("%u\n", `arc_stats.arcstat_c_min.value.ui64); exit(0); - }') + }' elif is_linux; then - min_arc_size=`awk '$1 == "c_min" { print $3 }' \ - /proc/spl/kstat/zfs/arcstats` - fi - - [[ $? -eq 0 ]] || log_fail "get_min_arc_size failed" - - echo $min_arc_size + awk '$1 == "c_min" { print $3 }' /proc/spl/kstat/zfs/arcstats + fi || log_fail "get_min_arc_size failed" } function get_max_arc_size { - typeset -l max_arc_size - if is_freebsd; then - max_arc_size=$(sysctl -n kstat.zfs.misc.arcstats.c_max) + sysctl -n kstat.zfs.misc.arcstats.c_max elif is_illumos; then - max_arc_size=$(dtrace -qn 'BEGIN { + dtrace -qn 'BEGIN { printf("%u\n", `arc_stats.arcstat_c_max.value.ui64); exit(0); - }') + }' elif is_linux; then - max_arc_size=`awk '$1 == "c_max" { print $3 }' \ - /proc/spl/kstat/zfs/arcstats` - fi - - [[ $? -eq 0 ]] || log_fail "get_max_arc_size failed" - - echo $max_arc_size + awk '$1 == "c_max" { print $3 }' /proc/spl/kstat/zfs/arcstats + fi || log_fail "get_max_arc_size failed" } function get_arc_target { - typeset -l arc_c - if is_freebsd; then - arc_c=$(sysctl -n kstat.zfs.misc.arcstats.c) + sysctl -n kstat.zfs.misc.arcstats.c elif is_illumos; then - arc_c=$(dtrace -qn 'BEGIN { + dtrace -qn 'BEGIN { printf("%u\n", `arc_stats.arcstat_c.value.ui64); exit(0); - }') + }' elif is_linux; then - arc_c=`awk '$1 == "c" { print $3 }' \ - /proc/spl/kstat/zfs/arcstats` - fi - - [[ $? -eq 0 ]] || log_fail "get_arc_target failed" - - echo $arc_c + awk '$1 == "c" { print $3 }' /proc/spl/kstat/zfs/arcstats + fi || log_fail "get_arc_target failed" } function get_dbuf_cache_size @@ -453,9 +432,7 @@ function get_dbuf_cache_size else dbuf_cache_shift=$(get_tunable DBUF_CACHE_SHIFT) dbuf_cache_size=$(($(get_arc_target) / 2**dbuf_cache_shift)) - fi - - [[ $? -eq 0 ]] || log_fail "get_dbuf_cache_size failed" + fi || log_fail "get_dbuf_cache_size failed" echo $dbuf_cache_size } From 2651e05cc4fc4cdf7bd27d67a8c5f09e315b3c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 22:01:06 +0100 Subject: [PATCH 38/63] tests: review all wc(1) invocations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/include/libtest.shlib | 9 ++++----- .../synctask_core/tst.terminate_by_signal.ksh | 13 +++++-------- .../functional/cli_root/zdb/zdb_display_block.ksh | 10 +++++----- .../functional/cli_root/zfs_get/zfs_get_004_pos.ksh | 2 +- .../cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh | 2 +- .../cli_root/zpool_events/zpool_events_errors.ksh | 2 +- .../cli_root/zpool_events/zpool_events_follow.ksh | 4 ++-- .../cli_user/zpool_iostat/zpool_iostat_002_pos.ksh | 2 +- .../tests/functional/fault/zpool_status_-s.ksh | 11 +++++------ .../log_spacemap/log_spacemap_import_logs.ksh | 7 ++----- .../functional/mv_files/mv_files_common.kshlib | 4 +--- .../tests/functional/procfs/procfs_list_basic.ksh | 4 ++-- .../functional/replacement/resilver_restart_002.ksh | 6 +++--- .../tests/functional/snapshot/clone_001_pos.ksh | 5 ++--- .../tests/functional/snapshot/rollback_001_pos.ksh | 7 +++---- .../tests/functional/snapshot/rollback_002_pos.ksh | 7 +++---- .../tests/functional/snapshot/snapshot_003_pos.ksh | 2 +- .../tests/functional/snapshot/snapshot_004_pos.ksh | 4 ++-- .../tests/functional/snapshot/snapshot_007_pos.ksh | 2 +- .../tests/functional/snapshot/snapshot_011_pos.ksh | 7 +++---- .../tests/functional/snapshot/snapshot_013_pos.ksh | 2 +- 21 files changed, 49 insertions(+), 63 deletions(-) diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index d4dae8e5931c..b01d8bc82f89 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2158,8 +2158,7 @@ function check_pool_status # pool token keyword typeset keyword=$3 typeset verbose=${4:-false} - scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" ' - ($1==token) {print $0}') + scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" '$1==token') if [[ $verbose == true ]]; then log_note $scan fi @@ -3075,7 +3074,7 @@ function vdevs_in_pool typeset tmpfile=$(mktemp) zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile for vdev in "$@"; do - grep -wq ${vdev##*/} $tmpfile || && return 1 + grep -wq ${vdev##*/} $tmpfile || return 1 done rm -f $tmpfile @@ -3959,10 +3958,10 @@ function directory_diff # dir_a dir_b # We check ctimes even with zil_replay=1 because the ZIL does store # creation times and we should make sure they match (if the creation times # do not match there is a "c" entry in one of the columns). - if ( rsync --version | grep -q "[, ] crtimes" >/dev/null ); then + if rsync --version | grep -q "[, ] crtimes"; then args+=("--crtimes") else - echo "NOTE: This rsync package does not support --crtimes (-N)." + log_note "This rsync package does not support --crtimes (-N)." fi # If we are testing a ZIL replay, we need to ignore timestamp changes. diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh index 2c9014a08483..53d5b819daf6 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh @@ -86,13 +86,10 @@ log_pos kill $CHILD # Make sure the channel program did not fully complete by enforcing # that not all of the snapshots were created. # -snap_count=$(zfs list -t snapshot | grep $TESTPOOL | wc -l) +snap_count=$(zfs list -t snapshot | grep -c $TESTPOOL) log_note "$snap_count snapshots created by ZCP" -if [ "$snap_count" -eq 0 ]; then - log_fail "Channel program failed to run." -elif [ "$snap_count" -gt 90 ]; then - log_fail "Too many snapshots after a cancel ($snap_count)." -else - log_pass "Canceling a long-running channel program works." -fi +log_mustnot [ "$snap_count" -eq 0 ] +log_mustnot [ "$snap_count" -gt 90 ] + +log_pass "Cancelling a long-running channel program works." diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh index ef7eb8fff13e..bab0dea2969b 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh @@ -69,16 +69,16 @@ obj=${array[0]} log_note "file $init_data has object number $obj" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L1 DVA" |head -n1) + |grep -m 1 "L1 DVA" ) dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*/\1/p' <<< "$output") log_note "first L1 block $init_data has a DVA of $dva" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + |grep -m 1 "L0 DVA" ) blk_out0=${output##*>} blk_out0=${blk_out0##+([[:space:]])} output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "1000 L0 DVA" |head -n1) + |grep -m 1 "1000 L0 DVA" ) blk_out1=${output##*>} blk_out1=${blk_out1##+([[:space:]])} @@ -110,7 +110,7 @@ vdev=$(echo "$dva" | cut -d: -f1) offset=$(echo "$dva" | cut -d: -f2) output=$(export ZDB_NO_ZLE=\"true\";\ zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) -block_cnt=$(echo "$output" | grep 'L0' | wc -l) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R :id (indirect block display) failed" fi @@ -120,7 +120,7 @@ vdev="$vdev.0" log_note "Reading from DVA $vdev:$offset:$l1_read_size" output=$(export ZDB_NO_ZLE=\"true\";\ zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null) -block_cnt=$(echo "$output" | grep 'L0' | wc -l) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R 0.0:offset:length:id (indirect block display) failed" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh index de52c586f357..20597c9a5feb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh @@ -167,7 +167,7 @@ while (( i < ${#opts[*]} )); do log_fail "There is no property for" \ "dataset $ds in 'get all' output." - propnum=$(awk -v ds="${ds}$" '$1 ~ ds {print $1}' $propfile | wc -l) + propnum=$(awk -v ds="${ds}$" '$1 ~ ds {++cnt} END {print cnt}' $propfile) case $(zfs get -H -o value type $ds) in filesystem ) (( propnum < fspropnum )) && \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh index 407c8f291122..a81e82ddf546 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh @@ -120,7 +120,7 @@ for x in {1..$ITERATIONS}; do for y in {1..$NUM_SNAPS}; do log_must zfs snapshot $TESTPOOL/$MYTEST@$y done; - n=$(ls -1 /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) + n=$(ls /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) verify_eq $n $NUM_SNAPS "count" zfs destroy -r $TESTPOOL/$MYTEST; done; diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh index f26c65f9db2c..b77437416317 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh @@ -115,7 +115,7 @@ function do_test out="$(zpool status -p | grep $VDEV1)" if [ "$ERR" == "corrupt" ] ; then - events=$(zpool events | grep checksum | wc -l) + events=$(zpool events | grep -c checksum) val=$(echo "$out" | awk '{print $5}') str="checksum" elif [ "$ERR" == "io" ] ; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh index 258de033b86c..3311eb546676 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh @@ -49,14 +49,14 @@ log_must eval "zpool events -H -f > $EVENTS_FILE &" pid=$! # 3. Generate some ZFS events -for i in `seq 1 $EVENTS_NUM`; do +for i in {1..$EVENTS_NUM}; do log_must zpool clear $TESTPOOL done # wait a bit to allow the kernel module to process new events zpool_events_settle # 4. Verify 'zpool events -f' successfully recorded these new events -EVENTS_LOG=$(cat $EVENTS_FILE | wc -l) +EVENTS_LOG=$(wc -l < $EVENTS_FILE) if [[ $EVENTS_LOG -ne $EVENTS_NUM ]]; then log_fail "Unexpected number of events: $EVENTS_LOG != $EVENTS_NUM" fi diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh index 49be7d0701c2..333177accbe5 100755 --- a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh @@ -62,7 +62,7 @@ fi zpool iostat $TESTPOOL 1 4 > $tmpfile 2>&1 & sleep 4 -stat_count=$(grep $TESTPOOL $tmpfile | wc -l) +stat_count=$(grep -c $TESTPOOL $tmpfile) if [[ $stat_count -ne 4 ]]; then log_fail "zpool iostat [pool_name] [interval] [count] failed" diff --git a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh index 5eb4b25c387f..4fe00e2c7195 100755 --- a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh +++ b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh @@ -68,10 +68,9 @@ sync_pool $TESTPOOL log_must zinject -c all SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}') -DELAY_EVENTS=$(zpool events | grep delay | wc -l) +DELAY_EVENTS=$(zpool events | grep -c delay) -if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then - log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -else - log_fail "Only saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -fi +log_must [ $SLOW_IOS -gt 0 ] +log_must [ $DELAY_EVENTS -gt 0 ] + +log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" diff --git a/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh b/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh index d1d283376bbb..d16574d3a8f7 100755 --- a/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh +++ b/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh @@ -57,7 +57,7 @@ function cleanup log_onexit cleanup LOGSM_POOL="logsm_import" -TESTDISK="$(echo $DISKS | cut -d' ' -f1)" +read -r TESTDISK _ <<<"$DISKS" log_must zpool create -o cachefile=none -f $LOGSM_POOL $TESTDISK log_must zfs create $LOGSM_POOL/fs @@ -70,10 +70,7 @@ sync_all_pools log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 1 log_must zpool export $LOGSM_POOL -LOGSM_COUNT=$(zdb -m -e $LOGSM_POOL | grep "Log Spacemap object" | wc -l) -if (( LOGSM_COUNT == 0 )); then - log_fail "Pool does not have any log spacemaps after being exported" -fi +log_must eval "zdb -m -e $LOGSM_POOL | grep -q \"Log Spacemap object\"" log_must set_tunable64 METASLAB_DEBUG_LOAD 1 log_must zpool import $LOGSM_POOL diff --git a/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib b/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib index 3ddd8f113a3b..26c2e84ce4ed 100644 --- a/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib +++ b/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib @@ -114,9 +114,7 @@ function mv_files # function count_files { - typeset -i file_num - file_num=$(find $1 -type f -print | wc -l | tr -d ' ') - (( file_num != $2 )) && \ + (( $(find $1 -type f -print | wc -l) != $2 )) && \ log_fail "The file number of target directory"\ "$2 is not equal to that of the source "\ "directory $1" diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh index 9104e4ba2ac3..5f6727ea44b5 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -48,8 +48,8 @@ function cleanup function count_snap_cmds { typeset expected_count=$1 - count=$(grep -E "command: (lt-)?zfs snapshot $FS@testsnapshot" | wc -l) - log_must eval "[[ $count -eq $expected_count ]]" + count=$(grep -cE "command: (lt-)?zfs snapshot $FS@testsnapshot") + log_must [ "$count" -eq "$expected_count" ] } typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh index b5b0ace59980..bc5bc017768c 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh @@ -64,7 +64,7 @@ objset=$(zdb -d $TESTPOOL1/ | sed -ne 's/.*ID \([0-9]*\).*/\1/p') object=$(ls -i /$TESTPOOL1/file | awk '{print $1}') # inject event to cause error during resilver -log_must zinject -b `printf "%x:%x:0:3fff" $objset $object` $TESTPOOL1 +log_must zinject -b $(printf "%x:%x:0:3fff" $objset $object) $TESTPOOL1 # clear events and start resilver log_must zpool events -c @@ -84,7 +84,7 @@ done log_note "waiting for resilver to finish" for iter in {0..59} do - finish=$(zpool events | grep "sysevent.fs.zfs.resilver_finish" | wc -l) + finish=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_finish") (( $finish > 0 )) && break sleep 1 done @@ -96,7 +96,7 @@ sync_pool $TESTPOOL1 sync_pool $TESTPOOL1 # check if resilver was restarted -start=$(zpool events | grep "sysevent.fs.zfs.resilver_start" | wc -l) +start=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_start") (( $start != 1 )) && log_fail "resilver restarted unnecessarily" log_pass "Resilver did not restart unnecessarily from scan errors" diff --git a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh index 9a63bf23483e..819e263b1c5b 100755 --- a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh @@ -142,8 +142,7 @@ while (( i < ${#args[*]} )); do if [[ -n ${args[i+3]} ]] ; then log_must zfs set mountpoint=${args[i+3]} ${args[i+2]} - FILE_COUNT=`ls -Al ${args[i+3]} | grep -v "total" \ - | grep -v "\.zfs" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]} | grep -cvF ".zfs") if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)." @@ -157,7 +156,7 @@ while (( i < ${#args[*]} )); do (( j = j + 1 )) done - FILE_COUNT=`ls -Al ${args[i+3]}/after* | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]}/after* | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "${args[i+3]} contains $FILE_COUNT after* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh index b64c026eebe7..38db22fdfe17 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh @@ -76,7 +76,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -97,14 +97,13 @@ sync_pool $TESTPOOL # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh index 6e562e6c90ff..571065fdd69b 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh @@ -79,7 +79,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -112,14 +112,13 @@ done # log_must zfs rollback $SNAPFS.1 -FILE_COUNT=`ls -Al $TESTDIR/aftersecond* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/aftersecond* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT aftersecond* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/original* $TESTDIR/afterfirst*| grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/original* $TESTDIR/afterfirst* | wc -l) if [[ $FILE_COUNT -ne 20 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT original* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh index 8cb7298a4836..a1357b1551e6 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh @@ -86,7 +86,7 @@ log_note "Remove all of the original files" i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`ls $SNAPDIR.$i/file* | wc -l` + FILECOUNT=$(ls $SNAPDIR.$i/file* | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR.$i/file$j $j diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh index 44fc6ec9e988..683afb5e1a3f 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh @@ -60,7 +60,7 @@ log_onexit cleanup [ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "BEFORE: $SNAPDIR contains $FILE_COUNT files(s)." @@ -77,7 +77,7 @@ while [[ $i -lt $COUNT ]]; do (( i = i + 1 )) done -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "AFTER: $SNAPDIR contains $FILE_COUNT files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh index 41d4b468268b..bcca2a04a7c4 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh @@ -90,7 +90,7 @@ log_note "Remove all of the original files" i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`echo $SNAPDIR1.$i/file* | wc -w` + FILECOUNT=$(ls $SNAPDIR1.$i/file* 2>/dev/null | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR1.$i/file$j $j diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh index fcf57f65f6dd..7fa7aec22d6f 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh @@ -74,7 +74,7 @@ done log_must zfs snapshot -r $SNAPPOOL -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if (( FILE_COUNT != COUNT )); then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -94,14 +94,13 @@ done # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if (( FILE_COUNT != 0 )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if (( FILE_COUNT != $COUNT )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh index aee6bb6ceb3f..27408222c80e 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh @@ -87,7 +87,7 @@ if ! datasetexists $ctrfs || ! snapexists $snapctrfs; then fi for dir in $fsdir $snapdir; do - FILE_COUNT=`ls -Al $dir | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A $dir | wc -l) (( FILE_COUNT != COUNT )) && log_fail "Got $FILE_COUNT expected $COUNT" done From 907eab0ec6776616b01932b88db0dacabe9dc14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 14 Mar 2022 22:50:56 +0100 Subject: [PATCH 39/63] tests: rsend.kshlib: cmp_ds_prop: mask out differences in origin pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes rsend_011_pos: 20:28:26.94 SUCCESS: cmp_ds_prop testpool/testfs/fs1/fs2 testpool2/testfs/fs1/fs2 20:28:26.96 2c2 20:28:26.96 < origin testpool@psnap - 20:28:26.96 --- 20:28:26.96 > origin testpool2@psnap - 20:28:26.97 ERROR: cmp_ds_prop testpool/pclone testpool2/pclone exited 1 Ref: #13250 Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 0098f647124c..1f6baf610db1 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -223,8 +223,8 @@ function cmp_ds_prop fi diff \ - <(zfs get -Ho property,value,source $props $dtst1 | sed "s:$dtst1:PREFIX:g") \ - <(zfs get -Ho property,value,source $props $dtst2 | sed "s:$dtst2:PREFIX:g") + <(zfs get -Ho property,value,source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') \ + <(zfs get -Ho property,value,source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') } # From 586486fd9ccd0bca48b4b4924fa4852afae77f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 14 Mar 2022 23:01:57 +0100 Subject: [PATCH 40/63] tests: rsend.kshlib: cmp_ds_prop: allow skipping source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes rsend_012_pos: 20:28:50.50 SUCCESS: eval zfs receive -d -F testpool2 < /mnt/testroot/backdir-rsend/pool-final-R 20:28:50.53 4,6c4,6 20:28:50.53 < acltype off local 20:28:50.53 < dnodesize 4k local 20:28:50.53 < atime off local 20:28:50.53 --- 20:28:50.53 > acltype off received 20:28:50.53 > dnodesize 4k received 20:28:50.53 > atime off received 20:28:50.53 8,13c8,13 20:28:50.53 < checksum sha256 local 20:28:50.53 < compression off local 20:28:50.53 < copies 2 local 20:28:50.53 < devices on local 20:28:50.53 < exec on local 20:28:50.53 < quota 1G local 20:28:50.53 --- 20:28:50.53 > checksum sha256 received 20:28:50.53 > compression off received 20:28:50.53 > copies 2 received 20:28:50.53 > devices on received 20:28:50.53 > exec on received 20:28:50.53 > quota 1G received 20:28:50.53 15c15 20:28:50.53 < recordsize 128K local 20:28:50.53 --- 20:28:50.53 > recordsize 128K received 20:28:50.53 17,18c17,18 20:28:50.53 < setuid off local 20:28:50.53 < snapdir visible local 20:28:50.53 --- 20:28:50.53 > setuid off received 20:28:50.53 > snapdir visible received 20:28:50.53 ERROR: cmp_ds_prop testpool testpool2 exited 1 Ref: #13250 Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 6 ++++-- tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 1f6baf610db1..085b58954c42 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -212,6 +212,8 @@ function cmp_ds_prop { typeset dtst1=$1 typeset dtst2=$2 + typeset source=",source" + [ -n "$3" ] && source= typeset props="type,origin,volblocksize,acltype,dnodesize" props+=",atime,canmount,checksum,compression,copies,devices" props+=",exec,quota,readonly,recordsize,reservation,setuid" @@ -223,8 +225,8 @@ function cmp_ds_prop fi diff \ - <(zfs get -Ho property,value,source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') \ - <(zfs get -Ho property,value,source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') + <(zfs get -Ho property,value$source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') \ + <(zfs get -Ho property,value$source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') } # diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index 6c75172be544..b92e5c460c20 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -158,7 +158,7 @@ set -A pair "$POOL" "$POOL2" \ typeset -i i=0 while ((i < ${#pair[@]})); do - log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} + log_must cmp_ds_prop ${pair[$i]} ${pair[((i+1))]} nosource ((i += 2)) done From 2f3c656294a9754eb06331b0a0a0b59e73fb24d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 21:08:55 +0100 Subject: [PATCH 41/63] tests: rsend_012_pos: backup/restore in one invocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/rsend/rsend_012_pos.ksh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index b92e5c460c20..48d70ec2d60d 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -47,28 +47,21 @@ function edited_prop typeset behaviour=$1 typeset ds=$2 typeset backfile=$TESTDIR/edited_prop_$ds + typeset te=0 case $behaviour in "get") + is_te_enabled && te=1 typeset props=$(zfs inherit 2>&1 | \ - awk '$2=="YES" && $1 !~ /^vol|\.\.\.$/ {print $1}') - for item in $props ; do - if [[ $item == "mlslabel" ]] && \ - ! is_te_enabled ; then - continue - fi - log_must eval "zfs get -H -o property,value $item $ds >> $backfile" - done + awk -v te=$te '$2=="YES" && $1 !~ /^vol|\.\.\.$/ && (te || $1 != "mlslabel") {printf("%s,", $1)}') + log_must eval "zfs get -Ho property,value ${props%,} $ds >> $backfile" ;; "set") if [[ ! -f $backfile ]] ; then log_fail "$ds need backup properties firstly." fi - typeset prop value - while read -r prop value; do - log_must zfs set "$prop=$value" "$ds" - done < $backfile + log_must zfs set $(tr '\t' '=' < $backfile) "$ds" ;; *) log_fail "Unrecognized behaviour: $behaviour" From 76cc1b6a38cbe349dadb48312e813fdf50825ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Mon, 14 Mar 2022 23:47:38 +0100 Subject: [PATCH 42/63] tests: prune cat (ab)uses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../functional/cli_root/zdb/zdb_objset_id.ksh | 28 +++++++++---------- .../zfs_receive/zfs_receive_005_neg.ksh | 4 +-- .../functional/history/history_007_pos.ksh | 2 +- .../functional/mmp/mmp_write_distribution.ksh | 10 +++---- .../tests/functional/pam/utilities.kshlib | 4 +-- .../functional/procfs/procfs_list_basic.ksh | 2 +- .../procfs/procfs_list_concurrent_readers.ksh | 5 ++-- .../functional/redacted_send/redacted.kshlib | 2 +- .../redacted_send/redacted_embedded.ksh | 18 ++++-------- .../redacted_send/redacted_resume.ksh | 4 +-- .../replacement/resilver_restart_001.ksh | 2 +- .../tests/functional/rsend/rsend.kshlib | 9 +++--- .../functional/rsend/send-c_zstreamdump.ksh | 6 ++-- .../rsend/send-cpL_varied_recsize.ksh | 2 +- .../tests/functional/xattr/cleanup.ksh | 2 +- .../functional/xattr/xattr_common.kshlib | 18 ++++-------- 16 files changed, 51 insertions(+), 67 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh index c3021d175921..fdda9ba22638 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -67,34 +67,32 @@ obj=${array[0]} log_note "file $init_data has object number $obj" sync_pool $TESTPOOL -output=$(zdb -d $TESTPOOL/$TESTFS) -objset_id=$(echo $output | cut -d, -f2 | cut -d' ' -f2) +IFS=", " read -r _ _ _ _ objset_id _ < <(zdb -d $TESTPOOL/$TESTFS) objset_hex=$(printf "0x%X" $objset_id) log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" for id in "$objset_id" "$objset_hex" do log_note "zdb -dddddd $TESTPOOL/$id $obj" - output=$(zdb -dddddd $TESTPOOL/$id $obj) - echo $output | grep -q "$TESTPOOL/$TESTFS" || - log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" - echo $output | grep -q "file1" || - log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" + output=$(zdb -dddddd $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" obj=$(printf "0x%X" $obj) log_note "zdb -NNNNNN $TESTPOOL/$id $obj" - output=$(zdb -NNNNNN $TESTPOOL/$id $obj) - echo $output | grep -q "$TESTPOOL/$TESTFS" || - log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" - echo $output | grep -q "file1" || - log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" + output=$(zdb -NNNNNN $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" done if is_linux; then - output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) + output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL | grep objset- | tail -1) objset_hex=${output#*-} - name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | - grep dataset_name | cut -d' ' -f3) + name_from_proc=$(grep dataset_name /proc/spl/kstat/zfs/$TESTPOOL/$output | cut -d' ' -f3) log_note "checking zdb output for $name_from_proc" log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh index d8c71f2c2877..6a708a45e177 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh @@ -80,8 +80,8 @@ log_must zfs snapshot $init_snap log_must eval "zfs send $init_snap > $full_bkup" log_note "'zfs receive' fails with invalid send streams." -log_mustnot eval "cat $orig_cmds_f1 + grep -v "^$" $orig_cmds_f > $orig_cmds_f1 log_must cp $tst_dir/${arch}.migratedpool.DAT.Z $import_dir log_must uncompress -f $import_dir/${arch}.migratedpool.DAT.Z diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh index b6bdc6811634..1ac254aa1dab 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { log_must zpool destroy $MMP_POOL - log_must rm $MMP_DIR/file.{0,1,2,3,4,5,6,7} + log_must rm $MMP_DIR/file.{0..7} log_must rm $MMP_HISTORY_TMP log_must rmdir $MMP_DIR log_must mmp_clear_hostid @@ -51,8 +51,8 @@ MMP_HISTORY=/proc/spl/kstat/zfs/$MMP_POOL/multihost # Step 1 log_must mkdir -p $MMP_DIR -log_must truncate -s 128M $MMP_DIR/file.{0,1,2,3,4,5,6,7} -log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0,1} mirror $MMP_DIR/file.{2,3,4,5,6,7} +log_must truncate -s 128M $MMP_DIR/file.{0..7} +log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0..1} mirror $MMP_DIR/file.{2..7} # Step 2 log_must mmp_set_hostid $HOSTID1 @@ -69,8 +69,8 @@ typeset -i min_writes=999 typeset -i max_writes=0 typeset -i write_count # copy to get as close to a consistent view as possible -cat $MMP_HISTORY > $MMP_HISTORY_TMP -for x in $(seq 0 7); do +cp $MMP_HISTORY $MMP_HISTORY_TMP +for x in {0..7}; do write_count=$(grep -c file.${x} $MMP_HISTORY_TMP) if [ $write_count -lt $min_writes ]; then min_writes=$write_count diff --git a/tests/zfs-tests/tests/functional/pam/utilities.kshlib b/tests/zfs-tests/tests/functional/pam/utilities.kshlib index d328034300b1..6e9f900913c2 100644 --- a/tests/zfs-tests/tests/functional/pam/utilities.kshlib +++ b/tests/zfs-tests/tests/functional/pam/utilities.kshlib @@ -28,7 +28,7 @@ pamservice="pam_zfs_key_test" pamconfig="/etc/pam.d/${pamservice}" function keystatus { - log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" == "$1" ] + log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" = "$1" ] } function genconfig { @@ -42,6 +42,6 @@ function rmconfig { } function references { - log_must [ "$(cat "${runstatedir}/$(id -u ${username})")" == "$1" ] + log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ] } diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh index 5f6727ea44b5..18caea3c32cc 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -85,7 +85,7 @@ done # Clear out old messages and check that they really are gone echo 0 >$ZFS_DBGMSG || log_fail "failed to write to $ZFS_DBGMSG" -cat $ZFS_DBGMSG | count_snap_cmds 0 +count_snap_cmds 0 < $ZFS_DBGMSG # # Even though we don't expect any messages in the file, reading should still # succeed. diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh index a24452ed5892..fcdd54da3591 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh @@ -41,8 +41,7 @@ function cleanup { - [[ -z $msgs1 ]] || log_must rm $msgs1 - [[ -z $msgs2 ]] || log_must rm $msgs2 + log_must rm -f $msgs1 $msgs2 datasetexists $FS && destroy_dataset $FS -r } @@ -69,7 +68,7 @@ msgs2=$(mktemp) || log_fail # Start reading file, pause and read it from another process, and then finish # reading. # -{ dd bs=512 count=4; cat $ZFS_DBGMSG >$msgs1; cat; } <$ZFS_DBGMSG >$msgs2 +{ dd bs=512 count=4; cp $ZFS_DBGMSG $msgs1; cat; } <$ZFS_DBGMSG >$msgs2 # # Truncate the result of the read that completed second in case it picked up an diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib index 6ad2e47018c8..a3810d55f97c 100644 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib @@ -231,7 +231,7 @@ function compare_files [[ -f $file2 ]] || log_fail "File $file2 does not exist." log_must eval "get_diff $file1 $file2 >$tmpfile" - typeset range="$(cat $tmpfile)" + typeset range="$(<$tmpfile)" log_must unmount_redacted $recvfs [[ "$expected" = "$range" ]] || log_fail "Unexpected range: $range" } diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh index 1c5b503a9be5..35faf038ad8f 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh @@ -60,13 +60,10 @@ for recsize in 512 1024 2048 4096 8192 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_must zfs destroy -R $recvfs @@ -91,13 +88,10 @@ for recsize in 1024 4096 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | log_must grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_pass "Embedded blocks and redacted send work correctly together." diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh index 8118ea59ec8b..31f7b0ada82c 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh @@ -53,7 +53,7 @@ log_must mount_redacted -f $recvfs log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1 log_must diff $send_mnt/f1 $recv_mnt/f1 log_must eval "get_diff $send_mnt/f2 $recv_mnt/f2 >$tmpdir/get_diff.out" -typeset range=$(cat $tmpdir/get_diff.out) +typeset range=$(<$tmpdir/get_diff.out) [[ "$RANGE9" = "$range" ]] || log_fail "Unexpected range: $range" log_must dd if=/dev/urandom of=$send_mnt/f3 bs=1024k count=3 @@ -70,7 +70,7 @@ resume_test "zfs send --redact book2 -i $sendfs#book1 $sendfs@snap2" \ log_must diff $send_mnt/f1 $recv_mnt/f1 log_must diff $send_mnt/f2 $recv_mnt/f2 log_must eval "get_diff $send_mnt/f3 $recv_mnt/f3 >$tmpdir/get_diff.out" -range=$(cat $tmpdir/get_diff.out) +range=$(<$tmpdir/get_diff.out) [[ "$RANGE10" = "$range" ]] || log_fail "Unexpected range: $range" # Test recv -A works properly and verify saved sends are not allowed diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh index 937693a67c9e..b498ba4af730 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh @@ -162,7 +162,7 @@ do # inject read io errors on vdev and verify resilver does not restart log_must zinject -a -d ${VDEV_FILES[2]} -e io -T read -f 0.25 $TESTPOOL1 - log_must eval "cat ${DATAPATHS[1]} > /dev/null" + log_must cp ${DATAPATHS[1]} /dev/null log_must zinject -c all # there should still be 2 resilver starts w/o defer, 1 with defer diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 085b58954c42..fdda1f5e92c3 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -625,7 +625,7 @@ function resume_test log_mustnot eval "zfs recv -suv $recvfs $BACKDIR/full" log_must stream_has_features $BACKDIR/full lz4 compressed -cat $BACKDIR/full | zstream dump -v > $BACKDIR/dump.out +zstream dump -v $BACKDIR/full > $BACKDIR/dump.out lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \ $BACKDIR/dump.out) @@ -63,8 +63,8 @@ csize_prop=$(get_prop used $sendfs) within_percent $csize $csize_prop 90 || log_fail \ "$csize and $csize_prop differed by too much" -x=$(get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs) -resume_token=$(cat /$streamfs/resume_token) +get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs +resume_token=$($stream" $verify eval "zfs recv $recv_ds <$stream" - typeset stream_size=$(cat $stream | zstream dump | sed -n \ + typeset stream_size=$(zstream dump $stream | sed -n \ 's/ Total write size = \(.*\) (0x.*)/\1/p') # diff --git a/tests/zfs-tests/tests/functional/xattr/cleanup.ksh b/tests/zfs-tests/tests/functional/xattr/cleanup.ksh index b3629629c78c..ab0fbf8124c8 100755 --- a/tests/zfs-tests/tests/functional/xattr/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/xattr/cleanup.ksh @@ -30,7 +30,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/xattr/xattr_common.kshlib -USES_NIS=$(cat $TEST_BASE_DIR/zfs-xattr-test-nis.txt) +USES_NIS=$(<$TEST_BASE_DIR/zfs-xattr-test-nis.txt) rm $TEST_BASE_DIR/zfs-xattr-test-nis.txt if [ "${USES_NIS}" == "true" ] diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib b/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib index bc06f4716867..5ff2b489024c 100644 --- a/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib +++ b/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib @@ -97,10 +97,10 @@ function delete_xattr { # filename xattr_name if is_illumos; then log_must runat $FILE rm $XATTR_NAME log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1" - else - log_must rm_xattr $XATTR_NAME $FILE - log_mustnot get_xattr $XATTR_NAME $FILE - fi + else + log_must rm_xattr $XATTR_NAME $FILE + log_mustnot get_xattr $XATTR_NAME $FILE + fi } # not sure about this : really this should be testing write/append @@ -126,12 +126,6 @@ function verify_write_xattr { # filename xattr_name function create_expected_output { # expected_output_file contents_of_the_output typeset FILE=$1 shift - if [[ -f $FILE ]]; then - log_must rm $FILE - fi - - for line in $@ - do - log_must eval "echo $line >> $FILE" - done + log_must rm -f $FILE + log_must eval "printf '%s\n' $* >> $FILE" } From 91b7181deb0001eb32c8594ffa9da59dd4c94239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 15 Mar 2022 01:00:03 +0100 Subject: [PATCH 43/63] tests: rsend.kshlib: cmp_ds_prop: anonymise "inherited from" sourcces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes rsend_012_pos: 00:04:59.68 SUCCESS: cmp_ds_prop testpool/testfs/vol testpool2/testfs/vol nosource 00:04:59.70 4c4 00:04:59.70 < acltype posix inherited from testpool 00:04:59.70 --- 00:04:59.70 > acltype posix inherited from testpool2 00:04:59.70 11,12c11,12 00:04:59.70 < devices off inherited from testpool 00:04:59.70 < exec on inherited from testpool 00:04:59.70 --- 00:04:59.70 > devices off inherited from testpool2 00:04:59.70 > exec on inherited from testpool2 00:04:59.70 17c17 00:04:59.70 < setuid off inherited from testpool 00:04:59.70 --- 00:04:59.70 > setuid off inherited from testpool2 00:04:59.70 ERROR: cmp_ds_prop testpool@final testpool2@final exited 1 Ref: #13250 Signed-off-by: Ahelenia Ziemiańska --- tests/zfs-tests/tests/functional/rsend/rsend.kshlib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index fdda1f5e92c3..6f04a6b7bb06 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -225,8 +225,8 @@ function cmp_ds_prop fi diff \ - <(zfs get -Ho property,value$source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') \ - <(zfs get -Ho property,value$source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/') + <(zfs get -Ho property,value$source $props $dtst1 | sed -e "s:$dtst1:PREFIX:g" -e 's/^origin [^@]*/origin POOL/' -e 's/ inherited from [^/]*/ inherited from POOL/') \ + <(zfs get -Ho property,value$source $props $dtst2 | sed -e "s:$dtst2:PREFIX:g" -e 's/^origin [^@]*/origin POOL/' -e 's/ inherited from [^/]*/ inherited from POOL/') } # From bc73a4a094d0237bab4d38dbac28cae0646db737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Wed, 23 Mar 2022 21:07:33 +0100 Subject: [PATCH 44/63] tests: rsend/send-c_props: make it chooch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original error: 23:47:40.59 SUCCESS: eval zfs receive -dFv testpool2 < /mnt/testroot/backdir-rsend/pool-final-p 23:47:40.61 1,23d0 23:47:40.61 < type filesystem - 23:47:40.61 < origin POOL@psnap - 23:47:40.61 < volblocksize - - 23:47:40.61 < acltype nfsv4 inherited from POOL 23:47:40.61 < dnodesize legacy inherited from POOL 23:47:40.61 < atime off local 23:47:40.61 < canmount off local 23:47:40.61 < checksum off local 23:47:40.61 < compression off local 23:47:40.61 < copies 3 local 23:47:40.61 < devices off local 23:47:40.61 < exec off local 23:47:40.61 < quota none default 23:47:40.61 < readonly on local 23:47:40.61 < recordsize 128K local 23:47:40.61 < reservation none default 23:47:40.61 < setuid off local 23:47:40.61 < snapdir hidden local 23:47:40.61 < version 5 - 23:47:40.61 < volsize - - 23:47:40.61 < xattr off local 23:47:40.61 < mountpoint /PREFIX inherited from POOL 23:47:40.61 < jailed on local 23:47:40.62 cannot open 'testpool2/pclone': dataset does not exist 23:47:40.62 ERROR: cmp_ds_prop testpool/pclone testpool2/pclone exited 1 So: (a) actually send all the datasets in -p mode and (b) drop origin for clones sent with -p: 00:38:05.46 SUCCESS: eval zfs receive -dFv testpool2 < /mnt/testroot/backdir-rsend/pool-final-p 00:38:05.48 2c2 00:38:05.48 < origin POOL@psnap 00:38:05.48 --- 00:38:05.48 > origin POOL 00:38:05.49 ERROR: cmp_ds_prop testpool/pclone testpool2/pclone nosource exited 1 Closes #13250 Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/rsend/rsend.kshlib | 10 +++++++--- .../tests/functional/rsend/send-c_props.ksh | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 6f04a6b7bb06..a18e69dbaf02 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -207,14 +207,18 @@ function cmp_ds_cont # # $1 dataset 1 # $2 dataset 2 +# $3 -n == don't track property source +# $4 -n == don't track the origin property # function cmp_ds_prop { typeset dtst1=$1 typeset dtst2=$2 - typeset source=",source" - [ -n "$3" ] && source= - typeset props="type,origin,volblocksize,acltype,dnodesize" + typeset nosource=$3 + typeset noorigin=$4 + typeset source=",source"; [ -n "$nosource" ] && source= + typeset origin=",origin"; [ -n "$noorigin" ] && origin= + typeset props="type$origin,volblocksize,acltype,dnodesize" props+=",atime,canmount,checksum,compression,copies,devices" props+=",exec,quota,readonly,recordsize,reservation,setuid" props+=",snapdir,version,volsize,xattr,mountpoint" diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh index 6e95c2c30b67..82a2eb91e825 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_props.ksh @@ -52,16 +52,27 @@ for opt in "-p" "-R"; do randomize_ds_props $POOL$ds done - log_must eval "zfs send -c $opt $POOL@final > $BACKDIR/pool-final$opt" - log_must eval "zfs receive -d -F $POOL2 < $BACKDIR/pool-final$opt" + if [ $opt = "-p" ]; then + for ds in ${datasets[@]}; do + log_must eval "zfs send -c $opt $POOL$ds@final > $BACKDIR/pool-final$opt" + log_must eval "zfs receive -dF $POOL2 < $BACKDIR/pool-final$opt" + done + else + log_must eval "zfs send -c $opt $POOL@final > $BACKDIR/pool-final$opt" + log_must eval "zfs receive -dF $POOL2 < $BACKDIR/pool-final$opt" + fi for ds in ${datasets[@]}; do - log_must cmp_ds_prop $POOL$ds $POOL2$ds + typeset origin= + if [ $opt = "-p" ] && [ ${ds/clone//} != $ds ]; then + origin=noorigin + fi + log_must cmp_ds_prop $POOL$ds $POOL2$ds nosource $origin log_must cmp_ds_prop $POOL$ds@final $POOL2$ds@final done # Don't cleanup the second time, since we do that on exit anyway. - [[ $opt = "-p" ]] && cleanup + [ $opt = "-p" ] && cleanup done log_pass "Compressed send doesn't interfere with preservation of properties" From 6f77acfcacfad63fb3efd4b6e721de63191892a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 15 Mar 2022 01:54:10 +0100 Subject: [PATCH 45/63] tests: echo-with-arguments review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- .../tests/functional/rsend/rsend_012_pos.ksh | 2 +- tests/zfs-tests/tests/functional/trim/trim.kshlib | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh index 48d70ec2d60d..0608598b8333 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -162,5 +162,5 @@ while ((i < ${#pair[@]})); do ((i += 2)) done -log_pass "Verify zfs send -R will backup all the filesystem properties " \ +log_pass "Verify zfs send -R will backup all the filesystem properties" \ "correctly." diff --git a/tests/zfs-tests/tests/functional/trim/trim.kshlib b/tests/zfs-tests/tests/functional/trim/trim.kshlib index fad15582b188..f36f3870fc4e 100644 --- a/tests/zfs-tests/tests/functional/trim/trim.kshlib +++ b/tests/zfs-tests/tests/functional/trim/trim.kshlib @@ -22,7 +22,7 @@ # function get_size_mb { - du --block-size 1048576 -s "$1" | awk '{printf("%s", $1)}' + du --block-size 1048576 -s "$1" | cut -f1 } # @@ -38,14 +38,12 @@ function get_trim_io # Sum the ind or agg columns of the trim request size histogram. case "$type" in "ind") - rval=$(zpool iostat -pr $pool $vdev | awk \ - '$1 ~ /[0-9].*/ { sum += $12 } END { print sum }') - echo -n "$rval" + zpool iostat -pr $pool $vdev | + awk '$1 ~ /[0-9].*/ { sum += $12 } END { print sum }' ;; "agg") - rval=$(zpool iostat -pr $pool $vdev | awk \ - '$1 ~ /[0-9].*/ { sum += $13 } END { print sum }') - echo -n "$rval" + zpool iostat -pr $pool $vdev | + awk '$1 ~ /[0-9].*/ { sum += $13 } END { print sum }' ;; *) log_fail "Type must be 'ind' or 'agg'" From cdc4edb03445d9c3632c7bf2fdd5298661992a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 22 Mar 2022 20:09:35 +0100 Subject: [PATCH 46/63] tests: move C test helpers into test cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ahelenia Ziemiańska --- tests/runfiles/common.run | 4 +- tests/runfiles/sanity.run | 4 +- tests/zfs-tests/cmd/.gitignore | 11 +++++ tests/zfs-tests/cmd/Makefile.am | 42 +++++++++++++++++++ .../functional => cmd}/checksum/edonr_test.c | 0 .../functional => cmd}/checksum/sha2_test.c | 0 .../functional => cmd}/checksum/skein_test.c | 0 .../functional/cp_files => cmd}/cp_files.c | 0 .../{tests/functional/ctime => cmd}/ctime.c | 0 .../acl/off => cmd}/dosmode_readonly_write.c | 0 .../cli_root/zpool_events => cmd}/ereports.c | 2 +- .../suid => cmd}/suid_write_to_file.c | 0 .../truncate => cmd}/truncate_test.c | 0 .../events => cmd}/zed_fd_spill-zedlet.c | 0 .../socket.c => cmd/zfs_diff-socket.c} | 0 tests/zfs-tests/include/commands.cfg | 13 +++++- .../tests/functional/acl/off/.gitignore | 1 - .../tests/functional/acl/off/Makefile.am | 7 ---- .../tests/functional/acl/off/dosmode.ksh | 3 +- .../tests/functional/checksum/.gitignore | 4 -- .../tests/functional/checksum/Makefile.am | 18 -------- .../functional/checksum/run_edonr_test.ksh | 2 +- .../functional/checksum/run_sha2_test.ksh | 2 +- .../functional/checksum/run_skein_test.ksh | 2 +- .../functional/cli_root/zfs_diff/.gitignore | 1 - .../functional/cli_root/zfs_diff/Makefile.am | 7 ---- .../cli_root/zfs_diff/zfs_diff_types.ksh | 2 +- .../cli_root/zpool_events/.gitignore | 1 - .../cli_root/zpool_events/Makefile.am | 10 ----- .../zpool_events_clear_retained.ksh | 4 +- .../zpool_events/zpool_events_duplicates.ksh | 4 +- .../tests/functional/cp_files/.gitignore | 1 - .../tests/functional/cp_files/Makefile.am | 7 ---- .../functional/cp_files/cp_files_001_pos.ksh | 5 +-- .../tests/functional/ctime/.gitignore | 1 - .../tests/functional/ctime/Makefile.am | 7 ---- .../tests/functional/ctime/ctime_001_pos.ksh | 2 +- .../tests/functional/events/.gitignore | 1 - .../tests/functional/events/Makefile.am | 6 --- .../tests/functional/events/zed_fd_spill.ksh | 9 ++-- .../tests/functional/hkdf/Makefile.am | 11 +---- .../tests/functional/hkdf/cleanup.ksh | 22 ---------- .../tests/functional/hkdf/run_hkdf_test.ksh | 30 ------------- .../zfs-tests/tests/functional/hkdf/setup.ksh | 22 ---------- .../tests/functional/libzfs/Makefile.am | 7 +--- .../tests/functional/suid/.gitignore | 1 - .../tests/functional/suid/Makefile.am | 7 ---- .../functional/suid/suid_write_to_none.ksh | 2 +- .../functional/suid/suid_write_to_sgid.ksh | 2 +- .../functional/suid/suid_write_to_suid.ksh | 2 +- .../suid/suid_write_to_suid_sgid.ksh | 2 +- .../functional/suid/suid_write_zil_replay.ksh | 16 +++---- .../tests/functional/truncate/.gitignore | 1 - .../tests/functional/truncate/Makefile.am | 7 ---- .../truncate/truncate_timestamps.ksh | 4 +- 55 files changed, 103 insertions(+), 216 deletions(-) rename tests/zfs-tests/{tests/functional => cmd}/checksum/edonr_test.c (100%) rename tests/zfs-tests/{tests/functional => cmd}/checksum/sha2_test.c (100%) rename tests/zfs-tests/{tests/functional => cmd}/checksum/skein_test.c (100%) rename tests/zfs-tests/{tests/functional/cp_files => cmd}/cp_files.c (100%) rename tests/zfs-tests/{tests/functional/ctime => cmd}/ctime.c (100%) rename tests/zfs-tests/{tests/functional/acl/off => cmd}/dosmode_readonly_write.c (100%) rename tests/zfs-tests/{tests/functional/cli_root/zpool_events => cmd}/ereports.c (98%) rename tests/zfs-tests/{tests/functional/suid => cmd}/suid_write_to_file.c (100%) rename tests/zfs-tests/{tests/functional/truncate => cmd}/truncate_test.c (100%) rename tests/zfs-tests/{tests/functional/events => cmd}/zed_fd_spill-zedlet.c (100%) rename tests/zfs-tests/{tests/functional/cli_root/zfs_diff/socket.c => cmd/zfs_diff-socket.c} (100%) delete mode 100644 tests/zfs-tests/tests/functional/acl/off/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/checksum/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/cp_files/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/ctime/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/events/.gitignore delete mode 100755 tests/zfs-tests/tests/functional/hkdf/cleanup.ksh delete mode 100755 tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh delete mode 100755 tests/zfs-tests/tests/functional/hkdf/setup.ksh delete mode 100644 tests/zfs-tests/tests/functional/suid/.gitignore delete mode 100644 tests/zfs-tests/tests/functional/truncate/.gitignore diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 87b669db7dcb..1cd439c434f2 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -640,7 +640,9 @@ tests = ['history_001_pos', 'history_002_pos', 'history_003_pos', tags = ['functional', 'history'] [tests/functional/hkdf] -tests = ['run_hkdf_test'] +pre = +post = +tests = ['hkdf_test'] tags = ['functional', 'hkdf'] [tests/functional/inheritance] diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index 9faf0e4d9913..0ed693c2f4ae 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -438,7 +438,9 @@ tests = ['history_004_pos', 'history_005_neg', 'history_007_pos', tags = ['functional', 'history'] [tests/functional/hkdf] -tests = ['run_hkdf_test'] +pre = +post = +tests = ['hkdf_test'] tags = ['functional', 'hkdf'] [tests/functional/inuse] diff --git a/tests/zfs-tests/cmd/.gitignore b/tests/zfs-tests/cmd/.gitignore index ea4d2613c578..e28fed8f12d8 100644 --- a/tests/zfs-tests/cmd/.gitignore +++ b/tests/zfs-tests/cmd/.gitignore @@ -32,3 +32,14 @@ /user_ns_exec /write_dos_attributes /xattrtest +/zed_fd_spill-zedlet +/suid_write_to_file +/cp_files +/ctime +/truncate_test +/ereports +/zfs_diff-socket +/dosmode_readonly_write +/edonr_test +/skein_test +/sha2_test diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am index ca3befb277c0..3b6f41ca0882 100644 --- a/tests/zfs-tests/cmd/Makefile.am +++ b/tests/zfs-tests/cmd/Makefile.am @@ -124,6 +124,45 @@ pkgexec_PROGRAMS += threadsappend threadsappend_SOURCES = threadsappend.c threadsappend_LDADD = -lpthread +pkgexec_PROGRAMS += suid_write_to_file +suid_write_to_file_SOURCES = suid_write_to_file.c + +pkgexec_PROGRAMS += cp_files +cp_files_SOURCES = cp_files.c + +pkgexec_PROGRAMS += ctime +ctime_SOURCES = ctime.c + +pkgexec_PROGRAMS += truncate_test +truncate_test_SOURCES = truncate_test.c + +pkgexec_PROGRAMS += ereports +ereports_SOURCES = ereports.c +ereports_LDADD = \ + $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ + $(abs_top_builddir)/lib/libzfs/libzfs.la + +pkgexec_PROGRAMS += zfs_diff-socket +zfs_diff_socket_SOURCES = zfs_diff-socket.c + +pkgexec_PROGRAMS += dosmode_readonly_write +dosmode_readonly_write_SOURCES = dosmode_readonly_write.c + + +pkgexec_PROGRAMS += edonr_test skein_test sha2_test +skein_test_SOURCES = checksum/skein_test.c +sha2_test_SOURCES = checksum/sha2_test.c +edonr_test_SOURCES = checksum/edonr_test.c +skein_test_LDADD = \ + $(abs_top_builddir)/lib/libicp/libicp.la \ + $(abs_top_builddir)/lib/libspl/libspl_assert.la +sha2_test_LDADD = \ + $(abs_top_builddir)/lib/libicp/libicp.la \ + $(abs_top_builddir)/lib/libspl/libspl_assert.la +edonr_test_LDADD = \ + $(abs_top_builddir)/lib/libicp/libicp.la \ + $(abs_top_builddir)/lib/libspl/libspl_assert.la + if BUILD_LINUX pkgexec_PROGRAMS += getversion @@ -142,4 +181,7 @@ user_ns_exec_SOURCES = user_ns_exec.c pkgexec_PROGRAMS += xattrtest xattrtest_SOURCES = xattrtest.c + +pkgexec_PROGRAMS += zed_fd_spill-zedlet +zed_fd_spill_zedlet_SOURCES = zed_fd_spill-zedlet.c endif diff --git a/tests/zfs-tests/tests/functional/checksum/edonr_test.c b/tests/zfs-tests/cmd/checksum/edonr_test.c similarity index 100% rename from tests/zfs-tests/tests/functional/checksum/edonr_test.c rename to tests/zfs-tests/cmd/checksum/edonr_test.c diff --git a/tests/zfs-tests/tests/functional/checksum/sha2_test.c b/tests/zfs-tests/cmd/checksum/sha2_test.c similarity index 100% rename from tests/zfs-tests/tests/functional/checksum/sha2_test.c rename to tests/zfs-tests/cmd/checksum/sha2_test.c diff --git a/tests/zfs-tests/tests/functional/checksum/skein_test.c b/tests/zfs-tests/cmd/checksum/skein_test.c similarity index 100% rename from tests/zfs-tests/tests/functional/checksum/skein_test.c rename to tests/zfs-tests/cmd/checksum/skein_test.c diff --git a/tests/zfs-tests/tests/functional/cp_files/cp_files.c b/tests/zfs-tests/cmd/cp_files.c similarity index 100% rename from tests/zfs-tests/tests/functional/cp_files/cp_files.c rename to tests/zfs-tests/cmd/cp_files.c diff --git a/tests/zfs-tests/tests/functional/ctime/ctime.c b/tests/zfs-tests/cmd/ctime.c similarity index 100% rename from tests/zfs-tests/tests/functional/ctime/ctime.c rename to tests/zfs-tests/cmd/ctime.c diff --git a/tests/zfs-tests/tests/functional/acl/off/dosmode_readonly_write.c b/tests/zfs-tests/cmd/dosmode_readonly_write.c similarity index 100% rename from tests/zfs-tests/tests/functional/acl/off/dosmode_readonly_write.c rename to tests/zfs-tests/cmd/dosmode_readonly_write.c diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c b/tests/zfs-tests/cmd/ereports.c similarity index 98% rename from tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c rename to tests/zfs-tests/cmd/ereports.c index bff3bb1ee808..392f5952d27a 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/ereports.c +++ b/tests/zfs-tests/cmd/ereports.c @@ -42,7 +42,7 @@ * When the class and all of these values match, then an ereport is * considered to be a duplicate. */ -static const char *criteria_name[] = { +static const char *const criteria_name[] = { FM_EREPORT_PAYLOAD_ZFS_POOL, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR, diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_to_file.c b/tests/zfs-tests/cmd/suid_write_to_file.c similarity index 100% rename from tests/zfs-tests/tests/functional/suid/suid_write_to_file.c rename to tests/zfs-tests/cmd/suid_write_to_file.c diff --git a/tests/zfs-tests/tests/functional/truncate/truncate_test.c b/tests/zfs-tests/cmd/truncate_test.c similarity index 100% rename from tests/zfs-tests/tests/functional/truncate/truncate_test.c rename to tests/zfs-tests/cmd/truncate_test.c diff --git a/tests/zfs-tests/tests/functional/events/zed_fd_spill-zedlet.c b/tests/zfs-tests/cmd/zed_fd_spill-zedlet.c similarity index 100% rename from tests/zfs-tests/tests/functional/events/zed_fd_spill-zedlet.c rename to tests/zfs-tests/cmd/zed_fd_spill-zedlet.c diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/socket.c b/tests/zfs-tests/cmd/zfs_diff-socket.c similarity index 100% rename from tests/zfs-tests/tests/functional/cli_root/zfs_diff/socket.c rename to tests/zfs-tests/cmd/zfs_diff-socket.c diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index 0951f719b95c..6e45d1ffc0af 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -206,4 +206,15 @@ export ZFSTEST_FILES='badsend user_ns_exec write_dos_attributes xattrtest - stride_dd' + stride_dd + zed_fd_spill-zedlet + suid_write_to_file + cp_files + edonr_test + skein_test + sha2_test + ctime + truncate_test + ereports + zfs_diff-socket + dosmode_readonly_write' diff --git a/tests/zfs-tests/tests/functional/acl/off/.gitignore b/tests/zfs-tests/tests/functional/acl/off/.gitignore deleted file mode 100644 index f3c93191cea9..000000000000 --- a/tests/zfs-tests/tests/functional/acl/off/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/dosmode_readonly_write diff --git a/tests/zfs-tests/tests/functional/acl/off/Makefile.am b/tests/zfs-tests/tests/functional/acl/off/Makefile.am index ae6a9c69d934..e315acc65ff8 100644 --- a/tests/zfs-tests/tests/functional/acl/off/Makefile.am +++ b/tests/zfs-tests/tests/functional/acl/off/Makefile.am @@ -1,5 +1,3 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off dist_pkgdata_SCRIPTS = \ @@ -7,8 +5,3 @@ dist_pkgdata_SCRIPTS = \ posixmode.ksh \ cleanup.ksh \ setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/acl/off - -pkgexec_PROGRAMS = dosmode_readonly_write -dosmode_readonly_write_SOURCES = dosmode_readonly_write.c diff --git a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh index 329eaef55dd3..bab2109b9d58 100755 --- a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh +++ b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh @@ -64,7 +64,6 @@ function hasflag log_assert "Verify DOS mode flags function correctly" log_onexit cleanup -tests_base=$STF_SUITE/tests/functional/acl/off testfile=$TESTDIR/testfile owner=$ZFS_ACL_STAFF1 other=$ZFS_ACL_STAFF2 @@ -157,7 +156,7 @@ log_must rm $testfile # READONLY is set. We have a special test program for that. log_must user_run $owner touch $testfile log_mustnot user_run $other $changeflags rdonly $testfile -log_must user_run $owner $tests_base/dosmode_readonly_write $testfile +log_must user_run $owner dosmode_readonly_write $testfile log_mustnot user_run $other $changeflags nordonly $testfile log_must hasflag rdonly $testfile if ! is_linux; then diff --git a/tests/zfs-tests/tests/functional/checksum/.gitignore b/tests/zfs-tests/tests/functional/checksum/.gitignore deleted file mode 100644 index 0411d5aa47dc..000000000000 --- a/tests/zfs-tests/tests/functional/checksum/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -skein_test -edonr_test -sha2_test - diff --git a/tests/zfs-tests/tests/functional/checksum/Makefile.am b/tests/zfs-tests/tests/functional/checksum/Makefile.am index 717098aa0723..2eed764befd2 100644 --- a/tests/zfs-tests/tests/functional/checksum/Makefile.am +++ b/tests/zfs-tests/tests/functional/checksum/Makefile.am @@ -1,9 +1,3 @@ -include $(top_srcdir)/config/Rules.am - -LDADD = \ - $(abs_top_builddir)/lib/libicp/libicp.la \ - $(abs_top_builddir)/lib/libspl/libspl_assert.la - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum dist_pkgdata_SCRIPTS = \ @@ -17,15 +11,3 @@ dist_pkgdata_SCRIPTS = \ dist_pkgdata_DATA = \ default.cfg - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum - -pkgexec_PROGRAMS = \ - edonr_test \ - skein_test \ - sha2_test - -skein_test_SOURCES = skein_test.c -sha2_test_SOURCES = sha2_test.c - -edonr_test_SOURCES = edonr_test.c diff --git a/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh b/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh index 42e88a8c8e3f..de5b21918edb 100755 --- a/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh +++ b/tests/zfs-tests/tests/functional/checksum/run_edonr_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the EdonR hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/edonr_test $freq +log_must edonr_test $freq log_pass "EdonR tests passed." diff --git a/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh b/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh index e238d7a53e6d..23954a5d35fe 100755 --- a/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh +++ b/tests/zfs-tests/tests/functional/checksum/run_sha2_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the SHA-2 hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/sha2_test $freq +log_must sha2_test $freq log_pass "SHA-2 tests passed." diff --git a/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh b/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh index b3a33c3ca8bc..d59bde206d77 100755 --- a/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh +++ b/tests/zfs-tests/tests/functional/checksum/run_skein_test.ksh @@ -25,6 +25,6 @@ log_assert "Run the tests for the Skein hash algorithm." freq=$(get_cpu_freq) -log_must $STF_SUITE/tests/functional/checksum/skein_test $freq +log_must skein_test $freq log_pass "Skein tests passed." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore deleted file mode 100644 index 7fa74c3575bd..000000000000 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/socket diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am index bfb01dcb8f86..136cfe186d6c 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/Makefile.am @@ -1,5 +1,3 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff dist_pkgdata_SCRIPTS = \ @@ -11,8 +9,3 @@ dist_pkgdata_SCRIPTS = \ zfs_diff_mangle.ksh \ zfs_diff_timestamp.ksh \ zfs_diff_types.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_diff - -pkgexec_PROGRAMS = socket -socket_SOURCES = socket.c diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh index 07b14e7aec6b..414fde336c78 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh @@ -123,7 +123,7 @@ verify_object_class "$MNTPOINT/dir" "/" # 2. = (Socket) log_must zfs snapshot "$TESTSNAP1" -log_must $STF_SUITE/tests/functional/cli_root/zfs_diff/socket "$MNTPOINT/sock" +log_must zfs_diff-socket "$MNTPOINT/sock" log_must zfs snapshot "$TESTSNAP2" verify_object_class "$MNTPOINT/sock" "=" diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore b/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore deleted file mode 100644 index a1f8c14838fa..000000000000 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ereports diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am index 765df102229d..e1a9fd404b62 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/Makefile.am @@ -1,7 +1,4 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zpool_events dist_pkgdata_SCRIPTS = \ setup.ksh \ @@ -17,10 +14,3 @@ dist_pkgdata_SCRIPTS = \ dist_pkgdata_DATA = \ zpool_events.cfg \ zpool_events.kshlib - -ereports_LDADD = \ - $(abs_top_builddir)/lib/libnvpair/libnvpair.la \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - -pkgexec_PROGRAMS = ereports -ereports_SOURCES = ereports.c diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh index 76d9c525e443..9b5b5e1a0227 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh @@ -55,8 +55,6 @@ OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX) RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX) OLD_CHECKSUMS=$(get_tunable CHECKSUM_EVENTS_PER_SECOND) -EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports" - function cleanup { log_must set_tunable64 CHECKSUM_EVENTS_PER_SECOND $OLD_CHECKSUMS @@ -78,7 +76,7 @@ function damage_and_repair log_must dd conv=notrunc if=$SUPPLY of=$VDEV1 bs=1M seek=4 count=$DAMAGEBLKS log_must zpool scrub $POOL log_must zpool wait -t scrub $POOL - log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports" + log_note "pass $1 observed $(ereports | grep -c checksum) checksum ereports" repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}') if [ "$repaired" == "0B" ]; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh index 142ebacd4558..08ab6a2fabcf 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh @@ -46,8 +46,6 @@ FILESIZE="10M" OLD_LEN_MAX=$(get_tunable ZEVENT_LEN_MAX) RETAIN_MAX=$(get_tunable ZEVENT_RETAIN_MAX) -EREPORTS="$STF_SUITE/tests/functional/cli_root/zpool_events/ereports" - duplicates=false function cleanup @@ -117,7 +115,7 @@ function do_dup_test log_must zinject -c all - ereports="$($EREPORTS | sort)" + ereports="$(ereports | sort)" actual=$(echo "$ereports" | wc -l) unique=$(echo "$ereports" | uniq | wc -l) log_note "$actual total $ERR $RW ereports where $unique were unique" diff --git a/tests/zfs-tests/tests/functional/cp_files/.gitignore b/tests/zfs-tests/tests/functional/cp_files/.gitignore deleted file mode 100644 index eac05e155378..000000000000 --- a/tests/zfs-tests/tests/functional/cp_files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/cp_files diff --git a/tests/zfs-tests/tests/functional/cp_files/Makefile.am b/tests/zfs-tests/tests/functional/cp_files/Makefile.am index 06c31f5f3f92..92e258f0d26d 100644 --- a/tests/zfs-tests/tests/functional/cp_files/Makefile.am +++ b/tests/zfs-tests/tests/functional/cp_files/Makefile.am @@ -1,13 +1,6 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files dist_pkgdata_SCRIPTS = \ cp_files_001_pos.ksh \ cleanup.ksh \ setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cp_files - -pkgexec_PROGRAMS = cp_files -cp_files_SOURCES= cp_files.c diff --git a/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh b/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh index 208ecfeed334..3a814ca3621f 100755 --- a/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh @@ -55,8 +55,7 @@ log_onexit cleanup NR_FILES=60000 BATCH=1000 -log_must mkdir $TESTDIR/src -log_must mkdir $TESTDIR/dst +log_must mkdir $TESTDIR/src $TESTDIR/dst WD=$PWD cd $TESTDIR/src @@ -67,7 +66,7 @@ cd $WD log_must test $NR_FILES -eq $(ls -U $TESTDIR/src | wc -l) # copy files from src to dst, use cp_files to make sure we copy in readdir order -log_must $STF_SUITE/tests/functional/cp_files/cp_files $TESTDIR/src $TESTDIR/dst +log_must cp_files $TESTDIR/src $TESTDIR/dst log_must test $NR_FILES -eq $(ls -U $TESTDIR/dst | wc -l) diff --git a/tests/zfs-tests/tests/functional/ctime/.gitignore b/tests/zfs-tests/tests/functional/ctime/.gitignore deleted file mode 100644 index 9e4539d5fee0..000000000000 --- a/tests/zfs-tests/tests/functional/ctime/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/ctime diff --git a/tests/zfs-tests/tests/functional/ctime/Makefile.am b/tests/zfs-tests/tests/functional/ctime/Makefile.am index e7479ae81056..724e5b99eee4 100644 --- a/tests/zfs-tests/tests/functional/ctime/Makefile.am +++ b/tests/zfs-tests/tests/functional/ctime/Makefile.am @@ -1,13 +1,6 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime dist_pkgdata_SCRIPTS = \ ctime_001_pos.ksh \ cleanup.ksh \ setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/ctime - -pkgexec_PROGRAMS = ctime -ctime_SOURCES = ctime.c diff --git a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh index de12efe46bc0..035785772db4 100755 --- a/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/ctime/ctime_001_pos.ksh @@ -38,7 +38,7 @@ log_note "Verify [acm]time is modified appropriately." for arg in ${args[*]}; do log_note "Testing with xattr set to $arg" log_must zfs set xattr=$arg $TESTPOOL - log_must $STF_SUITE/tests/functional/ctime/ctime + log_must ctime done log_pass "PASS" diff --git a/tests/zfs-tests/tests/functional/events/.gitignore b/tests/zfs-tests/tests/functional/events/.gitignore deleted file mode 100644 index ed5af03a1095..000000000000 --- a/tests/zfs-tests/tests/functional/events/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/zed_fd_spill-zedlet diff --git a/tests/zfs-tests/tests/functional/events/Makefile.am b/tests/zfs-tests/tests/functional/events/Makefile.am index 92ce5dbc3825..7d8ae6167637 100644 --- a/tests/zfs-tests/tests/functional/events/Makefile.am +++ b/tests/zfs-tests/tests/functional/events/Makefile.am @@ -1,5 +1,3 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/events dist_pkgdata_SCRIPTS = \ setup.ksh \ @@ -12,7 +10,3 @@ dist_pkgdata_SCRIPTS = \ dist_pkgdata_DATA = \ events.cfg \ events_common.kshlib - -pkgexecdir = $(pkgdatadir) -pkgexec_PROGRAMS = zed_fd_spill-zedlet -zed_fd_spill_zedlet_SOURCES = zed_fd_spill-zedlet.c diff --git a/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh b/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh index 4ae136d0f36c..d70dd0c7b445 100755 --- a/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh +++ b/tests/zfs-tests/tests/functional/events/zed_fd_spill.ksh @@ -48,13 +48,12 @@ logdir="$(mktemp -d)" log_must ln -s "$logdir" /tmp/zts-zed_fd_spill-logdir -self="$(readlink -f "$0")" -zedlet="${self%/*}/zed_fd_spill-zedlet" -log_must ln -s $zedlet "${ZEDLET_DIR}/all-dumpfds" +zedlet="$(command -v zed_fd_spill-zedlet)" +log_must ln -s "$zedlet" "${ZEDLET_DIR}/all-dumpfds" # zed will cry foul and refuse to run it if this isn't true -sudo chown root $zedlet -sudo chmod 700 $zedlet +sudo chown root "$zedlet" +sudo chmod 700 "$zedlet" log_must zpool events -c log_must zed_stop diff --git a/tests/zfs-tests/tests/functional/hkdf/Makefile.am b/tests/zfs-tests/tests/functional/hkdf/Makefile.am index 8ac9053223a4..1d126c4a907a 100644 --- a/tests/zfs-tests/tests/functional/hkdf/Makefile.am +++ b/tests/zfs-tests/tests/functional/hkdf/Makefile.am @@ -1,17 +1,8 @@ include $(top_srcdir)/config/Rules.am -pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf - -dist_pkgdata_SCRIPTS = \ - setup.ksh \ - cleanup.ksh \ - run_hkdf_test.ksh - pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/hkdf -pkgexec_PROGRAMS = \ - hkdf_test - +pkgexec_PROGRAMS = hkdf_test hkdf_test_SOURCES = hkdf_test.c hkdf_test_LDADD = \ $(abs_top_builddir)/lib/libzpool/libzpool.la diff --git a/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh b/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh deleted file mode 100755 index 2bdca1950d37..000000000000 --- a/tests/zfs-tests/tests/functional/hkdf/cleanup.ksh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -verify_runnable "global" - -log_pass diff --git a/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh b/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh deleted file mode 100755 index 5fde0b837d0f..000000000000 --- a/tests/zfs-tests/tests/functional/hkdf/run_hkdf_test.ksh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -# -# DESCRIPTION: -# Call the hkdf_test tool to test ZFS's HKDF implementation against -# a few test vectors. -# - -log_assert "Run the tests for the HKDF algorithm." - -log_must $STF_SUITE/tests/functional/hkdf/hkdf_test - -log_pass "HKDF tests pass." diff --git a/tests/zfs-tests/tests/functional/hkdf/setup.ksh b/tests/zfs-tests/tests/functional/hkdf/setup.ksh deleted file mode 100755 index 2bdca1950d37..000000000000 --- a/tests/zfs-tests/tests/functional/hkdf/setup.ksh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/ksh - -# -# This file and its contents are supplied under the terms of the -# Common Development and Distribution License ("CDDL"), version 1.0. -# You may only use this file in accordance with the terms of version -# 1.0 of the CDDL. -# -# A full copy of the text of the CDDL should have accompanied this -# source. A copy of the CDDL is also available via the Internet at -# http://www.illumos.org/license/CDDL. -# - -# -# Copyright (c) 2017 by Datto Inc. All rights reserved. -# - -. $STF_SUITE/include/libtest.shlib - -verify_runnable "global" - -log_pass diff --git a/tests/zfs-tests/tests/functional/libzfs/Makefile.am b/tests/zfs-tests/tests/functional/libzfs/Makefile.am index 53cb635444ab..51482f4e63b5 100644 --- a/tests/zfs-tests/tests/functional/libzfs/Makefile.am +++ b/tests/zfs-tests/tests/functional/libzfs/Makefile.am @@ -1,7 +1,6 @@ include $(top_srcdir)/config/Rules.am pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs - pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/libzfs dist_pkgdata_SCRIPTS = \ @@ -9,9 +8,7 @@ dist_pkgdata_SCRIPTS = \ setup.ksh \ libzfs_input.ksh -many_fds_LDADD = \ - $(abs_top_builddir)/lib/libzfs/libzfs.la - pkgexec_PROGRAMS = many_fds many_fds_SOURCES = many_fds.c - +many_fds_LDADD = \ + $(abs_top_builddir)/lib/libzfs/libzfs.la diff --git a/tests/zfs-tests/tests/functional/suid/.gitignore b/tests/zfs-tests/tests/functional/suid/.gitignore deleted file mode 100644 index a9a3db79ba44..000000000000 --- a/tests/zfs-tests/tests/functional/suid/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/suid_write_to_file diff --git a/tests/zfs-tests/tests/functional/suid/Makefile.am b/tests/zfs-tests/tests/functional/suid/Makefile.am index 0145c1205fb3..439b41adc7d1 100644 --- a/tests/zfs-tests/tests/functional/suid/Makefile.am +++ b/tests/zfs-tests/tests/functional/suid/Makefile.am @@ -1,5 +1,3 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid dist_pkgdata_SCRIPTS = \ @@ -10,8 +8,3 @@ dist_pkgdata_SCRIPTS = \ suid_write_zil_replay.ksh \ cleanup.ksh \ setup.ksh - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/suid - -pkgexec_PROGRAMS = suid_write_to_file -suid_write_to_file_SOURCES = suid_write_to_file.c diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh b/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh index 470350f960cf..907c94e3fd9c 100755 --- a/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh +++ b/tests/zfs-tests/tests/functional/suid/suid_write_to_none.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to regular file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH" +log_must suid_write_to_file "NONE" "PRECRASH" log_pass "Verify write(2) to regular file by non-owner passed" diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh b/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh index 3c95a402658e..4554bc3c00a4 100755 --- a/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh +++ b/tests/zfs-tests/tests/functional/suid/suid_write_to_sgid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SGID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH" +log_must suid_write_to_file "SGID" "PRECRASH" log_pass "Verify write(2) to SGID file by non-owner passed" diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh b/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh index 4183cbeefc20..541e1125d539 100755 --- a/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh +++ b/tests/zfs-tests/tests/functional/suid/suid_write_to_suid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SUID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH" +log_must suid_write_to_file "SUID" "PRECRASH" log_pass "Verify write(2) to SUID file by non-owner passed" diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh b/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh index f7a08a55fc4b..57361d2e39a9 100755 --- a/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh +++ b/tests/zfs-tests/tests/functional/suid/suid_write_to_suid_sgid.ksh @@ -47,6 +47,6 @@ function cleanup log_onexit cleanup log_note "Verify write(2) to SUID/SGID file by non-owner" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH" +log_must suid_write_to_file "SUID_SGID" "PRECRASH" log_pass "Verify write(2) to SUID/SGID file by non-owner passed" diff --git a/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh b/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh index 81f431f6b68b..8843e67da24b 100755 --- a/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh +++ b/tests/zfs-tests/tests/functional/suid/suid_write_zil_replay.ksh @@ -65,10 +65,10 @@ log_must zpool freeze $TESTPOOL # # 3. Unprivileged write to a setuid file # -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "PRECRASH" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "PRECRASH" +log_must suid_write_to_file "NONE" "PRECRASH" +log_must suid_write_to_file "SUID" "PRECRASH" +log_must suid_write_to_file "SGID" "PRECRASH" +log_must suid_write_to_file "SUID_SGID" "PRECRASH" # # 4. Unmount filesystem and export the pool @@ -91,9 +91,9 @@ log_must zpool export $TESTPOOL # log_must zpool import -f -d $VDIR $TESTPOOL -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "NONE" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SGID" "REPLAY" -log_must $STF_SUITE/tests/functional/suid/suid_write_to_file "SUID_SGID" "REPLAY" +log_must suid_write_to_file "NONE" "REPLAY" +log_must suid_write_to_file "SUID" "REPLAY" +log_must suid_write_to_file "SGID" "REPLAY" +log_must suid_write_to_file "SUID_SGID" "REPLAY" log_pass diff --git a/tests/zfs-tests/tests/functional/truncate/.gitignore b/tests/zfs-tests/tests/functional/truncate/.gitignore deleted file mode 100644 index f28d93573c51..000000000000 --- a/tests/zfs-tests/tests/functional/truncate/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/truncate_test diff --git a/tests/zfs-tests/tests/functional/truncate/Makefile.am b/tests/zfs-tests/tests/functional/truncate/Makefile.am index b2d804b5d4c2..14a2b301f1d1 100644 --- a/tests/zfs-tests/tests/functional/truncate/Makefile.am +++ b/tests/zfs-tests/tests/functional/truncate/Makefile.am @@ -1,5 +1,3 @@ -include $(top_srcdir)/config/Rules.am - pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate dist_pkgdata_SCRIPTS = \ @@ -11,8 +9,3 @@ dist_pkgdata_SCRIPTS = \ dist_pkgdata_DATA = \ truncate.cfg - -pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/truncate - -pkgexec_PROGRAMS = truncate_test -truncate_test_SOURCES = truncate_test.c diff --git a/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh b/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh index 27b28e82eb5b..3793178701d8 100755 --- a/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh +++ b/tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh @@ -42,7 +42,7 @@ function verify_truncate #