From 029c4ae03afe7ea938682244ad8a6abb2b029575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20F=C3=BCl=C3=B6p?= Date: Sat, 29 Mar 2025 17:27:43 +0100 Subject: [PATCH] ZTS: Fix zpool `dry run` tests depending on output format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Fülöp --- .../zpool_add/zpool_add_dryrun_output.ksh | 16 +++++++++++----- .../zpool_create/zpool_create_dryrun_output.ksh | 9 +++++---- .../zpool_split/zpool_split_dryrun_output.ksh | 8 +++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh index f3c208e88..9adf4d9bb 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add_dryrun_output.ksh @@ -155,9 +155,11 @@ for (( i=0; i < ${#tests[@]}; i+=1 )); do log_must eval zpool create "$TESTPOOL" $tree log_must poolexists "$TESTPOOL" - typeset out="$(log_must eval "zpool add -n '$TESTPOOL' $add" | \ - sed /^SUCCESS/d)" - + typeset out + out="$(eval zpool add -n '$TESTPOOL' $add)" + if [[ $? -ne 0 ]]; then + log_fail eval "zpool add -n '$TESTPOOL' $add" + fi if [[ "$out" != "$want" ]]; then log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" fi @@ -170,7 +172,11 @@ log_must eval "zpool create '$TESTPOOL' '${dev[0]}' log '${dev[1]}' \ # Create a hole vdev. log_must eval "zpool remove '$TESTPOOL' '${dev[1]}'" -log_mustnot eval "zpool add -n '$TESTPOOL' '${dev[1]}' | \ - grep -qE '[[:space:]]+hole'" +typeset out +out="$(eval zpool add -n '$TESTPOOL' '${dev[1]}')" +if [[ $? -ne 0 ]]; then + log_fail eval "zpool add -n '$TESTPOOL' '${dev[1]}'" +fi +log_mustnot grep -qE '[[:space:]]+hole' <<<"$out" log_pass "'zpool add -n ...' displays config correctly." diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh index 2bd836bcb..68a85a5b5 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_dryrun_output.ksh @@ -127,10 +127,11 @@ done for (( i=0; i < ${#tests[@]}; i+=1 )); do tree="${tests[$i].tree}" want="${tests[$i].want}" - - typeset out="$(log_must eval "zpool create -n '$TESTPOOL' $tree" | \ - sed /^SUCCESS/d)" - + typeset out + out="$(eval zpool create -n '$TESTPOOL' $tree)" + if [[ $? -ne 0 ]]; then + log_fail eval "zpool create -n '$TESTPOOL' $tree" + fi if [[ "$out" != "$want" ]]; then log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" fi diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh index 05addd282..628e8342a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_dryrun_output.ksh @@ -140,9 +140,11 @@ for (( i=0; i < ${#tests[@]}; i+=1 )); do log_must eval zpool create "$TESTPOOL" $tree log_must poolexists "$TESTPOOL" - typeset out="$(log_must eval "zpool split -n \ - '$TESTPOOL' '$NEWPOOL' $devs" | sed /^SUCCESS/d)" - + typeset out + out="$(eval zpool split -n '$TESTPOOL' '$NEWPOOL' $devs)" + if [[ $? -ne 0 ]]; then + log_fail eval "zpool split -n '$TESTPOOL' '$NEWPOOL' $devs" + fi if [[ "$out" != "$want" ]]; then log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" fi