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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27. $STF_SUITE/include/libtest.shlib 28. $STF_SUITE/tests/functional/cli_root/zpool_add/zpool_add.kshlib 29 30# 31# DESCRIPTION: 32# 'zpool add' should return fail if 33# 1. vdev is part of an active pool 34# 2. vdev is currently mounted 35# 3. vdev is in /etc/vfstab 36# 3. vdev is specified as the dedicated dump device 37# 38# STRATEGY: 39# 1. Create case scenarios 40# 2. For each scenario, try to add the device to the pool 41# 3. Verify the add operation get failed 42# 43 44verify_runnable "global" 45 46function cleanup 47{ 48 poolexists "$TESTPOOL" && \ 49 destroy_pool "$TESTPOOL" 50 poolexists "$TESTPOOL1" && \ 51 destroy_pool "$TESTPOOL1" 52 53 if [[ -n $saved_dump_dev ]]; then 54 log_must eval "$DUMPADM -u -d $saved_dump_dev > /dev/null" 55 fi 56 57 partition_cleanup 58} 59 60log_assert "'zpool add' should fail with inapplicable scenarios." 61 62log_onexit cleanup 63 64mnttab_dev=$(find_mnttab_dev) 65vfstab_dev=$(find_vfstab_dev) 66saved_dump_dev=$(save_dump_dev) 67dump_dev=${disk}s${SLICE3} 68 69create_pool "$TESTPOOL" "${disk}s${SLICE0}" 70log_must poolexists "$TESTPOOL" 71 72create_pool "$TESTPOOL1" "${disk}s${SLICE1}" 73log_must poolexists "$TESTPOOL1" 74log_mustnot $ZPOOL add -f "$TESTPOOL" ${disk}s${SLICE1} 75 76log_mustnot $ZPOOL add -f "$TESTPOOL" $mnttab_dev 77 78log_mustnot $ZPOOL add -f "$TESTPOOL" $vfstab_dev 79 80log_must $ECHO "y" | $NEWFS /dev/dsk/$dump_dev > /dev/null 2>&1 81log_must $DUMPADM -u -d /dev/dsk/$dump_dev > /dev/null 82log_mustnot $ZPOOL add -f "$TESTPOOL" $dump_dev 83 84log_pass "'zpool add' should fail with inapplicable scenarios." 85