From 23914a3b9146c05ddf985b134472b6c885cefdfe 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] tests: review every instance of $? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Reviewed-by: Ryan Moeller Signed-off-by: Ahelenia ZiemiaƄska Closes #13259 --- 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 | 71 ++++--- .../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, 560 insertions(+), 1485 deletions(-) diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index a97d1582d4..3e11d15483 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 5f0f2d56ac..d4dae8e593 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 1450f7b660..e0d40f3d2d 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 d88217e5ca..65c15388cf 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" - - # 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" - - # 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" -else +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 + +# Should be able to write to file +log_must user_run $ZFS_ACL_STAFF1 \ + "echo 'echo test > /dev/null' > $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 + +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 8764dd5a21..ac718ec588 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 3e9357063b..6f2f54ebdd 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 a5bc7753e9..172b694008 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 78accbc82d..78559dd186 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 97b456aade..5ea0f6c1a9 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 c5d7b2e3f4..2738d3916e 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 cefcbc51e7..667ac87b4f 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 58e2385ea0..9948c62801 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 f0fe1bbaa8..ad5b5367ae 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 a828ba2906..c937e90614 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 d4b3cdcaba..85c9b6ea63 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 36f1929dd1..0e4dcf8e6f 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 4f661262a7..d79933fd5b 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 9daf61f82f..c7e10bac45 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 0218e2e16b..84f758904b 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 993c6436a7..d3855cb315 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 703ae8043d..1e22da0045 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 acab500062..b18ffa404c 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 88822adfc7..6717787d06 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 c527cef087..13685ef6f4 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 296fe99968..9f3dd47cde 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 2580070e67..1e80d4d2b7 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 62f255ca38..aba317f542 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 f7461437c6..4a85999b4a 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 c0cb693f6c..b42b2496e4 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 8a6cd8c409..2b4a086965 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 37fe515e23..6cda13690c 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 4638b63d72..0a5b6c3611 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 788e093fb2..03701d4f55 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 af1c2f7bed..cafffbd852 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 b18433085e..2c7bac8516 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 42bdddd2cc..c55ce08d00 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 f1befe60c3..0ddafe178e 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 de6d83d227..b929047cf1 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 7177fac202..e24376a2bf 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 bd11ea0883..8ab52679eb 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 cf5ef5116e..318a9aae6b 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 04886e38c2..2858275cf2 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 013e04ba31..ea9f348e0e 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 c64157cee6..553605000d 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 cf8c84cfe3..ddd65e8885 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 16926a48dd..62bf71390c 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 c133403ac8..be5bbc8346 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 9499dca21e..40b936dee9 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 525dfd1629..3fc5509a61 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 89cc4b0d30..80a2213d9a 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 4637fe0d84..df04ecc5b8 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 618c6992ed..745f60507b 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 2c1f6e0ca6..426321db06 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 e4543f0df7..b3dd2cefc7 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 104b5ec986..39097df2fb 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 98d2ee543b..3e3c9ce942 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 1623a18e47..27e2cf0ba4 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 42c46712f3..0e3829fcc8 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 6bbd46289f..c49777e6b3 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 62843b0622..ccd266c727 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 2681e69f4e..5bd8b56ffd 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 8040d12b92..913a4cd6a3 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 b695b7188c..de39aa260f 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 89fca9cbd4..7c2e214b7d 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 87942b4a52..ce9885904b 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 d79c757d24..4b6fcbd80a 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 b91b496ee3..559810ff0e 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 ec387b2256..a9d5e2b319 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 6f4c2e3182..4f3c187b91 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 7b5d21cba2..ceef4cc316 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 8489fddb41..e104a9323f 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 3d142fdf70..9b3bc14322 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 1b18b1297a..f1b957e620 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 f076f26818..a524c4b17a 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 f08fdfab7f..6e4e6be6a1 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 3adfc59f51..490da6c8ca 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 98383a0876..604887f6a2 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 43cfd0cf21..8e3a5680d3 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 15adc5a636..90045f0b3e 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 2f13da7504..d783b41734 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 c11bf8442b..2082659a30 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 36d30b51e2..3a1a610b8d 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 f187b88f05..c0ce0aae74 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 2c32b1b6ce..57a7cb4466 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 f441799c89..95f9441bf6 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 cd6bd5c027..a485d0521d 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 95dc7359f2..4dfc3a8986 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 24918e2174..8c984df308 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 a9725e06dc..8e051d8b6f 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 6f6acdafaf..7955478502 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 1a1f3f4273..79676d79e6 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 2b1955fe93..0362f0644f 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 875d2f7c78..3a4a4b7f8f 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 6b97e2a407..a522174f11 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 dd0baeaa9b..c83883d356 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 00a6cc172a..5a4375410e 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 4386596f77..f282c37b7a 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 9b5c9166ed..a2ebd1f3f2 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 0d136550f7..40839ecc00 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 f62b1f33a3..af60e4bc1f 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 907be39eb4..e24cfdc96d 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 e80dd67cdc..f090fed3d8 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 2d7ecb45ea..4293c8d8bd 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 fd9c454916..675b4a159b 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 636d2fa686..da681164e1 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 a664433743..1c170208b5 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 c49b19c6c3..209c3509a3 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 fdadac32d5..c20831babf 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 5050447c00..1d1b1c944c 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 e66e7e10fe..a2427f2e18 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 fdefc0c3bd..18ef2309c6 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 4eb0693944..9d48d1961a 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 06f360d30b..44a5b09f90 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 0582164f9d..a90e001b24 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 88906d91cd..0402d241b1 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 84e20e2e7e..d55c4f3270 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 0ffe6394b5..12e882d47e 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 6399c11ced..78c33d81db 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 a8f58631f7..6b096f5d20 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 d7b6de1a2e..938a7d391a 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 998d3eec7c..384a588064 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 e99d681bb2..d855ad928b 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 f049c639d8..8c8eb1e883 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 b3c7995fd6..19823de124 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 2585397bba..f25e8f548b 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 ea63defdce..0098f64712 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 f2df0ed034..88f79f3e92 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 61d5e12cba..6c75172be5 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 e5c3490b32..55b8c002e6 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 dbdf1f1ce5..9d9bcf885d 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 34e72a70d7..b64c026eeb 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 dc375e2224..6e562e6c90 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 d229c1d74b..560e846cee 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 2c609c9eb5..29cbbeb660 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 ae748e2c63..896645f7ca 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 cee3c6fb32..40f9184c52 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 429b16e04e..e559022378 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 7ad36a7143..4f0fb1abf4 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 fdfefbf674..7d7827e135 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 efa9faab96..a5a43ff108 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 aa47f6c0fd..c0fd90f58e 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 297ad242fe..16ff1f5f87 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 e0dce0c2c3..0f8dbb1bcf 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 48dfe6d938..b4a6f12485 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 b69d2ce029..da8a494b4a 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 2ec8c72c67..6c6ca2b3b6 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 c9b4505e23..83e1da2542 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 }