tests: zfs_003_neg: handle failures correctly

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-17 21:27:11 +01:00 committed by Brian Behlendorf
parent 61f1502246
commit 34abca3e2c
1 changed files with 10 additions and 4 deletions

View File

@ -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."