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 https://opensource.org/licenses/CDDL-1.0.
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 (c) 2012, 2016 by Delphix. 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#
32#  When using the '-d' option with '-o feature@XXX=enabled' only the specified
33#  feature is enabled.
34#
35#  1. Create a new pool with '-d' and '-o feature@async_destroy=enabled'.
36#     async_destroy does not depend on anything so it should be the only
37#     feature that gets enabled.
38#  2. Verify that every feature@ property except feature@async_destroy is in
39#     the 'disabled' state
40#
41################################################################################
42
43verify_runnable "global"
44
45function cleanup
46{
47	datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
48}
49
50log_onexit cleanup
51
52log_assert "'zpool create -d -o feature@async_destroy=enabled' only " \
53    "enables async_destroy"
54
55log_must zpool create -f -d -o feature@async_destroy=enabled $TESTPOOL $DISKS
56
57state=$(zpool list -Ho feature@async_destroy $TESTPOOL)
58if [[ "$state" != "enabled" ]]; then
59	log_fail "async_destroy has state $state"
60fi
61
62for prop in $(zpool get all $TESTPOOL | awk '$2 ~ /feature@/ { print $2 }'); do
63	state=$(zpool list -Ho "$prop" $TESTPOOL)
64	if [[ "$prop" != "feature@async_destroy" \
65	    && "$state" != "disabled" ]]; then
66		log_fail "$prop is enabled on new pool"
67        fi
68done
69
70log_pass
71