Skip to content

Commit b5cf63a

Browse files
nabijaczleweliandrewc12
authored andcommitted
tests: zfs_003_neg: handle failures correctly
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Kennedy <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes openzfs#13259
1 parent 7164f87 commit b5cf63a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/zfs-tests/tests/functional/cli_root/zfs/zfs_003_neg.ksh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@
4545

4646
verify_runnable "global"
4747

48+
function cleanup
49+
{
50+
for file in $ZFS_DEV $MNTTAB; do
51+
log_must eval "[ -e ${file} ] || mv ${file}.bak $file"
52+
done
53+
}
54+
4855
log_assert "zfs fails with unexpected scenario."
56+
log_onexit cleanup
4957

5058
#verify zfs failed if ZFS_DEV cannot be opened
5159
ZFS_DEV=/dev/zfs
@@ -56,13 +64,11 @@ if is_linux; then
5664
fi
5765

5866
for file in $ZFS_DEV $MNTTAB; do
59-
if [[ -e $file ]]; then
60-
mv $file ${file}.bak
61-
fi
67+
log_must mv $file ${file}.bak
6268
for cmd in "" "list" "get all" "mount"; do
6369
log_mustnot eval "zfs $cmd >/dev/null 2>&1"
6470
done
65-
mv ${file}.bak $file
71+
log_must mv ${file}.bak $file
6672
done
6773

6874
log_pass "zfs fails with unexpected scenario as expected."

0 commit comments

Comments
 (0)