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 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# Specifically disabling a feature, all other features should be enabled. 33# 34# 1. Loop through all existing features: 35# a. Create a new pool with '-o feature@XXX=disabled'. 36# b. Verify that every other feature is 'enabled' or 'active'. 37# 38################################################################################ 39 40verify_runnable "global" 41 42function cleanup 43{ 44 datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL 45} 46 47function check_features 48{ 49 typeset feature="${1}" 50 51 zpool get all ${TESTPOOL} | grep feature@ | while read line; do 52 set -- $(echo "${line}") 53 54 if [[ "feature@${feature}" == "${2}" ]]; then 55 # Failure passed feature must be disabled. 56 if [[ "${3}" != "disabled" ]]; then 57 return 1; 58 fi 59 else 60 # Failure other features must be enabled or active. 61 if [[ "${3}" != "enabled" && "${3}" != "active" ]]; then 62 return 2; 63 fi 64 fi 65 done 66 67 # All features enabled or active except the expected one. 68 return 0 69} 70 71log_onexit cleanup 72 73# Several representative features are tested to keep the test time short. 74# The features 'extensible_dataset' and 'enabled_txg' are intentionally 75# excluded because other features depend on them. 76set -A features \ 77 "hole_birth" \ 78 "large_blocks" \ 79 "large_dnode" \ 80 "userobj_accounting" 81 82typeset -i i=0 83while (( $i < ${#features[*]} )); do 84 log_assert "'zpool create' creates pools with ${features[i]} disabled" 85 86 log_must zpool create -f -o "feature@${features[i]}=disabled" \ 87 $TESTPOOL $DISKS 88 log_must check_features "${features[i]}" 89 log_must zpool destroy -f $TESTPOOL 90 (( i = i+1 )) 91done 92 93log_pass "'zpool create -o feature@feature=disabled' disables features" 94