From 3886e7081ada7e4275ff20f7e42c19d3645af212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Fri, 11 Mar 2022 01:42:32 +0100
Subject: [PATCH] tests: zfs_unshare_006: log_unsupported iff usershares are
 actually off
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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
---
 tests/test-runner/bin/zts-report.py.in        |  2 +-
 .../zfs_unshare/zfs_unshare_006_pos.ksh       | 23 +++++++++----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/tests/test-runner/bin/zts-report.py.in b/tests/test-runner/bin/zts-report.py.in
index e15d6bded8..93d593791b 100755
--- a/tests/test-runner/bin/zts-report.py.in
+++ b/tests/test-runner/bin/zts-report.py.in
@@ -162,7 +162,6 @@ known = {
     'casenorm/mixed_none_lookup_ci': ['FAIL', '7633'],
     'casenorm/mixed_formd_lookup_ci': ['FAIL', '7633'],
     'cli_root/zfs_unshare/zfs_unshare_002_pos': ['SKIP', na_reason],
-    'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],
     'cli_root/zpool_import/import_rewind_device_replaced':
         ['FAIL', rewind_reason],
     'cli_user/misc/zfs_share_001_neg': ['SKIP', na_reason],
@@ -215,6 +214,7 @@ maybe = {
     'cli_root/zfs_rollback/zfs_rollback_001_pos': ['FAIL', known_reason],
     'cli_root/zfs_rollback/zfs_rollback_002_pos': ['FAIL', known_reason],
     'cli_root/zfs_snapshot/zfs_snapshot_002_neg': ['FAIL', known_reason],
+    'cli_root/zfs_unshare/zfs_unshare_006_pos': ['SKIP', na_reason],
     'cli_root/zpool_add/zpool_add_004_pos': ['FAIL', known_reason],
     'cli_root/zpool_destroy/zpool_destroy_001_pos': ['SKIP', '6145'],
     'cli_root/zpool_import/zpool_import_missing_003_pos': ['SKIP', '6839'],
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh
index b4318020cc..b6e5178cf2 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_unshare/zfs_unshare_006_pos.ksh
@@ -41,9 +41,7 @@
 
 verify_runnable "global"
 
-if is_linux; then
-	log_unsupported "some distros come with Samba "user shares" disabled"
-fi
+[ -d "/var/lib/samba/usershares" ] || log_unsupported "Samba usershares disabled"
 
 function cleanup
 {
@@ -51,9 +49,10 @@ function cleanup
 	log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1
 	log_must zfs destroy -f $TESTPOOL/$TESTFS/shared2
 	log_must zfs destroy -f $TESTPOOL/$TESTFS/shared3
+	log_must rm -f /var/lib/samba/usershares/testpool_testfs_shared{2,3}
 }
 
-log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified "\
+log_assert "Verify 'zfs unshare [nfs|smb] -a' only works on the specified" \
 	"protocol."
 log_onexit cleanup
 
@@ -74,19 +73,19 @@ log_must zfs share -a
 log_must zfs unshare nfs -a
 
 # 3. Verify that only nfs filesystems are unshared.
-log_must eval "not_shared $TESTPOOL/$TESTFS/shared1"
-log_must eval "not_shared $TESTPOOL/$TESTFS/shared2"
-log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared2"
-log_must eval "is_shared_smb $TESTPOOL/$TESTFS/shared3"
+log_must not_shared $TESTPOOL/$TESTFS/shared1
+log_must not_shared $TESTPOOL/$TESTFS/shared2
+log_must is_shared_smb $TESTPOOL/$TESTFS/shared2
+log_must is_shared_smb $TESTPOOL/$TESTFS/shared3
 
 # 4. Share all filesystems again.
 log_must zfs share -a
 
 # 5. Invoke 'zfs unshare smb -a' and verify only smb filesystems are unshared.
 log_must zfs unshare smb -a
-log_must eval "is_shared $TESTPOOL/$TESTFS/shared1"
-log_must eval "is_shared $TESTPOOL/$TESTFS/shared2"
-log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared2"
-log_must eval "not_shared_smb $TESTPOOL/$TESTFS/shared3"
+log_must is_shared $TESTPOOL/$TESTFS/shared1
+log_must is_shared $TESTPOOL/$TESTFS/shared2
+log_must not_shared_smb $TESTPOOL/$TESTFS/shared2
+log_must not_shared_smb $TESTPOOL/$TESTFS/shared3
 
 log_pass "'zfs unshare [nfs|smb] -a' only works on the specified protocol."