comparison usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create.shlib @ 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
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26
27 #
28 # Copyright (c) 2012 by Delphix. All rights reserved.
29 #
30
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.cfg
33
34 #
35 # Given a pool vdevs list, create the pool,verify the created pool,
36 # and destroy the pool
37 # $1, pool name
38 # $2, pool type, mirror, raidz, or none
39 # $3, vdevs list
40 #
41 function create_pool_test
42 {
43 typeset pool=$1
44 typeset keywd=$2
45 typeset vdevs
46 eval "typeset -a diskarray=($3)"
47
48 for vdevs in "${diskarray[@]}";do
49 create_pool $pool $keywd $vdevs
50 log_must poolexists $pool
51 destroy_pool $pool
52 done
53 }
54
55 #
56 # Create a ufs file system and make a file within the file
57 # system for storage pool vdev
58 # $1, file size
59 # $2, file name
60 # $3, disk name to create ufs file system
61 #
62 function create_blockfile
63 {
64 typeset size=$1
65 typeset file=$2
66 typeset disk=$3
67 typeset dir=`$DIRNAME $file`
68
69 if [[ -d $dir ]]; then
70 ismounted $dir ufs
71 (( $? == 0 )) && \
72 log_must $UMOUNT -f $dir
73 else
74 log_must $MKDIR -p $dir
75 fi
76
77 $ECHO "y" | $NEWFS /dev/rdsk/$disk >/dev/null 2>&1
78 (( $? != 0 )) &&
79 log_fail "Create ufs file system fail."
80
81 log_must $MOUNT /dev/dsk/$disk $dir
82 log_must $MKFILE $size $file
83 }
84
85 #
86 # Umount the ufs filesystem and remove the mountpoint
87 # $1, the mount point
88 #
89 function clean_blockfile
90 {
91 typeset dirs=$1
92
93 for dir in $dirs; do
94 if [[ -d $dir ]]; then
95 if ismounted $dir ufs; then
96 typeset dev=$($DF -lhF ufs | $GREP "$dir" | \
97 $AWK '{print $1}')
98 log_must $UMOUNT -f $dir
99 create_pool ${TESTPOOL}.tmp $dev
100 destroy_pool ${TESTPOOL}.tmp
101 fi
102 log_must $RM -rf $dir
103 fi
104 done
105 }
106
107 #
108 # Find the storage device in /etc/vfstab
109 #
110 function find_vfstab_dev
111 {
112 typeset vfstab="/etc/vfstab"
113 typeset tmpfile="/tmp/vfstab.tmp"
114 typeset vfstabdev
115 typeset vfstabdevs=""
116 typeset line
117
118 $CAT $vfstab | $GREP "^/dev/dsk" >$tmpfile
119 while read -r line
120 do
121 vfstabdev=`$ECHO "$line" | $AWK '{print $1}'`
122 vfstabdev=${vfstabdev%%:}
123 vfstabdevs="$vfstabdev $vfstabdevs"
124 done <$tmpfile
125
126 $RM -f $tmpfile
127 $ECHO $vfstabdevs
128 }
129
130 #
131 # Save the systme current dump device configuration
132 #
133 function save_dump_dev
134 {
135
136 typeset dumpdev
137 typeset fnd="Dump device"
138
139 dumpdev=`$DUMPADM | $GREP "$fnd" | $CUT -f2 -d : | \
140 $AWK '{print $1}'`
141 $ECHO $dumpdev
142 }