diff options
author | наб <[email protected]> | 2022-03-12 00:25:47 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-04-01 17:58:07 -0700 |
commit | f63c9dc70a40f930b09b586e6bc53cabf90fa3a1 (patch) | |
tree | adff416bb5dce241103bf240cfb390776b0f50e8 /tests | |
parent | 270d0a5a16869e2becf301ae4548ae1cefeed2fb (diff) |
egrep -> grep -E
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #13259
Diffstat (limited to 'tests')
17 files changed, 47 insertions, 74 deletions
diff --git a/tests/test-runner/include/logapi.shlib b/tests/test-runner/include/logapi.shlib index 33423a7e3..59ac4c2c3 100644 --- a/tests/test-runner/include/logapi.shlib +++ b/tests/test-runner/include/logapi.shlib @@ -103,10 +103,7 @@ function log_must_retry out="cat $logfile" if (( $status == 0 )); then - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or" \ " assertion failure exited $status" @@ -228,10 +225,7 @@ function log_neg_expect print -u2 $($out) _printerror "$@" "unexpectedly exited $status (SEGV)" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if (( $? == 0 )); then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" @@ -279,10 +273,7 @@ function log_pos print -u2 $($out) _printerror "$@" "exited $status" else - $out | egrep -i "internal error|assertion failed" \ - > /dev/null 2>&1 - # internal error or assertion failed - if [[ $? -eq 0 ]]; then + if $out | grep -qEi "internal error|assertion failed"; then print -u2 $($out) _printerror "$@" "internal error or assertion failure" \ " exited $status" diff --git a/tests/zfs-tests/include/blkdev.shlib b/tests/zfs-tests/include/blkdev.shlib index f776caa3b..a97d1582d 100644 --- a/tests/zfs-tests/include/blkdev.shlib +++ b/tests/zfs-tests/include/blkdev.shlib @@ -115,21 +115,18 @@ function is_physical_device #device if is_linux; then is_disk_device "$DEV_DSKDIR/$device" && \ - [[ -f /sys/module/loop/parameters/max_part ]] - return $? + [ -f /sys/module/loop/parameters/max_part ] elif is_freebsd; then is_disk_device "$DEV_DSKDIR/$device" && \ - echo $device | egrep -q \ + echo $device | grep -qE \ -e '^a?da[0-9]+$' \ -e '^md[0-9]+$' \ -e '^mfid[0-9]+$' \ -e '^nda[0-9]+$' \ -e '^nvd[0-9]+$' \ -e '^vtbd[0-9]+$' - return $? else - echo $device | egrep "^c[0-F]+([td][0-F]+)+$" > /dev/null 2>&1 - return $? + echo $device | grep -qE "^c[0-F]+([td][0-F]+)+$" fi } @@ -143,8 +140,7 @@ function is_real_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep disk >/dev/null - return $? + grep -q disk fi } @@ -158,8 +154,7 @@ function is_loop_device #disk if is_linux; then lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \ - egrep loop >/dev/null - return $? + grep -q loop fi } @@ -182,7 +177,7 @@ function is_mpath_device #disk if is_linux; then lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \ - egrep mpath >/dev/null + grep -q mpath if (($? == 0)); then readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1 return $? @@ -333,14 +328,14 @@ function on_off_disk # disk state{online,offline} host dep="$(ls /sys/block/${dm_name}/slaves | awk '{print $1}')" while [[ -n $dep ]]; do #check if disk is online - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then dep_dir="/sys/block/${dm_name}" dep_dir+="/slaves/${dep}/device" ss="${dep_dir}/state" sd="${dep_dir}/delete" log_must eval "echo 'offline' > ${ss}" log_must eval "echo '1' > ${sd}" - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then log_fail "Offlining $disk failed" fi fi @@ -348,17 +343,14 @@ function on_off_disk # disk state{online,offline} host done elif [[ $state == "offline" ]] && ( is_real_device $disk ); then #check if disk is online - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then + if lsscsi | grep -qF $disk; then dev_state="/sys/block/$disk/device/state" dev_delete="/sys/block/$disk/device/delete" log_must eval "echo 'offline' > ${dev_state}" log_must eval "echo '1' > ${dev_delete}" - lsscsi | egrep $disk > /dev/null - if (($? == 0)); then - log_fail "Offlining $disk" \ - "failed" - fi + if lsscsi | grep -qF $disk; then + log_fail "Offlining $disk failed" + fi else log_note "$disk is already offline" fi @@ -369,13 +361,13 @@ function on_off_disk # disk state{online,offline} host if is_mpath_device $disk; then dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)" dep="$(ls /sys/block/$dm_name/slaves | awk '{print $1}')" - if lsscsi | egrep -q $dep; then + if lsscsi | grep -qF $dep; then log_fail "Onlining $disk failed" fi elif is_real_device $disk; then block_device_wait typeset -i retries=0 - while ! lsscsi | egrep -q $disk; do + while ! lsscsi | grep -qF $disk; do if (( $retries > 2 )); then log_fail "Onlining $disk failed" break @@ -451,16 +443,14 @@ function load_scsi_debug # dev_size_mb add_host num_tgts max_luns blksz log_unsupported "Platform does not have scsi_debug" "module" fi - lsmod | egrep scsi_debug > /dev/null - if (($? == 0)); then + if lsmod | grep -q scsi_debug; then log_fail "scsi_debug module already installed" else log_must modprobe scsi_debug dev_size_mb=$devsize \ add_host=$hosts num_tgts=$tgts max_luns=$luns \ sector_size=$sector physblk_exp=$blkexp block_device_wait - lsscsi | egrep scsi_debug > /dev/null - if (($? == 1)); then + if ! lsscsi | grep -q scsi_debug; then log_fail "scsi_debug module install failed" fi fi diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg index a5ee92071..fcde48adc 100644 --- a/tests/zfs-tests/include/commands.cfg +++ b/tests/zfs-tests/include/commands.cfg @@ -32,7 +32,6 @@ export SYSTEM_FILES_COMMON='arp dmesg du echo - egrep env expr false diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 58e992698..88390456a 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -2018,8 +2018,8 @@ function verify_pool # function get_disklist # pool { - zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ - egrep -v -e '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$" + echo $(zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \ + grep -vEe '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$") } # @@ -2182,7 +2182,7 @@ function check_pool_status # pool token keyword <verbose> if [[ $verbose == true ]]; then log_note $scan fi - echo $scan | egrep -qi "$keyword" + echo $scan | grep -qi "$keyword" } # diff --git a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib index bfae8ec72..1450f7b66 100644 --- a/tests/zfs-tests/tests/functional/acl/acl_common.kshlib +++ b/tests/zfs-tests/tests/functional/acl/acl_common.kshlib @@ -403,8 +403,7 @@ function get_xattr #<obj> return 1 fi - for xattr in `runat $obj ls | \ - grep -E -v -e SUNWattr_ro -e SUNWattr_rw` ; do + for xattr in $(runat $obj ls | grep -v 'SUNWattr_r[ow]'); do runat $obj cksum $xattr done } 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 14635b27f..d88217e5c 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 @@ -57,7 +57,7 @@ log_onexit cleanup log_note "Testing access to FILE" log_must touch $TESTDIR/file.0 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:rw $TESTDIR/file.0 -getfacl $TESTDIR/file.0 2> /dev/null | egrep -q \ +getfacl $TESTDIR/file.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:rw-$" if [ "$?" -eq "0" ]; then # Should be able to write to file @@ -75,7 +75,7 @@ if [ "$?" -eq "0" ]; then log_note "expected mask drwxrw----+ but found $msk" log_fail "Expected permissions were not set." fi - getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ + getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:rw-$" if [ "$?" -ne "0" ]; then acl=$(getfacl $TESTDIR/dir.0 2> /dev/null) 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 bdcc18592..8764dd5a2 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 @@ -58,7 +58,7 @@ if ! ls -l $TESTDIR | grep "dir.0" | grep -q "drwx-wx---+"; then log_note "expected mask drwx-wx---+ but found $msk" log_fail "Expected permissions were not set." fi -getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \ +getfacl $TESTDIR/dir.0 2> /dev/null | grep -q \ "^group:$ZFS_ACL_STAFF_GROUP:-wx$" if [ "$?" -eq "0" ]; then # Should be able to create file in directory diff --git a/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh b/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh index 1b04a024f..bdd77bd37 100755 --- a/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh +++ b/tests/zfs-tests/tests/functional/acl/posix/posix_003_pos.ksh @@ -43,16 +43,14 @@ log_note "Testing access to DIRECTORY" log_must mkdir $ACLDIR log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR log_must setfacl -d -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR -getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str1" -if [ "$?" -eq "0" ]; then - getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str2" -fi -if [ "$?" -eq "0" ]; then +if getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str1" && + getfacl $ACLDIR 2> /dev/null | grep -q "$acl_str2" +then log_must zfs unmount $TESTPOOL/$TESTFS log_must zfs mount $TESTPOOL/$TESTFS - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str1\"" - log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str2\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str1\"" + log_must eval "getfacl $ACLDIR 2> /dev/null | grep -q \"$acl_str2\"" log_pass "POSIX ACLs survive remount" else log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rwx'" diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh index 6ad93d87c..75f15f6a8 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_block_size_histogram.ksh @@ -115,8 +115,7 @@ function histo_populate_test_pool of=/${pool}/B_${this_rs}/file_${filenum} \ bs=${this_rs} count=${thiscount} \ iflag=fullblock 2>&1 | \ - egrep -v -e "records in" -e "records out" \ - -e "bytes.*copied" + grep -ve "records in" -e "records out" -e "bytes.*copied" ((filenum+=1)) done done 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 945532903..e4664b52e 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 | awk 'END {print $1}') + grep -E "^ +-?([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 ff46b0f2f..2c85e6e93 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 @@ -60,8 +60,7 @@ function get_object_list_range function get_object_list { zdb -P -dd $@ 2>/dev/null | - egrep "^ +-?([0-9]+ +){7}" | - sed 's/^[[:space:]]*//' | + sed -E '/^ +-?([0-9]+ +){7}/!d;s/^[[:space:]]*//' | sort -n } diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh index 7fd6918b4..2580070e6 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_009_pos.ksh @@ -39,7 +39,7 @@ # STRATEGY: # 1. Create a multiple depth filesystem. # 2. 'zfs get -d <n>' to get the output. -# 3. 'zfs get -r|egrep' to get the expected output. +# 3. 'zfs get -r|grep' to get the expected output. # 4. Compare the two outputs, they should be same. # @@ -86,7 +86,7 @@ for dp in ${depth_array[@]}; do done for prop in $(gen_option_str "${all_props[*]}" "" "," $prop_numb); do log_must eval "zfs get -H -d $dp -o name $prop $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs get -rH -o name $prop $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs get -rH -o name $prop $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT done (( old_val=dp )) 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 37f7acfbf..b91b496ee 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 @@ -180,7 +180,7 @@ function _translate_vdev # typeset keywords="mirror replacing raidz1 raidz2 raidz3 indirect draid1 draid2 draid3" for word in $keywords; do - echo $vdev | egrep -qE \ + echo $vdev | grep -qE \ "^${word}-[0-9]+\$|^${word}:[0-9]+d:[0-9]c:[0-9]+s-[0-9]+\$" if [[ $? -eq 0 ]]; then vdev=$word 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 083b7e55a..5e40eee4b 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 @@ -76,7 +76,7 @@ while read -r offset size; do # Note we use '-t x4' instead of '-t x8' here because x8 is not # a supported format on FreeBSD. dd if=$SMALLFILE skip=$((offset / bs)) count=$((size / bs)) bs=$bs | - od -t x4 -Ad | egrep -q "deadbeef +deadbeef +deadbeef +deadbeef" || + od -t x4 -Ad | grep -qE "deadbeef +deadbeef +deadbeef +deadbeef" || log_fail "Pattern not found in metaslab free space" done diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh index 8e9009bd5..0f60113b7 100755 --- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh +++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_007_pos.ksh @@ -37,7 +37,7 @@ # # STRATEGY: # 1. 'zfs list -d <n>' to get the output. -# 2. 'zfs list -r|egrep' to get the expected output. +# 2. 'zfs list -r|grep' to get the expected output. # 3. Compare the two outputs, they should be same. # @@ -50,8 +50,7 @@ fi function cleanup { - log_must rm -f $DEPTH_OUTPUT - log_must rm -f $EXPECT_OUTPUT + log_must rm -f $DEPTH_OUTPUT $EXPECT_OUTPUT } log_onexit cleanup @@ -76,10 +75,10 @@ for dp in ${depth_array[@]}; do log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" [[ -s "$DEPTH_OUTPUT" ]] && \ log_fail "$DEPTH_OUTPUT should be null." - log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' + log_mustnot zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E "$eg_opt" else log_must eval "zfs list -H -d $dp -o name -t ${fs_type[$fs]} $DEPTH_FS > $DEPTH_OUTPUT" - log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | egrep -e '$eg_opt' > $EXPECT_OUTPUT" + log_must eval "zfs list -rH -o name -t ${fs_type[$fs]} $DEPTH_FS | grep -E '$eg_opt' > $EXPECT_OUTPUT" log_must diff $DEPTH_OUTPUT $EXPECT_OUTPUT fi (( fs+=1 )) diff --git a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh index 03fc15a8a..36d30b51e 100755 --- a/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/fault/auto_online_001_pos.ksh @@ -134,9 +134,8 @@ do ((timeout++)) sleep 1 - zpool events $TESTPOOL \ - | egrep sysevent.fs.zfs.resilver_finish > /dev/null - if (($? == 0)); then + if zpool events $TESTPOOL \ + | grep -qF sysevent.fs.zfs.resilver_finish; then log_note "Auto-online of $offline_disk is complete" sleep 1 break diff --git a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib index 28b115fd7..6399c11ce 100644 --- a/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib +++ b/tests/zfs-tests/tests/functional/redundancy/redundancy.kshlib @@ -221,7 +221,7 @@ function is_data_valid log_must zpool scrub -w $pool record_data $pool $PST_RECORD_FILE - if ! diff $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null 2>&1; then + if ! cmp $PRE_RECORD_FILE $PST_RECORD_FILE > /dev/null; then log_must cat $PRE_RECORD_FILE log_must cat $PST_RECORD_FILE diff -u $PRE_RECORD_FILE $PST_RECORD_FILE @@ -242,8 +242,8 @@ function get_vdevs #pool cnt typeset pool=$1 typeset -i cnt=$2 - typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}'| \ - egrep -ve "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" | \ + typeset all_devs=$(zpool iostat -v $pool | awk '{print $1}' | \ + grep -vEe "^pool$|^capacity$|^mirror\-[0-9]$|^raidz[1-3]\-[0-9]$|^draid[1-3].*\-[0-9]$|---" \ -e "/old$|^$pool$") typeset -i i=0 typeset vdevs |