diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index d4dae8e593..b01d8bc82f 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2158,8 +2158,7 @@ function check_pool_status # pool token keyword typeset keyword=$3 typeset verbose=${4:-false} - scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" ' - ($1==token) {print $0}') + scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" '$1==token') if [[ $verbose == true ]]; then log_note $scan fi @@ -3075,7 +3074,7 @@ function vdevs_in_pool typeset tmpfile=$(mktemp) zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile for vdev in "$@"; do - grep -wq ${vdev##*/} $tmpfile || && return 1 + grep -wq ${vdev##*/} $tmpfile || return 1 done rm -f $tmpfile @@ -3959,10 +3958,10 @@ function directory_diff # dir_a dir_b # We check ctimes even with zil_replay=1 because the ZIL does store # creation times and we should make sure they match (if the creation times # do not match there is a "c" entry in one of the columns). - if ( rsync --version | grep -q "[, ] crtimes" >/dev/null ); then + if rsync --version | grep -q "[, ] crtimes"; then args+=("--crtimes") else - echo "NOTE: This rsync package does not support --crtimes (-N)." + log_note "This rsync package does not support --crtimes (-N)." fi # If we are testing a ZIL replay, we need to ignore timestamp changes. diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh index 2c9014a084..53d5b819da 100755 --- a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.terminate_by_signal.ksh @@ -86,13 +86,10 @@ log_pos kill $CHILD # Make sure the channel program did not fully complete by enforcing # that not all of the snapshots were created. # -snap_count=$(zfs list -t snapshot | grep $TESTPOOL | wc -l) +snap_count=$(zfs list -t snapshot | grep -c $TESTPOOL) log_note "$snap_count snapshots created by ZCP" -if [ "$snap_count" -eq 0 ]; then - log_fail "Channel program failed to run." -elif [ "$snap_count" -gt 90 ]; then - log_fail "Too many snapshots after a cancel ($snap_count)." -else - log_pass "Canceling a long-running channel program works." -fi +log_mustnot [ "$snap_count" -eq 0 ] +log_mustnot [ "$snap_count" -gt 90 ] + +log_pass "Cancelling a long-running channel program works." 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 ef7eb8fff1..bab0dea296 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 @@ -69,16 +69,16 @@ obj=${array[0]} log_note "file $init_data has object number $obj" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L1 DVA" |head -n1) + |grep -m 1 "L1 DVA" ) dva=$(sed -Ene 's/^.+DVA\[0\]=<([^>]+)>.*/\1/p' <<< "$output") log_note "first L1 block $init_data has a DVA of $dva" output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "L0 DVA" |head -n1) + |grep -m 1 "L0 DVA" ) blk_out0=${output##*>} blk_out0=${blk_out0##+([[:space:]])} output=$(zdb -ddddddbbbbbb $TESTPOOL/$TESTFS $obj 2> /dev/null \ - |grep -m 1 "1000 L0 DVA" |head -n1) + |grep -m 1 "1000 L0 DVA" ) blk_out1=${output##*>} blk_out1=${blk_out1##+([[:space:]])} @@ -110,7 +110,7 @@ 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) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R :id (indirect block display) failed" fi @@ -120,7 +120,7 @@ vdev="$vdev.0" log_note "Reading from DVA $vdev:$offset:$l1_read_size" 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) +block_cnt=$(echo "$output" | grep -c 'L0') if [ $block_cnt -ne $write_count ]; then log_fail "zdb -R 0.0:offset:length:id (indirect block display) failed" 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 de52c586f3..20597c9a5f 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 @@ -167,7 +167,7 @@ while (( i < ${#opts[*]} )); do log_fail "There is no property for" \ "dataset $ds in 'get all' output." - propnum=$(awk -v ds="${ds}$" '$1 ~ ds {print $1}' $propfile | wc -l) + propnum=$(awk -v ds="${ds}$" '$1 ~ ds {++cnt} END {print cnt}' $propfile) case $(zfs get -H -o value type $ds) in filesystem ) (( propnum < fspropnum )) && \ 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 407c8f2911..a81e82ddf5 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 @@ -120,7 +120,7 @@ for x in {1..$ITERATIONS}; do for y in {1..$NUM_SNAPS}; do log_must zfs snapshot $TESTPOOL/$MYTEST@$y done; - n=$(ls -1 /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) + n=$(ls /$TESTPOOL/$MYTEST/.zfs/snapshot | wc -l) verify_eq $n $NUM_SNAPS "count" zfs destroy -r $TESTPOOL/$MYTEST; done; diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh index f26c65f9db..b774374163 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_errors.ksh @@ -115,7 +115,7 @@ function do_test out="$(zpool status -p | grep $VDEV1)" if [ "$ERR" == "corrupt" ] ; then - events=$(zpool events | grep checksum | wc -l) + events=$(zpool events | grep -c checksum) val=$(echo "$out" | awk '{print $5}') str="checksum" elif [ "$ERR" == "io" ] ; then diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh index 258de033b8..3311eb5466 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_events/zpool_events_follow.ksh @@ -49,14 +49,14 @@ log_must eval "zpool events -H -f > $EVENTS_FILE &" pid=$! # 3. Generate some ZFS events -for i in `seq 1 $EVENTS_NUM`; do +for i in {1..$EVENTS_NUM}; do log_must zpool clear $TESTPOOL done # wait a bit to allow the kernel module to process new events zpool_events_settle # 4. Verify 'zpool events -f' successfully recorded these new events -EVENTS_LOG=$(cat $EVENTS_FILE | wc -l) +EVENTS_LOG=$(wc -l < $EVENTS_FILE) if [[ $EVENTS_LOG -ne $EVENTS_NUM ]]; then log_fail "Unexpected number of events: $EVENTS_LOG != $EVENTS_NUM" fi diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh index 49be7d0701..333177accb 100755 --- a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_002_pos.ksh @@ -62,7 +62,7 @@ fi zpool iostat $TESTPOOL 1 4 > $tmpfile 2>&1 & sleep 4 -stat_count=$(grep $TESTPOOL $tmpfile | wc -l) +stat_count=$(grep -c $TESTPOOL $tmpfile) if [[ $stat_count -ne 4 ]]; then log_fail "zpool iostat [pool_name] [interval] [count] failed" 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 5eb4b25c38..4fe00e2c71 100755 --- a/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh +++ b/tests/zfs-tests/tests/functional/fault/zpool_status_-s.ksh @@ -68,10 +68,9 @@ sync_pool $TESTPOOL log_must zinject -c all SLOW_IOS=$(zpool status -sp | awk -v d="$DISK" '$0 ~ d {print $6}') -DELAY_EVENTS=$(zpool events | grep delay | wc -l) +DELAY_EVENTS=$(zpool events | grep -c delay) -if [ $SLOW_IOS -gt 0 ] && [ $DELAY_EVENTS -gt 0 ] ; then - log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -else - log_fail "Only saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" -fi +log_must [ $SLOW_IOS -gt 0 ] +log_must [ $DELAY_EVENTS -gt 0 ] + +log_pass "Correctly saw $SLOW_IOS slow IOs and $DELAY_EVENTS delay events" diff --git a/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh b/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh index d1d283376b..d16574d3a8 100755 --- a/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh +++ b/tests/zfs-tests/tests/functional/log_spacemap/log_spacemap_import_logs.ksh @@ -57,7 +57,7 @@ function cleanup log_onexit cleanup LOGSM_POOL="logsm_import" -TESTDISK="$(echo $DISKS | cut -d' ' -f1)" +read -r TESTDISK _ <<<"$DISKS" log_must zpool create -o cachefile=none -f $LOGSM_POOL $TESTDISK log_must zfs create $LOGSM_POOL/fs @@ -70,10 +70,7 @@ sync_all_pools log_must set_tunable64 KEEP_LOG_SPACEMAPS_AT_EXPORT 1 log_must zpool export $LOGSM_POOL -LOGSM_COUNT=$(zdb -m -e $LOGSM_POOL | grep "Log Spacemap object" | wc -l) -if (( LOGSM_COUNT == 0 )); then - log_fail "Pool does not have any log spacemaps after being exported" -fi +log_must eval "zdb -m -e $LOGSM_POOL | grep -q \"Log Spacemap object\"" log_must set_tunable64 METASLAB_DEBUG_LOAD 1 log_must zpool import $LOGSM_POOL diff --git a/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib b/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib index 3ddd8f113a..26c2e84ce4 100644 --- a/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib +++ b/tests/zfs-tests/tests/functional/mv_files/mv_files_common.kshlib @@ -114,9 +114,7 @@ function mv_files # function count_files { - typeset -i file_num - file_num=$(find $1 -type f -print | wc -l | tr -d ' ') - (( file_num != $2 )) && \ + (( $(find $1 -type f -print | wc -l) != $2 )) && \ log_fail "The file number of target directory"\ "$2 is not equal to that of the source "\ "directory $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 9104e4ba2a..5f6727ea44 100755 --- a/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh +++ b/tests/zfs-tests/tests/functional/procfs/procfs_list_basic.ksh @@ -48,8 +48,8 @@ function cleanup function count_snap_cmds { typeset expected_count=$1 - count=$(grep -E "command: (lt-)?zfs snapshot $FS@testsnapshot" | wc -l) - log_must eval "[[ $count -eq $expected_count ]]" + count=$(grep -cE "command: (lt-)?zfs snapshot $FS@testsnapshot") + log_must [ "$count" -eq "$expected_count" ] } typeset -r ZFS_DBGMSG=/proc/spl/kstat/zfs/dbgmsg 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 b5b0ace599..bc5bc01776 100755 --- a/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh +++ b/tests/zfs-tests/tests/functional/replacement/resilver_restart_002.ksh @@ -64,7 +64,7 @@ objset=$(zdb -d $TESTPOOL1/ | sed -ne 's/.*ID \([0-9]*\).*/\1/p') object=$(ls -i /$TESTPOOL1/file | awk '{print $1}') # inject event to cause error during resilver -log_must zinject -b `printf "%x:%x:0:3fff" $objset $object` $TESTPOOL1 +log_must zinject -b $(printf "%x:%x:0:3fff" $objset $object) $TESTPOOL1 # clear events and start resilver log_must zpool events -c @@ -84,7 +84,7 @@ done log_note "waiting for resilver to finish" for iter in {0..59} do - finish=$(zpool events | grep "sysevent.fs.zfs.resilver_finish" | wc -l) + finish=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_finish") (( $finish > 0 )) && break sleep 1 done @@ -96,7 +96,7 @@ sync_pool $TESTPOOL1 sync_pool $TESTPOOL1 # check if resilver was restarted -start=$(zpool events | grep "sysevent.fs.zfs.resilver_start" | wc -l) +start=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_start") (( $start != 1 )) && log_fail "resilver restarted unnecessarily" log_pass "Resilver did not restart unnecessarily from scan errors" diff --git a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh index 9a63bf2348..819e263b1c 100755 --- a/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh @@ -142,8 +142,7 @@ while (( i < ${#args[*]} )); do if [[ -n ${args[i+3]} ]] ; then log_must zfs set mountpoint=${args[i+3]} ${args[i+2]} - FILE_COUNT=`ls -Al ${args[i+3]} | grep -v "total" \ - | grep -v "\.zfs" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]} | grep -cvF ".zfs") if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)." @@ -157,7 +156,7 @@ while (( i < ${#args[*]} )); do (( j = j + 1 )) done - FILE_COUNT=`ls -Al ${args[i+3]}/after* | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A ${args[i+3]}/after* | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al ${args[i+3]} log_fail "${args[i+3]} contains $FILE_COUNT after* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh index b64c026eeb..38db22fdfe 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_001_pos.ksh @@ -76,7 +76,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -97,14 +97,13 @@ sync_pool $TESTPOOL # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh index 6e562e6c90..571065fdd6 100755 --- a/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/rollback_002_pos.ksh @@ -79,7 +79,7 @@ done log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne $COUNT ]]; then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -112,14 +112,13 @@ done # log_must zfs rollback $SNAPFS.1 -FILE_COUNT=`ls -Al $TESTDIR/aftersecond* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/aftersecond* 2> /dev/null | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT aftersecond* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/original* $TESTDIR/afterfirst*| grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/original* $TESTDIR/afterfirst* | wc -l) if [[ $FILE_COUNT -ne 20 ]]; then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT original* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh index 8cb7298a48..a1357b1551 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_003_pos.ksh @@ -86,7 +86,7 @@ log_note "Remove all of the original files" i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`ls $SNAPDIR.$i/file* | wc -l` + FILECOUNT=$(ls $SNAPDIR.$i/file* | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR.$i/file$j $j diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh index 44fc6ec9e9..683afb5e1a 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_004_pos.ksh @@ -60,7 +60,7 @@ log_onexit cleanup [ -n $TESTDIR ] && log_must rm -rf $TESTDIR/* log_must zfs snapshot $SNAPFS -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "BEFORE: $SNAPDIR contains $FILE_COUNT files(s)." @@ -77,7 +77,7 @@ while [[ $i -lt $COUNT ]]; do (( i = i + 1 )) done -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total 0" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if [[ $FILE_COUNT -ne 0 ]]; then ls $SNAPDIR log_fail "AFTER: $SNAPDIR contains $FILE_COUNT files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh index 41d4b46826..bcca2a04a7 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_007_pos.ksh @@ -90,7 +90,7 @@ log_note "Remove all of the original files" i=1 while [[ $i -lt $COUNT ]]; do - FILECOUNT=`echo $SNAPDIR1.$i/file* | wc -w` + FILECOUNT=$(ls $SNAPDIR1.$i/file* 2>/dev/null | wc -l) typeset j=1 while [ $j -lt $FILECOUNT ]; do log_must file_check $SNAPDIR1.$i/file$j $j diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh index fcf57f65f6..7fa7aec22d 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_011_pos.ksh @@ -74,7 +74,7 @@ done log_must zfs snapshot -r $SNAPPOOL -FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $SNAPDIR | wc -l) if (( FILE_COUNT != COUNT )); then ls -Al $SNAPDIR log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)." @@ -94,14 +94,13 @@ done # log_must zfs rollback $SNAPFS -FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/after* 2> /dev/null | wc -l) if (( FILE_COUNT != 0 )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT after* files(s)." fi -FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \ - | grep -v "total" | wc -l` +FILE_COUNT=$(ls -A $TESTDIR/before* 2> /dev/null | wc -l) if (( FILE_COUNT != $COUNT )); then ls -Al $TESTDIR log_fail "$TESTDIR contains $FILE_COUNT before* files(s)." diff --git a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh index aee6bb6ceb..27408222c8 100755 --- a/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh +++ b/tests/zfs-tests/tests/functional/snapshot/snapshot_013_pos.ksh @@ -87,7 +87,7 @@ if ! datasetexists $ctrfs || ! snapexists $snapctrfs; then fi for dir in $fsdir $snapdir; do - FILE_COUNT=`ls -Al $dir | grep -v "total" | wc -l` + FILE_COUNT=$(ls -A $dir | wc -l) (( FILE_COUNT != COUNT )) && log_fail "Got $FILE_COUNT expected $COUNT" done