aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2018-09-02 15:09:53 -0400
committerBrian Behlendorf <[email protected]>2018-09-02 12:09:53 -0700
commite8bcb693d6a19962291e4429f2dc4ce60693bef7 (patch)
treea4afbb8d0562aae23e9fd8fd561fd2182b14db8e /tests/zfs-tests
parentbb91178e60df553071ce2e18b0067ef703f7b583 (diff)
Add zfs module feature and property info to sysfs
This extends our sysfs '/sys/module/zfs' entry to include feature and property attributes. The primary consumer of this information is user processes, like the zfs CLI, that need to know what the current loaded ZFS module supports. The libzfs binary will consult this information when instantiating the zfs and zpool property tables and the pool features table. This introduces 4 kernel objects (dirs) into '/sys/module/zfs' with corresponding attributes (files): features.runtime features.pool properties.dataset properties.pool Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #7706
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/Makefile.am1
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am10
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/cleanup.ksh30
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/setup.ksh32
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfeature_set_unsupported.ksh54
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_get_unsupported.ksh53
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_set_unsupported.ksh54
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh57
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_get_unsupported.ksh55
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_set_unsupported.ksh54
10 files changed, 400 insertions, 0 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/Makefile.am
index aab49b168..7a765a160 100644
--- a/tests/zfs-tests/tests/functional/cli_root/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/Makefile.am
@@ -28,6 +28,7 @@ SUBDIRS = \
zfs_set \
zfs_share \
zfs_snapshot \
+ zfs_sysfs \
zfs_unload-key \
zfs_unmount \
zfs_unshare \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am
new file mode 100644
index 000000000..6a83edf2a
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/Makefile.am
@@ -0,0 +1,10 @@
+pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_sysfs
+dist_pkgdata_SCRIPTS = \
+ setup.ksh \
+ cleanup.ksh \
+ zfeature_set_unsupported.ksh \
+ zfs_get_unsupported.ksh \
+ zfs_set_unsupported.ksh \
+ zfs_sysfs_live.ksh \
+ zpool_get_unsupported.ksh \
+ zpool_set_unsupported.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/cleanup.ksh
new file mode 100755
index 000000000..79cd6e9f9
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/cleanup.ksh
@@ -0,0 +1,30 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+default_cleanup
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/setup.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/setup.ksh
new file mode 100755
index 000000000..969238599
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/setup.ksh
@@ -0,0 +1,32 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+DISK=${DISKS%% *}
+
+default_container_volume_setup $DISK
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfeature_set_unsupported.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfeature_set_unsupported.ksh
new file mode 100755
index 000000000..c9d242243
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfeature_set_unsupported.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# A feature not supported by the zfs module should fail in 'zpool set <feature>'
+#
+# STRATEGY:
+# 1. Run zpool set <featureprop> with env var 'ZFS_SYSFS_PROP_SUPPORT_TEST'
+# 2. Verify that zpool set returns error
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+claim="Features not supported by zfs module should fail in 'zpool set <feature>'"
+
+unsupported_feature="feature@large_blocks"
+value="enabled"
+
+log_assert $claim
+
+log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool set \
+ ${unsupported_feature}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_get_unsupported.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_get_unsupported.ksh
new file mode 100755
index 000000000..59ed7e950
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_get_unsupported.ksh
@@ -0,0 +1,53 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# A property not supported by the zfs module should fail in 'zfs get <prop>'
+#
+# STRATEGY:
+# 1. Run zfs get <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
+# 2. Verify that zfs get returns error
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+claim="Properties not supported by zfs module should fail in 'zfs get <prop>'"
+
+unsupported_prop="dnodesize"
+
+log_assert $claim
+
+log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zfs get ${unsupported_prop} \
+ $TESTPOOL/$TESTFS >/dev/null 2>&1"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_set_unsupported.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_set_unsupported.ksh
new file mode 100755
index 000000000..5a0b88a0b
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_set_unsupported.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# A property not supported by the zfs module should fail in 'zfs set <prop>'
+#
+# STRATEGY:
+# 1. Run zfs set <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
+# 2. Verify that zfs get returns error
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+claim="Properties not supported by zfs module should fail in 'zfs set <prop>'"
+
+unsupported_prop="dnodesize"
+value="any"
+
+log_assert $claim
+
+log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zfs set \
+ ${unsupported_prop}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh
new file mode 100755
index 000000000..17ac8f8a1
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zfs_sysfs_live.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# Test if the expected '/sys/module/zfs/<dir>/<attr>' are present
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+claim="Expected '/sys/module/zfs/<dir>/<attr>' attributes are present"
+
+feature_attr="/sys/module/zfs/features.pool/org.open-zfs:large_blocks/guid"
+pool_prop__attr="/sys/module/zfs/properties.pool/comment/values"
+ds_prop__attr="/sys/module/zfs/properties.dataset/recordsize/values"
+
+log_assert $claim
+
+log_must cat $feature_attr
+log_must cat $pool_prop__attr
+log_must cat $ds_prop__attr
+
+# force a read of all the attributes for show func code coverage
+log_must grep -R "[a-z]" /sys/module/zfs/features.*
+log_must grep -R "[a-z]" /sys/module/zfs/properties.*
+log_mustnot grep -RE "[^[:print:]]" /sys/module/zfs/properties.*
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_get_unsupported.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_get_unsupported.ksh
new file mode 100755
index 000000000..3ab1d941e
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_get_unsupported.ksh
@@ -0,0 +1,55 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# A property not supported by the zfs module should fail in 'zpool get <prop>'
+#
+# STRATEGY:
+# 1. Run zpool get <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
+# 2. Verify that zfs get returns error
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+export ZFS_SYSFS_PROP_SUPPORT_TEST
+
+claim="Properties not supported by zfs module should fail in 'zpool get <prop>'"
+
+unsupported_prop="comment"
+
+log_assert $claim
+
+log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool get \
+ ${unsupported_prop} $TESTPOOL/$TESTFS >/dev/null 2>&1"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_set_unsupported.ksh b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_set_unsupported.ksh
new file mode 100755
index 000000000..03eb2aea3
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zfs_sysfs/zpool_set_unsupported.ksh
@@ -0,0 +1,54 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# A property not supported by the zfs module should fail in 'zpool set <prop>'
+#
+# STRATEGY:
+# 1. Run zpool set <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
+# 2. Verify that zpool set returns error
+#
+
+verify_runnable "global"
+
+if ! is_linux ; then
+ log_unsupported "sysfs is linux-only"
+fi
+
+claim="Properties not supported by zfs module should fail in 'zpool set <prop>'"
+
+unsupported_prop="comment"
+value="You Shall Not Pass"
+
+log_assert $claim
+
+log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool set \
+ ${unsupported_prop}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
+
+log_pass $claim