comparison usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_005_pos.ksh @ 13899:0bcf78798346

3311 Want a test framework for arbitrary OS unit tests 3312 Add a testrunner package for OS unit tests 3313 Add a testrunner package to convert ZFS tests from STF Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Will Guyette <will.guyette@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Sonu Pillai <sonu.pillai@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author John Wren Kennedy <john.kennedy@delphix.com>
date Wed, 05 Dec 2012 22:04:50 -0500
parents
children 4a7f6353bcf0
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
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 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012 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 [-R root][-m mountpoint] <pool> <vdev> ...' can create an
38 # alternate root pool or a new pool mounted at the specified mountpoint.
39 #
40 # STRATEGY:
41 # 1. Create a pool with '-m' option
42 # 2. Verify the pool is mounted at the specified mountpoint
43 #
44
45 verify_runnable "global"
46
47 function cleanup
48 {
49 poolexists $TESTPOOL && \
50 log_must $ZPOOL destroy -f $TESTPOOL
51
52 for dir in $TESTDIR $TESTDIR1; do
53 [[ -d $dir ]] && $RM -rf $dir
54 done
55 }
56
57 log_assert "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' can create" \
58 "an alternate pool or a new pool mounted at the specified mountpoint."
59 log_onexit cleanup
60
61 set -A pooltype "" "mirror" "raidz" "raidz1" "raidz2"
62
63 #
64 # cleanup the pools created in previous case if zpool_create_004_pos timedout
65 #
66 for pool in $TESTPOOL2 $TESTPOOL1 $TESTPOOL; do
67 if poolexists $pool; then
68 destroy_pool $pool
69 fi
70 done
71
72 #prepare raw file for file disk
73 [[ -d $TESTDIR ]] && $RM -rf $TESTDIR
74 log_must $MKDIR -p $TESTDIR
75 typeset -i i=1
76 while (( i < 4 )); do
77 log_must $MKFILE $FILESIZE $TESTDIR/file.$i
78
79 (( i = i + 1 ))
80 done
81
82 #Remove the directory with name as pool name if it exists
83 [[ -d /$TESTPOOL ]] && $RM -rf /$TESTPOOL
84 file=$TESTDIR/file
85
86 for opt in "-R $TESTDIR1" "-m $TESTDIR1" \
87 "-R $TESTDIR1 -m $TESTDIR1" "-m $TESTDIR1 -R $TESTDIR1"
88 do
89 i=0
90 while (( i < ${#pooltype[*]} )); do
91 #Remove the testing pool and its mount directory
92 poolexists $TESTPOOL && \
93 log_must $ZPOOL destroy -f $TESTPOOL
94 [[ -d $TESTDIR1 ]] && $RM -rf $TESTDIR1
95 log_must $ZPOOL create $opt $TESTPOOL ${pooltype[i]} \
96 $file.1 $file.2 $file.3
97 ! poolexists $TESTPOOL && \
98 log_fail "Createing pool with $opt fails."
99 mpt=`$ZFS mount | $EGREP "^$TESTPOOL[^/]" | $AWK '{print $2}'`
100 (( ${#mpt} == 0 )) && \
101 log_fail "$TESTPOOL created with $opt is not mounted."
102 mpt_val=$(get_prop "mountpoint" $TESTPOOL)
103 [[ "$mpt" != "$mpt_val" ]] && \
104 log_fail "The value of mountpoint property is different\
105 from the output of zfs mount"
106 if [[ "$opt" == "-R $TESTDIR1" ]] || [[ "$opt" == "-m $TESTDIR1" ]];
107 then
108 [[ ! -d $TESTDIR1 ]] && \
109 log_fail "$TESTDIR1 is not created auotmatically."
110 [[ "$mpt" != "$TESTDIR1" ]] && \
111 log_fail "$TESTPOOL is not mounted on $TESTDIR1."
112 else
113 [[ ! -d ${TESTDIR1}$TESTDIR1 ]] && \
114 log_fail "${TESTDIR1}$TESTDIR1 is not created automatically."
115 [[ "$mpt" != "${TESTDIR1}$TESTDIR1" ]] && \
116 log_fail "$TESTPOOL is not mounted on ${TESTDIR1}$TESTDIR1."
117 fi
118 [[ -d /$TESTPOOL ]] && \
119 log_fail "The default mountpoint /$TESTPOOL is created" \
120 "while with $opt option."
121
122 (( i = i + 1 ))
123 done
124 done
125
126 log_pass "'zpool create [-R root][-m mountpoint] <pool> <vdev> ...' works as expected."