diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib index c9c01ab752..33423a7e3c 100644 --- a/tests/test-runner/include/logapi.shlib +++ b/tests/test-runner/include/logapi.shlib @@ -55,7 +55,6 @@ function log_note function log_neg { log_neg_expect "" "$@" - return $? } # Execute a positive test and exit $STF_FAIL is test fails @@ -64,8 +63,7 @@ function log_neg function log_must { - log_pos "$@" - (( $? != 0 )) && log_fail + log_pos "$@" || log_fail } # Execute a positive test (expecting no stderr) and exit $STF_FAIL @@ -74,8 +72,7 @@ function log_must function log_must_nostderr { - log_pos_nostderr "$@" - (( $? != 0 )) && log_fail + log_pos_nostderr "$@" || log_fail } # Execute a positive test but retry the command on failure if the output @@ -149,8 +146,7 @@ function log_must_retry # $@ - command to execute function log_must_busy { - log_must_retry "busy" 5 "$@" - (( $? != 0 )) && log_fail + log_must_retry "busy" 5 "$@" || log_fail } # Execute a negative test and exit $STF_FAIL if test passes @@ -159,8 +155,7 @@ function log_must_busy function log_mustnot { - log_neg "$@" - (( $? != 0 )) && log_fail + log_neg "$@" || log_fail } # Execute a negative test with keyword expected, and exit @@ -171,8 +166,7 @@ function log_mustnot function log_mustnot_expect { - log_neg_expect "$@" - (( $? != 0 )) && log_fail + log_neg_expect "$@" || log_fail } # Signal numbers are platform-dependent @@ -576,5 +570,5 @@ function _recursive_output #logfile fi rm -f $logfile logfile="$logfile.$$" - done + done } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index deb501698a..807954a606 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -154,12 +154,7 @@ typeset -i i=0 while ((i < ${#dataset[@]})); do for opt in "${options[@]}"; do for prop in ${all_props[@]}; do - eval "zfs get $opt $prop ${dataset[i]} > \ - $TESTDIR/$TESTFILE0" - ret=$? - if [[ $ret != 0 ]]; then - log_fail "zfs get returned: $ret" - fi + log_must eval "zfs get $opt $prop ${dataset[i]} > $TESTDIR/$TESTFILE0" check_return_value ${dataset[i]} "$prop" "$opt" done done @@ -170,12 +165,7 @@ i=0 while ((i < ${#bookmark[@]})); do for opt in "${options[@]}"; do for prop in ${bookmark_props[@]}; do - eval "zfs get $opt $prop ${bookmark[i]} > \ - $TESTDIR/$TESTFILE0" - ret=$? - if [[ $ret != 0 ]]; then - log_fail "zfs get returned: $ret" - fi + log_must eval "zfs get $opt $prop ${bookmark[i]} > $TESTDIR/$TESTFILE0" check_return_value ${bookmark[i]} "$prop" "$opt" done done 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 c3746514ea..88822adfc7 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,11 +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 - zfs get $opt $prop $dst > /dev/null 2>&1 - ret=$? - if [[ $ret != 0 ]]; then - log_fail "zfs get $opt $prop $dst (Code: $ret)" - fi + log_must eval "zfs get $opt $prop $dst > /dev/null" 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 510c54506d..c527cef087 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,12 +93,7 @@ function test_options for dst in ${dataset[@]}; do for opt in $opts; do for prop in $props; do - zfs get $opt -- $prop $dst > /dev/null 2>&1 - ret=$? - if [[ $ret == 0 ]]; then - log_fail "zfs get $opt -- $prop " \ - "$dst unexpectedly succeeded." - fi + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" done done done @@ -118,12 +113,7 @@ function test_options_bookmarks for dst in ${bookmark[@]}; do for opt in $opts; do for prop in $props; do - zfs get $opt -- $prop $dst > /dev/null 2>&1 - ret=$? - if [[ $ret == 0 ]]; then - log_fail "zfs get $opt -- $prop " \ - "$dst unexpectedly succeeded." - fi + log_mustnot eval "zfs get $opt -- $prop $dst > /dev/null" done done done 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 591d5b85e8..f187b88f05 100755 --- a/tests/zfs-tests/tests/functional/history/history_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_007_pos.ksh @@ -49,7 +49,7 @@ function cleanup poolexists $migratedpoolname && \ log_must zpool destroy -f $migratedpoolname - [[ -d $import_dir ]] && rm -rf $import_dir + rm -rf $import_dir } log_assert "Verify command history moves with migrated pool." @@ -80,10 +80,7 @@ for arch in "i386" "sparc"; do log_must zpool destroy -f $migratedpoolname log_must zpool import -d $import_dir $migratedpoolname - TZ=$TIMEZONE zpool history $migratedpoolname | grep -v "^$" \ - >$migrated_cmds_f - RET=$? - (( $RET != 0 )) && log_fail "zpool history $migratedpoolname fails." + 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 @@ -92,14 +89,13 @@ 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 "$subcmd" $migrated_cmds_f >/dev/null 2>&1 - RET=$? - (( $RET != 0 )) && 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=`cat $migrated_cmds_f | wc -l` + linenum=`wc -l < $migrated_cmds_f` (( linenum = linenum - 2 )) head -n $linenum $migrated_cmds_f > $tmpfile log_must diff $tmpfile $orig_cmds_f1 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 6b51598d7c..6f6acdafaf 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 @@ -120,7 +120,7 @@ typeset str typeset -i ret for volsize in $VOLSIZES; do log_note "Create a pool which will contain a volume device" - create_pool $TESTPOOL2 "$DISKS" + 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) @@ -140,7 +140,7 @@ for volsize in $VOLSIZES; do block_device_wait log_note "Create the largest pool allowed using the volume vdev" - create_pool $TESTPOOL "$VOL_PATH" + log_must create_pool $TESTPOOL "$VOL_PATH" log_note "Create a zfs file system in the largest pool" log_must zfs create $TESTPOOL/$TESTFS 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 68f0e13927..f2df0ed034 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_011_pos.ksh @@ -67,18 +67,12 @@ done # for ds in "$POOL/$FS/fs1" "$POOL/$FS/fs1/fs2" "$POOL/$FS/fs1/fclone" ; do for prop in $(fs_inherit_prop) ; do - zfs inherit $prop $ds - if (($? !=0 )); then - log_fail "zfs inherit $prop $ds" - fi + log_must zfs inherit $prop $ds done done if is_global_zone ; then for prop in $(vol_inherit_prop) ; do - zfs inherit $prop $POOL/$FS/vol - if (($? !=0 )); then - log_fail "zfs inherit $prop $POOL/$FS/vol" - fi + 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 594357dc4b..694dd15b44 100755 --- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh @@ -52,18 +52,13 @@ function edited_prop "get") typeset props=$(zfs inherit 2>&1 | \ awk '$2=="YES" {print $1}' | \ - egrep -v "^vol|\.\.\.$") + grep -Ev "^vol|\.\.\.$") for item in $props ; do if [[ $item == "mlslabel" ]] && \ ! is_te_enabled ; then continue fi - zfs get -H -o property,value $item $ds >> \ - $backfile - if (($? != 0)); then - log_fail "zfs get -H -o property,value"\ - "$item $ds > $backfile" - fi + log_must eval "zfs get -H -o property,value $item $ds >> $backfile" done ;; "set") @@ -72,11 +67,8 @@ function edited_prop fi typeset prop value - while read prop value ; do - eval zfs set $prop='$value' $ds - if (($? != 0)); then - log_fail "zfs set $prop=$value $ds" - fi + while read -r prop value; do + log_must zfs set "$prop=$value" "$ds" done < $backfile ;; *)