xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_set/zpool_set_ashift.ksh (revision 4e5ef1cee66fbfbbd2b3e56b81e2bb5700f4a59e)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2017, loli10K. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
29
30#
31# DESCRIPTION:
32#
33# zpool set can modify 'ashift' property
34#
35# STRATEGY:
36# 1. Create a pool
37# 2. Verify that we can set 'ashift' only to allowed values on that pool
38#
39
40verify_runnable "global"
41
42function cleanup
43{
44	poolexists $TESTPOOL && destroy_pool $TESTPOOL
45	log_must rm -f $disk
46}
47
48typeset goodvals=("0" "9" "10" "11" "12" "13" "14" "15" "16")
49typeset badvals=("off" "on" "1" "8" "17" "1b" "ff" "-")
50
51log_onexit cleanup
52
53log_assert "zpool set can modify 'ashift' property"
54
55disk=$TEST_BASE_DIR/$FILEDISK0
56log_must mkfile $SIZE $disk
57log_must zpool create $TESTPOOL $disk
58
59for ashift in ${goodvals[@]}
60do
61	log_must zpool set ashift=$ashift $TESTPOOL
62	typeset value=$(get_pool_prop ashift $TESTPOOL)
63	if [[ "$ashift" != "$value" ]]; then
64		log_fail "'zpool set' did not update ashift value to $ashift "\
65		    "(current = $value)"
66	fi
67done
68
69for ashift in ${badvals[@]}
70do
71	log_mustnot zpool set ashift=$ashift $TESTPOOL
72	typeset value=$(get_pool_prop ashift $TESTPOOL)
73	if [[ "$ashift" == "$value" ]]; then
74		log_fail "'zpool set' incorrectly set ashift value to $value"
75	fi
76done
77
78log_pass "zpool set can modify 'ashift' property"
79