diff options
author | George Melikov <[email protected]> | 2018-10-31 20:00:06 +0300 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-10-31 12:00:06 -0500 |
commit | 58aeb87a8f69019487457460a5d7c823910fc8ff (patch) | |
tree | 772309683978629c78596d5600031248f00fb5f8 /tests | |
parent | 9553c533a635bf39697b0b54f4751580f6d2590d (diff) |
ZTS: change `$(cat)` to `$(<)` for speedup
It's better to use ksh/bash built in methods,
rather than spawn new processes every time.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: John Wren Kennedy <[email protected]>
Signed-off-by: George Melikov <[email protected]>
Closes #8071
Diffstat (limited to 'tests')
15 files changed, 40 insertions, 40 deletions
diff --git a/tests/zfs-tests/callbacks/zfs_mmp.ksh b/tests/zfs-tests/callbacks/zfs_mmp.ksh index df2cd132d..402e0b03f 100755 --- a/tests/zfs-tests/callbacks/zfs_mmp.ksh +++ b/tests/zfs-tests/callbacks/zfs_mmp.ksh @@ -18,7 +18,7 @@ # $1: number of lines to output (default: 40) typeset lines=${1:-40} -typeset history=$(cat /sys/module/zfs/parameters/zfs_multihost_history) +typeset history=$(</sys/module/zfs/parameters/zfs_multihost_history) if [ $history -eq 0 ]; then exit diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 51088fccb..e66b2cbaf 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -3332,7 +3332,7 @@ function zed_stop log_note "Stopping ZED" if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then - zedpid=$(cat ${ZEDLET_DIR}/zed.pid) + zedpid=$(<${ZEDLET_DIR}/zed.pid) kill $zedpid while ps -p $zedpid > /dev/null; do sleep 1 diff --git a/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib b/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib index c1ecc5296..722a47755 100644 --- a/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib +++ b/tests/zfs-tests/tests/functional/channel_program/channel_common.kshlib @@ -67,10 +67,10 @@ function log_program outdiff=$(diff "$basename.out" "$tmpout") if [[ $? -ne 0 ]]; then - output=$(cat $tmpout) + output=$(<$tmpout) rm $tmpout $tmperr $tmpin log_fail "Output mismatch. Expected:\n" \ - "$(cat $basename.out)\nBut got:\n$output\n" \ + "$(<$basename.out)\nBut got:\n$output\n" \ "Diff:\n$outdiff" fi @@ -78,10 +78,10 @@ function log_program outdiff=$(diff "$basename.err" "$tmperr") if [[ $? -ne 0 ]]; then - outputerror=$(cat $tmperr) + outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin log_fail "Error mismatch. Expected:\n" \ - "$(cat $basename.err)\nBut got:\n$outputerror\n" \ + "$(<$basename.err)\nBut got:\n$outputerror\n" \ "Diff:\n$outdiff" fi @@ -89,7 +89,7 @@ function log_program grep -q "$expecterror" $tmperr if [[ $? -ne 0 ]]; then - outputerror=$(cat $tmperr) + outputerror=$(<$tmperr) rm $tmpout $tmperr $tmpin log_fail "Error mismatch. Expected to contain:\n" \ "$expecterror\nBut got:\n$outputerror\n" @@ -100,7 +100,7 @@ function log_program # If there's no expected output, error reporting is allowed to # vary, but ensure that we didn't fail silently. # - if [[ -z "$(cat $tmperr)" ]]; then + if [[ -z "$(<$tmperr)" ]]; then rm $tmpout $tmperr $tmpin log_fail "error with no stderr output" fi diff --git a/tests/zfs-tests/tests/functional/pool_checkpoint/pool_checkpoint.kshlib b/tests/zfs-tests/tests/functional/pool_checkpoint/pool_checkpoint.kshlib index 3638e3dfe..455a1d12d 100644 --- a/tests/zfs-tests/tests/functional/pool_checkpoint/pool_checkpoint.kshlib +++ b/tests/zfs-tests/tests/functional/pool_checkpoint/pool_checkpoint.kshlib @@ -220,8 +220,8 @@ function test_verify_pre_checkpoint_state { log_must zfs list $FS0 log_must zfs list $FS1 - log_must [ "$(cat $FS0FILE)" = "$FILECONTENTS0" ] - log_must [ "$(cat $FS1FILE)" = "$FILECONTENTS1" ] + log_must [ "$(<$FS0FILE)" = "$FILECONTENTS0" ] + log_must [ "$(<$FS1FILE)" = "$FILECONTENTS1" ] # # If we've opened the checkpointed state of the @@ -236,15 +236,15 @@ function test_verify_pre_checkpoint_state # Ensure post-checkpoint state is not present # log_mustnot zfs list $FS2 - log_mustnot [ "$(cat $FS0FILE)" = "$NEWFILECONTENTS0" ] + log_mustnot [ "$(<$FS0FILE)" = "$NEWFILECONTENTS0" ] } function nested_verify_pre_checkpoint_state { log_must zfs list $NESTEDFS0 log_must zfs list $NESTEDFS1 - log_must [ "$(cat $NESTEDFS0FILE)" = "$FILECONTENTS0" ] - log_must [ "$(cat $NESTEDFS1FILE)" = "$FILECONTENTS1" ] + log_must [ "$(<$NESTEDFS0FILE)" = "$FILECONTENTS0" ] + log_must [ "$(<$NESTEDFS1FILE)" = "$FILECONTENTS1" ] # # If we've opened the checkpointed state of the @@ -259,7 +259,7 @@ function nested_verify_pre_checkpoint_state # Ensure post-checkpoint state is not present # log_mustnot zfs list $NESTEDFS2 - log_mustnot [ "$(cat $NESTEDFS0FILE)" = "$NEWFILECONTENTS0" ] + log_mustnot [ "$(<$NESTEDFS0FILE)" = "$NEWFILECONTENTS0" ] } function test_change_state_after_checkpoint @@ -284,8 +284,8 @@ function test_verify_post_checkpoint_state { log_must zfs list $FS0 log_must zfs list $FS2 - log_must [ "$(cat $FS0FILE)" = "$NEWFILECONTENTS0" ] - log_must [ "$(cat $FS2FILE)" = "$NEWFILECONTENTS2" ] + log_must [ "$(<$FS0FILE)" = "$NEWFILECONTENTS0" ] + log_must [ "$(<$FS2FILE)" = "$NEWFILECONTENTS2" ] log_must zdb $TESTPOOL @@ -294,7 +294,7 @@ function test_verify_post_checkpoint_state # is not present # log_mustnot zfs list $FS1 - log_mustnot [ "$(cat $FS0FILE)" = "$FILECONTENTS0" ] + log_mustnot [ "$(<$FS0FILE)" = "$FILECONTENTS0" ] } function fragment_before_checkpoint diff --git a/tests/zfs-tests/tests/functional/privilege/cleanup.ksh b/tests/zfs-tests/tests/functional/privilege/cleanup.ksh index 0ef274604..45a6a0f76 100755 --- a/tests/zfs-tests/tests/functional/privilege/cleanup.ksh +++ b/tests/zfs-tests/tests/functional/privilege/cleanup.ksh @@ -37,10 +37,10 @@ fi verify_runnable "global" -ZFS_USER=$(cat $TEST_BASE_DIR/zfs-privs-test-user.txt) +ZFS_USER=$(<$TEST_BASE_DIR/zfs-privs-test-user.txt) [[ -z $ZFS_USER ]] && log_fail "no ZFS_USER found" -USES_NIS=$(cat $TEST_BASE_DIR/zfs-privs-test-nis.txt) +USES_NIS=$(<$TEST_BASE_DIR/zfs-privs-test-nis.txt) if [ "${USES_NIS}" == "true" ] then diff --git a/tests/zfs-tests/tests/functional/privilege/privilege_001_pos.ksh b/tests/zfs-tests/tests/functional/privilege/privilege_001_pos.ksh index 672bb8848..ae869380d 100755 --- a/tests/zfs-tests/tests/functional/privilege/privilege_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/privilege/privilege_001_pos.ksh @@ -63,7 +63,7 @@ fi log_assert "The RBAC profile \"ZFS Storage Management\" works" -ZFS_USER=$(cat $TEST_BASE_DIR/zfs-privs-test-user.txt) +ZFS_USER=$(<$TEST_BASE_DIR/zfs-privs-test-user.txt) # the user shouldn't be able to do anything initially log_mustnot user_run $ZFS_USER "zpool create $TESTPOOL $DISKS" diff --git a/tests/zfs-tests/tests/functional/privilege/privilege_002_pos.ksh b/tests/zfs-tests/tests/functional/privilege/privilege_002_pos.ksh index da8e33ce7..22cfaf55d 100755 --- a/tests/zfs-tests/tests/functional/privilege/privilege_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/privilege/privilege_002_pos.ksh @@ -66,7 +66,7 @@ fi log_assert "The RBAC profile \"ZFS File System Management\" works" -ZFS_USER=$(cat $TEST_BASE_DIR/zfs-privs-test-user.txt) +ZFS_USER=$(<$TEST_BASE_DIR/zfs-privs-test-user.txt) # Set a $DATASET where we can create child files systems if is_global_zone; then diff --git a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh index 3c29266e5..a3afe0c42 100755 --- a/tests/zfs-tests/tests/functional/procfs/pool_state.ksh +++ b/tests/zfs-tests/tests/functional/procfs/pool_state.ksh @@ -86,7 +86,7 @@ function check_all state1=$(zpool status $pool | awk '/state: /{print $2}'); state2=$(zpool list -H -o health $pool) - state3=$(cat /proc/spl/kstat/zfs/$pool/state) + state3=$(</proc/spl/kstat/zfs/$pool/state) log_note "Checking $expected = $state1 = $state2 = $state3" if [[ "$expected" == "$state1" && "$expected" == "$state2" && \ "$expected" == "$state3" ]] ; then diff --git a/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh b/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh index c363e7f8b..95a5e5c1e 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_stale_read.ksh @@ -86,7 +86,7 @@ typeset default_max_entries log_onexit cleanup -default_max_entries=$(cat $MAX_ENTRIES_PARAM) || log_fail +default_max_entries=$(<$MAX_ENTRIES_PARAM) || log_fail echo 50 >$MAX_ENTRIES_PARAM || log_fail # Clear all of the existing entries. diff --git a/tests/zfs-tests/tests/functional/removal/removal_multiple_indirection.ksh b/tests/zfs-tests/tests/functional/removal/removal_multiple_indirection.ksh index 1f71ec0e4..97b67a462 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_multiple_indirection.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_multiple_indirection.ksh @@ -67,8 +67,8 @@ log_onexit cleanup log_must set_tunable32 zfs_remove_max_segment 32768 log_must dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=128k count=1 -FILE_CONTENTS=`cat $TESTDIR/$TESTFILE0` -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +FILE_CONTENTS=$(<$TESTDIR/$TESTFILE0) +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] for i in {1..10}; do log_must zpool remove $TESTPOOL $TMPDIR/dsk1 @@ -78,7 +78,7 @@ for i in {1..10}; do log_must zinject -a log_must dd if=$TESTDIR/$TESTFILE0 of=/dev/null - log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] + log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] log_must zpool remove $TESTPOOL $TMPDIR/dsk2 log_must wait_for_removal $TESTPOOL @@ -87,7 +87,7 @@ for i in {1..10}; do log_must zinject -a log_must dd if=$TESTDIR/$TESTFILE0 of=/dev/null - log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] + log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] done log_pass "File contents transferred completely from one disk to another." diff --git a/tests/zfs-tests/tests/functional/removal/removal_sanity.ksh b/tests/zfs-tests/tests/functional/removal/removal_sanity.ksh index f7f69c7d2..e927e3c0e 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_sanity.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_sanity.ksh @@ -27,13 +27,13 @@ log_onexit default_cleanup_noexit FILE_CONTENTS="Leeloo Dallas mul-ti-pass." echo $FILE_CONTENTS >$TESTDIR/$TESTFILE0 -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] log_must zpool remove $TESTPOOL $REMOVEDISK log_must wait_for_removal $TESTPOOL log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK log_must dd if=/$TESTDIR/$TESTFILE0 of=/dev/null -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] log_pass "Removed device not in use after removal." diff --git a/tests/zfs-tests/tests/functional/removal/removal_with_dedup.ksh b/tests/zfs-tests/tests/functional/removal/removal_with_dedup.ksh index 4b6c94a80..ac79b7c17 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_with_dedup.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_with_dedup.ksh @@ -31,9 +31,9 @@ FILE_CONTENTS="Leeloo Dallas mul-ti-pass." echo $FILE_CONTENTS >$TESTDIR/$TESTFILE0 echo $FILE_CONTENTS >$TESTDIR/$TESTFILE1 echo $FILE_CONTENTS >$TESTDIR/$TESTFILE2 -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] -log_must [ "x$(cat $TESTDIR/$TESTFILE1)" = "x$FILE_CONTENTS" ] -log_must [ "x$(cat $TESTDIR/$TESTFILE2)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE1)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE2)" = "x$FILE_CONTENTS" ] log_must zpool remove $TESTPOOL $REMOVEDISK log_must wait_for_removal $TESTPOOL @@ -42,8 +42,8 @@ log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK log_must dd if=/$TESTDIR/$TESTFILE0 of=/dev/null log_must dd if=/$TESTDIR/$TESTFILE1 of=/dev/null log_must dd if=/$TESTDIR/$TESTFILE2 of=/dev/null -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] -log_must [ "x$(cat $TESTDIR/$TESTFILE1)" = "x$FILE_CONTENTS" ] -log_must [ "x$(cat $TESTDIR/$TESTFILE2)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE1)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE2)" = "x$FILE_CONTENTS" ] log_pass "Removed device not in use after removal." diff --git a/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh b/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh index 0cb22e3e1..35c90e6a5 100755 --- a/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh +++ b/tests/zfs-tests/tests/functional/removal/removal_with_ganging.ksh @@ -34,7 +34,7 @@ log_onexit cleanup FILE_CONTENTS="Leeloo Dallas mul-ti-pass." echo $FILE_CONTENTS >$TESTDIR/$TESTFILE0 -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] log_must file_write -o create -f $TESTDIR/$TESTFILE1 -b $((2**20)) -c $((2**7)) log_must zpool remove $TESTPOOL $REMOVEDISK @@ -42,6 +42,6 @@ log_must wait_for_removal $TESTPOOL log_mustnot vdevs_in_pool $TESTPOOL $REMOVEDISK log_must dd if=/$TESTDIR/$TESTFILE0 of=/dev/null -log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] +log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] log_pass "Removed device not in use after removal." 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 fa3fb5de7..447377152 100755 --- a/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh +++ b/tests/zfs-tests/tests/functional/removal/remove_mirror_sanity.ksh @@ -39,7 +39,7 @@ elif [[ -f $WORDS_FILE2 ]]; then log_must cp $WORDS_FILE2 $TESTDIR else echo $FILE_CONTENTS >$TESTDIR/$TESTFILE0 - log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] + log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] fi log_must zpool remove $TESTPOOL mirror-1 @@ -52,7 +52,7 @@ elif [[ -f $WORDS_FILE2 ]]; then log_must diff $WORDS_FILE2 $TESTDIR/words else log_must dd if=/$TESTDIR/$TESTFILE0 of=/dev/null - log_must [ "x$(cat $TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] + log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ] fi log_pass "Removed top-level mirror device not in use after removal." diff --git a/tests/zfs-tests/tests/perf/perf.shlib b/tests/zfs-tests/tests/perf/perf.shlib index c851ee32d..3802c6aec 100644 --- a/tests/zfs-tests/tests/perf/perf.shlib +++ b/tests/zfs-tests/tests/perf/perf.shlib @@ -416,7 +416,7 @@ function get_system_config then printf ",\n" >>$config fi - printf " \"$tunable\": \"$(cat $zfs_tunables/$tunable)\"" \ + printf " \"$tunable\": \"$(<$zfs_tunables/$tunable)\"" \ >>$config done printf "\n }\n" >>$config |