aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_disable.ksh54
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_homedir.ksh76
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_searchpath.ksh88
-rw-r--r--tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am5
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_disable.ksh54
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_homedir.ksh76
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_searchpath.ksh88
8 files changed, 444 insertions, 2 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am
index 747ec1dfa..aab4de0e7 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/Makefile.am
@@ -4,4 +4,7 @@ dist_pkgdata_SCRIPTS = \
cleanup.ksh \
zpool_status_001_pos.ksh \
zpool_status_002_pos.ksh \
- zpool_status_003_pos.ksh
+ zpool_status_003_pos.ksh \
+ zpool_status_-c_disable.ksh \
+ zpool_status_-c_homedir.ksh \
+ zpool_status_-c_searchpath.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_disable.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_disable.ksh
new file mode 100755
index 000000000..c8105fb4a
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_disable.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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool status command mode (-c) respects ZPOOL_SCRIPTS_ENABLED.
+#
+# STRATEGY:
+# 1. Set ZPOOL_SCRIPTS_ENABLED to 0, disabling zpool status -c
+# 2. zpool status -c must not run successfully
+# 3. Set ZPOOL_SCRIPTS_ENABLED to 1, enabling zpool status -c
+# 4. zpool status -c must run successfully
+# 5. Unset ZPOOL_SCRIPTS_ENABLED, enabling zpool status -c
+# 6. zpool status -c must run successfully
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+log_assert "zpool status -c properly handles ZPOOL_SCRIPTS_ENABLED"
+
+export ZPOOL_SCRIPTS_ENABLED=0
+log_mustnot zpool status -c media
+
+export ZPOOL_SCRIPTS_ENABLED=1
+log_must zpool status -c media
+
+unset ZPOOL_SCRIPTS_ENABLED
+log_must zpool status -c media
+
+log_pass "zpool status -c properly handles ZPOOL_SCRIPTS_ENABLED passed"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_homedir.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_homedir.ksh
new file mode 100755
index 000000000..4cc3deb6d
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_homedir.ksh
@@ -0,0 +1,76 @@
+#!/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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool status command mode (-c) works with scripts in user's
+# home directory.
+#
+# STRATEGY:
+# 1. Change HOME to /var/tmp
+# 2. Make a simple script that echos a key value pair
+# in /var/tmp/.zpool.d
+# 3. Make sure it can be run with -c
+# 4. Remove the script we created
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+# In tree testing sets this variable, we need to unset it
+# to restore zpool's search path.
+unset ZPOOL_SCRIPTS_PATH
+
+# change HOME
+export HOME="$TEST_BASE_DIR"
+typeset USER_SCRIPT_FULL="$HOME/.zpool.d/userscript"
+
+function cleanup
+{
+ log_must rm -rf "$HOME/.zpool.d"
+}
+
+log_assert "zpool status -c can run scripts from ~/.zpool.d"
+
+if [ -e "$USER_SCRIPT_FULL" ]; then
+ log_fail "$USER_SCRIPT_FULL already exists."
+fi
+
+log_onexit cleanup
+
+# create simple script
+log_must mkdir -p "$HOME/.zpool.d"
+cat > "$USER_SCRIPT_FULL" << EOF
+#!/bin/sh
+echo "USRCOL=USRVAL"
+EOF
+log_must chmod +x "$USER_SCRIPT_FULL"
+
+# test that we can run the script
+typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL")
+test_zpool_script "$USER_SCRIPT" "$TESTPOOL" "zpool status -P -c"
+
+log_pass "zpool status -c can run scripts from ~/.zpool.d passed"
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_searchpath.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_searchpath.ksh
new file mode 100755
index 000000000..a075b9a0c
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_status/zpool_status_-c_searchpath.ksh
@@ -0,0 +1,88 @@
+#!/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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool status command mode (-c) works with ZPOOL_SCRIPTS_PATH
+# defined.
+#
+# STRATEGY:
+# 1. Set ZPOOL_SCRIPTS_PATH to contain a couple of non-default dirs
+# 2. Make a simple script that echos a key value pair in each dir
+# 3. Make sure scripts can be run with -c
+# 4. Remove the scripts we created
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+typeset SCRIPT_1="$TEST_BASE_DIR/scripts1/test1"
+typeset SCRIPT_2="$TEST_BASE_DIR/scripts2/test2"
+
+function cleanup
+{
+ log_must rm -rf $(dirname "$SCRIPT_1")
+ log_must rm -rf $(dirname "$SCRIPT_2")
+}
+
+log_assert "zpool status -c can run scripts from custom search path"
+
+if [ -e "$SCRIPT_1" ]; then
+ log_fail "$SCRIPT_1 already exists."
+fi
+
+if [ -e "$SCRIPT_2" ]; then
+ log_fail "$SCRIPT_2 already exists."
+fi
+
+log_onexit cleanup
+
+# change zpool status search path
+export ZPOOL_SCRIPTS_PATH="$(dirname $SCRIPT_1):$(dirname $SCRIPT_2)"
+
+# create simple script in each dir
+log_must mkdir -p $(dirname "$SCRIPT_1")
+cat > "$SCRIPT_1" << EOF
+#!/bin/sh
+echo "USRCOL1=USRVAL1"
+EOF
+log_must chmod +x "$SCRIPT_1"
+
+log_must mkdir -p $(dirname "$SCRIPT_2")
+cat > "$SCRIPT_2" << EOF
+#!/bin/sh
+echo "USRCOL2=USRVAL2"
+EOF
+log_must chmod +x "$SCRIPT_2"
+
+# test that we can run the scripts
+typeset CMD_1=$(basename "$SCRIPT_1")
+typeset CMD_2=$(basename "$SCRIPT_2")
+test_zpool_script "$CMD_1" "$TESTPOOL" "zpool status -P -c"
+test_zpool_script "$CMD_2" "$TESTPOOL" "zpool status -P -c"
+test_zpool_script "$CMD_2,$CMD_1" "$TESTPOOL" "zpool status -P -c"
+
+log_pass "zpool status -c can run scripts from custom search path passed"
diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am
index cadf9439a..5ee30eafc 100644
--- a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/Makefile.am
@@ -6,4 +6,7 @@ dist_pkgdata_SCRIPTS = \
zpool_iostat_002_pos.ksh \
zpool_iostat_003_neg.ksh \
zpool_iostat_004_pos.ksh \
- zpool_iostat_005_pos.ksh
+ zpool_iostat_005_pos.ksh \
+ zpool_iostat_-c_disable.ksh \
+ zpool_iostat_-c_searchpath.ksh \
+ zpool_iostat_-c_homedir.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_disable.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_disable.ksh
new file mode 100755
index 000000000..0d64eb0ec
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_disable.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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool iostat command mode (-c) respects ZPOOL_SCRIPTS_ENABLED.
+#
+# STRATEGY:
+# 1. Set ZPOOL_SCRIPTS_ENABLED to 0, disabling zpool iostat -c
+# 2. zpool iostat -c must not run successfully
+# 3. Set ZPOOL_SCRIPTS_ENABLED to 1, enabling zpool iostat -c
+# 4. zpool iostat -c must run successfully
+# 5. Unset ZPOOL_SCRIPTS_ENABLED, enabling zpool iostat -c
+# 6. zpool iostat -c must run successfully
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+log_assert "zpool iostat -c properly handles ZPOOL_SCRIPTS_ENABLED"
+
+export ZPOOL_SCRIPTS_ENABLED=0
+log_mustnot zpool iostat -c media
+
+export ZPOOL_SCRIPTS_ENABLED=1
+log_must zpool iostat -c media
+
+unset ZPOOL_SCRIPTS_ENABLED
+log_must zpool iostat -c media
+
+log_pass "zpool iostat -c properly handles ZPOOL_SCRIPTS_ENABLED passed"
diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_homedir.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_homedir.ksh
new file mode 100755
index 000000000..5cb50fde6
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_homedir.ksh
@@ -0,0 +1,76 @@
+#!/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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool iostat command mode (-c) works with scripts in user's
+# home directory.
+#
+# STRATEGY:
+# 1. Change HOME to /var/tmp
+# 2. Make a simple script that echos a key value pair
+# in /var/tmp/.zpool.d
+# 3. Make sure it can be run with -c
+# 4. Remove the script we created
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+# In tree testing sets this variable, we need to unset it
+# to restore zpool's search path.
+unset ZPOOL_SCRIPTS_PATH
+
+# change HOME
+export HOME="$TEST_BASE_DIR"
+typeset USER_SCRIPT_FULL="$HOME/.zpool.d/userscript"
+
+function cleanup
+{
+ log_must rm -rf "$HOME/.zpool.d"
+}
+
+log_assert "zpool iostat -c can run scripts from ~/.zpool.d"
+
+if [ -e "$USER_SCRIPT_FULL" ]; then
+ log_fail "$USER_SCRIPT_FULL already exists."
+fi
+
+log_onexit cleanup
+
+# create simple script
+log_must mkdir -p "$HOME/.zpool.d"
+cat > "$USER_SCRIPT_FULL" << EOF
+#!/bin/sh
+echo "USRCOL=USRVAL"
+EOF
+log_must chmod +x "$USER_SCRIPT_FULL"
+
+# test that we can run the script
+typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL")
+test_zpool_script "$USER_SCRIPT" "$TESTPOOL" "zpool iostat -P -c"
+
+log_pass "zpool iostat -c can run scripts from ~/.zpool.d passed"
diff --git a/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_searchpath.ksh b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_searchpath.ksh
new file mode 100755
index 000000000..1197ea2d1
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_user/zpool_iostat/zpool_iostat_-c_searchpath.ksh
@@ -0,0 +1,88 @@
+#!/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) 2017 by Lawrence Livermore National Security, LLC.
+#
+
+# DESCRIPTION:
+# Verify zpool iostat command mode (-c) works with ZPOOL_SCRIPTS_PATH
+# defined.
+#
+# STRATEGY:
+# 1. Set ZPOOL_SCRIPTS_PATH to contain a couple of non-default dirs
+# 2. Make a simple script that echos a key value pair in each dir
+# 3. Make sure scripts can be run with -c
+# 4. Remove the scripts we created
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/include/zpool_script.shlib
+
+verify_runnable "both"
+
+typeset SCRIPT_1="$TEST_BASE_DIR/scripts1/test1"
+typeset SCRIPT_2="$TEST_BASE_DIR/scripts2/test2"
+
+function cleanup
+{
+ log_must rm -rf $(dirname "$SCRIPT_1")
+ log_must rm -rf $(dirname "$SCRIPT_2")
+}
+
+log_assert "zpool iostat -c can run scripts from custom search path"
+
+if [ -e "$SCRIPT_1" ]; then
+ log_fail "$SCRIPT_1 already exists."
+fi
+
+if [ -e "$SCRIPT_2" ]; then
+ log_fail "$SCRIPT_2 already exists."
+fi
+
+log_onexit cleanup
+
+# change zpool iostat search path
+export ZPOOL_SCRIPTS_PATH="$(dirname $SCRIPT_1):$(dirname $SCRIPT_2)"
+
+# create simple script in each dir
+log_must mkdir -p $(dirname "$SCRIPT_1")
+cat > "$SCRIPT_1" << EOF
+#!/bin/sh
+echo "USRCOL1=USRVAL1"
+EOF
+log_must chmod +x "$SCRIPT_1"
+
+log_must mkdir -p $(dirname "$SCRIPT_2")
+cat > "$SCRIPT_2" << EOF
+#!/bin/sh
+echo "USRCOL2=USRVAL2"
+EOF
+log_must chmod +x "$SCRIPT_2"
+
+# test that we can run the scripts
+typeset CMD_1=$(basename "$SCRIPT_1")
+typeset CMD_2=$(basename "$SCRIPT_2")
+test_zpool_script "$CMD_1" "$TESTPOOL" "zpool iostat -P -c"
+test_zpool_script "$CMD_2" "$TESTPOOL" "zpool iostat -P -c"
+test_zpool_script "$CMD_2,$CMD_1" "$TESTPOOL" "zpool iostat -P -c"
+
+log_pass "zpool iostat -c can run scripts from custom search path passed"