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# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27. $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib 28 29################################################################################# 30# __stc_assertion_start 31# 32# ID: zpool_import_009_neg 33# 34# DESCRIPTION: 35# Try each 'zpool import' with inapplicable scenarios to make sure 36# it returns an error. include: 37# * A non-existent pool name is given 38# * '-d', but no device directory specified 39# * '-R', but no alter root directory specified 40# * '-a', but a pool name specified either 41# * more than 2 pool names is given 42# * The new pool name specified already exists 43# * Contain invalid characters not allowed in the ZFS namespace 44# 45# STRATEGY: 46# 1. Create an array of parameters 47# 2. For each parameter in the array, execute the sub-command 48# 3. Verify an error is returned. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-07-07) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "global" 61 62set -A args "blah" "-d" "-R" "-a $TESTPOOL" \ 63 "$TESTPOOL ${TESTPOOL}-new ${TESTPOOL}-new" \ 64 "$TESTPOOL $TESTPOOL1" \ 65 "$TESTPOOL ${TESTPOOL1}*" "$TESTPOOL ${TESTPOOL1}?" 66 67set -A pools "$TESTPOOL" "$TESTPOOL1" 68set -A devs "" "-d $DEVICE_DIR" 69 70function cleanup 71{ 72 typeset -i i=0 73 typeset -i j=0 74 75 while (( i < ${#pools[*]} )); do 76 77 poolexists ${pools[i]} && \ 78 log_must $ZPOOL export ${pools[i]} 79 80 datasetexists "${pools[i]}/$TESTFS" || \ 81 log_must $ZPOOL import ${devs[i]} ${pools[i]} 82 83 ismounted "${pools[i]}/$TESTFS" || \ 84 log_must $ZFS mount ${pools[i]}/$TESTFS 85 86 ((i = i + 1)) 87 done 88 89 cleanup_filesystem $TESTPOOL1 $TESTFS 90 91 destroy_pool $TESTPOOL1 92} 93 94log_onexit cleanup 95 96log_assert "Badly-formed 'zpool import' with inapplicable scenarios " \ 97 "should return an error." 98 99setup_filesystem "$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1 100 101log_must $ZPOOL export $TESTPOOL 102 103typeset -i i=0 104while (( i < ${#args[*]} )); do 105 log_mustnot $ZPOOL import ${args[i]} 106 ((i = i + 1)) 107done 108 109log_pass "Badly formed 'zpool import' with inapplicable scenarios " \ 110 "fail as expected." 111