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 (c) 2012, 2016 by Delphix. All rights reserved.
25#
26
27. $STF_SUITE/include/libtest.shlib
28
29################################################################################
30#
31#  Newly created pools should have all features enabled.
32#  Specifying a feature to be enabled with '-o' should be a no-op.
33#
34#  1. Create a new pool.
35#  2. Verify that every feature@ property is in the 'enabled' or 'active' state
36#  3. Destroy the pool and create a new pool with
37#     '-o feature@async_destroy=enabled'
38#  4. Verify again.
39#
40################################################################################
41
42verify_runnable "global"
43
44function cleanup
45{
46	datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
47}
48
49function check_features
50{
51	for state in $(zpool get all $TESTPOOL | \
52	    awk '$2 ~ /feature@/ { print $3 }'); do
53		if [[ "$state" != "enabled" && "$state" != "active" ]]; then
54			log_fail "some features are not enabled on new pool"
55	        fi
56	done
57}
58
59log_onexit cleanup
60
61log_assert "'zpool create' creates pools with all features enabled"
62
63log_must zpool create -f $TESTPOOL $DISKS
64check_features
65log_must zpool destroy -f $TESTPOOL
66
67log_must zpool create -f -o feature@async_destroy=enabled $TESTPOOL $DISKS
68check_features
69
70log_pass "'zpool create' creates pools with all features enabled"
71