ZTS: zfs_list_004_neg should not check paths that belong to ZFS

When ZFS is on root, /tmp is a ZFS. This causes zfs_list_004_neg to
fail since `zfs list` on /tmp passes when the test expects it not to.
The fix is to exclude paths that belong to ZFS.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Palash Gandhi <pbg4930@rit.edu>
Closes #12744
This commit is contained in:
Palash Gandhi 2021-11-11 07:46:44 -08:00 committed by GitHub
parent c23803be84
commit 637771a066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View File

@ -116,3 +116,22 @@ function verify_reverse_sort { # command list name
"unexpected number of filesystems found in list output!"
fi
}
function is_fs_type_zfs {
typeset dirname=$1
typeset fs="$(df $dirname | tail -1 | awk '{print $NF}')"
if is_freebsd; then
fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $4}' \
| sed -n 's/(\(.*\),/\1/p')
elif is_linux; then
fs_type=$(mount | awk -v fs=$fs '{if ($3 == fs) print $5}')
fi
if [[ $fs_type == "zfs" ]]; then
true
else
false
fi
}

View File

@ -29,7 +29,7 @@
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_user/zfs_list/zfs_list.kshlib
#
# DESCRIPTION:
@ -55,8 +55,12 @@ paths="$TESTPOOL/NONEXISTFS $TESTPOOL/$TESTFS/NONEXISTFS \
cd /tmp
for fs in $paths ; do
log_mustnot zfs list $fs
log_mustnot zfs list -r $fs
# In cases when ZFS is on root, /tmp will belong to ZFS and hence must be
# skipped
if ! is_fs_type_zfs $fs; then
log_mustnot zfs list $fs
log_mustnot zfs list -r $fs
fi
done
log_pass "'zfs list [-r]' fails while the given dataset/path does not exist " \