aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLOLi <[email protected]>2018-09-13 22:37:42 +0200
committerBrian Behlendorf <[email protected]>2018-09-13 13:37:42 -0700
commit5140a58f3b2a25ce24ff9ae2b01277cd6c64f5ad (patch)
treef4155d286765913db500544c93eca05fcec030f6 /tests
parent92b432139da587c85648ac96dc31ed8c4b5d7b97 (diff)
zpool should detect invalid fs property on create
This change improve the handling of invalid filesystem properties when specified at pool creation: this is useful when 'zpool create -n' (dry run) is executed to detect invalid fs-level options (-O) before the actual command is run. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7620 Closes #7878
Diffstat (limited to 'tests')
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_003_pos.ksh52
1 files changed, 36 insertions, 16 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_003_pos.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_003_pos.ksh
index 51ddced76..100a24c50 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_003_pos.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_003_pos.ksh
@@ -38,7 +38,8 @@
# actually creating the pool.
#
# STRATEGY:
-# 1. Create storage pool with -n option
+# 1. Create storage pool with -n option; this should only work when valid
+# properties are specified on the command line
# 2. Verify the pool has not been actually created
#
@@ -67,20 +68,39 @@ if is_mpath_device $DISK; then
partition_disk $SIZE $disk 1
fi
-#
-# Make sure disk is clean before we use it
-#
-create_pool $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} > $tmpfile
-destroy_pool $TESTPOOL
-
-zpool create -n $TESTPOOL ${disk}${SLICE_PREFIX}${SLICE0} > $tmpfile
-
-poolexists $TESTPOOL && \
- log_fail "'zpool create -n <pool> <vspec> ...' fail."
-
-str="would create '$TESTPOOL' with the following layout:"
-cat $tmpfile | grep "$str" >/dev/null 2>&1
-(( $? != 0 )) && \
- log_fail "'zpool create -n <pool> <vspec>...' is executed as unexpected."
+typeset vspec="${disk}${SLICE_PREFIX}${SLICE0}"
+typeset goodprops=('' '-o comment=text' '-O checksum=on' '-O ns:prop=value')
+typeset badprops=('-o ashift=9999' '-O doesnotexist=on' '-O volsize=10M')
+
+# Verify zpool create -n with valid pool-level and fs-level options
+for prop in "${goodprops[@]}"
+do
+ #
+ # Make sure disk is clean before we use it
+ #
+ create_pool $TESTPOOL $vspec > $tmpfile
+ destroy_pool $TESTPOOL
+
+ log_must eval "zpool create -n $prop $TESTPOOL $vspec > $tmpfile"
+
+ poolexists $TESTPOOL && \
+ log_fail "'zpool create -n <pool> <vspec> ...' fail."
+
+ str="would create '$TESTPOOL' with the following layout:"
+ grep "$str" $tmpfile >/dev/null 2>&1 || \
+ log_fail "'zpool create -n <pool> <vspec>...' is executed as unexpected."
+done
+
+# Verify zpool create -n with invalid options
+for prop in "${badprops[@]}"
+do
+ #
+ # Make sure disk is clean before we use it
+ #
+ create_pool $TESTPOOL $vspec > $tmpfile
+ destroy_pool $TESTPOOL
+
+ log_mustnot zpool create -n $prop $TESTPOOL $vspec
+done
log_pass "'zpool create -n <pool> <vspec>...' success."