diff options
author | наб <[email protected]> | 2022-01-17 16:40:45 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-01-26 11:30:03 -0800 |
commit | e0c5a48b3f37cffedb9f720ab3952effb4a8dcb4 (patch) | |
tree | 32d921d22eb317e8d10f875a40d977472f37e32f /tests | |
parent | a67a187335063234cdd255a8d446557fbfb5ee4b (diff) |
tests: simplify find_vfstab_dev()
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #12979
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib | 17 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib | 17 |
2 files changed, 2 insertions, 32 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib index a7a1fb330..272d0834c 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib @@ -36,28 +36,13 @@ # function find_vfstab_dev { - typeset vfstabdev - typeset vfstabdevs="" - typeset line - if is_illumos; then vfstab="/etc/vfstab" - tmpfile="$TEST_BASE_DIR/vfstab.tmp" else vfstab="/etc/fstab" - tmpfile="$TEST_BASE_DIR/fstab.tmp" fi - cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile - while read -r line - do - vfstabdev=`echo "$line" | awk '{print $1}'` - vfstabdev=${vfstabdev%%:} - vfstabdevs="$vfstabdev $vfstabdevs" - done <$tmpfile - - rm -f $tmpfile - echo $vfstabdevs + awk -v pat="^${DEV_DSKDIR}" '$0 ~ pat {sub(/:$/, "", $1); print $1}' $vfstab } # diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib index c98e49518..005cf979b 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @@ -69,28 +69,13 @@ function create_blockfile # function find_vfstab_dev { - typeset vfstabdev - typeset vfstabdevs="" - typeset line - if is_illumos; then vfstab="/etc/vfstab" - tmpfile="$TEST_BASE_DIR/vfstab.tmp" else vfstab="/etc/fstab" - tmpfile="$TEST_BASE_DIR/fstab.tmp" fi - cat $vfstab | grep "^${DEV_DSKDIR}" >$tmpfile - while read -r line - do - vfstabdev=`echo "$line" | awk '{print $1}'` - vfstabdev=${vfstabdev%%:} - vfstabdevs="$vfstabdev $vfstabdevs" - done <$tmpfile - - rm -f $tmpfile - echo $vfstabdevs + awk -v pat="^${DEV_DSKDIR}" '$0 ~ pat {sub(/:$/, "", $1); print $1}' $vfstab } # |