diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index b9bebc1ab7..ad2c26976d 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -1448,7 +1448,7 @@ function unshare_fs #fs typeset fs=$1 if is_shared $fs || is_shared_smb $fs; then - zfs unshare $fs || log_fail "zfs unshare $fs failed" + log_must zfs unshare $fs fi } @@ -2141,10 +2141,7 @@ function check_hotspare_state # pool disk state{inuse,avail} cur_state=$(get_device_state $pool $disk "spares") - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -2204,10 +2201,7 @@ function check_vdev_state # pool disk state{online,offline,unavail} cur_state=$(get_device_state $pool $disk) - if [[ $state != ${cur_state} ]]; then - return 1 - fi - return 0 + [ $state = $cur_state ] } # @@ -3197,32 +3191,8 @@ function get_rootfs # function get_rootpool { - typeset rootfs="" - typeset rootpool="" - - if is_freebsd; then - rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}') - elif ! is_linux; then - rootfs=$(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \ - /etc/mnttab) - fi - if [[ -z "$rootfs" ]]; then - log_fail "Can not get rootpool" - fi - zfs list $rootfs > /dev/null 2>&1 - if (($? == 0)); then - echo ${rootfs%%/*} - else - log_fail "This is not a zfsroot system." - fi -} - -# -# Get the word numbers from a string separated by white space -# -function get_word_count -{ - echo $1 | wc -w + typeset rootfs=$(get_rootfs) + echo ${rootfs%%/*} } # @@ -3232,7 +3202,7 @@ function verify_disk_count { typeset -i min=${2:-1} - typeset -i count=$(get_word_count "$1") + typeset -i count=$(echo "$1" | wc -w) if ((count < min)); then log_untested "A minimum of $min disks is required to run." \ @@ -3266,26 +3236,23 @@ function ds_is_snapshot # function is_te_enabled { - svcs -H -o state labeld 2>/dev/null | grep "enabled" - if (($? != 0)); then - return 1 - else - return 0 - fi + svcs -H -o state labeld 2>/dev/null | grep -q "enabled" } # Utility function to determine if a system has multiple cpus. function is_mp { - if is_linux; then - (($(nproc) > 1)) - elif is_freebsd; then - sysctl -n kern.smp.cpus - else - (($(psrinfo | wc -l) > 1)) - fi - - return $? + case $(uname) in + Linux) + (($(nproc) > 1)) + ;; + FreeBSD) + sysctl -n kern.smp.cpus + ;; + *) + (($(psrinfo | wc -l) > 1)) + ;; + esac } function get_cpu_freq @@ -3409,20 +3376,20 @@ function write_compressible done done else - log_must eval "fio \ + log_must eval fio \ --name=job \ --fallocate=0 \ --minimal \ --randrepeat=0 \ --buffer_compress_percentage=66 \ --buffer_compress_chunk=4096 \ - --directory=$dir \ - --numjobs=$nfiles \ - --nrfiles=$nfiles \ + --directory="$dir" \ + --numjobs="$nfiles" \ + --nrfiles="$nfiles" \ --rw=write \ - --bs=$bs \ - --filesize=$megs \ - --filename_format='$fname.\$jobnum' >/dev/null" + --bs="$bs" \ + --filesize="$megs" \ + "--filename_format='$fname.\$jobnum' >/dev/null" fi } @@ -3593,24 +3560,13 @@ function zed_cleanup if ! is_linux; then return fi - EXTRA_ZEDLETS=$@ - log_must rm -f ${ZEDLET_DIR}/zed.rc - log_must rm -f ${ZEDLET_DIR}/zed-functions.sh - log_must rm -f ${ZEDLET_DIR}/all-syslog.sh - log_must rm -f ${ZEDLET_DIR}/all-debug.sh - log_must rm -f ${ZEDLET_DIR}/state - - if [[ -n "$EXTRA_ZEDLETS" ]] ; then - for i in $EXTRA_ZEDLETS ; do - log_must rm -f ${ZEDLET_DIR}/$i - done - fi - log_must rm -f $ZED_LOG - log_must rm -f $ZED_DEBUG_LOG - log_must rm -f $VDEVID_CONF_ETC - log_must rm -f $VDEVID_CONF - rmdir $ZEDLET_DIR + for extra_zedlet; do + log_must rm -f ${ZEDLET_DIR}/$extra_zedlet + done + log_must rm -fd ${ZEDLET_DIR}/zed.rc ${ZEDLET_DIR}/zed-functions.sh ${ZEDLET_DIR}/all-syslog.sh ${ZEDLET_DIR}/all-debug.sh ${ZEDLET_DIR}/state \ + $ZED_LOG $ZED_DEBUG_LOG $VDEVID_CONF_ETC $VDEVID_CONF \ + $ZEDLET_DIR } # diff --git a/tests/zfs-tests/include/properties.shlib b/tests/zfs-tests/include/properties.shlib index 6d467b6005..e66dc0a21e 100644 --- a/tests/zfs-tests/include/properties.shlib +++ b/tests/zfs-tests/include/properties.shlib @@ -100,12 +100,8 @@ else binary_props+=('zoned') fi -if is_linux; then - # Only older kernels support non-blocking mandatory locks - if [[ $(linux_version) -lt $(linux_version "4.4") ]]; then - binary_props+=('nbmand') - fi -else +# Newer Linuxes dropped non-blocking mandatory locks +if ! is_linux || [ $(linux_version) -lt $(linux_version "4.4") ]; then binary_props+=('nbmand') fi @@ -114,7 +110,6 @@ function toggle_prop typeset ds=$1 typeset prop=$2 - datasetexists $ds || log_fail "$ds does not exist" typeset val=$(get_prop $prop $ds) typeset newval='off' @@ -137,7 +132,6 @@ function randomize_ds_props typeset ds=$1 typeset prop proplist val - datasetexists $ds || log_fail "$ds does not exist" if ds_is_volume $ds; then toggle_prop $ds readonly proplist="${vol_props[@]}" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh index c482f9c3c7..7f90630360 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_reservation/zfs_reservation_002_pos.ksh @@ -73,16 +73,8 @@ log_must zfs set reservation=none $TESTPOOL/$RESERVATION2 for FS in $TESTPOOL/$RESERVATION $TESTPOOL/$RESERVATION2 do - - reserve=`zfs get -pH reservation $FS | awk '{print $3}'` - if [[ $reserve -ne 0 ]]; then - log_fail "ZFS get -p reservation did not return 0" - fi - - reserve=`zfs get -H reservation $FS | awk '{print $3}'` - if [[ $reserve != "none" ]]; then - log_fail "ZFS get reservation did not return 'none'" - fi + log_must [ $(zfs get -pHo value reservation $FS) -eq 0 ] + log_must [ $(zfs get -Ho value reservation $FS) = none ] done log_pass "Successfully set reservation to 0 and 'none'" diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh index b1bc054776..bb7cd4cccc 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @@ -77,9 +77,7 @@ function cleanup if datasetexists $ds; then mntp=$(get_prop mountpoint $ds) destroy_dataset $ds - if [[ -d $mntp ]]; then - rm -fr $mntp - fi + [ -d $mntp ] && rm -fr $mntp fi snapexists $TESTPOOL/$TESTFS@$TESTSNAP && \ @@ -91,9 +89,7 @@ function cleanup zfs unmount -a > /dev/null 2>&1 log_must zfs mount -a - if [[ -d $tmpmnt ]]; then - rm -fr $tmpmnt - fi + [ -d $tmpmnt ] && rm -fr $tmpmnt } log_assert "Setting canmount=noauto to file system, it must be successful." diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh index 083a6b1f46..29a7093974 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/snapdir_001_pos.ksh @@ -57,22 +57,12 @@ function verify_snapdir_visible # $1 dataset, $2 hidden|visible typeset dataset=$1 typeset value=$2 typeset mtpt=$(get_prop mountpoint $dataset) - typeset name - for name in `ls -a $mtpt`; do - if [[ $name == ".zfs" ]]; then - if [[ $value == "visible" ]]; then - return 0 - else - return 1 - fi - fi - done - - if [[ $value == "visible" ]]; then - return 1 + # $mtpt/.zfs always actually exists so [ -d $mtpt/.zfs ] is always true + if ls -a $mtpt | grep -xFq .zfs; then + [ $value = "visible" ] else - return 0 + [ $value != "visible" ] fi } @@ -95,15 +85,14 @@ log_assert "Setting a valid snapdir property on a dataset succeeds." for dataset in $all_datasets; do for value in hidden visible; do - if [[ $dataset == "$TESTPOOL/$TESTVOL" ]] ; then + if [ "$dataset" = "$TESTPOOL/$TESTVOL" ]; then set_n_check_prop "$value" "snapdir" \ "$dataset" "false" else set_n_check_prop "$value" "snapdir" \ "$dataset" - verify_snapdir_visible $dataset $value - [[ $? -eq 0 ]] || \ - log_fail "$dataset/.zfs is not $value as expect." + verify_snapdir_visible $dataset $value || + log_fail "$dataset/.zfs is not $value as expected." fi done done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh index c9bc7565ab..5cfaec55e4 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_001_neg.ksh @@ -77,9 +77,9 @@ while (( i < ${#dataset[@]} )); do done (( j += 1 )) done - # Additional recordsize - set_n_check_prop "recordsize" "2048K" "${dataset[i]}" false - set_n_check_prop "recordsize" "128B" "${dataset[i]}" false + # Additional recordsize + set_n_check_prop "2048K" "recordsize" "${dataset[i]}" false + set_n_check_prop "128B" "recordsize" "${dataset[i]}" false (( i += 1 )) done diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib index 7e34341d85..04886e38c2 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib @@ -73,17 +73,17 @@ function set_n_check_prop reservation|reserv|quota ) if [[ $expect_value == "none" ]]; then [[ $cur_value != "0" ]] && \ - log_fail "The '$dataset' '$prop' value \ - '$cur_value' is not expected." + log_fail "The '$dataset' '$prop' value" \ + "'$cur_value' is not expected." elif [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; * ) if [[ $cur_value != $expect_value ]]; then - log_fail "The '$dataset' '$prop' value '$cur_value' \ - does not equal the expected value '$expect_value'." + log_fail "The '$dataset' '$prop' value '$cur_value'" \ + "does not equal the expected value '$expect_value'." fi ;; esac @@ -244,11 +244,7 @@ function check_user_prop typeset expect_value="$3" typeset value=$(zfs get -p -H -o value "$user_prop" $dtst 2>&1) - if [[ "$expect_value" == "$value" ]]; then - return 0 - else - return 1 - fi + [ "$expect_value" = "$value" ] } # @@ -315,15 +311,8 @@ function check_prop_inherit typeset value=$(get_prop "$prop" "$checked_dtst") typeset source=$(get_source "$prop" "$checked_dtst") - if [[ "$value" != "$inherited_value" || \ - "$source" != "inherited from $inherited_dtst" ]] - then - log_note "expected (value '$inherited_value', source 'inherited from $inherited_dtst')," \ - "got (value '$value', source '$source')" - return 1 - else - return 0 - fi + [ "$value" = "$inherited_value" ] && + [ "$source" = "inherited from $inherited_dtst" ] } # @@ -346,12 +335,7 @@ function check_prop_received log_fail "Unable to get $prop received value for dataset" \ "$dataset" fi - if [[ "$received" == "$value" ]] - then - return 0 - else - return 1 - fi + if [ "$received" = "$value" ] } # @@ -371,10 +355,5 @@ function check_prop_missing if (($? != 0)); then log_fail "Unable to get $prop value for dataset $dataset" fi - if [[ "-" == "$value" ]] - then - return 0 - else - return 1 - fi + [ "$value" = "-" ] } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh index 131b039e1c..efd7a2d0c7 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_share/zfs_share_011_pos.ksh @@ -67,20 +67,14 @@ typeset origdir=$PWD # unmount fails will not unshare the shared filesystem log_must zfs set sharenfs=on $TESTPOOL/$TESTFS log_must is_shared $TESTDIR -if cd $TESTDIR ; then - log_mustnot zfs umount $TESTPOOL/$TESTFS -else - log_fail "cd $TESTDIR fails" -fi +log_must cd $TESTDIR +log_mustnot zfs umount $TESTPOOL/$TESTFS log_must is_shared $TESTDIR # destroy fails will not unshare the shared filesystem log_must zfs create $TESTPOOL/$TESTFS/fs2 -if cd $TESTDIR/fs2 ; then - log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 -else - log_fail "cd $TESTDIR/fs2 fails" -fi +log_must cd $TESTDIR/fs2 +log_mustnot zfs destroy $TESTPOOL/$TESTFS/fs2 log_must is_shared $TESTDIR/fs2 log_pass "Verify that umount and destroy fail, and do not unshare the shared" \ diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh index e26ca5c2aa..2fb8ae7814 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_002_pos.ksh @@ -91,7 +91,7 @@ function test_legacy_unshare # log_fail "'zfs set sharenfs=off' fails to make ZFS " \ "filesystem $filesystem unshared." - log_must eval "share_nfs $mntp" + log_must share_nfs $mntp is_shared $mntp || \ log_fail "'share' command fails to share ZFS file system." # diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh index 7023c49e51..142ebacd45 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_duplicates.ksh @@ -103,7 +103,7 @@ function do_dup_test # Read the file a few times to generate some # duplicate errors of the same blocks for _ in {1..15}; do - dd if=$FILEPATH of=/dev/null bs=128K > /dev/null 2>&1 + dd if=$FILEPATH of=/dev/null bs=128K 2>/dev/null done log_must zinject -c all fi @@ -140,4 +140,3 @@ if $duplicates; then else log_pass "Duplicate I/O ereport errors are not posted" fi - diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh index 6369a297c1..77fe116983 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_001_pos.ksh @@ -79,7 +79,7 @@ function cleanup cleanup_filesystem $TESTPOOL1 $TESTFS - destroy_pool $TESTPOOL1 + destroy_pool $TESTPOOL1 [[ -d $ALTER_ROOT ]] && \ log_must rm -rf $ALTER_ROOT diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh index a199c2a7fb..e450d9a622 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_errata4.ksh @@ -43,18 +43,16 @@ POOL_FILE=missing_ivset.dat function uncompress_pool { log_note "Creating pool from $POOL_FILE" - log_must bzcat \ + log_must eval bzcat \ $STF_SUITE/tests/functional/cli_root/zpool_import/blockfiles/$POOL_FILE.bz2 \ - > /$TESTPOOL/$POOL_FILE - return 0 + "> /$TESTPOOL/$POOL_FILE" } function cleanup { log_must set_tunable32 DISABLE_IVSET_GUID_CHECK 0 poolexists $POOL_NAME && log_must zpool destroy $POOL_NAME - [[ -e /$TESTPOOL/$POOL_FILE ]] && rm /$TESTPOOL/$POOL_FILE - return 0 + log_must rm -rf /$TESTPOOL/$POOL_FILE } log_onexit cleanup @@ -65,11 +63,7 @@ function has_ivset_guid # dataset ds="$1" ivset_guid=$(get_prop ivsetguid $ds) - if [ "$ivset_guid" == "-" ]; then - return 1 - else - return 0 - fi + [ "$ivset_guid" != "-" ] } # 1. Import a pre-packaged pool with Errata #4 and verify its state @@ -78,9 +72,7 @@ log_must zpool import -d /$TESTPOOL/ $POOL_NAME log_must eval "zpool status $POOL_NAME | grep -q 'Errata #4'" log_must eval "zpool status $POOL_NAME | grep -q ZFS-8000-ER" bm2_value=$(zpool get -H -o value feature@bookmark_v2 $POOL_NAME) -if [ "$bm2_value" != "disabled" ]; then - log_fail "initial pool's bookmark_v2 feature is not disabled" -fi +log_must [ "$bm2_value" = "disabled" ] log_mustnot has_ivset_guid $POOL_NAME/testfs@snap1 log_mustnot has_ivset_guid $POOL_NAME/testfs@snap2 diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh index 9d4629a779..bcb795b19f 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_missing_003_pos.ksh @@ -107,7 +107,7 @@ function verify function cleanup { - cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" + log_must cd $DEVICE_DIR for pool in $TESTPOOL1 $TESTPOOL2; do if poolexists "$pool" ; then @@ -136,7 +136,7 @@ function cleanup_all done log_must rm -f $DEVICE_DIR/$DEVICE_ARCHIVE - cd $CWD || log_fail "Unable change directory to $CWD" + log_must cd $CWD } @@ -146,7 +146,7 @@ log_assert "Verify that import could handle device overlapped." CWD=$PWD -cd $DEVICE_DIR || log_fail "Unable change directory to $DEVICE_DIR" +log_must cd $DEVICE_DIR log_must tar cf $DEVICE_DIR/$DEVICE_ARCHIVE ${DEVICE_FILE}* checksum1=$(sum $MYTESTFILE | awk '{print $1}') diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh index 14c35b3da6..0d15c0c8e5 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh @@ -41,7 +41,6 @@ # 1. Attempt to share a dataset # 2. Verify the dataset was not shared. # -# verify_runnable "global" @@ -51,17 +50,11 @@ fi log_assert "zfs share returns an error when run as a user" -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was incorrectly shared initially!" -fi +log_mustnot is_shared $TESTDIR/unshared log_mustnot zfs share $TESTPOOL/$TESTFS/unshared # Now verify that the above command didn't actually do anything -if is_shared $TESTDIR/unshared -then - log_fail "$TESTPOOL/$TESTFS/unshared was actually shared!" -fi +log_mustnot is_shared $TESTDIR/unshared log_pass "zfs share returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh index 7ae86fc4ec..62b5bf39f4 100755 --- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh @@ -52,17 +52,13 @@ fi log_assert "zfs unshare returns an error when run as a user" # verify that the filesystem was shared initially -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!" log_mustnot zfs unshare $TESTPOOL/$TESTFS/shared # now verify that the above command didn't do anything -if not_shared $TESTDIR/shared -then - log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" -fi +log_mustnot not_shared $TESTDIR/shared +log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!" log_pass "zfs unshare returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh b/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh index 1e0ed80d32..22e52ccc90 100755 --- a/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/delegate/zfs_allow_001_pos.ksh @@ -57,7 +57,7 @@ function cleanup restore_root_datasets } -log_assert "everyone' is interpreted as a keyword even if a user " \ +log_assert "'everyone' is interpreted as a keyword even if a user " \ "or group named 'everyone' exists." log_onexit cleanup @@ -79,9 +79,7 @@ if [[ $user_added == "TRUE" ]]; then fi log_note "Created a group called 'everyone'." -if ! cat /etc/group | awk -F: '{print $1}' | \ - grep -w 'everyone' > /dev/null 2>&1 -then +if ! grep -q '^everyone:' /etc/group; then group_added="TRUE" log_must add_group everyone fi diff --git a/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh b/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh index 4229537b39..1cfa84a930 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_spare_shared.ksh @@ -70,10 +70,7 @@ FAIL_FILEDEVPOOL2="$TEST_BASE_DIR/file-fail-dev2" SPARE_FILEDEV="$TEST_BASE_DIR/file-spare-dev" SPARE_DISKDEV="$(get_debug_device)" -for vdev in $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 \ - $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV; do - log_must truncate -s $MINVDEVSIZE $vdev -done +log_must truncate -s $MINVDEVSIZE $SAFE_FILEDEVPOOL1 $SAFE_FILEDEVPOOL2 $FAIL_FILEDEVPOOL1 $FAIL_FILEDEVPOOL2 $SPARE_FILEDEV for spare in $SPARE_FILEDEV $SPARE_DISKDEV; do # 1. Create two pools diff --git a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh index 8e174dcb7e..26f728bb17 100755 --- a/tests/zfs-tests/tests/functional/history/history_008_pos.ksh +++ b/tests/zfs-tests/tests/functional/history/history_008_pos.ksh @@ -55,8 +55,7 @@ log_assert "Pool history records all recursive operations." log_onexit cleanup root_testfs=$TESTPOOL/$TESTFS -fs1=$root_testfs/fs1; fs2=$root_testfs/fs2; fs3=$root_testfs/fs3 -for fs in $fs1 $fs2 $fs3; do +for fs in $root_testfs/fs{1..3}; do log_must zfs create $fs done diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh index b8220791f1..4f151ef15c 100755 --- a/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/reservation/reservation_001_pos.ksh @@ -60,10 +60,10 @@ function cleanup log_onexit cleanup -log_assert "Verify that to set a reservation on a filesystem or volume must " \ +log_assert "Verify that to set a reservation on a filesystem or volume must" \ "use value smaller than space available property of pool" -space_avail=`get_prop available $TESTPOOL` +space_avail=$(get_prop available $TESTPOOL) if ! is_global_zone ; then OBJ_LIST="" @@ -103,7 +103,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zfs set reservation=$resv_size_set $obj - resv_size_get=`get_prop reservation $obj` + resv_size_get=$(get_prop reservation $obj) if [[ $resv_size_set != $resv_size_get ]]; then log_fail "Reservation not the expected value " \ "($resv_size_set != $resv_size_get)" @@ -111,7 +111,7 @@ for obj in $TESTPOOL/$TESTFS $OBJ_LIST; do log_must zero_reservation $obj - new_space_avail=`get_prop available $obj` + new_space_avail=$(get_prop available $obj) # # Due to the way space is consumed and released by metadata we diff --git a/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh b/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh index 32bacf753a..0d592ad33e 100755 --- a/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/rootpool_002_neg.ksh @@ -54,7 +54,7 @@ typeset tmpfile="$TEST_BASE_DIR/mounted-datasets.$$" # damage done by the attempted pool destroy. The destroy itself should fail, # but some filesystems can become unmounted in the process, and aren't # automatically remounted. -mount -p | awk '{if ($4 == "zfs") print $1}' > $tmpfile +mount -p | awk '$4 == "zfs" {print $1}' > $tmpfile log_mustnot zpool destroy $rootpool diff --git a/tests/zfs-tests/tests/functional/rootpool/setup.ksh b/tests/zfs-tests/tests/functional/rootpool/setup.ksh index 8d80971081..d81b3dfbdd 100755 --- a/tests/zfs-tests/tests/functional/rootpool/setup.ksh +++ b/tests/zfs-tests/tests/functional/rootpool/setup.ksh @@ -35,7 +35,7 @@ verify_runnable "global" # # This functionality is supported under Linux, but these test cases -# are disabled by default since they manipulate the systems root pool. +# are disabled by default since they manipulate the system's root pool. # if is_linux || is_freebsd; then log_unsupported "Supported but disabled by default" diff --git a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh index 056fc2cc25..5d308d8f65 100755 --- a/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh +++ b/tests/zfs-tests/tests/functional/rsend/send-c_stream_size_estimate.ksh @@ -40,19 +40,11 @@ function get_estimated_size { typeset cmd=$1 typeset ds=${cmd##* } - if is_freebsd; then - mkdir -p $BACKDIR - typeset tmpfile=$(TMPDIR=$BACKDIR mktemp) - else - typeset tmpfile=$(mktemp -p $BACKDIR) - fi + typeset tmpfile=$(mktemp $BACKDIR/size_estimate.XXXXXXXX) - eval "$cmd >$tmpfile" - [[ $? -eq 0 ]] || log_fail "get_estimated_size: $cmd" - typeset size=$(eval "awk '\$2 == \"$ds\" {print \$3}' $tmpfile") + eval "$cmd >$tmpfile" || log_fail "$cmd: $?" + awk -v ds="$ds" '$2 == ds {print $3}' $tmpfile rm -f $tmpfile - - echo $size } log_assert "Verify the stream size given by -P accounts for compressed send." @@ -75,23 +67,19 @@ for compress in "${compress_prop_vals[@]}"; do typeset ds_size=$(get_estimated_size "zfs send -nP $send_ds@snap") typeset ds_lrefer=$(get_prop lrefer $send_ds) - within_percent $ds_size $ds_lrefer 90 || log_fail \ - "$ds_size and $ds_lrefer differed by too much" + log_must within_percent $ds_size $ds_lrefer 90 typeset vol_size=$(get_estimated_size "zfs send -nP $send_vol@snap") typeset vol_lrefer=$(get_prop lrefer $send_vol) - within_percent $vol_size $vol_lrefer 90 || log_fail \ - "$vol_size and $vol_lrefer differed by too much" + log_must within_percent $vol_size $vol_lrefer 90 typeset ds_csize=$(get_estimated_size "zfs send -nP -c $send_ds@snap") typeset ds_refer=$(get_prop refer $send_ds) - within_percent $ds_csize $ds_refer 90 || log_fail \ - "$ds_csize and $ds_refer differed by too much" + log_must within_percent $ds_csize $ds_refer 90 typeset vol_csize=$(get_estimated_size "zfs send -nP -c $send_vol@snap") typeset vol_refer=$(get_prop refer $send_vol) - within_percent $vol_csize $vol_refer 90 || log_fail \ - "$vol_csize and $vol_refer differed by too much" + log_must within_percent $vol_csize $vol_refer 90 done log_pass "The stream size given by -P accounts for compressed send." diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh b/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh index 693ca0a634..f5c0ab0c22 100755 --- a/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh @@ -52,19 +52,6 @@ function cleanup { fi } -function get_pool_size { - poolname=$1 - psize=$(zpool list -H -o allocated $poolname) - if [[ $psize == *[mM] ]] - then - returnvalue=$(echo $psize | sed -e 's/m//g' -e 's/M//g') - returnvalue=$((returnvalue * 1024)) - else - returnvalue=$(echo $psize | sed -e 's/k//g' -e 's/K//g') - fi - echo $returnvalue -} - log_assert "xattr file sizes count towards normal disk usage" log_onexit cleanup @@ -77,10 +64,10 @@ if is_global_zone then # get pool and filesystem sizes. Since we're starting with an empty # pool, the usage should be small - a few k. - POOL_SIZE=$(get_pool_size $TESTPOOL) + POOL_SIZE=$(get_pool_prop allocated $TESTPOOL) fi -FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) +FS_SIZE=$(get_prop used $TESTPOOL/$TESTFS) if is_freebsd; then # FreeBSD setextattr has awful scaling with respect to input size. @@ -106,7 +93,7 @@ sync_pool # now check to see if our pool disk usage has increased if is_global_zone then - NEW_POOL_SIZE=$(get_pool_size $TESTPOOL) + NEW_POOL_SIZE=$(get_pool_prop allocated $TESTPOOL) (($NEW_POOL_SIZE <= $POOL_SIZE)) && \ log_fail "The new pool size $NEW_POOL_SIZE was less \ than or equal to the old pool size $POOL_SIZE." @@ -114,7 +101,7 @@ then fi # also make sure our filesystem usage has increased -NEW_FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS) +NEW_FS_SIZE=$(get_prop used $TESTPOOL/$TESTFS) (($NEW_FS_SIZE <= $FS_SIZE)) && \ log_fail "The new filesystem size $NEW_FS_SIZE was less \ than or equal to the old filesystem size $FS_SIZE." diff --git a/tests/zfs-tests/tests/perf/perf.shlib b/tests/zfs-tests/tests/perf/perf.shlib index 5a404df083..27f56676db 100644 --- a/tests/zfs-tests/tests/perf/perf.shlib +++ b/tests/zfs-tests/tests/perf/perf.shlib @@ -265,7 +265,7 @@ function apply_zinject_delays typeset idx=0 while [[ $idx -lt "${#ZINJECT_DELAYS[@]}" ]]; do [[ -n ${ZINJECT_DELAYS[$idx]} ]] || \ - log_must "No zinject delay found at index: $idx" + log_fail "No zinject delay found at index: $idx" for disk in $DISKS; do log_must zinject \