From 37c5b78aa68111ad498e38bb8173eb474f6801e7 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 1/2] 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 f3c208e88f4c..9adf4d9bbcd1 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 2bd836bcbc4a..68a85a5b50a6 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 05addd2823a8..628e8342a06f 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 From 0f86a67943bd2c5e40fdb517c7d8e5421f3b49f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20F=C3=BCl=C3=B6p?= Date: Sat, 29 Mar 2025 19:59:20 +0100 Subject: [PATCH 2/2] ZTS: Fix zpool `dry run` tests output formating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Fülöp --- .../cli_root/zpool_add/zpool_add_dryrun_output.ksh | 6 +++++- .../cli_root/zpool_create/zpool_create_dryrun_output.ksh | 6 +++++- .../cli_root/zpool_split/zpool_split_dryrun_output.ksh | 6 +++++- 3 files changed, 15 insertions(+), 3 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 9adf4d9bbcd1..3f9ce321059c 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 @@ -161,7 +161,11 @@ for (( i=0; i < ${#tests[@]}; i+=1 )); do log_fail eval "zpool add -n '$TESTPOOL' $add" fi if [[ "$out" != "$want" ]]; then - log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" + log_note "Got:" + log_note "$out" + log_note "but expected:" + log_note "$want" + log_fail "Dry run does not display config correctly" fi log_must destroy_pool "$TESTPOOL" done 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 68a85a5b50a6..5d654ec3a6d6 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 @@ -133,7 +133,11 @@ for (( i=0; i < ${#tests[@]}; i+=1 )); do log_fail eval "zpool create -n '$TESTPOOL' $tree" fi if [[ "$out" != "$want" ]]; then - log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" + log_note "Got:" + log_note "$out" + log_note "but expected:" + log_note "$want" + log_fail "Dry run does not display config correctly" fi done 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 628e8342a06f..e66456a71893 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 @@ -146,7 +146,11 @@ for (( i=0; i < ${#tests[@]}; i+=1 )); do log_fail eval "zpool split -n '$TESTPOOL' '$NEWPOOL' $devs" fi if [[ "$out" != "$want" ]]; then - log_fail "Got:\n" "$out" "\nbut expected:\n" "$want" + log_note "Got:" + log_note "$out" + log_note "but expected:" + log_note "$want" + log_fail "Dry run does not display config correctly" fi log_must destroy_pool "$TESTPOOL" done