1#!/usr/local/bin/ksh93 -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# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zpool_add_005_pos.ksh 1.4 09/06/22 SMI" 30# 31. $STF_SUITE/include/libtest.kshlib 32. $STF_SUITE/tests/cli_root/zpool_add/zpool_add.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zpool_add_005_pos 39# 40# DESCRIPTION: 41# 'zpool add' should return fail if 42# 1. vdev is part of an active pool 43# 2. vdev is currently mounted 44# 3. vdev is in /etc/vfstab 45# 3. vdev is specified as the dedicated dump device 46# 47# STRATEGY: 48# 1. Create case scenarios 49# 2. For each scenario, try to add the device to the pool 50# 3. Verify the add operation get failed 51# 52# TESTABILITY: explicit 53# 54# TEST_AUTOMATION_LEVEL: automated 55# 56# CODING_STATUS: COMPLETED (2005-09-29) 57# 58# __stc_assertion_end 59# 60############################################################################### 61 62verify_runnable "global" 63 64function cleanup 65{ 66 poolexists "$TESTPOOL" && \ 67 destroy_pool "$TESTPOOL" 68 poolexists "$TESTPOOL1" && \ 69 destroy_pool "$TESTPOOL1" 70 71 if [[ -n $saved_dump_dev ]]; then 72 log_must eval "$DUMPADM -u -d $saved_dump_dev > /dev/null" 73 fi 74 75 partition_cleanup 76} 77 78log_assert "'zpool add' should fail with inapplicable scenarios." 79 80log_onexit cleanup 81 82mnttab_dev=$(find_mnttab_dev) 83vfstab_dev=$(find_vfstab_dev) 84saved_dump_dev=$(save_dump_dev) 85dump_dev=${disk}p3 86 87create_pool "$TESTPOOL" "${disk}p1" 88log_must poolexists "$TESTPOOL" 89 90create_pool "$TESTPOOL1" "${disk}p2" 91log_must poolexists "$TESTPOOL1" 92log_mustnot $ZPOOL add -f "$TESTPOOL" ${disk}p2 93 94log_mustnot $ZPOOL add -f "$TESTPOOL" $mnttab_dev 95 96log_mustnot $ZPOOL add -f "$TESTPOOL" $vfstab_dev 97 98log_must $ECHO "y" | $NEWFS /dev/$dump_dev > /dev/null 2>&1 99log_must $DUMPADM -u -d /dev/$dump_dev > /dev/null 100log_mustnot $ZPOOL add -f "$TESTPOOL" $dump_dev 101 102log_pass "'zpool add' should fail with inapplicable scenarios." 103