tests: nawk -> awk

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-12 00:13:19 +01:00 committed by Brian Behlendorf
parent 75746e9a40
commit 270d0a5a16
26 changed files with 68 additions and 98 deletions

View File

@ -297,7 +297,6 @@ constrain_path() {
create_links "$SYSTEM_DIRS" "$SYSTEM_FILES"
# Exceptions
ln -fs "$STF_PATH/awk" "$STF_PATH/nawk"
if [ "$UNAME" = "Linux" ] ; then
ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck"
ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"

View File

@ -253,7 +253,7 @@ function set_device_dir
if is_linux; then
while (( i < $DISK_ARRAY_NUM )); do
disk="$(echo $DISKS | nawk '{print $(i + 1)}')"
disk="$(echo $DISKS | awk '{print $(i + 1)}')"
if is_mpath_device $disk; then
export DEV_DSKDIR=$DEV_MPATHDIR
return 0
@ -294,20 +294,15 @@ function get_device_dir #device
function get_persistent_disk_name #device
{
typeset device=$1
typeset dev_id
if is_linux; then
if is_real_device $device; then
dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \
| egrep disk/by-id | nawk '{print $2; exit}' \
| nawk -F / '{print $3}')"
echo $dev_id
udevadm info -q all -n $DEV_DSKDIR/$device \
| awk '/disk\/by-id/ {print $2; exit}' | cut -d/ -f3
elif is_mpath_device $device; then
dev_id="$(udevadm info -q all -n $DEV_DSKDIR/$device \
| egrep disk/by-id/dm-uuid \
| nawk '{print $2; exit}' \
| nawk -F / '{print $3}')"
echo $dev_id
udevadm info -q all -n $DEV_DSKDIR/$device \
| awk '/disk\/by-id\/dm-uuid/ {print $2; exit}' \
| cut -d/ -f3
else
echo $device
fi
@ -334,28 +329,22 @@ function on_off_disk # disk state{online,offline} host
if is_linux; then
if [[ $state == "offline" ]] && ( is_mpath_device $disk ); then
dm_name="$(readlink $DEV_DSKDIR/$disk \
| nawk -F / '{print $2}')"
dep="$(ls /sys/block/${dm_name}/slaves \
| nawk '{print $1}')"
dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)"
dep="$(ls /sys/block/${dm_name}/slaves | awk '{print $1}')"
while [[ -n $dep ]]; do
#check if disk is online
lsscsi | egrep $dep > /dev/null
if (($? == 0)); then
if lsscsi | egrep -q $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}"
lsscsi | egrep $dep > /dev/null
if (($? == 0)); then
log_fail "Offlining" \
"$disk failed"
fi
if lsscsi | egrep -q $dep; then
log_fail "Offlining $disk failed"
fi
fi
dep="$(ls /sys/block/$dm_name/slaves \
2>/dev/null | nawk '{print $1}')"
dep="$(ls /sys/block/$dm_name/slaves 2>/dev/null | awk '{print $1}')"
done
elif [[ $state == "offline" ]] && ( is_real_device $disk ); then
#check if disk is online
@ -378,12 +367,9 @@ function on_off_disk # disk state{online,offline} host
scan_scsi_hosts $host
block_device_wait
if is_mpath_device $disk; then
dm_name="$(readlink $DEV_DSKDIR/$disk \
| nawk -F / '{print $2}')"
dep="$(ls /sys/block/$dm_name/slaves \
| nawk '{print $1}')"
lsscsi | egrep $dep > /dev/null
if (($? != 0)); 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
log_fail "Onlining $disk failed"
fi
elif is_real_device $disk; then
@ -496,7 +482,7 @@ function unload_scsi_debug
function get_debug_device
{
for i in {1..10} ; do
val=$(lsscsi | nawk '/scsi_debug/ {print $6; exit}' | cut -d / -f3)
val=$(lsscsi | awk '/scsi_debug/ {print $6; exit}' | cut -d/ -f3)
# lsscsi can take time to settle
if [ "$val" != "-" ] ; then

View File

@ -2018,13 +2018,8 @@ function verify_pool
#
function get_disklist # pool
{
typeset disklist=""
disklist=$(zpool iostat -v $1 | nawk '(NR >4) {print $1}' | \
grep -v "\-\-\-\-\-" | \
egrep -v -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$")
echo $disklist
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]$"
}
#
@ -2033,8 +2028,7 @@ function get_disklist # pool
#
function get_disklist_fullpath # pool
{
args="-P $1"
get_disklist $args
get_disklist "-P $1"
}
@ -2183,14 +2177,12 @@ function check_pool_status # pool token keyword <verbose>
typeset keyword=$3
typeset verbose=${4:-false}
scan=$(zpool status -v "$pool" 2>/dev/null | nawk -v token="$token:" '
scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" '
($1==token) {print $0}')
if [[ $verbose == true ]]; then
log_note $scan
fi
echo $scan | egrep -i "$keyword" > /dev/null 2>&1
return $?
echo $scan | egrep -qi "$keyword"
}
#
@ -2968,15 +2960,14 @@ function get_device_state #pool disk field("", "spares","logs")
typeset disk=${2#$DEV_DSKDIR/}
typeset field=${3:-$pool}
state=$(zpool status -v "$pool" 2>/dev/null | \
nawk -v device=$disk -v pool=$pool -v field=$field \
zpool status -v "$pool" 2>/dev/null | \
awk -v device=$disk -v pool=$pool -v field=$field \
'BEGIN {startconfig=0; startfield=0; }
/config:/ {startconfig=1}
(startconfig==1) && ($1==field) {startfield=1; next;}
(startfield==1) && ($1==device) {print $2; exit;}
(startfield==1) &&
($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}')
echo $state
($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}'
}
#

View File

@ -58,7 +58,7 @@ function get_acl #<obj>
return 1
fi
ls -vd $obj | nawk '(NR != 1) {print $0}'
ls -vd $obj | awk '(NR != 1) {print $0}'
}
#
@ -73,7 +73,7 @@ function get_compact_acl #<obj>
return 1
fi
ls -Vd $obj | nawk '(NR != 1) {print $0}'
ls -Vd $obj | awk '(NR != 1) {print $0}'
}
#
@ -246,7 +246,7 @@ function count_ACE #<file or dir name>
return 1
fi
ls -vd $1 | nawk 'BEGIN {count=0}
ls -vd $1 | awk 'BEGIN {count=0}
(NR != 1)&&(/[0-9]:/) {count++}
END {print count}'

View File

@ -52,8 +52,7 @@ do
log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \
special $stype $sdisks
ac_value="$(zpool get -H -o property,value all | \
egrep allocation_classes | nawk '{print $2}')"
ac_value="$(zpool get -H -o property,value all | awk '/allocation_classes/ {print $2}')"
if [ "$ac_value" = "active" ]; then
log_note "feature@allocation_classes is active"
else

View File

@ -94,7 +94,7 @@ function verify_cache_device
#
# mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE
#
set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \
set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \
/\tcache/ {start=1}
/\tmirror/ || /\tspares/ || /^$/ {start=0}
(start==1) && /\t (\/|[a-zA-Z])/ \

View File

@ -33,5 +33,5 @@ export CPATH1=$TEST_BASE_DIR/cachefile.1.$$
export CPATH2=$TEST_BASE_DIR/cachefile.2.$$
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir

View File

@ -76,10 +76,10 @@ function verify_size_estimates
typeset file_size=$2
typeset refer_diff=$(echo "$refer_size - $estimate_size" | bc)
refer_diff=$(echo "$refer_diff / 1" | bc)
refer_diff=$(echo "$refer_diff" | nawk '{print ($1 < 0) ? ($1 * -1): $1'})
refer_diff=$(echo "$refer_diff" | awk '{print ($1 < 0) ? ($1 * -1): $1'})
typeset file_diff=$(echo "$file_size - $estimate_size" | bc)
file_diff=$(echo "$file_diff / 1" | bc)
file_diff=$(echo "$file_diff" | nawk '{print ($1 < 0) ? ($1 * -1):$1'})
file_diff=$(echo "$file_diff" | awk '{print ($1 < 0) ? ($1 * -1):$1'})
typeset expected_diff=$(cal_percentage $refer_size)
[[ -z $refer_diff && -z $file_diff && -z $expected_diff ]] && \

View File

@ -86,9 +86,9 @@ done
log_note "verify multiple snapshot transaction group"
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" | awk -v j=$i 'FNR == j {print}')
[[ $txg_tag != $(echo "$txg_group" | \
nawk -v j=$i 'FNR == j {print}') ]] \
awk -v j=$i 'FNR == j {print}') ]] \
&& log_fail "snapshots belong to different transaction groups"
done
log_note "verify snapshot contents"

View File

@ -71,7 +71,7 @@ typeset expect_str2="All filesystems are formatted with the current version"
typeset expect_str3="The following filesystems are out of date, and can be upgraded"
typeset -i COUNT OLDCOUNT
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
OLDCOUNT=$(wc -l < $oldoutput)
old_datasets=""
@ -98,8 +98,8 @@ log_must eval 'zfs upgrade > $output 2>&1'
# we also check that the usage message contains at least a description
# 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
log_must grep -q "${expect_str1} $ZFS_VERSION" $output
zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output
COUNT=$(wc -l < $output)
typeset -i i=0
@ -118,13 +118,13 @@ for fs in $old_datasets ; do
done
log_must eval 'zfs upgrade > $output 2>&1'
log_must eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
log_must grep -q "${expect_str1} $ZFS_VERSION" $output
if (( OLDCOUNT == 0 )); then
log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1'
log_must grep -q "${expect_str2}" $output
else
log_must eval 'grep "${expect_str3}" $output > /dev/null 2>&1'
log_must grep -q "${expect_str3}" $output
fi
zfs upgrade | nawk '$1 ~ "^[0-9]+$" {print $2}'> $output
zfs upgrade | awk '$1 ~ "^[0-9]+$" {print $2}'> $output
COUNT=$(wc -l < $output)
if (( COUNT != OLDCOUNT )); then

View File

@ -60,8 +60,8 @@ typeset expect_str2="Enhanced directory entries"
log_must eval 'zfs upgrade -v > /dev/null 2>&1'
zfs upgrade -v | nawk '$1 ~ "^[0-9]+$" {print $0}'> $output
log_must eval 'grep "${expect_str1}" $output > /dev/null 2>&1'
log_must eval 'grep "${expect_str2}" $output > /dev/null 2>&1'
zfs upgrade -v | awk '$1 ~ "^[0-9]+$" {print $0}'> $output
log_must grep -q "${expect_str1}" $output
log_must grep -q "${expect_str2}" $output
log_pass "Executing 'zfs upgrade -v' command succeeds."

View File

@ -28,7 +28,7 @@
# Copyright (c) 2012 by Delphix. All rights reserved.
#
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISKSARRAY=$DISKS
echo $DISKS | read DISK0 DISK1

View File

@ -18,7 +18,7 @@
verify_runnable "global"
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISKSARRAY=$DISKS
export SMALL_FILE_SIZE=10
export LARGE_FILE_SIZE=80
@ -29,9 +29,8 @@ export SDHOSTS=1
export SDTGTS=1
export SDLUNS=1
export DISK1=$(echo $DISKS | nawk '{print $1}')
export DISK2=$(echo $DISKS | nawk '{print $2}')
export DISK3=$(echo $DISKS | nawk '{print $3}')
read -r DISK1 DISK2 DISK3 _ <<<"$DISKS"
export DISK1 DISK2 DISK3
if is_linux; then
set_slice_prefix

View File

@ -23,8 +23,7 @@
# Copyright (c) 2018 by Datto. All rights reserved.
#
export DISK1=$(echo $DISKS | nawk '{print $1}')
export DISK2=$(echo $DISKS | nawk '{print $2}')
export DISK3=$(echo $DISKS | nawk '{print $3}')
read -r DISK1 DISK2 DISK3 _ <<<"$DISKS"
export DISK1 DISK2 DISK3
export MAXTIMEOUT=300

View File

@ -14,5 +14,5 @@
#
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir

View File

@ -26,7 +26,7 @@
verify_runnable "global"
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISKSARRAY=$DISKS
export FSIZE=10M
export MAXTIMEOUT=30
@ -36,9 +36,8 @@ export SDHOSTS=1
export SDTGTS=1
export SDLUNS=1
export DISK1=$(echo $DISKS | nawk '{print $1}')
export DISK2=$(echo $DISKS | nawk '{print $2}')
export DISK3=$(echo $DISKS | nawk '{print $3}')
read -r DISK1 DISK2 DISK3 _ <<<"$DISKS"
export DISK1 DISK2 DISK3
if is_linux; then
set_slice_prefix

View File

@ -31,7 +31,7 @@
. $STF_SUITE/include/libtest.shlib
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set -A disk_array $(find_disks $DISKS)
case "${#disk_array[*]}" in
0)

View File

@ -36,10 +36,8 @@ function check_pool_import # pool opts token keyword
typeset keyword=$4
zpool import $opts 2>&1 | \
nawk -v token="$token:" '($1==token) {print $0}' | \
grep -i "$keyword" > /dev/null 2>&1
return $?
awk -v token="$token:" '($1==token) {print}' | \
grep -iq "$keyword"
}
function is_pool_imported # pool opts

View File

@ -30,7 +30,7 @@
export DISK=${DISKS%% *}
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir
export TESTFILE=testfile

View File

@ -38,5 +38,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8
export STF_TIMEOUT=3600
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir

View File

@ -101,7 +101,7 @@ function verify_slog_device
#
# mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE
#
set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \
set -A dev_stat_tab $(zpool status -v $pool | awk 'BEGIN {start=0} \
/\tlogs/ {start=1}
/\tmirror/ || /\tspares/ || /^$/ {start=0}
(start==1) && /\t (\/|[a-zA-Z])/ \

View File

@ -39,5 +39,5 @@ export HOLES_COUNT=${HOLES_COUNT-"16384"} # FILESIZE/BLKSIZE/8
export STF_TIMEOUT=3600
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir

View File

@ -34,6 +34,6 @@ export TRUNC_FILEOFFSET=${TRUNC_FILEOFFSET-""}
export TRUNC_COUNT=${TRUNC_COUNT-"16384"} # FILESIZE/BLKSIZE/8
export DISKSARRAY=$DISKS
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
set_device_dir

View File

@ -32,7 +32,7 @@
verify_runnable "global"
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISKSARRAY=$DISKS
if is_linux; then

View File

@ -32,7 +32,7 @@
verify_runnable "global"
export DISK_ARRAY_NUM=$(echo ${DISKS} | nawk '{print NF}')
export DISK_ARRAY_NUM=$(echo ${DISKS} | awk '{print NF}')
export DISKSARRAY=$DISKS
if is_linux; then

View File

@ -34,11 +34,11 @@
# Remember swap devices
#
if is_linux; then
SAVESWAPDEVS=$(swapon -s | nawk '(NR != 1) {print $1}')
SAVESWAPDEVS=$(swapon -s | awk '(NR != 1) {print $1}')
elif is_freebsd; then
SAVESWAPDEVS=$(swapctl -l | nawk '(NR != 1) {print $1}')
SAVESWAPDEVS=$(swapctl -l | awk '(NR != 1) {print $1}')
else
SAVESWAPDEVS=$(swap -l | nawk '(NR != 1) {print $1}')
SAVESWAPDEVS=$(swap -l | awk '(NR != 1) {print $1}')
fi
export BLOCKSZ=$(( 1024 * 1024 ))