summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/linux.run3
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am3
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh106
3 files changed, 110 insertions, 2 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index a7b58474e..73f19ecfa 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -230,7 +230,8 @@ tests = ['zpool_001_neg', 'zpool_002_pos', 'zpool_003_pos']
# zpool_add_006_pos - https://github.com/zfsonlinux/zfs/issues/3484
[tests/functional/cli_root/zpool_add]
tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos',
- 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg']
+ 'zpool_add_007_neg', 'zpool_add_008_neg', 'zpool_add_009_neg',
+ 'add-o_ashift']
[tests/functional/cli_root/zpool_attach]
tests = ['zpool_attach_001_neg']
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am
index fef934325..60a16e102 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/Makefile.am
@@ -12,4 +12,5 @@ dist_pkgdata_SCRIPTS = \
zpool_add_006_pos.ksh \
zpool_add_007_neg.ksh \
zpool_add_008_neg.ksh \
- zpool_add_009_neg.ksh
+ zpool_add_009_neg.ksh \
+ add-o_ashift.ksh
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
new file mode 100644
index 000000000..a7180b5c5
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
@@ -0,0 +1,106 @@
+#!/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 2017, loli10K. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
+
+#
+# DESCRIPTION:
+# 'zpool add -o ashift=<n> ...' should work with different ashift
+# values.
+#
+# STRATEGY:
+# 1. Create a pool with default values.
+# 2. Verify 'zpool add -o ashift=<n>' works with allowed values (9-13).
+# 3. Verify 'zpool add -o ashift=<n>' doesn't accept other invalid values.
+#
+
+verify_runnable "global"
+
+function cleanup
+{
+ poolexists $TESTPOOL && destroy_pool $TESTPOOL
+ log_must $RM $disk1 $disk2
+}
+
+#
+# Verify every label in device $1 contains ashift value $2
+# $1 device
+# $2 ashift value
+#
+function verify_device_ashift
+{
+ typeset device=$1
+ typeset value=$2
+ typeset ashift
+
+ $ZDB -e -l $device | $GREP " ashift:" | {
+ while read ashift ; do
+ if [[ "ashift: $value" != "$ashift" ]]; then
+ return 1
+ fi
+ done
+ }
+
+ return 0
+}
+
+log_assert "zpool add -o ashift=<n>' works with different ashift values"
+log_onexit cleanup
+
+disk1=$TEST_BASE_DIR/$FILEDISK0
+disk2=$TEST_BASE_DIR/$FILEDISK1
+log_must $MKFILE $SIZE $disk1
+log_must $MKFILE $SIZE $disk2
+
+typeset ashifts=("9" "10" "11" "12" "13")
+for ashift in ${ashifts[@]}
+do
+ log_must $ZPOOL create $TESTPOOL $disk1
+ log_must $ZPOOL add -o ashift=$ashift $TESTPOOL $disk2
+ verify_device_ashift $disk2 $ashift
+ if [[ $? -ne 0 ]]
+ then
+ log_fail "Device was added without setting ashift value to "\
+ "$ashift"
+ fi
+ # clean things for the next run
+ log_must $ZPOOL destroy $TESTPOOL
+ log_must $ZPOOL labelclear $disk1
+ log_must $ZPOOL labelclear $disk2
+done
+
+typeset badvals=("off" "on" "1" "8" "14" "1b" "ff" "-")
+for badval in ${badvals[@]}
+do
+ log_must $ZPOOL create $TESTPOOL $disk1
+ log_mustnot $ZPOOL add -o ashift="$badval" $disk2
+ log_must $ZPOOL destroy $TESTPOOL
+ log_must $ZPOOL labelclear $disk1
+ log_must $ZPOOL labelclear $disk2
+done
+
+log_pass "zpool add -o ashift=<n>' works with different ashift values"