From 34abca3e2c51f34f94ec4b4b91974792951e863a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 17 Mar 2022 21:27:11 +0100 Subject: [PATCH] tests: zfs_003_neg: handle failures correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Reviewed-by: Ryan Moeller Signed-off-by: Ahelenia ZiemiaƄska Closes #13259 --- .../tests/functional/cli_root/zfs/zfs_003_neg.ksh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh index 0438bae8f6..6c85e0c13a 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh @@ -45,7 +45,15 @@ verify_runnable "global" +function cleanup +{ + for file in $ZFS_DEV $MNTTAB; do + log_must eval "[ -e ${file} ] || mv ${file}.bak $file" + done +} + log_assert "zfs fails with unexpected scenario." +log_onexit cleanup #verify zfs failed if ZFS_DEV cannot be opened ZFS_DEV=/dev/zfs @@ -56,13 +64,11 @@ if is_linux; then fi for file in $ZFS_DEV $MNTTAB; do - if [[ -e $file ]]; then - mv $file ${file}.bak - fi + log_must mv $file ${file}.bak for cmd in "" "list" "get all" "mount"; do log_mustnot eval "zfs $cmd >/dev/null 2>&1" done - mv ${file}.bak $file + log_must mv ${file}.bak $file done log_pass "zfs fails with unexpected scenario as expected."