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 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27
28#
29# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
34
35#
36# DESCRIPTION:
37# 'zpool create -n <pool> <vspec> ...' can display the configuration without
38# actually creating the pool.
39#
40# STRATEGY:
41# 1. Create storage pool with -n option
42# 2. Verify the pool has not been actually created
43#
44
45verify_runnable "global"
46
47function cleanup
48{
49	[[ -e $tmpfile ]] && log_must rm -f $tmpfile
50}
51
52tmpfile="/var/tmp/zpool_create_003.tmp$$"
53
54log_assert "'zpool create -n <pool> <vspec> ...' can display the configureation" \
55        "without actually creating the pool."
56
57log_onexit cleanup
58
59if [[ -n $DISK ]]; then
60        disk=$DISK
61else
62        disk=$DISK0
63fi
64
65#
66# Make sure disk is clean before we use it
67#
68create_pool $TESTPOOL ${disk}s${SLICE0} > $tmpfile
69destroy_pool $TESTPOOL
70
71zpool create -n  $TESTPOOL ${disk}s${SLICE0} > $tmpfile
72
73poolexists $TESTPOOL && \
74        log_fail "'zpool create -n <pool> <vspec> ...' fail."
75
76str="would create '$TESTPOOL' with the following layout:"
77cat $tmpfile | grep "$str" >/dev/null 2>&1
78(( $? != 0 )) && \
79        log_fail "'zpool create -n <pool> <vspec>...' is executed as unexpected."
80
81log_pass "'zpool create -n <pool> <vspec>...' success."
82