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