]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_destroy/zpool_destroy_002_pos.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 2009 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
/zpool_destroy
/zpool_destroy.cfg
37 # 'zpool destroy -f <pool>' can forcely destroy the specified pool.
40 # 1. Create a storage pool
41 # 2. Create some datasets within the pool
42 # 3. Change directory to any mountpoint of these datasets,
43 # Verify 'zpool destroy' without '-f' will fail.
44 # 4. 'zpool destroy -f' the pool
45 # 5. Verify the pool is destroyed successfully
48 verify_runnable
"global"
52 [[ -n $cwd ]] && log_must
cd $cwd
54 if [[ -d $TESTDIR ]]; then
57 log_must
$UNMOUNT $TESTDIR
58 log_must
$RM -rf $TESTDIR
62 while (( $i < ${#datasets[*]} )); do
63 datasetexists
${datasets[i]} && \
64 log_must
$ZFS destroy
${datasets[i]}
68 poolexists
$TESTPOOL && destroy_pool
$TESTPOOL
71 set -A datasets
"$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR/$TESTFS1" \
72 "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTVOL" \
74 log_assert
"'zpool destroy -f <pool>' can forcely destroy the specified pool"
80 create_pool
"$TESTPOOL" "$DISK"
81 log_must
$ZFS create
$TESTPOOL/$TESTFS
82 log_must
$MKDIR -p $TESTDIR
83 log_must
$ZFS set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
84 log_must
$ZFS create
$TESTPOOL/$TESTCTR
85 log_must
$ZFS create
$TESTPOOL/$TESTCTR/$TESTFS1
86 log_must
$ZFS create
-V $VOLSIZE $TESTPOOL/$TESTVOL
89 while (( $i < ${#datasets[*]} )); do
90 datasetexists
"${datasets[i]}" || \
91 log_fail
"Create datasets fail."
96 log_note
"'zpool destroy' without '-f' will fail " \
99 for dir
in $TESTDIR /$TESTPOOL/$TESTCTR /$TESTPOOL/$TESTCTR/$TESTFS1 ; do
101 log_mustnot
$ZPOOL destroy
$TESTPOOL
103 # Need mount here, otherwise some dataset may be unmounted.
104 log_must
$ZFS mount
-a
107 while (( i
< ${#datasets[*]} )); do
108 datasetexists
"${datasets[i]}" || \
109 log_fail
"Dataset ${datasets[i]} removed unexpected."
114 destroy_pool
$TESTPOOL
115 log_mustnot poolexists
"$TESTPOOL"
117 log_pass
"'zpool destroy -f <pool>' success."