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 c3021d1759..fdda9ba226 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -67,34 +67,32 @@ obj=${array[0]} log_note "file $init_data has object number $obj" sync_pool $TESTPOOL -output=$(zdb -d $TESTPOOL/$TESTFS) -objset_id=$(echo $output | cut -d, -f2 | cut -d' ' -f2) +IFS=", " read -r _ _ _ _ objset_id _ < <(zdb -d $TESTPOOL/$TESTFS) objset_hex=$(printf "0x%X" $objset_id) log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" for id in "$objset_id" "$objset_hex" do log_note "zdb -dddddd $TESTPOOL/$id $obj" - output=$(zdb -dddddd $TESTPOOL/$id $obj) - echo $output | grep -q "$TESTPOOL/$TESTFS" || - log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" - echo $output | grep -q "file1" || - log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" + output=$(zdb -dddddd $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -dddddd $TESTPOOL/$id $obj failed (file1 not in zdb output)" obj=$(printf "0x%X" $obj) log_note "zdb -NNNNNN $TESTPOOL/$id $obj" - output=$(zdb -NNNNNN $TESTPOOL/$id $obj) - echo $output | grep -q "$TESTPOOL/$TESTFS" || - log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" - echo $output | grep -q "file1" || - log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" + output=$(zdb -NNNNNN $TESTPOOL/$id $obj) + echo $output | grep -q "$TESTPOOL/$TESTFS" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed ($TESTPOOL/$TESTFS not in zdb output)" + echo $output | grep -q "file1" || + log_fail "zdb -NNNNNN $TESTPOOL/$id $obj failed (file1 not in zdb output)" done if is_linux; then - output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) + output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL | grep objset- | tail -1) objset_hex=${output#*-} - name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | - grep dataset_name | cut -d' ' -f3) + name_from_proc=$(grep dataset_name /proc/spl/kstat/zfs/$TESTPOOL/$output | cut -d' ' -f3) log_note "checking zdb output for $name_from_proc" log_must eval "zdb -dddddd $TESTPOOL/$objset_hex | grep -q \"$name_from_proc\"" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh index d8c71f2c28..6a708a45e1 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_receive/zfs_receive_005_neg.ksh @@ -80,8 +80,8 @@ log_must zfs snapshot $init_snap log_must eval "zfs send $init_snap > $full_bkup" log_note "'zfs receive' fails with invalid send streams." -log_mustnot eval "cat $orig_cmds_f1 + grep -v "^$" $orig_cmds_f > $orig_cmds_f1 log_must cp $tst_dir/${arch}.migratedpool.DAT.Z $import_dir log_must uncompress -f $import_dir/${arch}.migratedpool.DAT.Z diff --git a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh index b6bdc68116..1ac254aa1d 100755 --- a/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh +++ b/tests/zfs-tests/tests/functional/mmp/mmp_write_distribution.ksh @@ -37,7 +37,7 @@ verify_runnable "both" function cleanup { log_must zpool destroy $MMP_POOL - log_must rm $MMP_DIR/file.{0,1,2,3,4,5,6,7} + log_must rm $MMP_DIR/file.{0..7} log_must rm $MMP_HISTORY_TMP log_must rmdir $MMP_DIR log_must mmp_clear_hostid @@ -51,8 +51,8 @@ MMP_HISTORY=/proc/spl/kstat/zfs/$MMP_POOL/multihost # Step 1 log_must mkdir -p $MMP_DIR -log_must truncate -s 128M $MMP_DIR/file.{0,1,2,3,4,5,6,7} -log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0,1} mirror $MMP_DIR/file.{2,3,4,5,6,7} +log_must truncate -s 128M $MMP_DIR/file.{0..7} +log_must zpool create -f $MMP_POOL mirror $MMP_DIR/file.{0..1} mirror $MMP_DIR/file.{2..7} # Step 2 log_must mmp_set_hostid $HOSTID1 @@ -69,8 +69,8 @@ typeset -i min_writes=999 typeset -i max_writes=0 typeset -i write_count # copy to get as close to a consistent view as possible -cat $MMP_HISTORY > $MMP_HISTORY_TMP -for x in $(seq 0 7); do +cp $MMP_HISTORY $MMP_HISTORY_TMP +for x in {0..7}; do write_count=$(grep -c file.${x} $MMP_HISTORY_TMP) if [ $write_count -lt $min_writes ]; then min_writes=$write_count diff --git a/tests/zfs-tests/tests/functional/pam/utilities.kshlib b/tests/zfs-tests/tests/functional/pam/utilities.kshlib index d328034300..6e9f900913 100644 --- a/tests/zfs-tests/tests/functional/pam/utilities.kshlib +++ b/tests/zfs-tests/tests/functional/pam/utilities.kshlib @@ -28,7 +28,7 @@ pamservice="pam_zfs_key_test" pamconfig="/etc/pam.d/${pamservice}" function keystatus { - log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" == "$1" ] + log_must [ "$(zfs list -Ho keystatus "$TESTPOOL/pam/${username}")" = "$1" ] } function genconfig { @@ -42,6 +42,6 @@ function rmconfig { } function references { - log_must [ "$(cat "${runstatedir}/$(id -u ${username})")" == "$1" ] + log_must [ "$(<"${runstatedir}/$(id -u ${username})")" = "$1" ] } diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh index 5f6727ea44..18caea3c32 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -85,7 +85,7 @@ done # Clear out old messages and check that they really are gone echo 0 >$ZFS_DBGMSG || log_fail "failed to write to $ZFS_DBGMSG" -cat $ZFS_DBGMSG | count_snap_cmds 0 +count_snap_cmds 0 < $ZFS_DBGMSG # # Even though we don't expect any messages in the file, reading should still # succeed. diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh index a24452ed58..fcdd54da35 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_concurrent_readers.ksh @@ -41,8 +41,7 @@ function cleanup { - [[ -z $msgs1 ]] || log_must rm $msgs1 - [[ -z $msgs2 ]] || log_must rm $msgs2 + log_must rm -f $msgs1 $msgs2 datasetexists $FS && destroy_dataset $FS -r } @@ -69,7 +68,7 @@ msgs2=$(mktemp) || log_fail # Start reading file, pause and read it from another process, and then finish # reading. # -{ dd bs=512 count=4; cat $ZFS_DBGMSG >$msgs1; cat; } <$ZFS_DBGMSG >$msgs2 +{ dd bs=512 count=4; cp $ZFS_DBGMSG $msgs1; cat; } <$ZFS_DBGMSG >$msgs2 # # Truncate the result of the read that completed second in case it picked up an diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib index 6ad2e47018..a3810d55f9 100644 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted.kshlib @@ -231,7 +231,7 @@ function compare_files [[ -f $file2 ]] || log_fail "File $file2 does not exist." log_must eval "get_diff $file1 $file2 >$tmpfile" - typeset range="$(cat $tmpfile)" + typeset range="$(<$tmpfile)" log_must unmount_redacted $recvfs [[ "$expected" = "$range" ]] || log_fail "Unexpected range: $range" } diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh index 1c5b503a9b..35faf038ad 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_embedded.ksh @@ -60,13 +60,10 @@ for recsize in 512 1024 2048 4096 8192 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_must zfs destroy -R $recvfs @@ -91,13 +88,10 @@ for recsize in 1024 4096 16384; do log_must eval "zdb -ddddd $sendfs $send_obj >$tmpdir/send.zdb" log_must eval "zdb -ddddd $recvfs $recv_obj >$tmpdir/recv.zdb" - grep -q "EMBEDDED" $tmpdir/send.zdb || \ - log_fail "Obj $send_obj not embedded in $sendfs" - grep -q "EMBEDDED" $tmpdir/recv.zdb || \ - log_fail "Obj $recv_obj not embedded in $recvfs" + log_must grep -q "EMBEDDED" $tmpdir/send.zdb + log_must grep -q "EMBEDDED" $tmpdir/recv.zdb - cat $stream | zstream dump -v | log_must grep -q \ - "WRITE_EMBEDDED object = $send_obj offset = 0" + log_must eval "zstream dump -v $stream | log_must grep -q \"WRITE_EMBEDDED object = $send_obj offset = 0\"" done log_pass "Embedded blocks and redacted send work correctly together." diff --git a/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh b/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh index 8118ea59ec..31f7b0ada8 100755 --- a/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh +++ b/tests/zfs-tests/tests/functional/redacted_send/redacted_resume.ksh @@ -53,7 +53,7 @@ log_must mount_redacted -f $recvfs log_must set_tunable32 ALLOW_REDACTED_DATASET_MOUNT 1 log_must diff $send_mnt/f1 $recv_mnt/f1 log_must eval "get_diff $send_mnt/f2 $recv_mnt/f2 >$tmpdir/get_diff.out" -typeset range=$(cat $tmpdir/get_diff.out) +typeset range=$(<$tmpdir/get_diff.out) [[ "$RANGE9" = "$range" ]] || log_fail "Unexpected range: $range" log_must dd if=/dev/urandom of=$send_mnt/f3 bs=1024k count=3 @@ -70,7 +70,7 @@ resume_test "zfs send --redact book2 -i $sendfs#book1 $sendfs@snap2" \ log_must diff $send_mnt/f1 $recv_mnt/f1 log_must diff $send_mnt/f2 $recv_mnt/f2 log_must eval "get_diff $send_mnt/f3 $recv_mnt/f3 >$tmpdir/get_diff.out" -range=$(cat $tmpdir/get_diff.out) +range=$(<$tmpdir/get_diff.out) [[ "$RANGE10" = "$range" ]] || log_fail "Unexpected range: $range" # Test recv -A works properly and verify saved sends are not allowed diff --git a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh index 937693a67c..b498ba4af7 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_001.ksh @@ -162,7 +162,7 @@ do # inject read io errors on vdev and verify resilver does not restart log_must zinject -a -d ${VDEV_FILES[2]} -e io -T read -f 0.25 $TESTPOOL1 - log_must eval "cat ${DATAPATHS[1]} > /dev/null" + log_must cp ${DATAPATHS[1]} /dev/null log_must zinject -c all # there should still be 2 resilver starts w/o defer, 1 with defer diff --git a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib index 085b58954c..fdda1f5e92 100644 --- a/tests/zfs-tests/tests/functional/rsend/rsend.kshlib +++ b/tests/zfs-tests/tests/functional/rsend/rsend.kshlib @@ -625,7 +625,7 @@ function resume_test log_mustnot eval "zfs recv -suv $recvfs $BACKDIR/full" log_must stream_has_features $BACKDIR/full lz4 compressed -cat $BACKDIR/full | zstream dump -v > $BACKDIR/dump.out +zstream dump -v $BACKDIR/full > $BACKDIR/dump.out lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \ $BACKDIR/dump.out) @@ -63,8 +63,8 @@ csize_prop=$(get_prop used $sendfs) within_percent $csize $csize_prop 90 || log_fail \ "$csize and $csize_prop differed by too much" -x=$(get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs) -resume_token=$(cat /$streamfs/resume_token) +get_resume_token "zfs send -c $sendfs@full" $streamfs $recvfs +resume_token=$($stream" $verify eval "zfs recv $recv_ds <$stream" - typeset stream_size=$(cat $stream | zstream dump | sed -n \ + typeset stream_size=$(zstream dump $stream | sed -n \ 's/ Total write size = \(.*\) (0x.*)/\1/p') # diff --git a/tests/zfs-tests/tests/functional/xattr/cleanup.ksh b/tests/zfs-tests/tests/functional/xattr/cleanup.ksh index b3629629c7..ab0fbf8124 100755 --- a/tests/zfs-tests/tests/functional/xattr/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/xattr/cleanup.ksh @@ -30,7 +30,7 @@ . $STF_SUITE/include/libtest.shlib . $STF_SUITE/tests/functional/xattr/xattr_common.kshlib -USES_NIS=$(cat $TEST_BASE_DIR/zfs-xattr-test-nis.txt) +USES_NIS=$(<$TEST_BASE_DIR/zfs-xattr-test-nis.txt) rm $TEST_BASE_DIR/zfs-xattr-test-nis.txt if [ "${USES_NIS}" == "true" ] diff --git a/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib b/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib index bc06f47168..5ff2b48902 100644 --- a/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib +++ b/tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib @@ -97,10 +97,10 @@ function delete_xattr { # filename xattr_name if is_illumos; then log_must runat $FILE rm $XATTR_NAME log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1" - else - log_must rm_xattr $XATTR_NAME $FILE - log_mustnot get_xattr $XATTR_NAME $FILE - fi + else + log_must rm_xattr $XATTR_NAME $FILE + log_mustnot get_xattr $XATTR_NAME $FILE + fi } # not sure about this : really this should be testing write/append @@ -126,12 +126,6 @@ function verify_write_xattr { # filename xattr_name function create_expected_output { # expected_output_file contents_of_the_output typeset FILE=$1 shift - if [[ -f $FILE ]]; then - log_must rm $FILE - fi - - for line in $@ - do - log_must eval "echo $line >> $FILE" - done + log_must rm -f $FILE + log_must eval "printf '%s\n' $* >> $FILE" }