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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib 34 35# 36# DESCRIPTION: 37# 'zpool create' have to use '-f' scenarios 38# 39# STRATEGY: 40# 1. Prepare the scenarios 41# 2. Create pool without '-f' and verify it fails 42# 3. Create pool with '-f' and verify it succeeds 43# 44 45verify_runnable "global" 46 47function cleanup 48{ 49 if [[ $exported_pool == true ]]; then 50 if [[ $force_pool == true ]]; then 51 log_must zpool create -f $TESTPOOL $DISK0 52 else 53 log_must zpool import $TESTPOOL 54 fi 55 fi 56 57 if poolexists $TESTPOOL ; then 58 destroy_pool $TESTPOOL 59 fi 60 61 if poolexists $TESTPOOL1 ; then 62 destroy_pool $TESTPOOL1 63 fi 64} 65 66log_assert "'zpool create' have to use '-f' scenarios" 67log_onexit cleanup 68 69typeset exported_pool=false 70typeset force_pool=false 71 72# overlapped slices as vdev need -f to create pool 73 74# Make the disk is EFI labeled first via pool creation 75create_pool $TESTPOOL $DISK0 76destroy_pool $TESTPOOL 77 78# exported device to be as spare vdev need -f to create pool 79 80log_must zpool create -f $TESTPOOL $DISK0 81destroy_pool $TESTPOOL 82create_pool $TESTPOOL $DISK0 $DISK1 83log_must zpool export $TESTPOOL 84exported_pool=true 85log_mustnot zpool create $TESTPOOL1 $DISK1 spare $DISK2 86create_pool $TESTPOOL1 $DISK1 spare $DISK2 87force_pool=true 88destroy_pool $TESTPOOL1 89 90log_pass "'zpool create' have to use '-f' scenarios" 91