[PATCH fstests v2 2/3] generic/513: limit to filesystems that support capabilities

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



This test requires being able to set file capabilities which some
filesystems (namely NFS) do not support. Add a _require_setcap test
and only run it on filesystems that pass it.

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
 common/rc         | 13 +++++++++++++
 tests/generic/513 |  1 +
 2 files changed, 14 insertions(+)

diff --git a/common/rc b/common/rc
index 5c4429ed0425..33e74d20c28b 100644
--- a/common/rc
+++ b/common/rc
@@ -5048,6 +5048,19 @@ _require_mknod()
 	rm -f $TEST_DIR/$seq.null
 }
 
+_require_setcap()
+{
+	local testfile=$TEST_DIR/setcaptest.$$
+
+	touch $testfile
+	$SETCAP_PROG "cap_sys_module=p" $testfile > $testfile.out 2>&1
+	if grep -q 'Operation not supported' $testfile.out; then
+	  _notrun "File capabilities are not supported on this filesystem"
+	fi
+
+	rm -f $testfile $testfile.out
+}
+
 _getcap()
 {
 	$GETCAP_PROG "$@" | _filter_getcap
diff --git a/tests/generic/513 b/tests/generic/513
index dc082787ae4e..52f9eb916b4a 100755
--- a/tests/generic/513
+++ b/tests/generic/513
@@ -18,6 +18,7 @@ _supported_fs generic
 _require_scratch_reflink
 _require_command "$GETCAP_PROG" getcap
 _require_command "$SETCAP_PROG" setcap
+_require_setcap
 
 _scratch_mkfs >>$seqres.full 2>&1
 _scratch_mount

-- 
2.41.0




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux