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" 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_assert "zfs fails with unexpected scenario."
log_onexit cleanup
#verify zfs failed if ZFS_DEV cannot be opened #verify zfs failed if ZFS_DEV cannot be opened
ZFS_DEV=/dev/zfs ZFS_DEV=/dev/zfs
@ -56,13 +64,11 @@ if is_linux; then
fi fi
for file in $ZFS_DEV $MNTTAB; do for file in $ZFS_DEV $MNTTAB; do
if [[ -e $file ]]; then log_must mv $file ${file}.bak
mv $file ${file}.bak
fi
for cmd in "" "list" "get all" "mount"; do for cmd in "" "list" "get all" "mount"; do
log_mustnot eval "zfs $cmd >/dev/null 2>&1" log_mustnot eval "zfs $cmd >/dev/null 2>&1"
done done
mv ${file}.bak $file log_must mv ${file}.bak $file
done done
log_pass "zfs fails with unexpected scenario as expected." log_pass "zfs fails with unexpected scenario as expected."