]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_009_neg.ksh
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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_mount
/zfs_mount.kshlib
34 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_import
/zpool_import.cfg
37 # Try each 'zpool import' with inapplicable scenarios to make sure
38 # it returns an error. include:
39 # * A non-existent pool name is given
40 # * '-d', but no device directory specified
41 # * '-R', but no alter root directory specified
42 # * '-a', but a pool name specified either
43 # * more than 2 pool names is given
44 # * The new pool name specified already exists
45 # * Contain invalid characters not allowed in the ZFS namespace
48 # 1. Create an array of parameters
49 # 2. For each parameter in the array, execute the sub-command
50 # 3. Verify an error is returned.
53 verify_runnable
"global"
55 set -A args
"blah" "-d" "-R" "-a $TESTPOOL" \
56 "$TESTPOOL ${TESTPOOL}-new ${TESTPOOL}-new" \
57 "$TESTPOOL $TESTPOOL1" \
58 "$TESTPOOL ${TESTPOOL1}*" "$TESTPOOL ${TESTPOOL1}?"
60 set -A pools
"$TESTPOOL" "$TESTPOOL1"
61 set -A devs
"" "-d $DEVICE_DIR"
68 while (( i
< ${#pools[*]} )); do
70 poolexists
${pools[i]} && \
71 log_must
$ZPOOL export ${pools[i]}
73 datasetexists
"${pools[i]}/$TESTFS" || \
74 log_must
$ZPOOL import
${devs[i]} ${pools[i]}
76 ismounted
"${pools[i]}/$TESTFS" || \
77 log_must
$ZFS mount
${pools[i]}/$TESTFS
82 cleanup_filesystem
$TESTPOOL1 $TESTFS
84 destroy_pool
$TESTPOOL1
89 log_assert
"Badly-formed 'zpool import' with inapplicable scenarios " \
90 "should return an error."
92 setup_filesystem
"$DEVICE_FILES" $TESTPOOL1 $TESTFS $TESTDIR1
94 log_must
$ZPOOL export $TESTPOOL
97 while (( i
< ${#args[*]} )); do
98 log_mustnot
$ZPOOL import
${args[i]}
102 log_pass
"Badly formed 'zpool import' with inapplicable scenarios " \