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 " \