aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c5
-rw-r--r--tests/zfs-tests/include/blkdev.shlib18
-rw-r--r--tests/zfs-tests/include/libtest.shlib237
-rw-r--r--tests/zfs-tests/include/zpool_script.shlib8
-rw-r--r--tests/zfs-tests/tests/functional/acl/acl_common.kshlib18
-rwxr-xr-xtests/zfs-tests/tests/functional/acl/off/dosmode.ksh8
-rwxr-xr-xtests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh14
-rwxr-xr-xtests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh5
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib12
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh16
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh14
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh52
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh3
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib13
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh9
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh3
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh28
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh11
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh10
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh9
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh1
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh16
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib12
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh99
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh7
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg6
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh9
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib17
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh5
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh2
-rw-r--r--tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib2
-rwxr-xr-xtests/zfs-tests/tests/functional/compression/compress_001_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/compression/compress_002_pos.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib10
-rw-r--r--tests/zfs-tests/tests/functional/events/events.cfg2
-rwxr-xr-xtests/zfs-tests/tests/functional/events/events_002_pos.ksh18
-rw-r--r--tests/zfs-tests/tests/functional/events/events_common.kshlib21
-rwxr-xr-xtests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh9
-rwxr-xr-xtests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/history/history_001_pos.ksh1
-rwxr-xr-xtests/zfs-tests/tests/functional/history/history_003_pos.ksh9
-rwxr-xr-xtests/zfs-tests/tests/functional/history/history_004_pos.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/history/history_common.kshlib30
-rwxr-xr-xtests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/mount/umountall_001.ksh9
-rwxr-xr-xtests/zfs-tests/tests/functional/no_space/enospc_df.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh10
-rwxr-xr-xtests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/procfs/pool_state.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh4
-rw-r--r--tests/zfs-tests/tests/functional/redacted_send/redacted.cfg6
-rwxr-xr-xtests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh21
-rw-r--r--tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib11
-rwxr-xr-xtests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh2
-rw-r--r--tests/zfs-tests/tests/functional/reservation/reservation.shlib18
-rwxr-xr-xtests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh2
-rw-r--r--tests/zfs-tests/tests/functional/rsend/rsend.cfg5
-rw-r--r--tests/zfs-tests/tests/functional/rsend/rsend.kshlib8
-rwxr-xr-xtests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh3
-rwxr-xr-xtests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/simd/simd_supported.ksh6
-rw-r--r--tests/zfs-tests/tests/functional/trim/trim.kshlib3
-rwxr-xr-xtests/zfs-tests/tests/functional/trim/trim_l2arc.ksh4
-rwxr-xr-xtests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh2
-rwxr-xr-xtests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh2
-rw-r--r--tests/zfs-tests/tests/functional/zvol/zvol_common.shlib6
-rwxr-xr-xtests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh2
132 files changed, 404 insertions, 764 deletions
diff --git a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c b/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c
index ed0906c36..36d7b31ba 100644
--- a/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c
+++ b/tests/zfs-tests/cmd/read_dos_attributes/read_dos_attributes.c
@@ -156,12 +156,11 @@ main(int argc, const char * const argv[])
(void) close(fd);
- char buffer[BUFFER_SIZE];
- memset(buffer, 0, BUFFER_SIZE);
+ char buffer[BUFFER_SIZE] = "";
(void) attribute_to_str(dosflags, buffer);
- (void) printf("%s\n", buffer);
+ (void) puts(buffer);
return (EXIT_SUCCESS);
}
diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib
index 7159b92c0..6d37494ee 100644
--- a/tests/zfs-tests/include/blkdev.shlib
+++ b/tests/zfs-tests/include/blkdev.shlib
@@ -223,13 +223,11 @@ function set_slice_prefix
if is_linux; then
while (( i < $DISK_ARRAY_NUM )); do
- disk="$(echo $DISKS | nawk '{print $(i + 1)}')"
- if ( is_mpath_device $disk ) && [[ -z $(echo $disk | awk 'substr($1,18,1)\
- ~ /^[[:digit:]]+$/') ]] || ( is_real_device $disk ); then
+ disk="$(echo $DISKS | awk '{print $(i + 1)}')"
+ if is_mpath_device $disk && ! echo $disk | awk 'substr($1,18,1) ~ /^[[:digit:]]+$/ {exit 1}' || is_real_device $disk; then
export SLICE_PREFIX=""
return 0
- elif ( is_mpath_device $disk || is_loop_device \
- $disk ); then
+ elif is_mpath_device $disk || is_loop_device $disk; then
export SLICE_PREFIX="p"
return 0
else
@@ -518,11 +516,11 @@ function get_pool_devices #testpool #devdir
typeset devdir=$2
typeset out=""
- if is_linux || is_freebsd; then
- out=$(zpool status -P $testpool |grep ${devdir} | awk '{print $1}')
- out=$(echo $out | sed -e "s|${devdir}/||g" | tr '\n' ' ')
- fi
- echo $out
+ case $(uname) in
+ Linux|FreeBSD)
+ zpool status -P $testpool | awk -v d="$devdir" '$1 ~ d {sub(d "/", ""); printf("%s ", $1)}'
+ ;;
+ esac
}
#
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 800929962..60d54428a 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -149,14 +149,11 @@ function ismounted
case $fstype in
zfs)
if [[ "$1" == "/"* ]] ; then
- for out in $(zfs mount | awk '{print $2}'); do
- [[ $1 == $out ]] && return 0
- done
+ ! zfs mount | awk -v fs="$1" '$2 == fs {exit 1}'
else
- for out in $(zfs mount | awk '{print $1}'); do
- [[ $1 == $out ]] && return 0
- done
+ ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}'
fi
+ return $?
;;
ufs|nfs)
if is_freebsd; then
@@ -178,7 +175,7 @@ function ismounted
fi
;;
ext*)
- out=$(df -t $fstype $1 2>/dev/null)
+ df -t $fstype $1 > /dev/null 2>&1
return $?
;;
zvol)
@@ -608,10 +605,8 @@ function default_cleanup_noexit
log_must zfs set reservation=none $fs
log_must zfs set recordsize=128K $fs
log_must zfs set mountpoint=/$fs $fs
- typeset enc=""
- enc=$(get_prop encryption $fs)
- if [[ $? -ne 0 ]] || [[ -z "$enc" ]] || \
- [[ "$enc" == "off" ]]; then
+ typeset enc=$(get_prop encryption $fs)
+ if [ -z "$enc" ] || [ "$enc" = "off" ]; then
log_must zfs set checksum=on $fs
fi
log_must zfs set compression=off $fs
@@ -684,8 +679,6 @@ function destroy_snapshot
typeset mtpt=""
if ismounted $snap; then
mtpt=$(get_prop mountpoint $snap)
- (($? != 0)) && \
- log_fail "get_prop mountpoint $snap failed."
fi
destroy_dataset "$snap"
@@ -710,8 +703,6 @@ function destroy_clone
typeset mtpt=""
if ismounted $clone; then
mtpt=$(get_prop mountpoint $clone)
- (($? != 0)) && \
- log_fail "get_prop mountpoint $clone failed."
fi
destroy_dataset "$clone"
@@ -743,7 +734,6 @@ function destroy_bookmark
function snapexists
{
zfs list -H -t snapshot "$1" > /dev/null 2>&1
- return $?
}
#
@@ -754,7 +744,6 @@ function snapexists
function bkmarkexists
{
zfs list -H -t bookmark "$1" > /dev/null 2>&1
- return $?
}
#
@@ -765,8 +754,7 @@ function bkmarkexists
#
function holdexists
{
- zfs holds "$2" | awk '{ print $2 }' | grep "$1" > /dev/null 2>&1
- return $?
+ ! zfs holds "$2" | awk -v t="$1" '$2 ~ t { exit 1 }'
}
#
@@ -934,9 +922,8 @@ function set_partition
# Determine the cylinder size for the device and using
# that calculate the end offset in cylinders.
typeset -i cly_size_kb=0
- cly_size_kb=$(parted -m $disk -s -- \
- unit cyl print | head -3 | tail -1 | \
- awk -F '[:k.]' '{print $4}')
+ cly_size_kb=$(parted -m $disk -s -- unit cyl print |
+ awk -F '[:k.]' 'NR == 3 {print $4}')
((end = (size_mb * 1024 / cly_size_kb) + start))
parted $disk -s -- \
@@ -1077,15 +1064,14 @@ function get_endslice #<disk> <slice>
typeset -i ratio=0
ratio=$(prtvtoc /dev/rdsk/${disk}s2 | \
- grep "sectors\/cylinder" | \
- awk '{print $2}')
+ awk '/sectors\/cylinder/ {print $2}')
if ((ratio == 0)); then
return
fi
typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 |
- nawk -v token="$slice" '{if ($1==token) print $6}')
+ awk -v token="$slice" '$1 == token {print $6}')
((endcyl = (endcyl + 1) / ratio))
;;
@@ -1163,56 +1149,22 @@ function fill_fs # destdir dirnum filenum bytes num_writes data
return 0
}
-#
-# Simple function to get the specified property. If unable to
-# get the property then exits.
-#
-# Note property is in 'parsable' format (-p)
-#
+# Get the specified dataset property in parsable format or fail
function get_prop # property dataset
{
- typeset prop_val
typeset prop=$1
typeset dataset=$2
- prop_val=$(zfs get -pH -o value $prop $dataset 2>/dev/null)
- if [[ $? -ne 0 ]]; then
- log_note "Unable to get $prop property for dataset " \
- "$dataset"
- return 1
- fi
-
- echo "$prop_val"
- return 0
+ zfs get -Hpo value "$prop" "$dataset" || log_fail "zfs get $prop $dataset"
}
-#
-# Simple function to get the specified property of pool. If unable to
-# get the property then exits.
-#
-# Note property is in 'parsable' format (-p)
-#
+# Get the specified pool property in parsable format or fail
function get_pool_prop # property pool
{
- typeset prop_val
typeset prop=$1
typeset pool=$2
- if poolexists $pool ; then
- prop_val=$(zpool get -pH $prop $pool 2>/dev/null | tail -1 | \
- awk '{print $3}')
- if [[ $? -ne 0 ]]; then
- log_note "Unable to get $prop property for pool " \
- "$pool"
- return 1
- fi
- else
- log_note "Pool $pool not exists."
- return 1
- fi
-
- echo "$prop_val"
- return 0
+ zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool"
}
# Return 0 if a pool exists; $? otherwise
@@ -1988,19 +1940,16 @@ function verify_ashift # device ashift
typeset device="$1"
typeset ashift="$2"
- zdb -e -lll $device | awk -v ashift=$ashift '/ashift: / {
- if (ashift != $2)
- exit 1;
- else
- count++;
- } END {
- if (count != 4)
- exit 1;
- else
- exit 0;
+ zdb -e -lll $device | awk -v ashift=$ashift '
+ /ashift: / {
+ if (ashift != $2)
+ exit 1;
+ else
+ count++;
+ }
+ END {
+ exit (count != 4);
}'
-
- return $?
}
#
@@ -2375,35 +2324,24 @@ function find_disks
swap -l > $sfi
dumpadm > $dmpi 2>/dev/null
-# write an awk script that can process the output of format
-# to produce a list of disks we know about. Note that we have
-# to escape "$2" so that the shell doesn't interpret it while
-# we're creating the awk script.
-# -------------------
- cat > /tmp/find_disks.awk <<EOF
-#!/bin/nawk -f
- BEGIN { FS="."; }
-
- /^Specify disk/{
- searchdisks=0;
- }
+ disks=${@:-$(echo "" | format -e 2>/dev/null | awk '
+BEGIN { FS="."; }
- {
- if (searchdisks && \$2 !~ "^$"){
- split(\$2,arr," ");
- print arr[1];
- }
- }
+/^Specify disk/{
+ searchdisks=0;
+}
- /^AVAILABLE DISK SELECTIONS:/{
- searchdisks=1;
+{
+ if (searchdisks && $2 !~ "^$"){
+ split($2,arr," ");
+ print arr[1];
}
-EOF
-#---------------------
+}
- chmod 755 /tmp/find_disks.awk
- disks=${@:-$(echo "" | format -e 2>/dev/null | /tmp/find_disks.awk)}
- rm /tmp/find_disks.awk
+/^AVAILABLE DISK SELECTIONS:/{
+ searchdisks=1;
+}
+')}
unused=""
for disk in $disks; do
@@ -2801,23 +2739,21 @@ function safe_to_destroy_pool { # $1 the pool name
# this is a list of the top-level directories in each of the
# files that make up the path to the files the pool is based on
- FILEPOOL=$(zpool status -v $pool | grep /$1/ | \
- awk '{print $1}')
+ FILEPOOL=$(zpool status -v $pool | awk -v pool="/$1/" '$0 ~ pool {print $1}')
# this is a list of the zvols that make up the pool
- ZVOLPOOL=$(zpool status -v $pool | grep "$ZVOL_DEVDIR/$1$" \
- | awk '{print $1}')
+ ZVOLPOOL=$(zpool status -v $pool | awk -v zvols="$ZVOL_DEVDIR/$1$" '$0 ~ zvols {print $1}')
# also want to determine if it's a file-based pool using an
# alternate mountpoint...
POOL_FILE_DIRS=$(zpool status -v $pool | \
- grep / | awk '{print $1}' | \
- awk -F/ '{print $2}' | grep -v "dev")
+ awk '/\// {print $1}' | \
+ awk -F/ '!/dev/ {print $2}')
for pooldir in $POOL_FILE_DIRS
do
OUTPUT=$(zfs list -H -r -o mountpoint $1 | \
- grep "${pooldir}$" | awk '{print $1}')
+ awk -v pd="${pooldir}$" '$0 ~ pd {print $1}')
ALTMOUNTPOOL="${ALTMOUNTPOOL}${OUTPUT}"
done
@@ -2935,21 +2871,11 @@ function get_config
if ! poolexists "$pool" ; then
return 1
fi
- alt_root=$(zpool list -H $pool | awk '{print $NF}')
- if [[ $alt_root == "-" ]]; then
- value=$(zdb -C $pool | grep "$config:" | awk -F: \
- '{print $2}')
+ if [ "$(get_pool_prop cachefile "$pool")" = "none" ]; then
+ zdb -e $pool
else
- value=$(zdb -e $pool | grep "$config:" | awk -F: \
- '{print $2}')
- fi
- if [[ -n $value ]] ; then
- value=${value#'}
- value=${value%'}
- fi
- echo $value
-
- return 0
+ zdb -C $pool
+ fi | awk -F: -v cfg="$config:" '$0 ~ cfg {sub(/^'\''/, $2); sub(/'\''$/, $2); print $2}'
}
#
@@ -2967,8 +2893,7 @@ function _random_get
typeset -i ind
((ind = RANDOM % cnt + 1))
- typeset ret=$(echo "$str" | cut -f $ind -d ' ')
- echo $ret
+ echo "$str" | cut -f $ind -d ' '
}
#
@@ -3031,20 +2956,7 @@ function datasetcksum
typeset cksum
sync
sync_all_pools
- cksum=$(zdb -vvv $1 | grep "^Dataset $1 \[" | grep "cksum" \
- | awk -F= '{print $7}')
- echo $cksum
-}
-
-#
-# Get cksum of file
-# #1 file path
-#
-function checksum
-{
- typeset cksum
- cksum=$(cksum $1 | awk '{print $1}')
- echo $cksum
+ zdb -vvv $1 | awk -F= -v ds="^Dataset $1 "'\\[' '$0 ~ ds && /cksum/ {print $7}'
}
#
@@ -3067,27 +2979,6 @@ function get_device_state #pool disk field("", "spares","logs")
echo $state
}
-
-#
-# print the given directory filesystem type
-#
-# $1 directory name
-#
-function get_fstype
-{
- typeset dir=$1
-
- if [[ -z $dir ]]; then
- log_fail "Usage: get_fstype <directory>"
- fi
-
- #
- # $ df -n /
- # / : ufs
- #
- df -n $dir | awk '{print $3}'
-}
-
#
# Given a disk, label it to VTOC regardless what label was on the disk
# $1 disk
@@ -3142,16 +3033,6 @@ function labelvtoc
}
#
-# check if the system was installed as zfsroot or not
-# return: 0 if zfsroot, non-zero if not
-#
-function is_zfsroot
-{
- df -n / | grep zfs > /dev/null 2>&1
- return $?
-}
-
-#
# get the root filesystem name if it's zfsroot system.
#
# return: root filesystem name
@@ -3162,7 +3043,7 @@ function get_rootfs
if is_freebsd; then
rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}')
elif ! is_linux; then
- rootfs=$(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \
+ rootfs=$(awk '$2 == "/" && $3 == "zfs" {print $1}' \
/etc/mnttab)
fi
if [[ -z "$rootfs" ]]; then
@@ -3460,9 +3341,7 @@ function wait_freeing #pool
function wait_replacing #pool
{
typeset pool=${1:-$TESTPOOL}
- while true; do
- [[ "" == "$(zpool status $pool |
- awk '/replacing-[0-9]+/ {print $1}')" ]] && break
+ while zpool status $pool | grep -qE 'replacing-[0-9]+'; do
log_must sleep 1
done
}
@@ -3910,7 +3789,9 @@ function md5digest
md5 -q $file
;;
*)
- md5sum -b $file | awk '{ print $1 }'
+ typeset sum _
+ read -r sum _ < <(md5sum -b $file)
+ echo $sum
;;
esac
}
@@ -3928,7 +3809,9 @@ function sha256digest
sha256 -q $file
;;
*)
- sha256sum -b $file | awk '{ print $1 }'
+ typeset sum _
+ read -r sum _ < <(sha256sum -b $file)
+ echo $sum
;;
esac
}
@@ -4116,9 +3999,7 @@ function kstat # stat flags?
sysctl $flags kstat.zfs.misc.$stat
;;
Linux)
- typeset zfs_kstat="/proc/spl/kstat/zfs/$stat"
- [[ -f "$zfs_kstat" ]] || return 1
- cat $zfs_kstat
+ cat "/proc/spl/kstat/zfs/$stat" 2>/dev/null
;;
*)
false
@@ -4135,7 +4016,7 @@ function get_arcstat # stat
kstat arcstats.$stat
;;
Linux)
- kstat arcstats | awk "/$stat/ { print \$3 }"
+ kstat arcstats | awk "/$stat/"' { print $3 }'
;;
*)
false
diff --git a/tests/zfs-tests/include/zpool_script.shlib b/tests/zfs-tests/include/zpool_script.shlib
index 10bc0cc26..cbf1e0780 100644
--- a/tests/zfs-tests/include/zpool_script.shlib
+++ b/tests/zfs-tests/include/zpool_script.shlib
@@ -15,7 +15,7 @@ function test_zpool_script {
out="$($wholecmd)"
# Default number of columns that get printed without -c
- if echo "$cmd" | grep -q iostat ; then
+ if [ "$cmd" != "${cmd/iostat/_/}" ]; then
# iostat
dcols=7
else
@@ -39,9 +39,9 @@ function test_zpool_script {
# zpool iostat -v output is 7 columns, so if the script ran correctly
# we should see more than that.
if ! newcols=$(echo "$out" | \
- awk '/\/dev/{print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \
- head -n 1) ; \
- then
+ awk '/\/dev/ {print NF-'$dcols'; if (NF <= '$dcols') {exit 1}}' | \
+ head -n 1)
+ then
log_fail "'$wholecmd' didn't create a new column value"
else
log_note "'$wholecmd' passed ($newcols new columns)"
diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
index 1e9d736fd..c2e09687e 100644
--- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
+++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib
@@ -185,9 +185,7 @@ function plus_sign_check_l #<obj>
return 1
fi
- ls -ld $obj | awk '{print $1}' | grep "+$" > /dev/null
-
- return $?
+ ! ls -ld $obj | awk '$1 ~ /\+$/ {exit 1}'
}
#
@@ -202,9 +200,7 @@ function plus_sign_check_v #<obj>
return 1
fi
- ls -vd $obj | awk '(NR == 1) {print $1}' | grep "+$" > /dev/null
-
- return $?
+ ! ls -vd $obj | awk 'NR == 1 && $1 ~ /\+$ {exit 1}'
}
#
@@ -216,7 +212,6 @@ function plus_sign_check_v #<obj>
function chgusr_exec #<login_name> <commands> [...]
{
chg_usr_exec $@
- return $?
}
#
@@ -237,7 +232,6 @@ function set_cur_usr #<login_name>
function usr_exec #<commands> [...]
{
chg_usr_exec "$ZFS_ACL_CUR_USER" $@
- return $?
}
#
@@ -447,12 +441,10 @@ function get_group #node
fi
if [[ -d $node ]]; then
- value=$(ls -dl $node | awk '{print $4}')
+ ls -dl $node
elif [[ -e $node ]]; then
- value=$(ls -l $node | awk '{print $4}')
- fi
-
- echo $value
+ ls -l $node
+ fi | awk '{print $4}'
}
diff --git a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh
index 585aa0253..329eaef55 100755
--- a/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh
+++ b/tests/zfs-tests/tests/functional/acl/off/dosmode.ksh
@@ -55,12 +55,10 @@ function hasflag
typeset path=$2
if is_linux; then
- read_dos_attributes $path | awk \
- '{ gsub(",", "\n", $1); print $1 }' | grep -qxF $flag
+ read_dos_attributes $path
else
- ls -lo $path | awk '{ gsub(",", "\n", $5); print $5 }' | \
- grep -qxF $flag
- fi
+ ls -lo $path | awk '{ print $5 }'
+ fi | grep -qwF $flag
}
log_assert "Verify DOS mode flags function correctly"
diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh
index d62bf9c34..14635b27f 100755
--- a/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/acl/posix/posix_001_pos.ksh
@@ -70,9 +70,8 @@ if [ "$?" -eq "0" ]; then
log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/dir.0
# Confirm permissions
- ls -l $TESTDIR |grep "dir.0" |grep -q "drwxrw----+"
- if [ "$?" -ne "0" ]; then
- msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}')
+ if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwxrw----+"; then
+ msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}')
log_note "expected mask drwxrw----+ but found $msk"
log_fail "Expected permissions were not set."
fi
diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh
index d9b503645..bdcc18592 100755
--- a/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh
@@ -53,9 +53,8 @@ log_must mkdir $TESTDIR/dir.0
log_must chmod 700 $TESTDIR/dir.0
log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0
# Confirm permissions
-ls -l $TESTDIR |grep "dir.0" |grep -q "drwx-wx---+"
-if [ "$?" -ne "0" ]; then
- msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}')
+if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then
+ msk=$(ls -l $TESTDIR | awk '/dir.0/ {print $1}')
log_note "expected mask drwx-wx---+ but found $msk"
log_fail "Expected permissions were not set."
fi
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh
index 337114cdb..08c703e21 100755
--- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh
@@ -42,7 +42,7 @@ do
log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
fi
ac_value="$(zpool get -H -o property,value all | \
- egrep allocation_classes | awk '{print $2}')"
+ awk '/allocation_classes/ {print $2}')"
if [ "$ac_value" = "enabled" ]; then
log_note "feature@allocation_classes is enabled"
else
@@ -57,7 +57,7 @@ do
$CLASS_DISK0 $CLASS_DISK1
fi
ac_value="$(zpool get -H -o property,value all | \
- egrep allocation_classes | awk '{print $2}')"
+ awk '/allocation_classes/ {print $2}')"
if [ "$ac_value" = "active" ]; then
log_note "feature@allocation_classes is active"
else
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh
index 2c14c69d8..cbf5cbf89 100755
--- a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh
@@ -39,7 +39,7 @@ for value in 0 512 1024 2048 4096 8192 16384 32768 65536 131072
do
log_must zfs set special_small_blocks=$value $TESTPOOL
ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \
- grep special_small_blocks | awk '{print $3}')
+ awk '/special_small_blocks/ {print $3}')
if [ "$ACTUAL" != "$value" ]
then
log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!"
diff --git a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh
index 712309eda..aaab800b6 100755
--- a/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh
@@ -56,8 +56,7 @@ function testdbufstat # stat_name dbufstat_filter
[[ -n "$2" ]] && filter="-F $2"
if is_linux; then
- from_dbufstat=$(grep -w "$name" "$DBUFSTATS_FILE" |
- awk '{ print $3 }')
+ read -r _ _ from_dbufstat _ < <(grep -w "$name" "$DBUFSTATS_FILE")
else
from_dbufstat=$(awk "/dbufstats\.$name:/ { print \$2 }" \
"$DBUFSTATS_FILE")
diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh
index e719b94e2..78accbc82 100755
--- a/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_003_pos.ksh
@@ -74,7 +74,7 @@ do
log_must zfs create $POOL/$TESTFS
log_must zpool set bootfs=$POOL/$TESTFS $POOL
- RES=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
+ RES=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $RES != "$POOL/$TESTFS" ]
then
log_fail "Expected $RES == $POOL/$TESTFS"
diff --git a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh
index d29fe7e89..c5d7b2e3f 100755
--- a/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh
+++ b/tests/zfs-tests/tests/functional/bootfs/bootfs_006_pos.ksh
@@ -60,7 +60,7 @@ function verify_bootfs { # $POOL
log_must zfs create $POOL/$TESTFS
log_must zpool set bootfs=$POOL/$TESTFS $POOL
- VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
+ VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $VAL != "$POOL/$TESTFS" ]
then
log_must zpool status -v $POOL
@@ -74,7 +74,7 @@ function verify_no_bootfs { # $POOL
POOL=$1
log_must zfs create $POOL/$TESTFS
log_mustnot zpool set bootfs=$POOL/$TESTFS $POOL
- VAL=$(zpool get bootfs $POOL | tail -1 | awk '{print $3}' )
+ VAL=$(zpool get bootfs $POOL | awk 'END {print $3}' )
if [ $VAL == "$POOL/$TESTFS" ]
then
log_must zpool status -v $POOL
diff --git a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh
index 22ea37548..905a3c327 100755
--- a/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh
+++ b/tests/zfs-tests/tests/functional/channel_program/lua_core/tst.timeout.ksh
@@ -34,15 +34,11 @@ function test_instr_limit
{
typeset lim=$1
- error=$(zfs program -t $lim $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)
- [[ $? -ne 0 ]] || log_fail "Channel program with limit $lim exited 0: $error"
-
- instrs_run=$(echo $error | awk -F "chunk" '{print $2}' | awk '{print $1}')
- if [[ $instrs_run -lt $(( $lim - 100 )) ]]; then
- log_fail "Runtime (${instrs_run} instr) < limit (${lim} - 100 instr)"
- elif [[ $instrs_run -gt $(( $lim + 100 )) ]]; then
- log_fail "Runtime (${instrs_run} instr) > limit (${lim} + 100 instr)"
- fi
+ log_mustnot eval 'error=$(zfs program -t '$lim' $TESTPOOL $ZCP_ROOT/lua_core/tst.timeout.zcp 2>&1)'
+
+ read -r instrs_run _ < <(echo $error | awk -F "chunk" '{print $2}')
+ log_must [ $instrs_run -ge $(( $lim - 100 )) ]
+ log_must [ $instrs_run -le $(( $lim + 100 )) ]
log_note "With limit $lim the program ended after $instrs_run instructions"
}
diff --git a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh
index 615b41f31..c9cefcd43 100755
--- a/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/checksum/filetest_001_pos.ksh
@@ -85,7 +85,7 @@ log_must zpool import $TESTPOOL
log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL
-cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | awk '{print $5}')
+cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}')
log_assert "Normal file write test saw $cksum checksum errors"
log_must [ $cksum -eq 0 ]
@@ -105,8 +105,7 @@ while [[ $j -lt ${#CHECKSUM_TYPES[*]} ]]; do
log_must zpool scrub $TESTPOOL
log_must wait_scrubbed $TESTPOOL
- cksum=$(zpool status -P -v $TESTPOOL | grep "$firstvdev" | \
- awk '{print $5}')
+ cksum=$(zpool status -P -v $TESTPOOL | awk -v v="$firstvdev" '$0 ~ v {print $5}')
log_assert "Checksum '$type' caught $cksum checksum errors"
log_must [ $cksum -ne 0 ]
diff --git a/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
index 2b84f6a9c..1e4917aff 100644
--- a/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/cli_common.kshlib
@@ -31,21 +31,13 @@
. $STF_SUITE/include/libtest.shlib
#
-# Get the checksum and size of the file.
-#
-function get_cksum # <file path>
-{
- return $(cksum $1 | awk '{print $1 $2}')
-}
-
-#
# Compare the checksum of target files with the original file
#
function compare_cksum #<orig_data> <target_data1>...<target_datan>
{
typeset orig_data=$1
- typeset orig_sum=$(get_cksum $orig_data)
+ typeset orig_sum=$(cksum < $orig_data)
typeset target_sum=""
typeset bad_data_list=""
typeset -i bad_count=0
@@ -58,7 +50,7 @@ function compare_cksum #<orig_data> <target_data1>...<target_datan>
continue
fi
- target_sum=$(get_cksum $data)
+ target_sum=$(cksum < $data)
if [[ $target_sum != $orig_sum ]]; then
bad_data_list="$bad_data_list $data"
(( bad_count +=1 ))
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
index 2c6e6e9be..52bcc0311 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_004_pos.ksh
@@ -70,12 +70,14 @@ log_must dd if=$DEV_RDSKDIR/${DISK[0]} of=$DEV_RDSKDIR/${DISK[1]} bs=1K count=25
ubs=$(zdb -lu ${DISK[1]} | grep -e LABEL -e Uberblock -e 'labels = ')
log_note "vdev 1: ubs $ubs"
+set -o pipefail
ub_dump_counts=$(zdb -lu ${DISK[1]} | \
awk ' /LABEL/ {label=$NF; blocks[label]=0};
/Uberblock/ {blocks[label]++};
- END {print blocks[0],blocks[1],blocks[2],blocks[3]}')
-(( $? != 0)) && log_fail "failed to get ub_dump_counts from DISK[1]"
+ END {print blocks[0],blocks[1],blocks[2],blocks[3]}') ||
+ log_fail "failed to get ub_dump_counts from DISK[1]"
log_note "vdev 1: ub_dump_counts $ub_dump_counts"
+set +o pipefail
set -A dump_count $ub_dump_counts
for label in 0 1 2 3; do
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh
index 1ebcbfb44..f10d13fb5 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress.ksh
@@ -73,7 +73,7 @@ obj=${array[0]}
log_note "file $init_data has object number $obj"
output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \
- |grep -m 1 "L0 DVA" |head -n1)
+ |grep -m 1 "L0 DVA")
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of $init_data has a DVA of $dva"
@@ -81,15 +81,13 @@ log_note "block 0 of $init_data has a DVA of $dva"
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
log_note "block size $size_str"
-vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}')
-offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}')
+vdev=$(echo "$dva" | cut -d: -f1)
+offset=$(echo "$dva" | cut -d: -f2)
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:d 2> /dev/null)
-echo $output |grep $pattern > /dev/null
-(( $? != 0 )) && log_fail "zdb -R :d failed to decompress the data properly"
+echo $output | grep -q $pattern || log_fail "zdb -R :d failed to decompress the data properly"
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
-echo $output |grep $four_k > /dev/null
-(( $? != 0 )) && log_fail "zdb -R :dr failed to decompress the data properly"
+echo $output | grep -q $four_k || log_fail "zdb -R :dr failed to decompress the data properly"
output=$(zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
result=${#output}
@@ -97,8 +95,8 @@ result=${#output}
"zdb -R failed to decompress the data to the length (${#output} != $size_str)"
# decompress using lsize
-lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}')
-psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}')
+lsize=$(echo $size_str | cut -d/ -f1)
+psize=$(echo $size_str | cut -d/ -f2)
output=$(zdb -R $TESTPOOL $vdev:$offset:$lsize:dr 2> /dev/null)
result=${#output}
(( $result != $blksize)) && log_fail \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh
index 238d49560..9daf61f82 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_decompress_zstd.ksh
@@ -76,11 +76,11 @@ log_note "block 0 of $init_data has a DVA of $dva"
# use the length reported by zdb -ddddddbbbbbb
size_str=$(sed -Ene 's/^.+ size=([^ ]+) .*$/\1/p' <<< "$output")
# convert sizes to decimal
-lsize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[1]}')
+lsize=$(echo $size_str | cut -d/ -f 1)
lsize_orig=$lsize
lsize=${lsize%?}
lsize_bytes=$((16#$lsize))
-psize=$(echo $size_str |awk '{split($0,array,"/")} END{print array[2]}')
+psize=$(echo $size_str | cut -d/ -f 2)
psize_orig=$psize
psize=${psize%?}
psize_bytes=$((16#$psize))
@@ -88,21 +88,21 @@ log_note "block size $size_str"
# Get the ZSTD header reported by zdb -Z
zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
-zstd_size=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
+zstd_size=$(echo "$zstd_str" | cut -d: -f 1)
log_note "ZSTD compressed size $zstd_size"
(( $psize_bytes < $zstd_size )) && log_fail \
"zdb -Z failed: physical block size was less than header content length ($psize_bytes < $zstd_size)"
-zstd_version=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
+zstd_version=$(echo "$zstd_str" | cut -d: -f 2)
log_note "ZSTD version $zstd_version"
-zstd_level=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
+zstd_level=$(echo "$zstd_str" | cut -d: -f 3)
log_note "ZSTD level $zstd_level"
(( $zstd_level != $random_level )) && log_fail \
"zdb -Z failed: compression level did not match header level ($zstd_level < $random_level)"
-vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}')
-offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}')
+vdev=$(echo "$dva" | cut -d: -f 1)
+offset=$(echo "$dva" | cut -d: -f 2)
# Check the first 1024 bytes
output=$(ZDB_NO_ZLE="true" zdb -R $TESTPOOL $vdev:$offset:$size_str:dr 2> /dev/null)
outsize=$(wc -c <<< "$output")
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh
index 5cc457585..ef7eb8fff 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_display_block.ksh
@@ -106,8 +106,8 @@ if [ "$output" != "$blk_out1" ]; then
log_fail "zdb -R :b80d (block 1 display/decompress) failed"
fi
-vdev=$(echo "$dva" |awk '{split($0,array,":")} END{print array[1]}')
-offset=$(echo "$dva" |awk '{split($0,array,":")} END{print array[2]}')
+vdev=$(echo "$dva" | cut -d: -f1)
+offset=$(echo "$dva" | cut -d: -f2)
output=$(export ZDB_NO_ZLE=\"true\";\
zdb -R $TESTPOOL $vdev:$offset:$l1_read_size:id 2> /dev/null)
block_cnt=$(echo "$output" | grep 'L0' | wc -l)
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh
index e20144058..945532903 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_neg.ksh
@@ -65,7 +65,7 @@ done
# Specifying a non-existent object identifier returns an error
obj_id_highest=$(zdb -P -dd $TESTPOOL/$TESTFS 2>/dev/null |
- egrep "^ +-?([0-9]+ +){7}" | sort -n | tail -n 1 | awk '{print $1}')
+ egrep "^ +-?([0-9]+ +){7}" | sort -n | awk 'END {print $1}')
obj_id_invalid=$(( $obj_id_highest + 1 ))
log_mustnot zdb -dd $TESTPOOL/$TESTFS $obj_id_invalid
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh
index 1e63ac7d2..ff46b0f2f 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_object_range_pos.ksh
@@ -42,8 +42,8 @@ function get_object_list_range
begin=$2
end=$3
get_object_list $dataset |
- while read line; do
- obj=$(echo $line | awk '{print $1}')
+ while read -r line; do
+ read -r obj _ <<<"$line"
if [[ $obj -ge $begin && $obj -le $end ]] ; then
echo "$line"
elif [[ $obj -gt $end ]] ; then
@@ -142,7 +142,7 @@ log_must test "\n$actual\n" == "\n$expected\n"
# Specifying individual object IDs works
objects="$start1 $end1 $start2 $end2"
expected="$objects"
-actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{print $1}' | tr '\n' ' ')
+actual=$(get_object_list $TESTPOOL/$TESTFS $objects | awk '{printf("%s ", $1)}' | tr '\n' ' ')
log_must test "${actual% }" == "$expected"
# Get all objects in the meta-objset to test m (spacemap) and z (zap) flags
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh
index accb12528..c3021d175 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh
@@ -68,63 +68,41 @@ log_note "file $init_data has object number $obj"
sync_pool $TESTPOOL
output=$(zdb -d $TESTPOOL/$TESTFS)
-objset_id=$(echo $output | awk '{split($0,array,",")} END{print array[2]}' |
- awk '{split($0,array," ")} END{print array[2]}')
+objset_id=$(echo $output | cut -d, -f2 | cut -d' ' -f2)
objset_hex=$(printf "0x%X" $objset_id)
log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)"
for id in "$objset_id" "$objset_hex"
do
log_note "zdb -dddddd $TESTPOOL/$id $obj"
- output=$(zdb -dddddd $TESTPOOL/$id $obj)
- reason="($TESTPOOL/$TESTFS not in zdb output)"
- echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null
- (( $? != 0 )) && log_fail \
- "zdb -dddddd $TESTPOOL/$id $obj failed $reason"
- reason="(file1 not in zdb output)"
- echo $output |grep "file1" > /dev/null
- (( $? != 0 )) && log_fail \
- "zdb -dddddd $TESTPOOL/$id $obj failed $reason"
- obj=$(printf "0x%X" $obj)
+ output=$(zdb -dddddd $TESTPOOL/$id $obj)
+ echo $output | grep -q "$TESTPOOL/$TESTFS" ||
+ log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)"
+ echo $output | grep -q "file1" ||
+ log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)"
+ obj=$(printf "0x%X" $obj)
log_note "zdb -NNNNNN $TESTPOOL/$id $obj"
output=$(zdb -NNNNNN $TESTPOOL/$id $obj)
- reason="($TESTPOOL/$TESTFS not in zdb output)"
- echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null
- (( $? != 0 )) && log_fail \
- "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason"
- reason="(file1 not in zdb output)"
- echo $output |grep "file1" > /dev/null
- (( $? != 0 )) && log_fail \
- "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason"
+ echo $output | grep -q "$TESTPOOL/$TESTFS" ||
+ log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)"
+ echo $output | grep -q "file1" ||
+ log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)"
done
if is_linux; then
output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1)
objset_hex=${output#*-}
name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output |
- grep dataset_name | awk '{split($0,array," ")} END{print array[3]}')
+ grep dataset_name | cut -d' ' -f3)
log_note "checking zdb output for $name_from_proc"
- reason="(name $name_from_proc from proc not in zdb output)"
- log_note "zdb -dddddd $TESTPOOL/$objset_hex"
- output=$(zdb -dddddd $TESTPOOL/$objset_hex)
- echo $output |grep "$name_from_proc" > /dev/null
- (( $? != 0 )) && log_fail \
- "zdb -dddddd $TESTPOOL/$objset_hex failed $reason"
+ log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\""
fi
log_must zfs create $hex_ds
log_must zfs create $num_ds
-output=$(zdb -d $hex_ds)
-reason="($TESTPOOL/0x400 not in zdb output)"
-echo $output |grep "$hex_ds" > /dev/null
-(( $? != 0 )) && log_fail \
- "zdb -d $hex_ds failed $reason"
-output=$(zdb -d $num_ds)
-reason="($num_ds not in zdb output)"
-echo $output |grep "$num_ds" > /dev/null
-(( $? != 0 )) && log_fail \
- "zdb -d $num_ds failed $reason"
+log_must eval "zdb -d $hex_ds | grep -q \"$hex_ds\""
+log_must eval "zdb -d $num_ds | grep -q \"$num_ds\""
# force numeric interpretation, expect fail
log_mustnot zdb -N $hex_ds
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh
index 4bfb3d5f7..5f42006de 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_007_pos.ksh
@@ -40,8 +40,7 @@
# 2. Verify it succeed while upgrade, but fails while the version downgraded.
#
-ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \
- | sed -e 's/\.//g')
+ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*')
verify_runnable "both"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh
index 13f5418d4..643bf1cf2 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_clone/zfs_clone_010_pos.ksh
@@ -221,7 +221,7 @@ for (( i = 1; i <= (ZFS_MAXPROPLEN / 200 + 1); i++ )); do
log_must zfs clone ${fs}@snap ${fs}/${TESTCLONE}${xs}.${i}
done
clone_list=$(zfs list -o clones $fs@snap)
-char_count=$(echo "$clone_list" | tail -1 | wc | awk '{print $3}')
+char_count=$(echo "$clone_list" | tail -1 | wc -c)
[[ $char_count -eq $ZFS_MAXPROPLEN ]] || \
log_fail "Clone list not truncated correctly. Unexpected character count" \
"$char_count"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh
index 61d7aa28d..aa895956c 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_copies/zfs_copies_002_pos.ksh
@@ -94,11 +94,9 @@ done
log_note "Verify df(1) can correctly display the space charged."
for val in 1 2 3; do
if is_freebsd; then
- used=`df -m /$TESTPOOL/fs_$val | grep $TESTPOOL/fs_$val \
- | awk -v fs=fs_$val '$4 ~ fs {print $3}'`
+ used=`df -m /$TESTPOOL/fs_$val | awk -v pa=$TESTPOOL/fs_$val -v fs=fs_$val '$0 ~ pa && $4 ~ fs {print $3}'`
else
- used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | grep $TESTPOOL/fs_$val \
- | awk '{print $3}'`
+ used=`df -F zfs -k /$TESTPOOL/fs_$val/$FILE | awk -v pa=$TESTPOOL/fs_$val '$0 ~ pa {print $3}'`
(( used = used * 1024 )) # kb -> bytes
fi
check_used $used $val
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh
index 63f5e595e..6722a659e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_009_neg.ksh
@@ -62,8 +62,7 @@ function cleanup
# check to see if there is any new fs created during the test
# if so destroy it.
#
- for dset in $(zfs list -H | \
- awk '{print $1}' | grep / ); do
+ for dset in $(zfs list -H | awk '$1 ~ /\/ {print $1}'); do
found=false
i=0
while (( $i < ${#existed_fs[*]} )); do
@@ -99,7 +98,7 @@ log_assert "Verify 'zfs create <filesystem>' fails with bad <filesystem> argumen
datasetexists $TESTPOOL/$TESTFS || \
log_must zfs create $TESTPOOL/$TESTFS
-set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / )
+set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}')
log_mustnot zfs create $TESTPOOL
log_mustnot zfs create $TESTPOOL/$TESTFS
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh
index 4b1401d86..d4784d653 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_010_neg.ksh
@@ -62,8 +62,7 @@ function cleanup
# check to see if there is any new fs created during the test
# if so destroy it.
#
- for dset in $(zfs list -H | \
- awk '{print $1}' | grep / ); do
+ for dset in $(zfs list -H | awk '$1 ~ /\// {print $1}'); do
found=false
i=0
while (( $i < ${#existed_fs[*]} )); do
@@ -108,7 +107,7 @@ set -A options "" "-s"
datasetexists $TESTPOOL/$TESTVOL || \
log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL
-set -A existed_fs $(zfs list -H | awk '{print $1}' | grep / )
+set -A existed_fs $(zfs list -H | awk '$1 ~ /\// {print $1}')
log_mustnot zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL
log_mustnot zfs create -s -V $VOLSIZE $TESTPOOL/$TESTVOL
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh
index a0b8d52f0..2a140d954 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_012_pos.ksh
@@ -41,8 +41,7 @@
# 2. Verify only the leaf filesystem to be version=1, others use the current version
#
-ZFS_VERSION=$(zfs upgrade | head -1 | awk '{print $NF}' \
- | sed -e 's/\.//g')
+ZFS_VERSION=$(zfs upgrade | grep -wom1 '[[:digit:]]*')
verify_runnable "both"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib
index 4c3f8b908..bf8e145e5 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_create/zfs_create_common.kshlib
@@ -40,15 +40,12 @@ function propertycheck
{
typeset dtst=$1
typeset propstr=$2
+ typeset prop expect_value
- typeset prop=$(echo $propstr | awk -F= '{print $1}')
- typeset expect_value=$(echo $propstr | awk -F= '{print $2}')
- typeset value=$(zfs get -H -p -o value $prop $dtst)
+ IFS='=' read -r prop expect_value <<<"$propstr"
+ typeset value=$(get_prop $prop $dtst)
- if [[ "$expect_value" == "$value" ]]; then
- return 0
- else
- return 1
- fi
+
+ [ "$expect_value" = "$value" ]
}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh
index 9a2ff6bea..d618f21e9 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_destroy/zfs_destroy_004_pos.ksh
@@ -98,8 +98,7 @@ log_must zfs set mountpoint=$mntp1 $fs1
log_must zfs set mountpoint=$mntp2 $clone
for arg in "$fs1 $mntp1" "$clone $mntp2"; do
- fs=`echo $arg | awk '{print $1}'`
- mntp=`echo $arg | awk '{print $2}'`
+ read -r fs mntp <<<"$arg"
log_note "Verify that 'zfs destroy' fails to" \
"destroy filesystem when it is busy."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh
index 51a1b4aa1..ca8df6dab 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_changes.ksh
@@ -47,7 +47,7 @@ function verify_object_change # <path> <change>
change="$2"
log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
- diffchg="$(awk -v path="$path" '$NF == path { print $1 }' < $FILEDIFF)"
+ diffchg="$(awk -v path="$path" '$NF == path { print $1 }' $FILEDIFF)"
if [[ "$diffchg" != "$change" ]]; then
log_fail "Unexpected change for $path ('$diffchg' != '$change')"
else
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
index 0d08cf629..81ee87f8a 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_timestamp.ksh
@@ -73,10 +73,8 @@ log_must zfs snapshot "$TESTSNAP2"
# 3. Verify 'zfs diff -t' correctly display timestamps
typeset -i count=0
log_must eval "zfs diff -t $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
-awk '{print substr($1,1,index($1,".")-1)" "$NF}' < "$FILEDIFF" | while read line
+awk '{print substr($1,1,index($1,".")-1) " " $NF}' "$FILEDIFF" | while read -r ctime file
do
- read ctime file <<< "$line"
-
# If path from 'zfs diff' is not a file (could be xattr object) skip it
if [[ ! -f "$file" ]]; then
continue;
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh
index 8e521b9f5..51f0295cd 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_diff/zfs_diff_types.ksh
@@ -52,7 +52,7 @@ function verify_object_class # <path> <symbol>
symbol="$2"
log_must eval "zfs diff -F $TESTSNAP1 $TESTSNAP2 > $FILEDIFF"
- diffsym="$(awk -v path="$path" '$NF == path { print $2 }' < $FILEDIFF)"
+ diffsym="$(awk -v path="$path" '$NF == path { print $2 }' $FILEDIFF)"
if [[ "$diffsym" != "$symbol" ]]; then
log_fail "Unexpected type for $path ('$diffsym' != '$symbol')"
else
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh
index 807954a60..b3286c31e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh
@@ -102,16 +102,15 @@ function check_return_value
found=0
while read line; do
- typeset item
- typeset value
+ typeset item value _
- item=$(echo $line | awk '{print $2}' 2>&1)
+ read -r _ item _ <<<"$line"
if [[ $item == $p ]]; then
((found += 1))
cols=$(echo $line | awk '{print NF}')
fi
- value=$(echo $line | awk '{print $3}' 2>&1)
+ read -r _ _ value _ <<<"$line"
if [[ $value == $uint64_max ]]; then
log_fail "'zfs get $opt $props $dst' return " \
"UINT64_MAX constant."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh
index 2ea5aa0cb..e96899118 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_003_pos.ksh
@@ -55,9 +55,8 @@ log_onexit cleanup
log_must zfs set atime=on $TESTPOOL/$TESTFS
log_must zfs mount -o remount,noatime $TESTPOOL/$TESTFS
-value1=$(zfs get -H atime $TESTPOOL/$TESTFS | awk '{print $3}')
-value2=$(zfs get -H all $TESTPOOL/$TESTFS | awk '{print $2 " " $3}' | \
- grep ^atime | awk '{print $2}')
+read -r _ _ value1 _ < <(zfs get -H atime $TESTPOOL/$TESTFS)
+read -r _ value2 < <(zfs get -H all $TESTPOOL/$TESTFS | cut -f2,3 | grep ^atime)
if [[ $value1 != $value2 ]]; then
log_fail "value1($value1) != value2($value2)"
fi
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh
index 3bc4c6240..de52c586f 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_004_pos.ksh
@@ -163,15 +163,12 @@ while (( i < ${#opts[*]} )); do
log_must eval "zfs get ${opts[i]} all >$propfile"
for ds in $allds; do
- grep $ds $propfile >/dev/null 2>&1
- (( $? != 0 )) && \
+ grep -q $ds $propfile || \
log_fail "There is no property for" \
"dataset $ds in 'get all' output."
- propnum=`cat $propfile | awk '{print $1}' | \
- grep "${ds}$" | wc -l`
- ds_type=`zfs get -H -o value type $ds`
- case $ds_type in
+ propnum=$(awk -v ds="${ds}$" '$1 ~ ds {print $1}' $propfile | wc -l)
+ case $(zfs get -H -o value type $ds) in
filesystem )
(( propnum < fspropnum )) && \
(( failflag += 1 ))
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh
index 8af9f80cf..11a97a83e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key.ksh
@@ -70,7 +70,8 @@ log_must key_available $TESTPOOL/$TESTFS1
log_mustnot eval "echo $PASSPHRASE | zfs load-key $TESTPOOL/$TESTFS1"
-typeset DISK2="$(echo $DISKS | awk '{ print $2 }')"
+typeset DISK2 _
+read -r _ DISK2 _ <<<"$DISKS"
log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \
"-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $DISK2"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh
index 3c18e4538..515753722 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_load-key/zfs_load-key_all.ksh
@@ -56,7 +56,8 @@ log_must zfs create -o encryption=on -o keyformat=passphrase \
log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \
-o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol
-typeset DISK2="$(echo $DISKS | awk '{ print $2}')"
+typeset DISK2 _
+read -r _ DISK2 _ <<<"$DISKS"
log_must zpool create -O encryption=on -O keyformat=passphrase \
-O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
index 85566e565..23cab2511 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
@@ -35,10 +35,7 @@ function force_unmount #dev
{
typeset dev=$1
- ismounted $dev
- if (( $? == 0 )); then
- log_must zfs $unmountforce $dev
- fi
+ ismounted $dev && log_must zfs $unmountforce $dev
return 0
}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh
index 409dd06d7..a11f53d79 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_007_pos.ksh
@@ -112,7 +112,7 @@ function get_reverse_option
typeset val
typeset -i ind=0
- val=$(get_prop $prop $fs) || log_fail "get_prop $prop $fs"
+ val=$(get_prop $prop $fs)
if [[ $val == "on" ]]; then
(( ind = i * 2 ))
else
@@ -127,7 +127,6 @@ cleanup
for property in ${properties[@]}; do
orig_val=$(get_prop $property $fs)
- (($? != 0)) && log_fail "get_prop $property $fs"
# Set filesystem property temporarily
reverse_opt=$(get_reverse_option $fs $property)
@@ -135,7 +134,6 @@ for property in ${properties[@]}; do
log_must zfs mount -o $reverse_opt $fs
cur_val=$(get_prop $property $fs)
- (($? != 0)) && log_fail "get_prop $property $fs"
# In LZ, a user with all zone privileges can never with "devices"
if ! is_global_zone && [[ $property == devices ]] ; then
@@ -153,7 +151,6 @@ for property in ${properties[@]}; do
log_must zfs mount $fs
cur_val=$(get_prop $property $fs)
- (($? != 0)) && log_fail "get_prop $property $fs"
if [[ $orig_val != $cur_val ]]; then
log_fail "zfs mount -o $reverse_opt " \
"change the property that is stored on disks"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh
index f31ff4809..f53a4ac71 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_property/zfs_written_property_001_pos.ksh
@@ -217,12 +217,11 @@ for ds in $datasets; do
sync_pool
done
recursive_output=$(zfs get -p -r written@current $TESTPOOL | \
- grep -v $TESTFS1@ | grep -v $TESTFS2@ | grep -v $TESTFS3@ | \
- grep -v "VALUE" | grep -v "-")
+ grep -ve $TESTFS1@ -e $TESTFS2@ -e $TESTFS3@ -e "VALUE" | grep -v "-")
expected="$((20 * mb_block))"
for ds in $datasets; do
writtenat=$(echo "$recursive_output" | grep -v $ds/)
- writtenat=$(echo "$writtenat" | grep $ds | awk '{print $3}')
+ writtenat=$(echo "$writtenat" | awk -v ds="$ds" '$0 ~ ds {print $3}')
within_percent $writtenat $expected 99.5 || \
log_fail "Unexpected written@ value on $ds"
done
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh
index cce387615..48cebc87f 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_003_pos.ksh
@@ -62,7 +62,7 @@ log_onexit cleanup
ibackup=$TEST_BASE_DIR/ibackup.$$
fs=$TESTPOOL/$TESTFS; snap1=$fs@snap1; snap2=$fs@snap2
-mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs"
+mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh
index 79f34bd3f..06a080451 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_006_pos.ksh
@@ -82,7 +82,7 @@ datasetexists $ancestor_fs || \
log_must zfs create $ancestor_fs
log_must zfs create $fs
-mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs"
+mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh
index fbf0654e4..ec2437db9 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_007_neg.ksh
@@ -64,7 +64,7 @@ ibackup=$TEST_BASE_DIR/ibackup.$$
datasetexists $fs || log_must zfs create $fs
-mntpnt=$(get_prop mountpoint $fs) || log_fail "get_prop mountpoint $fs"
+mntpnt=$(get_prop mountpoint $fs)
log_must mkfile 10m $mntpnt/file1
log_must zfs snapshot $snap1
log_must mkfile 10m $mntpnt/file2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh
index dc4892b5d..f948dfd66 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_008_pos.ksh
@@ -86,9 +86,6 @@ for orig_fs in $datasets ; do
typeset mntpnt
mntpnt=$(get_prop mountpoint $orig_fs)
- if [[ $? -ne 0 ]] ; then
- log_fail "get_prop mountpoint $orig_fs failed"
- fi
typeset mnt_file=$mntpnt/file1
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh
index e1e93e9d2..87bb63b36 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_013_pos.ksh
@@ -52,7 +52,7 @@ log_onexit cleanup
truncate -s 100M $tpoolfile
log_must zpool create $temppool $tpoolfile
log_must zfs create $src_fs
-src_mnt=$(get_prop mountpoint $src_fs) || log_fail "get_prop mountpoint $src_fs"
+src_mnt=$(get_prop mountpoint $src_fs)
echo blah > $src_mnt/blah
zfs snapshot $src_fs@base
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh
index 72eebb4f9..05c2ece46 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_from_zstd.ksh
@@ -58,27 +58,22 @@ log_note "Randomly selected ZSTD level: $random_level"
log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS1
# Make a 5kb compressible file
-log_must cat $src_data $src_data $src_data $src_data $src_data \
- > /$TESTPOOL/$TESTFS1/$TESTFILE0
+log_must eval cat $src_data $src_data $src_data $src_data $src_data \
+ "> /$TESTPOOL/$TESTFS1/$TESTFILE0"
typeset checksum=$(md5digest /$TESTPOOL/$TESTFS1/$TESTFILE0)
log_must zfs snapshot $snap
# get object number of file
-listing=$(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0)
-set -A array $listing
-obj=${array[0]}
+read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS1/$TESTFILE0)
log_note "file /$TESTPOOL/$TESTFS1/$TESTFILE0 has object number $obj"
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS1 $obj 2> /dev/null \
- |grep -m 1 "L0 DVA" |head -n1)
+ | grep -m 1 "L0 DVA")
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of /$TESTPOOL/$TESTFS1/$TESTFILE0 has a DVA of $dva"
-zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
-zstd_size1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
-zstd_version1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
-zstd_level1=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
+read -r zstd_size1 zstd_version1 zstd_level1 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output")
log_note "ZSTD src: size=$zstd_size1 version=$zstd_version1 level=$zstd_level1"
log_note "Verify ZFS can receive the ZSTD compressed stream"
@@ -89,23 +84,18 @@ typeset cksum1=$(md5digest /$TESTPOOL/$TESTFS2/$TESTFILE0)
log_fail "Checksums differ ($cksum1 != $checksum)"
# get object number of file
-listing=$(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0)
-set -A array $listing
-obj=${array[0]}
+read -r obj _ < <(ls -i /$TESTPOOL/$TESTFS2/$TESTFILE0)
log_note "file /$TESTPOOL/$TESTFS2/$TESTFILE0 has object number $obj"
output=$(zdb -Zddddddbbbbbb $TESTPOOL/$TESTFS2 $obj 2> /dev/null \
- |grep -m 1 "L0 DVA" |head -n1)
+ | grep -m 1 "L0 DVA")
dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*$/\1/p' <<< "$output")
log_note "block 0 of /$TESTPOOL/$TESTFS2/$TESTFILE0 has a DVA of $dva"
-zstd_str=$(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1:\2:\3/p' <<< "$output")
-zstd_size2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[1]}')
+read -r zstd_size2 zstd_version2 zstd_level2 < <(sed -Ene 's/^.+ ZSTD:size=([^:]+):version=([^:]+):level=([^:]+):.*$/\1 \2 \3/p' <<< "$output")
+log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2"
(( $zstd_size2 != $zstd_size1 )) && log_fail \
"ZFS recv failed: compressed size differs ($zstd_size2 != $zstd_size1)"
-zstd_version2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[2]}')
-zstd_level2=$(echo "$zstd_str" |awk '{split($0,array,":")} END{print array[3]}')
-log_note "ZSTD dest: size=$zstd_size2 version=$zstd_version2 level=$zstd_level2"
(( $zstd_level2 != $zstd_level1 )) && log_fail \
"ZFS recv failed: compression level did not match header level ($zstd_level2 != $zstd_level1)"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh
index 1c707762a..96826d814 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_nounmount.ksh
@@ -39,7 +39,7 @@ function rename_cleanup
zfs destroy -fR $TESTPOOL/renamed
}
-back=$(pwd)
+back=$PWD
log_onexit rename_cleanup
log_must zfs create $TESTPOOL/rename_test
@@ -72,14 +72,15 @@ log_must zfs list $TESTPOOL/renamed
log_must zfs list $TESTPOOL/renamed/child
log_must zfs list $TESTPOOL/renamed/child/grandchild
-missing=$(zfs mount | awk -v pat=$TESTPOOL/renamed '$1 ~ pat' | awk \
+missing=$(zfs mount | awk \
+ -v genpat=$TESTPOOL/renamed \
-v mntp_p=$mntp_p \
-v mntp_c=$mntp_c \
-v mntp_g=$mntp_g '
BEGIN { p = c = g = 0 }
- $2 == mntp_p { p = 1 }
- $2 == mntp_c { c = 1 }
- $2 == mntp_g { g = 1 }
+ $1 ~ genpat && $2 == mntp_p { p = 1 }
+ $1 ~ genpat && $2 == mntp_c { c = 1 }
+ $1 ~ genpat && $2 == mntp_g { g = 1 }
END {
if (p != 1)
print mntp_p
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh
index 85d076310..157603981 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_send/zfs_send_007_pos.ksh
@@ -52,7 +52,7 @@ streamfile=$(mktemp $TESTDIR/file.XXXXXX)
vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX)
-test_pool ()
+function test_pool
{
POOL=$1
log_must zfs create -o recordsize=512 $POOL/fs
@@ -67,10 +67,7 @@ test_pool ()
sync_all_pools
# check if we started reusing objects
object=$(ls -i $mntpnt | sort -n | awk -v object=$object \
- '{if ($1 <= object) {exit 1}} END {print $1}')
- if [[ $? -ne 0 ]]; then
- break
- fi
+ '{if ($1 <= object) {exit 1}} END {print $1}') || break
done
dd if=/dev/urandom of=${mntpnt}/$FILE bs=512 count=1 seek=1 2>/dev/null
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh
index ac5fc8188..fe8aa2fd1 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/canmount_001_pos.ksh
@@ -81,14 +81,8 @@ function cleanup
log_assert "Setting a valid property of canmount to file system, it must be successful."
log_onexit cleanup
-typeset old_fs_canmount="" old_ctr_canmount=""
-
-old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
-[[ $? != 0 ]] && \
- log_fail "Get the $TESTPOOL/$TESTFS canmount error."
-old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
-[[ $? != 0 ]] && \
- log_fail "Get the $TESTPOOL/$TESTCTR canmount error."
+typeset old_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
+typeset old_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
log_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
log_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh
index 1255ae5f5..30efef1c3 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_001_pos.ksh
@@ -69,11 +69,7 @@ log_assert "Setting a valid mountpoint to file system, it must be successful."
log_onexit cleanup
old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
-[[ $? != 0 ]] && \
- log_fail "Get the $TESTPOOL/$TESTFS mountpoint error."
old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
-[[ $? != 0 ]] && \
- log_fail "Get the $TESTPOOL/$TESTCTR mountpoint error."
if [[ ! -d $TESTDIR2 ]]; then
log_must mkdir $TESTDIR2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh
index 48580cafd..603e84dcd 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_002_pos.ksh
@@ -66,11 +66,7 @@ log_assert "Setting a valid mountpoint for an unmounted file system, \
log_onexit cleanup
old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
-[[ $? != 0 ]] && \
- log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTFS"
old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
-[[ $? != 0 ]] && \
- log_fail "Unable to get the mountpoint property for $TESTPOOL/$TESTCTR"
if [[ ! -d $TESTDIR2 ]]; then
log_must mkdir $TESTDIR2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh
index 4d86100c0..38bbda0d1 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_set/mountpoint_003_pos.ksh
@@ -109,10 +109,8 @@ while ((i < ${#args[@]})); do
msg=$(mount | grep "$tmpmnt ")
- echo $msg | grep "${args[((i))]}" > /dev/null 2>&1
- if (($? != 0)) ; then
- echo $msg | grep "${args[((i-1))]}" > /dev/null 2>&1
- if (($? == 0)) ; then
+ if ! echo $msg | grep -q "${args[((i))]}"; then
+ if echo $msg | grep -q "${args[((i-1))]}"; then
log_fail "Expected option: ${args[((i))]} \n" \
"Real option: $msg"
fi
@@ -130,8 +128,7 @@ while ((i < ${#args[@]})); do
args[((i+1))]="/nodevices/"
fi
- echo $msg | grep "${args[((i+1))]}" > /dev/null 2>&1
- if (($? != 0)) ; then
+ if ! echo $msg | grep -q "${args[((i+1))]}"; then
log_fail "Expected option: ${args[((i+1))]} \n" \
"Real option: $msg"
fi
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh
index 4ff539a37..407936c7c 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_snapshot/zfs_snapshot_009_pos.ksh
@@ -84,7 +84,7 @@ while (( i < ${#invalid_args[*]} )); do
((i = i + 1))
done
log_note "verify multiple snapshot transaction group"
-txg_group=$(zdb -Pd $TESTPOOL | grep snap | awk '{print $7}')
+txg_group=$(zdb -Pd $TESTPOOL | awk '/snap/ {print $7}')
for i in 1 2 3; do
txg_tag=$(echo "$txg_group" | nawk -v j=$i 'FNR == j {print}')
[[ $txg_tag != $(echo "$txg_group" | \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh
index 55da68262..6d3d37bd6 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unload-key/zfs_unload-key_all.ksh
@@ -54,7 +54,8 @@ log_must zfs create $TESTPOOL/$TESTFS1/child
log_must zfs create -V 64M -o encryption=on -o keyformat=passphrase \
-o keylocation=file:///$TESTPOOL/pkey $TESTPOOL/zvol
-typeset DISK2="$(echo $DISKS | awk '{ print $2}')"
+typeset DISK2 _
+read -r _ DISK2 _ <<<"$DISKS"
log_must zpool create -O encryption=on -O keyformat=passphrase \
-O keylocation=file:///$TESTPOOL/pkey $TESTPOOL1 $DISK2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh
index 8b70e8868..0afb9b6f8 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unmount/zfs_unmount_006_pos.ksh
@@ -56,7 +56,6 @@ log_onexit cleanup
# Call cleanup to make sure the file system are mounted.
cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
-(($? != 0)) && log_fail "get_prop mountpoint $TESTPOOL/$TESTFS"
typeset -i i=0
while (( i < 10000 )); do
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh
index ab7646163..3b4451c74 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade_001_pos.ksh
@@ -72,7 +72,7 @@ typeset expect_str3="The following filesystems are out of date, and can be upgra
typeset -i COUNT OLDCOUNT
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
-OLDCOUNT=$( wc -l $oldoutput | awk '{print $1}' )
+OLDCOUNT=$(wc -l < $oldoutput)
old_datasets=""
for version in $ZFS_ALL_VERSIONS ; do
@@ -100,7 +100,7 @@ log_must eval 'zfs upgrade > $output 2>&1'
# of the current ZFS version.
log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output
-COUNT=$( wc -l $output | awk '{print $1}' )
+COUNT=$(wc -l < $output)
typeset -i i=0
for fs in ${old_datasets}; do
@@ -125,7 +125,7 @@ else
log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1'
fi
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output
-COUNT=$( wc -l $output | awk '{print $1}' )
+COUNT=$(wc -l < $output)
if (( COUNT != OLDCOUNT )); then
cat $output
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh
index 8c7f40ba9..b131bc708 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool/zpool_colors.ksh
@@ -39,8 +39,7 @@ log_onexit cleanup
log_assert "Test colorized zpool status output"
-DISK2="$(echo $DISKS | cut -d' ' -f2)"
-DISK3="$(echo $DISKS | cut -d' ' -f3)"
+read -r _ DISK2 DISK3 _ <<<"$DISKS"
log_must dd if=/dev/urandom of=/$TESTDIR/testfile bs=10M count=1
@@ -62,16 +61,15 @@ log_note "$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status)"
# Replace the escape codes with "ESC" so they're easier to grep
out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status | \
- grep -E 'pool:|DEGRADED' | \
- sed -r 's/[[:space:]]+//g;'$(echo -e 's/\033/ESC/g'))"
+ sed -E '/pool:|DEGRADED/!d;s/[[:space:]]+//g;'$(printf 's/\033/ESC/g'))"
log_note "$(echo $out)"
log_note "Look for 'pool:' in bold"
-log_must eval "echo \"$out\" | grep -q 'ESC\[1mpool:ESC\[0m' "
+log_must grep -q 'ESC\[1mpool:ESC\[0m' <<<"$out"
log_note "Look for 'DEGRADED' in yellow"
-log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'"
+log_must grep -q 'ESC\[0;33mDEGRADEDESC\[0m' <<<"$out"
#
# The escape code for 'FAULTED' is a little more tricky. The line starts like
@@ -83,9 +81,11 @@ log_must eval "echo \"$out\" | grep -q 'ESC\[0;33mDEGRADEDESC\[0m'"
# we can easily remove the vdev field to get what we want.
#
out="$(faketty TERM=xterm-256color ZFS_COLOR=1 zpool status \
- | awk '/FAULTED/{print $1$3$4}' | sed -r $(echo -e 's/\033/ESC/g'))"
+ | awk '/FAULTED/ {print $1$3$4}' | sed -E $(printf 's/\033/ESC/g'))"
+
+log_note "$(echo $out)"
log_note "Look for 'FAULTED' in red"
-log_must eval "echo \"$out\" | grep -q 'ESC\[0;31mFAULTEDESC\[0m'"
+log_must grep -q 'ESC\[0;31mFAULTEDESC\[0m' <<<"$out"
log_pass "zpool status displayed colors"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh
index 61f5f6d1c..677d0762e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add_nested_replacing_spare.ksh
@@ -90,10 +90,8 @@ do
log_must wait_vdev_state $TESTPOOL $REPLACE_DEV "ONLINE" 60
zpool status | awk -v poolname="$TESTPOOL" -v type="$type" 'BEGIN {s=""}
$1 ~ poolname {c=4}; (c && c--) { s=s$1":" }
- END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }'
- if [[ $? -ne 0 ]]; then
+ END { if (s != poolname":"type"-0:spare-0:replacing-0:") exit 1; }' ||
log_fail "Pool does not contain nested replacing/spare vdevs"
- fi
# 3. Verify 'zpool add' is able to add new devices
log_must zpool add $TESTPOOL spare $SPARE_DEV2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib
index c64b4a35a..e10357340 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib
@@ -50,9 +50,8 @@ function find_vfstab_dev
#
function find_mnttab_dev
{
- typeset mnttabdev
+ typeset mnttabdev _
typeset mnttabdevs=""
- typeset line
if is_freebsd; then
# FreeBSD doesn't have a mnttab file.
@@ -61,21 +60,16 @@ function find_mnttab_dev
return 0
elif is_linux; then
typeset mnttab="/etc/mtab"
- typeset tmpfile="$TEST_BASE_DIR/mtab.tmp"
else
typeset mnttab="/etc/mnttab"
- typeset tmpfile="$TEST_BASE_DIR/mnttab.tmp"
fi
- cat $mnttab | grep "^${DEV_DSKDIR}" >$tmpfile
- while read -r line
+ while read -r mnttabdev _
do
- mnttabdev=`echo "$line" | awk '{print $1}'`
mnttabdev=${mnttabdev%%:}
mnttabdevs="$mnttabdev $mnttabdevs"
- done <$tmpfile
+ done < <(grep "^${DEV_DSKDIR}" $mnttab)
- rm -f $tmpfile
echo $mnttabdevs
}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh
index a6b03ff32..381644466 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_003_pos.ksh
@@ -90,8 +90,8 @@ done
log_must zpool add -f $TESTPOOL $config
zpool status $TESTPOOL | awk 'NR == 1, /NAME/ { next } /^$/ {exit}
{print $1}' > "$TMPFILE_PREFIX-vdevtree"
-cat "$TMPFILE_PREFIX-dryrun" | awk 'NR == 1, /would/ {next}
- /^$/ {next} {print $1}' > "$TMPFILE_PREFIX-vdevtree-n"
-log_must eval "diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree"
+awk 'NR == 1, /would/ {next}
+ /^$/ {next} {print $1}' "$TMPFILE_PREFIX-dryrun" > "$TMPFILE_PREFIX-vdevtree-n"
+log_must diff $TMPFILE_PREFIX-vdevtree-n $TMPFILE_PREFIX-vdevtree
log_pass "'zpool add -n <pool> <vdev> ...' executes successfully."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh
index 1188ca10d..f1f926831 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_clear/zpool_clear_001_pos.ksh
@@ -50,9 +50,7 @@ function cleanup
poolexists $TESTPOOL1 && \
log_must zpool destroy -f $TESTPOOL1
- for file in `ls $TEST_BASE_DIR/file.*`; do
- log_must rm -f $file
- done
+ log_must rm -f $fbase.{0..2}
}
@@ -60,14 +58,8 @@ log_assert "Verify 'zpool clear' can clear errors of a storage pool."
log_onexit cleanup
#make raw files to create various configuration pools
-typeset -i i=0
-while (( i < 3 )); do
- log_must truncate -s $FILESIZE $TEST_BASE_DIR/file.$i
-
- (( i = i + 1 ))
-done
-
fbase=$TEST_BASE_DIR/file
+log_must truncate -s $FILESIZE $fbase.{0..2}
set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \
"raidz1 $fbase.0 $fbase.1 $fbase.2" \
"raidz2 $fbase.0 $fbase.1 $fbase.2"
@@ -75,59 +67,24 @@ set -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \
function check_err # <pool> [<vdev>]
{
typeset pool=$1
- shift
- if (( $# > 0 )); then
- typeset checkvdev=$1
- else
- typeset checkvdev=""
- fi
- typeset -i errnum=0
- typeset c_read=0
- typeset c_write=0
- typeset c_cksum=0
- typeset tmpfile=$TEST_BASE_DIR/file.$$
- typeset healthstr="pool '$pool' is healthy"
- typeset output="`zpool status -x $pool`"
-
- [[ "$output" == "$healthstr" ]] && return $errnum
-
- zpool status -x $pool | grep -v "^$" | grep -v "pool:" \
- | grep -v "state:" | grep -v "config:" \
- | grep -v "errors:" > $tmpfile
- typeset line
- typeset -i fetchbegin=1
- while read line; do
- if (( $fetchbegin != 0 )); then
- echo $line | grep "NAME" >/dev/null 2>&1
- (( $? == 0 )) && (( fetchbegin = 0 ))
- continue
- fi
+ typeset checkvdev=$2
- if [[ -n $checkvdev ]]; then
- echo $line | grep $checkvdev >/dev/null 2>&1
- (( $? != 0 )) && continue
- c_read=`echo $line | awk '{print $3}'`
- c_write=`echo $line | awk '{print $4}'`
- c_cksum=`echo $line | awk '{print $5}'`
- if [ $c_read != 0 ] || [ $c_write != 0 ] || \
- [ $c_cksum != 0 ]
- then
- (( errnum = errnum + 1 ))
- fi
- break
- fi
+ [ "$(zpool status -x $pool)" = "pool '$pool' is healthy" ] && return
+
+ typeset -i skipstart=1
+ typeset vdev _ c_read c_write c_cksum rest
+ while read -r vdev _ c_read c_write c_cksum rest; do
+ if [ $skipstart -ne 0 ]; then
+ [ "$vdev" = "NAME" ] && skipstart=0
+ continue
+ fi
- c_read=`echo $line | awk '{print $3}'`
- c_write=`echo $line | awk '{print $4}'`
- c_cksum=`echo $line | awk '{print $5}'`
- if [ $c_read != 0 ] || [ $c_write != 0 ] || \
- [ $c_cksum != 0 ]
- then
- (( errnum = errnum + 1 ))
+ if [ -n "$checkvdev" ]; then
+ [ "$vdev" = "$checkvdev" ] || continue
fi
- done <$tmpfile
- return $errnum
+ [ $c_read$c_write$c_cksum = 000 ] || return
+ done < <(zpool status -x $pool | grep -ve "^$" -e "pool:" -e "state:" -e "config:" -e "errors:")
}
function do_testing #<clear type> <vdevs>
@@ -137,6 +94,7 @@ function do_testing #<clear type> <vdevs>
typeset type=$1
shift
typeset vdev="$@"
+ (( i = $RANDOM % 3 ))
log_must zpool create -f $TESTPOOL1 $vdev
log_must zfs create $FS
@@ -146,14 +104,13 @@ function do_testing #<clear type> <vdevs>
#
avail=$(get_prop available $FS)
fill_mb=$(((avail / 1024 / 1024) * 25 / 100))
- log_must dd if=/dev/urandom of=$file.$i bs=$BLOCKSZ count=$fill_mb
+ log_must dd if=/dev/urandom of=$file bs=$BLOCKSZ count=$fill_mb
#
# Make errors to the testing pool by overwrite the vdev device with
# dd command. We do not want to have a full overwrite. That
# may cause the system panic. So, we should skip the vdev label space.
#
- (( i = $RANDOM % 3 ))
typeset -i wcount=0
typeset -i size
case $FILESIZE in
@@ -173,25 +130,19 @@ function do_testing #<clear type> <vdevs>
(( wcount = FILESIZE/1024 - 512 ))
;;
esac
- dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc \
- > /dev/null 2>&1
+ dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc 2>/dev/null
sync_all_pools
log_must sync #ensure the vdev files are written out
log_must zpool scrub -w $TESTPOOL1
- check_err $TESTPOOL1 && \
- log_fail "No error generated."
- if [[ $type == "device" ]]; then
- log_must zpool clear $TESTPOOL1 $fbase.$i
- ! check_err $TESTPOOL1 $fbase.$i && \
- log_fail "'zpool clear' fails to clear error for $fbase.$i device."
+ log_mustnot check_err $TESTPOOL1
+ typeset dev=
+ if [ "$type" = "device" ]; then
+ dev=$fbase.$i
fi
- if [[ $type == "pool" ]]; then
- log_must zpool clear $TESTPOOL1
- ! check_err $TESTPOOL1 && \
- log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1."
- fi
+ log_must zpool clear $TESTPOOL1 $dev
+ log_must check_err $TESTPOOL1 $dev
log_must zpool destroy $TESTPOOL1
}
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
index 005cf979b..9954bc23f 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib
@@ -83,14 +83,9 @@ function find_vfstab_dev
#
function save_dump_dev
{
- typeset dumpdev=""
-
if is_illumos; then
- typeset fnd="Dump device"
- dumpdev=`dumpadm | grep "$fnd" | cut -f2 -d : | \
- awk '{print $1}'`
+ dumpadm | grep "Dump device" | cut -f2 -d : | awk '{print $1}'
fi
- echo $dumpdev
}
#
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
index e1d8cc474..98f469108 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh
@@ -90,8 +90,8 @@ do
$file.1 $file.2 $file.3 $file.4
! poolexists $TESTPOOL && \
log_fail "Creating pool with $opt fails."
- mpt=`zfs mount | egrep "^$TESTPOOL[^/]" | awk '{print $2}'`
- (( ${#mpt} == 0 )) && \
+ mpt=`zfs mount | awk -v pat="^$TESTPOOL[^/]" '$0 ~ pat {print $2}'`
+ [ -z "$mpt" ] && \
log_fail "$TESTPOOL created with $opt is not mounted."
mpt_val=$(get_prop "mountpoint" $TESTPOOL)
[[ "$mpt" != "$mpt_val" ]] && \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh
index 36888e497..b9274c08b 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_012_neg.ksh
@@ -51,12 +51,11 @@ function cleanup
}
if is_freebsd; then
- typeset swap_disks=$(swapinfo -l | grep "/dev" | awk '{print $1}')
+ typeset swap_disks=$(swapinfo -l | awk '/\/dev/ {print $1}')
elif is_linux; then
- typeset swap_disks=`swapon -s | grep "/dev" | awk '{print $1}'`
+ typeset swap_disks=$(swapon -s | awk '/\/dev/ {print $1}')
else
- typeset swap_disks=`swap -l | grep "c[0-9].*d[0-9].*s[0-9]" | \
- awk '{print $1}'`
+ typeset swap_disks=$(swap -l | awk '/c[0-9].*d[0-9].*s[0-9]/ {print $1}')
fi
log_assert "'zpool create' should fail with disk slice in swap."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh
index 1fa205b0f..e4543f0df 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_016_pos.ksh
@@ -67,8 +67,8 @@ function cleanup
fi
}
-typeset swap_disks=$(swap -l | grep -v "swapfile" | awk '{print $1}')
-typeset dump_device=$(dumpadm | grep "Dump device" | awk '{print $3}')
+typeset swap_disks=$(swap -l | awk '!/swapfile/ {print $1}')
+typeset dump_device=$(dumpadm | awk '/Dump device/ {print $3}')
log_assert "'zpool create' should success with no device in swap."
log_onexit cleanup
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
index 8fd1cea36..a75bdecff 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
@@ -55,11 +55,9 @@ for poolprop in "${poolprops[@]}"; do
# 2. Verify the pool is created with the specified temporary name
log_must poolexists $TEMPPOOL
log_mustnot poolexists $TESTPOOL
- propname="$(awk -F= '{print $1}' <<< $fsprop)"
- propval="$(awk -F= '{print $2}' <<< $fsprop)"
+ IFS='=' read -r propname propval <<<"$fsprop"
log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
- propname="$(awk -F= '{print $1}' <<< $poolprop)"
- propval="$(awk -F= '{print $2}' <<< $poolprop)"
+ IFS='=' read -r propname propval <<<"$poolprop"
log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
# Cleanup
destroy_pool $TEMPPOOL
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh
index 22212a8f5..76d9c525e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_clear_retained.ksh
@@ -80,7 +80,7 @@ function damage_and_repair
log_must zpool wait -t scrub $POOL
log_note "pass $1 observed $($EREPORTS | grep -c checksum) checksum ereports"
- repaired=$(zpool status $POOL | grep "scan: scrub repaired" | awk '{print $4}')
+ repaired=$(zpool status $POOL | awk '/scan: scrub repaired/ {print $4}')
if [ "$repaired" == "0B" ]; then
log_fail "INVALID TEST -- expected scrub to repair some blocks"
else
@@ -90,7 +90,7 @@ function damage_and_repair
function checksum_error_count
{
- zpool status -p $POOL | grep $VDEV1 | awk '{print $5}'
+ zpool status -p $POOL | awk -v dev=$VDEV1 '$0 ~ dev {print $5}'
}
assertion="Damage to recently repaired blocks should be reported/counted"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
index 8bfb067c7..349399263 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_export/zpool_export.cfg
@@ -30,9 +30,9 @@
. $STF_SUITE/include/libtest.shlib
-export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
-export DISK1=$(echo $DISKS | awk '{print $1}')
-export DISK2=$(echo $DISKS | awk '{print $3}')
+export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
+read -r DISK1 _ DISK2 _ <<<"$DISKS"
+export DISK1 DISK2
if is_linux; then
set_slice_prefix
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh
index ba83fadb0..b695b7188 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_002_pos.ksh
@@ -88,7 +88,7 @@ done
# increment the counter to include the header line
i=$(( $i + 1 ))
-COUNT=$(wc $values | awk '{print $1}')
+COUNT=$(wc -l < $values)
if [ $i -ne $COUNT ]
then
log_fail "Found zpool features not in the zpool_get test config $i/$COUNT."
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh
index ad27d180f..4481dab69 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get_005_pos.ksh
@@ -50,14 +50,9 @@ typeset -i i=0
while [[ $i -lt "${#properties[@]}" ]]; do
log_note "Checking for parsable ${properties[$i]} property"
log_must eval "zpool get -p ${properties[$i]} $TESTPOOL >/tmp/value.$$"
- grep "${properties[$i]}" /tmp/value.$$ >/dev/null 2>&1
- if [[ $? -ne 0 ]]; then
- log_fail "${properties[$i]} not seen in output"
- fi
-
- typeset v=$(grep "${properties[$i]}" /tmp/value.$$ | awk '{print $3}')
+ log_must grep -q "${properties[$i]}" /tmp/value.$$
- log_note "${properties[$i]} has a value of $v"
+ typeset v=$(awk -v p="${properties[$i]}" '$0 ~ p {print $3}' /tmp/value.$$)
# Determine if this value is a valid number, result in return code
log_must test -n "$v"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib
index 5503d30b5..37f7acfbf 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import.kshlib
@@ -143,13 +143,12 @@ function verify_data_md5sums
return 1
fi
- cat $md5file | \
- while read digest file; do
+ while read -r digest file; do
typeset digest1=$(md5digest $file)
if [[ "$digest1" != "$digest" ]]; then
return 1
fi
- done
+ done < $md5file
return 0
}
@@ -227,8 +226,7 @@ function check_pool_config
typeset actual=""
typeset began=false
- printf "$status\n" | while read line; do
- typeset vdev=$(echo "$line" | awk '{printf $1}')
+ while read -r vdev _; do
if ( ! $began ) && [[ $vdev == NAME ]]; then
began=true
continue
@@ -240,7 +238,7 @@ function check_pool_config
vdev=$(_translate_vdev $vdev)
actual="$actual $vdev"
fi
- done
+ done <<<"$status"
expected="$poolname $expected"
@@ -295,8 +293,7 @@ function check_pool_healthy
return 1
fi
- status=$(echo "$status" | grep "$pool" | grep -v "pool:" | \
- awk '{print $2}')
+ status=$(echo "$status" | awk -v p="$pool" '!/pool:/ && $0 ~ p {print $2}')
if [[ $status != "ONLINE" ]]; then
log_note "Invalid zpool status for '$pool': '$status'" \
@@ -314,9 +311,7 @@ function pool_is_replacing
{
typeset pool=$1
- zpool status $pool | grep "replacing" | grep "ONLINE" > /dev/null
-
- return $?
+ zpool status $pool | grep "replacing" | grep -q "ONLINE"
}
function set_vdev_validate_skip
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
index 4ebe6b591..9f5503454 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_all_001_pos.ksh
@@ -76,11 +76,11 @@ function cleanup_all
#
# Try import individually if 'import -a' failed.
#
- for pool in `zpool import | grep "pool:" | awk '{print $2}'`; do
+ for pool in $(zpool import | awk '/pool:/ {print $2}'); do
zpool import -f $pool
done
- for pool in `zpool import -d $DEVICE_DIR | grep "pool:" | awk '{print $2}'`; do
+ for pool in $(zpool import -d $DEVICE_DIR | awk '/pool:/ {print $2}'); do
log_must zpool import -d $DEVICE_DIR -f $pool
done
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh
index f774970a7..083b7e55a 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_initialize/zpool_initialize_verify_initialized.ksh
@@ -65,10 +65,7 @@ log_must zpool export $TESTPOOL
metaslabs=0
bs=512
zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' |
-while read -r offset_size; do
- typeset offset=$(echo $offset_size | cut -d ' ' -f1)
- typeset size=$(echo $offset_size | cut -d ' ' -f2)
-
+while read -r offset size; do
log_note "offset: '$offset'"
log_note "size: '$size'"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
index fdf2f4284..f98b1c061 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_scrub/zpool_scrub.cfg
@@ -28,8 +28,8 @@
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
#
-export DISK1=${DISKS%% *}
-export DISK2=$(echo $DISKS | awk '{print $2}')
+read -r DISK1 DISK2 _ <<<"$DISKS"
+export DISK1 DISK2
export ZFS_SCAN_VDEV_LIMIT_SLOW=$((128*1024))
export ZFS_SCAN_VDEV_LIMIT_DEFAULT=$((4*1024*1024))
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh
index 1aff8d31d..39ae1c9d5 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_props.ksh
@@ -71,12 +71,11 @@ fi
# Verify we can set a combination of valid property values on the new pool
for prop in "${good_props[@]}"
do
- propname="$(awk -F= '{print $1}' <<< $prop)"
- propval="$(awk -F= '{print $2}' <<< $prop)"
+ IFS='=' read -r propname propval <<<"$prop"
setup_mirror
log_must zpool split -o $prop $TESTPOOL $TESTPOOL2
log_must zpool import -N -d $TEST_BASE_DIR $TESTPOOL2
- log_must test "$(get_pool_prop $propname $TESTPOOL2)" == "$propval"
+ log_must test "$(get_pool_prop $propname $TESTPOOL2)" = "$propval"
destroy_pool $TESTPOOL
destroy_pool $TESTPOOL2
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
index 9866cf7a5..d2be9b65c 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
@@ -122,7 +122,7 @@ typeset altroot="$TESTDIR/altroot-$TESTPOOL2"
for config in "${goodconfs[@]}"
do
create_config="${config%% *}"
- add_config="$(awk '{$1= "";print $0}' <<< $config)"
+ add_config="$(awk '{$1=""; print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do
log_must zpool add -f $TESTPOOL $(pool_config $vdev)
@@ -137,7 +137,7 @@ done
for config in "${badconfs[@]}"
do
create_config="${config%% *}"
- add_config="$(awk '{$1= "";print $0}' <<< $config)"
+ add_config="$(awk '{$1=""; print $0}' <<< $config)"
log_must zpool create $TESTPOOL $(pool_config $create_config)
for vdev in $add_config; do
log_must zpool add -f $TESTPOOL $(pool_config $vdev)
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
index 783ae54e7..0bc2cfab0 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_upgrade/zpool_upgrade.kshlib
@@ -132,8 +132,7 @@ function check_poolversion
fi
# check version using zpool upgrade
- actual=$(zpool upgrade | grep $pool$ | \
- awk '{print $1}' | sed -e 's/ //g')
+ actual=$(zpool upgrade | awk -v p="$pool$" '$0 ~ p {gsub(/ /, "", $1); print $1}')
if [[ $actual != $vers ]] ; then
log_fail "$pool: zpool reported version $actual, expected $vers"
fi
diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh
index bfe8cf4bb..9188e4ba6 100755
--- a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh
@@ -55,6 +55,6 @@ TEMPFILE="$TEST_BASE_DIR/zfs_001_neg.$$.txt"
zfs > $TEMPFILE 2>&1
log_must grep "usage: zfs command args" "$TEMPFILE"
-log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE"
+log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE
log_pass "zfs shows a usage message when run as a user"
diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh
index 0fddc08b2..00a86eeba 100755
--- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh
@@ -59,6 +59,6 @@ log_assert "zpool shows a usage message when run as a user"
eval "zpool > $TEMPFILE 2>&1"
log_must grep "usage: zpool command args" "$TEMPFILE"
-log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE"
+log_must awk '{if (length($0) > 80) exit 1}' $TEMPFILE
log_pass "zpool shows a usage message when run as a user"
diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh
index 7415cebf2..c8abf4da5 100755
--- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh
@@ -54,12 +54,12 @@ while [[ $i -lt ${#args[*]} ]]
do
PROP=${props[$i]}
EXPECTED=${prop_vals[$i]}
- ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' )
+ ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED"
fi
- i=$(( $i + 1 ))
+ i=$(( $i + 1 ))
done
log_must zpool get all $TESTPOOL
diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh
index 941e20c00..03d01f20e 100755
--- a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh
@@ -59,7 +59,7 @@ do
log_mustnot $POOL set $PROP=$NEW $TESTPOOL
# Now verify that the above command did nothing
- ACTUAL=$( zpool get $PROP $TESTPOOL | grep $PROP | awk '{print $1}' )
+ ACTUAL=$( zpool get $PROP $TESTPOOL | awk -v p=$PROP '$0 ~ p {print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED"
diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
index 889ae46fb..d993c3037 100644
--- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
@@ -120,7 +120,7 @@ function verify_reverse_sort { # command list name
function is_fs_type_zfs {
typeset dirname=$1
- typeset fs="$(df $dirname | tail -1 | awk '{print $NF}')"
+ typeset fs="$(df $dirname | awk 'END {print $NF}')"
if is_freebsd; then
fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \
diff --git a/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh b/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh
index fe3a3acac..fb3bae3b6 100755
--- a/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/compression/compress_001_pos.ksh
@@ -60,8 +60,8 @@ log_must file_write -o $OP -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \
sleep 60
-FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{ print $1}'`
-FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{ print $1}'`
+FILE0_BLKS=`du -k $TESTDIR/$TESTFILE0 | awk '{print $1}'`
+FILE1_BLKS=`du -k $TESTDIR/$TESTFILE1 | awk '{print $1}'`
if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then
log_fail "$TESTFILE0 is smaller than $TESTFILE1" \
diff --git a/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh b/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh
index a07d70824..e7c6d6c6e 100755
--- a/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/compression/compress_002_pos.ksh
@@ -65,8 +65,8 @@ log_must file_write -o $OP -f $TESTDIR1/$TESTFILE1 -b $BLOCKSZ \
sleep 60
-FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{ print $1}'`
-FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{ print $1}'`
+FILE0_BLKS=`du -k $TESTDIR1/$TESTFILE0 | awk '{print $1}'`
+FILE1_BLKS=`du -k $TESTDIR1/$TESTFILE1 | awk '{print $1}'`
if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then
log_fail "$TESTFILE0 is smaller than $TESTFILE1" \
diff --git a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib
index a78b390aa..15adc5a63 100644
--- a/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib
+++ b/tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib
@@ -391,12 +391,11 @@ function verify_send
user_run $user eval "zfs send $snap > $bak_user"
log_must eval "zfs send $snap > $bak_root"
- if [[ $(checksum $bak_user) == $(checksum $bak_root) ]]; then
+ if [ "$(cksum < $bak_user)" = "$(cksum < $bak_root)" ]; then
ret=0
fi
- rm -rf $bak_user > /dev/null
- rm -rf $bak_root > /dev/null
+ rm -rf $bak_user $bak_root
return $ret
}
@@ -462,12 +461,11 @@ function verify_fs_receive
log_must eval "zfs receive $dtst < $bak_root"
log_must eval "zfs send $dtstsnap > $bak_root"
log_must_busy zfs destroy -rf $dtst
- if [[ $(checksum $bak_user) != $(checksum $bak_root) ]]; then
+ if [ "$(cksum < $bak_user)" != "$(cksum < $bak_root)" ]; then
return 1
fi
- rm -rf $bak_user > /dev/null
- rm -rf $bak_root > /dev/null
+ rm -rf $bak_user $bak_root
done
diff --git a/tests/zfs-tests/tests/functional/events/events.cfg b/tests/zfs-tests/tests/functional/events/events.cfg
index 1405dab6f..27046c1b0 100644
--- a/tests/zfs-tests/tests/functional/events/events.cfg
+++ b/tests/zfs-tests/tests/functional/events/events.cfg
@@ -33,6 +33,4 @@ VDEV4=$TEST_BASE_DIR/vdev4
export TMP_EVENTS=$TEST_BASE_DIR/tmp_events.$$
export TMP_EVENTS_FULL=$TEST_BASE_DIR/tmp_events_full.$$
-export TMP_EVENT_FULL=$TEST_BASE_DIR/tmp_event_full.$$
export TMP_EVENTS_ZED=$TEST_BASE_DIR/tmp_events_zed.$$
-export TMP_EVENT_ZED=$TEST_BASE_DIR/tmp_event_zed.$$
diff --git a/tests/zfs-tests/tests/functional/events/events_002_pos.ksh b/tests/zfs-tests/tests/functional/events/events_002_pos.ksh
index 9407656b6..42088fc09 100755
--- a/tests/zfs-tests/tests/functional/events/events_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/events/events_002_pos.ksh
@@ -42,15 +42,8 @@ verify_runnable "both"
function cleanup
{
- if poolexists $MPOOL; then
- destroy_pool $MPOOL
- fi
-
- for file in $VDEV1 $VDEV2; do
- [[ -f $file ]] && rm -f $file
- done
-
- log_must rm -f $TMP_EVENTS_ZED
+ poolexists $MPOOL && log_must destroy_pool $MPOOL
+ log_must rm -f $VDEV1 $VDEV2 $TMP_EVENTS_ZED
log_must zed_stop
}
@@ -69,10 +62,9 @@ log_must zed_start
log_must file_wait_event $ZED_DEBUG_LOG 'sysevent\.fs\.zfs\.config_sync' 150
log_must cp $ZED_DEBUG_LOG $TMP_EVENTS_ZED
-awk -v event="sysevent.fs.zfs.pool_create" \
- 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
- $TMP_EVENTS_ZED >$TMP_EVENT_ZED
-log_must grep -q "^ZEVENT_POOL=$MPOOL" $TMP_EVENT_ZED
+log_mustnot awk -v event="sysevent.fs.zfs.pool_create" -v crit="\\nZEVENT_POOL=$MPOOL" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
+ $TMP_EVENTS_ZED
# 3. Stop the ZED
zed_stop
diff --git a/tests/zfs-tests/tests/functional/events/events_common.kshlib b/tests/zfs-tests/tests/functional/events/events_common.kshlib
index cc600c4ed..73bf4cf35 100644
--- a/tests/zfs-tests/tests/functional/events/events_common.kshlib
+++ b/tests/zfs-tests/tests/functional/events/events_common.kshlib
@@ -94,7 +94,7 @@ function run_and_verify
pool=${pool:-$TESTPOOL}
fullcmd="$1"
- cmd=$(echo $fullcmd | awk '{print $1}')
+ read -r cmd _ <<<"$fullcmd"
# If we aren't running zpool or zfs, something is wrong
[[ $cmd == "zpool" || $cmd == "zfs" ]] || \
@@ -147,23 +147,20 @@ function run_and_verify
log_must grep -q "$event" $TMP_EVENTS
# Verify the event is in the verbose output with pool name.
- awk -v event="$event" \
- 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
- $TMP_EVENTS_FULL >$TMP_EVENT_FULL
- log_must grep -q "pool = \"$pool\"" $TMP_EVENT_FULL
+ log_mustnot awk -v event="$event" -v crit="pool = \"$pool\"" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
+ $TMP_EVENTS_FULL
# all-debug.sh filters history events (seen in ZED_DEBUG_LOG)
- if [[ "$event" == "sysevent.fs.zfs.history_event" ]]; then
+ if [ "$event" = "sysevent.fs.zfs.history_event" ]; then
continue
fi
# Verify the event was received by the ZED and logged.
- awk -v event="$event" \
- 'BEGIN{FS="\n"; RS=""} $0 ~ event { print $0 }' \
- $TMP_EVENTS_ZED >$TMP_EVENT_ZED
- log_must grep -q "^ZEVENT_POOL=$pool" $TMP_EVENT_ZED
+ log_mustnot awk -v event="$event" -v crit="\\nZEVENT_POOL=$pool" \
+ 'BEGIN{FS="\n"; RS=""} $0 ~ event && $0 ~ crit { exit 1 }' \
+ $TMP_EVENTS_ZED
done
- rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENT_FULL \
- $TMP_EVENTS_ZED $TMP_EVENT_ZED
+ rm -f $TMP_EVENTS $TMP_EVENTS_FULL $TMP_EVENTS_ZED
}
diff --git a/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh
index ef2ce24e0..17bde9a70 100755
--- a/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/fault/auto_offline_001_pos.ksh
@@ -96,8 +96,7 @@ do
log_must zpool create -f $TESTPOOL $conf
block_device_wait ${DEV_DSKDIR}/${removedev}
- mntpnt=$(get_prop mountpoint /$TESTPOOL) ||
- log_fail "get_prop mountpoint /$TESTPOOL"
+ mntpnt=$(get_prop mountpoint /$TESTPOOL)
# 2. Simulate physical removal of one device
remove_disk $removedev
@@ -128,8 +127,7 @@ do
block_device_wait ${DEV_DSKDIR}/${removedev}
log_must zpool add $TESTPOOL spare $sparedev
- mntpnt=$(get_prop mountpoint /$TESTPOOL) ||
- log_fail "get_prop mountpoint /$TESTPOOL"
+ mntpnt=$(get_prop mountpoint /$TESTPOOL)
# 2. Simulate physical removal of one device
remove_disk $removedev
@@ -161,8 +159,7 @@ do
block_device_wait ${DEV_DSKDIR}/${removedev}
log_must zpool add $TESTPOOL spare $sparedev
- mntpnt=$(get_prop mountpoint /$TESTPOOL) ||
- log_fail "get_prop mountpoint /$TESTPOOL"
+ mntpnt=$(get_prop mountpoint /$TESTPOOL)
# 2. Fault the spare device making it unavailable
log_must zpool offline -f $TESTPOOL $sparedev
diff --git a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
index 0302c4537..57180cdc1 100755
--- a/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/fault/auto_replace_001_pos.ksh
@@ -72,8 +72,8 @@ echo "alias scsidebug /dev/disk/by-id/$SD_DEVICE_ID" >>$VDEVID_CONF
block_device_wait
SD_DEVICE=$(udevadm info -q all -n $DEV_DSKDIR/$SD | \
- awk -F'=' '/ID_VDEV=/{print $2; exit}')
-[[ -z $SD_DEVICE ]] && log_fail "vdev rule was not registered properly"
+ awk -F'=' '/ID_VDEV=/ {print $2; exit}')
+[ -z $SD_DEVICE ] && log_fail "vdev rule was not registered properly"
log_must zpool events -c
log_must zpool create -f $TESTPOOL raidz1 $SD_DEVICE $DISK1 $DISK2 $DISK3
diff --git a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh
index a290053fd..5eb4b25c3 100755
--- a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh
+++ b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh
@@ -67,7 +67,7 @@ log_must mkfile 1048576 /$TESTPOOL/testfile
sync_pool $TESTPOOL
log_must zinject -c all
-SLOW_IOS=$(zpool status -sp | grep "$DISK" | awk '{print $6}')
+SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}')
DELAY_EVENTS=$(zpool events | grep delay | wc -l)
if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then
diff --git a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh
index cb1e940a7..c00b3b6c7 100755
--- a/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh
@@ -73,7 +73,7 @@ log_must zfs umount $TEST_FS
for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
dnsize=$(zdb -dddd $TEST_FS ${inodes[$i]} |
- awk '/ZFS plain file/ {print $6}' | tr K k)
+ awk '/ZFS plain file/ {gsub(/K/, "k", $6); print $6}')
if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then
log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})"
fi
diff --git a/tests/zfs-tests/tests/functional/history/history_001_pos.ksh b/tests/zfs-tests/tests/functional/history/history_001_pos.ksh
index f33265185..5b576b8a1 100755
--- a/tests/zfs-tests/tests/functional/history/history_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/history/history_001_pos.ksh
@@ -59,7 +59,6 @@ log_assert "Verify zpool sub-commands which modify state are logged."
log_onexit cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL)
-(( $? != 0)) && log_fail "get_prop($TESTPOOL mountpoint)"
VDEV1=$mntpnt/vdev1; VDEV2=$mntpnt/vdev2;
VDEV3=$mntpnt/vdev3; VDEV4=$mntpnt/vdev4;
diff --git a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh
index 46af53f8a..1bebd4039 100755
--- a/tests/zfs-tests/tests/functional/history/history_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/history/history_003_pos.ksh
@@ -55,7 +55,6 @@ log_assert "zpool history limitation test."
log_onexit cleanup
mntpnt=$(get_prop mountpoint $TESTPOOL)
-(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL"
VDEV0=$mntpnt/vdev0
log_must mkfile $MINVDEVSIZE $VDEV0
@@ -79,16 +78,16 @@ done
TMPFILE=$TEST_BASE_DIR/spool.$$
zpool history $spool >$TMPFILE
-typeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}')
+typeset -i entry_count=$(wc -l < $TMPFILE)
typeset final_md5=$(head -2 $TMPFILE | md5digest)
-grep 'zpool create' $TMPFILE >/dev/null 2>&1 ||
+grep -q 'zpool create' $TMPFILE ||
log_fail "'zpool create' was not found in pool history"
-grep 'zfs create' $TMPFILE >/dev/null 2>&1 &&
+grep -q 'zfs create' $TMPFILE &&
log_fail "'zfs create' was found in pool history"
-grep 'zfs set compress' $TMPFILE >/dev/null 2>&1 ||
+grep -q 'zfs set compress' $TMPFILE ||
log_fail "'zfs set compress' was found in pool history"
# Verify that the creation of the pool was preserved in the history.
diff --git a/tests/zfs-tests/tests/functional/history/history_004_pos.ksh b/tests/zfs-tests/tests/functional/history/history_004_pos.ksh
index 1b8e7dfe0..8bdc38f26 100755
--- a/tests/zfs-tests/tests/functional/history/history_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/history/history_004_pos.ksh
@@ -46,7 +46,7 @@ verify_runnable "global"
log_assert "'zpool history' can cope with simultaneous commands."
-typeset -i orig_count=$(zpool history $spool | wc -l | awk '{print $1}')
+typeset -i orig_count=$(zpool history $spool | wc -l)
typeset -i i=0
while ((i < 10)); do
@@ -90,7 +90,7 @@ while ((i < 10)); do
((i += 1))
done
-typeset -i entry_count=$(zpool history $spool | wc -l | awk '{print $1}')
+typeset -i entry_count=$(zpool history $spool | wc -l)
if ((entry_count - orig_count != 200)); then
log_fail "The entries count error: entry_count=$entry_count " \
diff --git a/tests/zfs-tests/tests/functional/history/history_common.kshlib b/tests/zfs-tests/tests/functional/history/history_common.kshlib
index ff3260f3c..f441799c8 100644
--- a/tests/zfs-tests/tests/functional/history/history_common.kshlib
+++ b/tests/zfs-tests/tests/functional/history/history_common.kshlib
@@ -52,14 +52,12 @@ function run_and_verify
flags="$2"
if is_illumos; then
- histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g')
+ histcmd=$(echo $fullcmd | sed 's=/usr/sbin/==g')
else
- histcmd=$(echo $fullcmd | sed 's/^.*\/\(zpool .*\).*$/\1/')
- histcmd=$(echo $histcmd | sed 's/^.*\/\(zfs .*\).*$/\1/')
+ histcmd=$(echo $fullcmd | sed -E 's=^.*/(zpool|zfs)$=\1=')
fi
- cmd=$(echo $histcmd | awk '{print $1}')
- subcmd=$(echo $histcmd | awk '{print $2}')
+ read -r cmd subcmd _ <<<"$histcmd"
# If we aren't running zpool or zfs, something is wrong
[[ $cmd == "zpool" || $cmd == "zfs" ]] || \
@@ -77,11 +75,10 @@ function run_and_verify
log_must_busy user_run $user "$fullcmd"
fi
zpool history $flags $pool > $TMP_HISTORY 2>/dev/null
- diff $OLD_HISTORY $TMP_HISTORY | grep "^> " | sed 's/^> //g' \
- > $NEW_HISTORY
+ diff $OLD_HISTORY $TMP_HISTORY | sed -n 's/^> //gp' > $NEW_HISTORY
# Verify what's common to every case, regardless of zpool history flags.
- grep "$histcmd" $NEW_HISTORY >/dev/null 2>&1 || \
+ grep -q "$histcmd" $NEW_HISTORY || \
log_fail "Didn't find \"$histcmd\" in pool history"
# If 'zpool history' was called without any flags, then we're done.
@@ -116,8 +113,7 @@ function verify_long
suffix=":freebsd"
fi
- grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY
- if [[ $? != 0 ]]; then
+ if grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY; then
log_note "Couldn't find long information for \"$cmd\""
return 1
fi
@@ -133,7 +129,8 @@ function verify_hold
[[ $flags =~ "i" ]] || return 1
- typeset tag=$(echo $cmd | awk '{print $4}')
+ typeset tag _
+ read -r _ _ _ tag _ <<<"$cmd"
typeset fullname=${cmd##* }
typeset dsname=${fullname%%@*}
typeset snapname=${fullname##*@}
@@ -141,9 +138,7 @@ function verify_hold
# This works whether or not the hold was recursive
for ds in $(zfs list -r -Ho name -t snapshot $dsname | \
grep "@$snapname"); do
- grep "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY \
- >/dev/null 2>&1
- if [[ $? != 0 ]]; then
+ if grep -q "$subcmd $ds ([0-9]*) tag=$tag" $NEW_HISTORY; then
log_note "Didn't find hold on $ds with $tag"
return 1
fi
@@ -231,8 +226,7 @@ function verify_allow
# - Whether the operation applies locally or to descendent datasets (or
# both)
#
- echo $cmd | awk '{i = NF - 1; print $i}' | grep '@' >/dev/null \
- 2>&1 && is_set=1
+ echo $cmd | awk '$(NF - 1) ~ /@/ {exit 1}' || is_set=1
dsname=${cmd##* }
[[ $cmd =~ "-l " ]] && lflag=1
[[ $cmd =~ "-d " ]] && dflag=1
@@ -275,7 +269,7 @@ function verify_allow
str="u"
[[ -n $is_set ]] && str="U"
tmp=${cmd##*-u }
- opt=$(echo $tmp | awk '{print $2}')
+ read -r _ opt _ <<<"$opt"
uid=$(id -u ${tmp%% *})
if [[ -n $lflag ]]; then
code="${str}l\$$uid $opt"
@@ -299,7 +293,7 @@ function verify_allow
str="g"
[[ -n $is_set ]] && str="G"
tmp=${cmd##*-g }
- opt=$(echo $tmp | awk '{print $2}')
+ read -r _ opt _ <<<"$opt"
gid=$(awk -F: "/^${tmp%% *}:/ {print \$3}" /etc/group)
if [[ -n $lflag ]]; then
code="${str}l\$$gid $opt"
diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh
index 965732252..2222721af 100755
--- a/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh
+++ b/tests/zfs-tests/tests/functional/inuse/inuse_006_pos.ksh
@@ -77,7 +77,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
-PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'`
+PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'`
unset NOINUSE_CHECK
while (( i < ${#vdevs[*]} )); do
diff --git a/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh b/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh
index b96b80890..775f1af63 100755
--- a/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh
+++ b/tests/zfs-tests/tests/functional/inuse/inuse_007_pos.ksh
@@ -82,7 +82,7 @@ set -A vdevs "" "mirror" "raidz" "raidz1" "raidz2"
typeset -i i=0
-PREVDUMPDEV=`dumpadm | grep "Dump device" | awk '{print $3}'`
+PREVDUMPDEV=`dumpadm | awk '/Dump device/ {print $3}'`
while (( i < ${#vdevs[*]} )); do
typeset spare="spare $sdisks"
diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh
index 95efa3f2d..6f7b9aff7 100755
--- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh
@@ -89,8 +89,7 @@ arcstat_quiescence_noecho l2_size
log_must zpool export $TESTPOOL
arcstat_quiescence_noecho l2_feeds
-typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \
- awk '{print $2}')
+typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')
typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh
index bc6d71b7c..3b893d28d 100755
--- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh
@@ -92,8 +92,7 @@ arcstat_quiescence_noecho l2_size
log_must zpool export $TESTPOOL
arcstat_quiescence_noecho l2_feeds
-typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \
- awk '{print $2}')
+typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')
typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh
index 99cd3a2fc..8a572c264 100755
--- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh
@@ -80,8 +80,7 @@ log_must zpool export $TESTPOOL
arcstat_quiescence_noecho l2_feeds
typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
-typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \
- awk '{print $2}')
+typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')
log_must zpool import -d $VDIR $TESTPOOL
log_must zpool online $TESTPOOL $VDEV_CACHE
diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh
index ae0167eb4..9663437c6 100755
--- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh
+++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh
@@ -77,8 +77,7 @@ log_must zpool offline $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size
typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
-typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | grep log_blk_count | \
- awk '{print $2}')
+typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')
log_must zpool online $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size
diff --git a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh
index 6130e2c82..40045a7a9 100755
--- a/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh
+++ b/tests/zfs-tests/tests/functional/mount/umount_unlinked_drain.ksh
@@ -47,8 +47,8 @@ function unlinked_size_is
last_usize=0
while [[ $iters -le $MAX_ITERS ]]; do
kstat_file=$(grep -nrwl /proc/spl/kstat/zfs/$2/objset-0x* -e $3)
- nunlinks=`cat $kstat_file | grep nunlinks | awk '{print $3}'`
- nunlinked=`cat $kstat_file | grep nunlinked | awk '{print $3}'`
+ nunlinks=$(awk '/nunlinks/ {print $3}' $kstat_file)
+ nunlinked=$(awk '/nunlinked/ {print $3}' $kstat_file)
usize=$(($nunlinks - $nunlinked))
if [[ $iters == $MAX_ITERS && $usize == $1 ]]; then
return 0
diff --git a/tests/zfs-tests/tests/functional/mount/umountall_001.ksh b/tests/zfs-tests/tests/functional/mount/umountall_001.ksh
index 814c831e4..40c94593b 100755
--- a/tests/zfs-tests/tests/functional/mount/umountall_001.ksh
+++ b/tests/zfs-tests/tests/functional/mount/umountall_001.ksh
@@ -44,11 +44,11 @@ zfs_list="/ /lib /sbin /tmp /usr /var /var/adm /var/run"
# Append our ZFS filesystems to the list, not worrying about duplicates.
if is_linux; then
- typeset mounts=$(mount | awk '{if ($5 == "zfs") print $3}')
+ typeset mounts=$(mount | awk '$5 == "zfs" {print $3}')
elif is_freebsd; then
- typeset mounts=$(mount -p | awk '{if ($3 == "zfs") print $2}')
+ typeset mounts=$(mount -p | awk '$3 == "zfs" {print $2}')
else
- typeset mounts=$(mount -p | awk '{if ($4 == "zfs") print $3}')
+ typeset mounts=$(mount -p | awk '$4 == "zfs" {print $3}')
fi
for fs in $mounts; do
@@ -56,8 +56,7 @@ for fs in $mounts; do
done
if is_linux; then
- mounts=$(umount --fake -av -t zfs 2>&1 | \
- grep "successfully umounted" | awk '{print $1}')
+ mounts=$(umount --fake -av -t zfs 2>&1 | awk '/successfully umounted/ {print $1}')
# Fallback to /proc/mounts for umount(8) (util-linux-ng 2.17.2)
if [[ -z $mounts ]]; then
mounts=$(awk '/zfs/ { print $2 }' /proc/mounts)
diff --git a/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh b/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh
index b1eeaf2cc..cf788ca7f 100755
--- a/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh
+++ b/tests/zfs-tests/tests/functional/no_space/enospc_df.ksh
@@ -64,8 +64,8 @@ log_must zfs umount $TESTPOOL/$TESTFS
log_must eval "df -h | grep $TESTPOOL"
# Confirm df size and used are non-zero.
-size=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $2}')
-used=$(df -h /$TESTPOOL | grep $TESTPOOL | awk '{print $3}')
+size=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $2}')
+used=$(df -h /$TESTPOOL | awk -v p=$TESTPOOL '$0 ~ p {print $3}')
if [[ "$size" = "0" ]] || [[ "$used" = "0" ]]
then
log_fail "df failed with size $size and used $used."
diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh
index a18e634ce..7cfc3b182 100755
--- a/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh
+++ b/tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_lun_expsz.ksh
@@ -42,13 +42,13 @@ setup_nested_pools
log_onexit cleanup_nested_pools
populate_nested_pool
-INITSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}')
+INITSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}')
log_must zpool checkpoint $NESTEDPOOL
log_must truncate -s $EXPSZ $FILEDISK1
log_must zpool online -e $NESTEDPOOL $FILEDISK1
-NEWSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}')
-DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}')
+NEWSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}')
+DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}')
nested_change_state_after_checkpoint
log_mustnot [ "$INITSZ" = "$NEWSZ" ]
log_must [ "$DEXPSZ" = "-" ]
@@ -57,8 +57,8 @@ log_must zpool export $NESTEDPOOL
log_must zpool import -d $FILEDISKDIR --rewind-to-checkpoint $NESTEDPOOL
nested_verify_pre_checkpoint_state
-FINSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $2}')
-DEXPSZ=$(zpool list -v | grep "$FILEDISK1" | awk '{print $6}')
+FINSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $2}')
+DEXPSZ=$(zpool list -v | awk -v d="$FILEDISK1" '$0 ~ d {print $6}')
log_must [ "$EXPSZ" = "$FINSZ" ]
log_must [ "$DEXPSZ" != "-" ]
diff --git a/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh b/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh
index 048cb29e3..1f4780ccd 100755
--- a/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/poolversion/poolversion_001_pos.ksh
@@ -47,8 +47,7 @@ log_assert "zpool set version can upgrade a pool"
for version in 1 2 3 4 5 6 7 8
do
log_must zpool set version=$version $TESTPOOL
- ACTUAL=$(zpool get version $TESTPOOL | grep version \
- | awk '{print $3}')
+ ACTUAL=$(get_pool_prop version $TESTPOOL)
if [ "$ACTUAL" != "$version" ]
then
log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $version!"
diff --git a/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh b/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh
index 69586473e..15cd446b6 100755
--- a/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh
+++ b/tests/zfs-tests/tests/functional/poolversion/poolversion_002_pos.ksh
@@ -50,7 +50,7 @@ log_must zpool set version=6 $TESTPOOL2
# verify it's actually that version - by checking the version property
# and also by trying to set bootfs (which should fail if it is not version 6)
-VERSION=$(zpool get version $TESTPOOL2| grep version | awk '{print $3}')
+VERSION=$(get_pool_prop version $TESTPOOL2)
if [ "$VERSION" != "6" ]
then
log_fail "Version $VERSION set for $TESTPOOL2 expected version 6!"
@@ -62,7 +62,7 @@ log_mustnot zpool set version=5 $TESTPOOL2
log_mustnot zpool set version=-1 $TESTPOOL2
# verify the version is still 6
-VERSION=$(zpool get version $TESTPOOL2 | grep version | awk '{print $3}')
+VERSION=$(get_pool_prop version $TESTPOOL2)
if [ "$VERSION" != "6" ]
then
log_fail "Version $VERSION set for $TESTPOOL2, expected version 6!"
diff --git a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh
index 080fdddb2..d29bfd806 100755
--- a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh
+++ b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh
@@ -106,7 +106,7 @@ log_assert "Testing /proc/spl/kstat/zfs/<pool>/state kstat"
check_all $TESTPOOL "ONLINE"
# Fault one of the disks, and check that pool is degraded
-DISK1=$(echo "$DISKS" | awk '{print $2}')
+read -r DISK1 _ <<<"$DISKS"
log_must zpool offline -tf $TESTPOOL $DISK1
check_all $TESTPOOL "DEGRADED"
log_must zpool online $TESTPOOL $DISK1
diff --git a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh
index fc4a93f04..51e790348 100755
--- a/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/projectquota/projectspace_004_pos.ksh
@@ -65,10 +65,10 @@ log_must chattr +P -p $PRJID1 $PRJDIR
log_must user_run $PUSER mkfile 50m $PRJDIR/qf
sync_pool
-total=$(df $PRJDIR | tail -n 1 | awk '{ print $2 }')
+total=$(df $PRJDIR | awk 'END { print $2 }')
[[ $total -eq 102400 ]] || log_fail "expect '102400' resource, but got '$total'"
-used=$(df -i $PRJDIR | tail -n 1 | awk '{ print $5 }')
+used=$(df -i $PRJDIR | awk 'END { print $5 }')
[[ "$used" == "2%" ]] || log_fail "expect '2%' used, but got '$used'"
log_pass "'df' on the directory with inherit project ID flag pass as expect"
diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg b/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg
index f964b37ba..3b9e1714d 100644
--- a/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg
+++ b/tests/zfs-tests/tests/functional/redacted_send/redacted.cfg
@@ -23,8 +23,8 @@
# Copyright (c) 2018 by Delphix. All rights reserved.
#
-export DISK1=$(echo $DISKS | awk '{print $1}')
-export DISK2=$(echo $DISKS | awk '{print $2}')
+read -r DISK1 DISK2 _ <<<"$DISKS"
+export DISK1 DISK2
export POOL=$TESTPOOL
export POOL2=$TESTPOOL2
@@ -83,4 +83,4 @@ typeset RANGE12="0,2097152"
typeset RANGE13="0,16384"
typeset RANGE14=""
typeset RANGE15="0,4194304"
-typeset RANGE16="0,6291456" \ No newline at end of file
+typeset RANGE16="0,6291456"
diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh
index e4163c4ef..74b71cdf6 100755
--- a/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh
+++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_props.ksh
@@ -66,8 +66,8 @@ get_guid_list $tmpdir/prop_list $sendfs#book1
get_guid_list $tmpdir/zdb_list $sendfs#book1 true
get_guid_list $tmpdir/recvd_prop_list $recvfs@snap
-count=$(wc -l $tmpdir/prop_list | awk '{print $1}')
-[[ $count -eq 16 ]] || log_fail "Found incorrect number of redaction snapshots."
+count=$(wc -l < $tmpdir/prop_list)
+[ $count -eq 16 ] || log_fail "Found incorrect number of redaction snapshots."
diff $tmpdir/prop_list $tmpdir/zdb_list || \
log_fail "Property list differed from zdb output"
diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh
index 7456084b0..1634ffe06 100755
--- a/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh
+++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_size.ksh
@@ -43,22 +43,19 @@ typeset clone_mnt="$(get_prop mountpoint $clone)"
log_must rm -rf $clone_mnt/*
log_must zfs snapshot $clone@snap
log_must zfs redact $sendfs@snap book $clone@snap
-log_must eval "zfs send -nvP --redact book $sendfs@snap | \
- grep '^size' | awk '{print \$2}' >$size"
-log_must eval "zfs send --redact book $sendfs@snap | wc -c \
- >$size2"
-bytes1=$(cat $size | tr -d '[[:space:]]')
-bytes2=$(cat $size2 | tr -d '[[:space:]]')
-[[ "$bytes1" -eq "$bytes2" ]] || \
+log_must eval "zfs send -nvP --redact book $sendfs@snap | awk '/^size/ {print \$2}' >$size"
+log_must eval "zfs send --redact book $sendfs@snap | wc -c >$size2"
+read -r bytes1 < $size
+read -r bytes2 < $size2
+[ "$bytes1" -eq "$bytes2" ] || \
log_fail "Full sizes differ: estimate $bytes1 and actual $bytes2"
log_must zfs snapshot $sendfs@snap2
-log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | \
- grep '^size' | awk '{print \$2}' >$size"
+log_must eval "zfs send -nvP -i $sendfs#book $sendfs@snap2 | awk '/^size/ {print \$2}' >$size"
log_must eval "zfs send -i $sendfs#book $sendfs@snap2 | wc -c >$size2"
-bytes1=$(cat $size | tr -d '[[:space:]]')
-bytes2=$(cat $size2 | tr -d '[[:space:]]')
-[[ "$bytes1" -eq "$bytes2" ]] || \
+read -r bytes1 < $size
+read -r bytes2 < $size2
+[ "$bytes1" -eq "$bytes2" ] || \
log_fail "Incremental sizes differ: estimate $bytes1 and actual $bytes2"
log_pass "Size estimates of redacted sends estimate accurately."
diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib
index 55816b451..28b115fd7 100644
--- a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib
+++ b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib
@@ -200,10 +200,10 @@ function is_healthy
ret=$?
(( $ret == 0 )) && return 1
typeset l_scan
- typeset errnum
+ typeset errnum _
l_scan=$(zpool status -x $pool | grep "scan:")
l_scan=${l_scan##*"with"}
- errnum=$(echo $l_scan | awk '{print $1}')
+ read -r errnum _ <<<"$l_scan"
return $errnum
fi
@@ -243,12 +243,13 @@ function get_vdevs #pool cnt
typeset -i cnt=$2
typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \
- egrep -v "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \
- egrep -v "/old$|^$pool$")
+ egrep -ve "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \
+ -e "/old$|^$pool$")
typeset -i i=0
typeset vdevs
while ((i < cnt)); do
- typeset dev=$(echo $all_devs | awk '{print $1}')
+ typeset dev _
+ read -r dev _ <<<"$all_devs"
eval all_devs=\${all_devs##*$dev}
vdevs="$dev $vdevs"
diff --git a/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh b/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh
index 447377152..21af3965a 100755
--- a/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh
+++ b/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh
@@ -21,9 +21,7 @@
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/removal/removal.kshlib
-DISK1=$(echo $DISKS | awk '{print $1}')
-DISK2=$(echo $DISKS | awk '{print $2}')
-DISK3=$(echo $DISKS | awk '{print $3}')
+read -r DISK1 DISK2 DISK3 _ <<<"$DISKS"
DISKS="$DISK1 $DISK2 $DISK3"
log_must default_setup_noexit "$DISK1 mirror $DISK2 $DISK3"
diff --git a/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh b/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh
index d17d83b78..5e86a8ccb 100755
--- a/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh
+++ b/tests/zfs-tests/tests/functional/replacement/rebuild_disabled_feature.ksh
@@ -45,8 +45,7 @@ function check_feature_flag
pool=$2
expected_value=$3
- value="$(zpool get -H -o property,value all $pool | \
- egrep "$feature" | awk '{print $2}')"
+ value="$(zpool get -H -o property,value all $pool | awk -v f="$feature" '$0 ~ f {print $2}')"
if [ "$value" = "$expected_value" ]; then
log_note "$feature verified to be $value"
else
diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh
index 67be04e1e..b5b0ace59 100755
--- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh
+++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh
@@ -74,7 +74,7 @@ log_note "waiting for read errors to start showing up"
for iter in {0..59}
do
sync_pool $TESTPOOL1
- err=$(zpool status $TESTPOOL1 | grep ${VDEV_FILES[0]} | awk '{print $3}')
+ err=$(zpool status $TESTPOOL1 | awk -v dev=${VDEV_FILES[0]} '$0 ~ dev {print $3}')
(( $err > 0 )) && break
sleep 1
done
diff --git a/tests/zfs-tests/tests/functional/reservation/reservation.shlib b/tests/zfs-tests/tests/functional/reservation/reservation.shlib
index 47bd70f7c..9bac794a9 100644
--- a/tests/zfs-tests/tests/functional/reservation/reservation.shlib
+++ b/tests/zfs-tests/tests/functional/reservation/reservation.shlib
@@ -38,25 +38,15 @@
#
function zero_reservation
{
- typeset resv_val
dataset=$1
log_must zfs set reservation=none $dataset
- resv_val=`zfs get -H reservation $dataset | awk '{print $3}'`
- if [[ $? -ne 0 ]]; then
- log_fail "Unable to get reservation prop on $dataset"
- elif [[ $resv_val != "none" ]]; then
- log_fail "Reservation not 'none' ($resv_val) as expected"
- fi
-
+ log_must eval 'resv_val="$(zfs get -Ho value reservation $dataset)"'
+ log_must [ $resv_val = "none" ]
- resv_val=`zfs get -pH reservation $dataset | awk '{print $3}'`
- if [[ $? -ne 0 ]]; then
- log_fail "Unable to get reservation prop on $dataset"
- elif [[ $resv_val -ne 0 ]]; then
- log_fail "Reservation not 0 ($resv_val) as expected"
- fi
+ log_must eval 'resv_val="$(zfs get -pHo value reservation $dataset)"'
+ log_must [ $resv_val -eq 0 ]
return 0
}
diff --git a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh
index bf0955223..786d5d4d3 100755
--- a/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh
+++ b/tests/zfs-tests/tests/functional/reservation/reservation_013_pos.ksh
@@ -72,8 +72,6 @@ log_must zfs create $TESTPOOL/$TESTFS1
log_must zfs create $TESTPOOL/$TESTFS1/$TESTFS2
space_avail=$(get_prop available $TESTPOOL)
-[[ $? -ne 0 ]] && \
- log_fail "Unable to get space available property for $TESTPOOL"
typeset -il resv_set=space_avail/5
resv_set=$(floor_volsize $resv_set)
diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.cfg b/tests/zfs-tests/tests/functional/rsend/rsend.cfg
index 8400ecfe3..99e87d936 100644
--- a/tests/zfs-tests/tests/functional/rsend/rsend.cfg
+++ b/tests/zfs-tests/tests/functional/rsend/rsend.cfg
@@ -29,9 +29,8 @@
export BACKDIR=${TEST_BASE_DIR%%/}/backdir-rsend
-export DISK1=$(echo $DISKS | awk '{print $1}')
-export DISK2=$(echo $DISKS | awk '{print $2}')
-export DISK3=$(echo $DISKS | awk '{print $3}')
+read -r DISK1 DISK2 DISK3 _ <<<"$DISKS"
+export DISK1 DISK2 DISK3
export POOL=$TESTPOOL
export POOL2=$TESTPOOL2
diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib
index 1df5c3542..ea63defdc 100644
--- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib
+++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib
@@ -293,7 +293,6 @@ function snapshot_tree
typeset -i ret=0
if [[ $type == "filesystem" ]]; then
typeset mntpnt=$(get_prop mountpoint $ds)
- ((ret |= $?))
if ((ret == 0)) ; then
eval random_tree $mntpnt/${snap##$ds}
@@ -364,8 +363,7 @@ function fs_inherit_prop
fi
else
fs_prop=$(zfs inherit 2>&1 | \
- awk '$2=="YES" && $3=="YES" {print $1}'|
- egrep -v "devices|mlslabel|sharenfs|sharesmb|zoned")
+ awk '$2=="YES" && $3=="YES" && !/devices|mlslabel|sharenfs|sharesmb|zoned/ {print $1}')
fi
echo $fs_prop
@@ -595,8 +593,8 @@ function mess_send_file
# We use zstream dump to verify there is an intact DRR_BEGIN record.
offset=$(((($RANDOM * $RANDOM) % ($filesize - $minsize)) + $minsize))
nr_begins=$(head -c $offset $file | zstream dump | \
- grep DRR_BEGIN | awk '{ print $5 }')
- log_must test "$nr_begins" -eq 1
+ awk '/DRR_BEGIN/ { print $5 }')
+ log_must [ "$nr_begins" -eq 1 ]
if (($RANDOM % 7 <= 1)); then
#
diff --git a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
index 694dd15b4..61d5e12cb 100755
--- a/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
+++ b/tests/zfs-tests/tests/functional/rsend/rsend_012_pos.ksh
@@ -51,8 +51,7 @@ function edited_prop
case $behaviour in
"get")
typeset props=$(zfs inherit 2>&1 | \
- awk '$2=="YES" {print $1}' | \
- grep -Ev "^vol|\.\.\.$")
+ awk '$2=="YES" && $1 !~ /^vol|\.\.\.$/ {print $1}')
for item in $props ; do
if [[ $item == "mlslabel" ]] && \
! is_te_enabled ; then
diff --git a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh
index aa19847e0..aff54e3a7 100755
--- a/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh
+++ b/tests/zfs-tests/tests/functional/rsend/send_encrypted_truncated_files.ksh
@@ -54,11 +54,11 @@ function recursive_cksum
{
case "$(uname)" in
FreeBSD)
- find $1 -type f -exec sha256 -q {} \; | \
+ find $1 -type f -exec sha256 -q {} + | \
sort | sha256digest
;;
*)
- find $1 -type f -exec sha256sum {} \; | \
+ find $1 -type f -exec sha256sum {} + | \
sort -k 2 | awk '{ print $1 }' | sha256digest
;;
esac
diff --git a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh
index d88bc582b..8b45e51bc 100755
--- a/tests/zfs-tests/tests/functional/simd/simd_supported.ksh
+++ b/tests/zfs-tests/tests/functional/simd/simd_supported.ksh
@@ -38,14 +38,14 @@
log_note "Testing if we support SIMD instructions (Linux x86 only)"
-if !is_linux; then
+if ! is_linux; then
log_unsupported "Not a Linux System"
fi
case "$(uname -m)" in
-i386|i686|x86_64)
+i?86|x86_64)
typeset -R modparam="/sys/module/zcommon/parameters/zfs_fletcher_4_impl"
- if cat /proc/cpuinfo | awk '/^flags/ {print; exit;}' | grep -q sse; then
+ if awk '/^flags/ {exit !/sse/}' /proc/cpuinfo; then
log_must grep -q sse "$modparam"
log_pass "SIMD instructions supported"
else
diff --git a/tests/zfs-tests/tests/functional/trim/trim.kshlib b/tests/zfs-tests/tests/functional/trim/trim.kshlib
index dc1a60a5e..fad15582b 100644
--- a/tests/zfs-tests/tests/functional/trim/trim.kshlib
+++ b/tests/zfs-tests/tests/functional/trim/trim.kshlib
@@ -22,8 +22,7 @@
#
function get_size_mb
{
- typeset rval=$(du --block-size 1048576 -s "$1" | awk '{print $1}')
- echo -n "$rval"
+ du --block-size 1048576 -s "$1" | awk '{printf("%s", $1)}'
}
#
diff --git a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh
index bd2710c6f..0bbd08acd 100755
--- a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh
+++ b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh
@@ -97,8 +97,8 @@ done
verify_trim_io $TESTPOOL "ind" 5 $TRIM_VDEV2
-typeset cache_size=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $2}')
-typeset cache_alloc=$(zpool list -vp | grep $TRIM_VDEV2 | awk '{print $3}')
+typeset cache_size cache_alloc _
+read -r _ cache_size cache_alloc _ < <(zpool list -vp | grep $TRIM_VDEV2)
log_must test $cache_alloc -lt $cache_size
diff --git a/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh b/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh
index 364f67e34..88d09759b 100755
--- a/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh
+++ b/tests/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos.ksh
@@ -109,7 +109,7 @@ log_must chattr -p 100 $TESTDIR/fs3/dir
log_must sleep 5 # upgrade done in the background so let's wait for a while
zfs projectspace -o used $TESTPOOL/fs3 | grep -q "USED" ||
log_fail "project quota should be enabled for $TESTPOOL/fs3"
-cnt=$(zfs get -H projectobjused@100 $TESTPOOL/fs3 | awk '{print $3}')
+cnt=$(get_prop projectobjused@100 $TESTPOOL/fs3)
# if 'xattr=on', then 'cnt = 2'
[[ $cnt -ne 1 ]] && [[ $cnt -ne 2 ]] &&
log_fail "projectquota accounting failed $cnt"
diff --git a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh
index 86dc058eb..3d0f55d5a 100755
--- a/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh
+++ b/tests/zfs-tests/tests/functional/vdev_zaps/vdev_zaps_004_pos.ksh
@@ -48,7 +48,7 @@ assert_zap_common $TESTPOOL $DISK "top" $orig_top
# Attach a disk.
#
-disk2=$(echo $DISKS | awk '{print $2}')
+read -r _ disk2 _ <<<"$DISKS"
log_must zpool attach $TESTPOOL $DISK $disk2
log_must zpool wait -t resilver $TESTPOOL
log_must eval "zdb -PC $TESTPOOL > $conf"
diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib
index 4f74c9b92..aa47f6c0f 100644
--- a/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib
+++ b/tests/zfs-tests/tests/functional/zvol/zvol_common.shlib
@@ -71,8 +71,7 @@ function default_zvol_cleanup
function get_dumpdevice
{
- typeset ret=$(dumpadm | grep "Dump device:" | awk '{print $3}')
- echo $ret
+ dumpadm | awk '/Dump device:/ {print $3}'
}
function set_dumpsize
@@ -86,8 +85,7 @@ function set_dumpsize
log_must zfs set volsize=64m $volume
- output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | \
- tail -1 | awk '{print $3}')
+ output=$(dumpadm -d /dev/zvol/dsk/$volume 2>&1 | awk 'END {print $3}')
if [[ -n $output ]]; then
(( output = output / 1024 / 1024 ))
diff --git a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh
index aafdb7a49..588663dba 100755
--- a/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap_003_pos.ksh
@@ -74,7 +74,7 @@ PREV_VFSTAB_FILE=$TEST_BASE_DIR/zvol_vfstab.PREV.$$
[[ -f $NEW_VFSTAB_FILE ]] && cp /dev/null $NEW_VFSTAB_FILE
-awk '{if ($4 != "swap") print $1}' /etc/vfstab > $NEW_VFSTAB_FILE
+awk '$4 != "swap" {print $1}' /etc/vfstab > $NEW_VFSTAB_FILE
echo "$voldev\t-\t-\tswap\t-\tno\t-" >> $NEW_VFSTAB_FILE
# Copy off the original vfstab, and run swapadd on the newly constructed one.