]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_add/add-o_ashift.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / cli_root / zpool_add / add-o_ashift.ksh
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_add/zpool_add.kshlib
29
30 #
31 # DESCRIPTION:
32 #       'zpool add -o ashift=<n> ...' should work with different ashift
33 #       values.
34 #
35 # STRATEGY:
36 #       1. Create a pool with default values.
37 #       2. Verify 'zpool add -o ashift=<n>' works with allowed values (9-16).
38 #       3. Verify 'zpool add -o ashift=<n>' doesn't accept other invalid values.
39 #
40
41 verify_runnable "global"
42
43 function cleanup
44 {
45         poolexists $TESTPOOL && destroy_pool $TESTPOOL
46         rm -f $disk1 $disk2
47 }
48
49 log_assert "zpool add -o ashift=<n>' works with different ashift values"
50 log_onexit cleanup
51
52 disk1=$TEST_BASE_DIR/disk1
53 disk2=$TEST_BASE_DIR/disk2
54 log_must mkfile $SIZE $disk1
55 log_must mkfile $SIZE $disk2
56
57 typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
58 for ashift in ${ashifts[@]}
59 do
60         log_must zpool create $TESTPOOL $disk1
61         log_must zpool add -o ashift=$ashift $TESTPOOL $disk2
62         verify_ashift $disk2 $ashift
63         if [[ $? -ne 0 ]]
64         then
65                 log_fail "Device was added without setting ashift value to "\
66                     "$ashift"
67         fi
68         # clean things for the next run
69         log_must zpool destroy $TESTPOOL
70         log_must zpool labelclear $disk1
71         log_must zpool labelclear $disk2
72 done
73
74 typeset badvals=("off" "on" "1" "8" "17" "1b" "ff" "-")
75 for badval in ${badvals[@]}
76 do
77         log_must zpool create $TESTPOOL $disk1
78         log_mustnot zpool add -o ashift="$badval" $TESTPOOL $disk2
79         # clean things for the next run
80         log_must zpool destroy $TESTPOOL
81         log_must zpool labelclear $disk1
82         log_mustnot zpool labelclear $disk2
83 done
84
85 log_pass "zpool add -o ashift=<n>' works with different ashift values"