aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPalash Gandhi <[email protected]>2021-11-11 07:46:44 -0800
committerGitHub <[email protected]>2021-11-11 08:46:44 -0700
commit637771a066ba10083e818eb52d299e0d448f149b (patch)
treee8c354012890827e99bd8983bf31c4f7eac571a2
parentc23803be84cb5cc9d98186221f4106a9962dfc45 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Palash Gandhi <[email protected]> Closes #12744
-rw-r--r--tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib19
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh10
2 files changed, 26 insertions, 3 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
index 03c9d1f07..889ae46fb 100644
--- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
+++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list.kshlib
@@ -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
+}
diff --git a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh
index 5d1114dac..727c0aef0 100755
--- a/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh
+++ b/tests/zfs-tests/tests/functional/cli_user/zfs_list/zfs_list_004_neg.ksh
@@ -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 " \