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) 2016 by Delphix. All rights reserved. 25# 26. $STF_SUITE/include/libtest.shlib 27. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib 28 29# 30# DESCRIPTION: 31# Attempting to initialize unsupported vdevs should fail. 32# 33# STRATEGY: 34# 1. Create a pool with the following configuration: 35# root 36# mirror 37# vdev0 38# vdev1 (offline) 39# cache 40# vdev2 41# spare 42# vdev3 43# 2. Try to initialize vdev1, vdev2, and vdev3. Ensure that all 3 fail. 44# 45function cleanup 46{ 47 if datasetexists $TESTPOOL; then 48 log_must zpool destroy -f $TESTPOOL 49 fi 50 if [[ -d $TESTDIR ]]; then 51 log_must rm -rf $TESTDIR 52 fi 53} 54log_onexit cleanup 55 56log_must mkdir $TESTDIR 57set -A FDISKS 58for n in {0..2}; do 59 log_must mkfile $MINVDEVSIZE $TESTDIR/vdev$n 60 FDISKS+=("$TESTDIR/vdev$n") 61done 62FDISKS+=("${DISKS%% *}") 63 64log_must zpool create $TESTPOOL mirror ${FDISKS[0]} ${FDISKS[1]} \ 65 spare ${FDISKS[2]} cache ${FDISKS[3]} 66 67log_must zpool offline $TESTPOOL ${FDISKS[1]} 68 69log_mustnot zpool initialize $TESTPOOL mirror-0 70for n in {1..3}; do 71 log_mustnot zpool initialize $TESTPOOL ${FDISKS[$n]} 72done 73 74log_pass "Attempting to initialize failed on unsupported devices" 75