Mercurial > illumos > illumos-gate
comparison usr/src/test/zfs-tests/tests/functional/cli_root/zpool_add/zpool_add.kshlib @ 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 2007 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_add/zpool_add.cfg | |
33 | |
34 # | |
35 # check if the <pool> contains <vdev> ... | |
36 # | |
37 # $1 pool | |
38 # $2..n <vdev> ... | |
39 # | |
40 # Return 0 if <vdev> are contained in the <pool>; 1 if not used; 2 if pool | |
41 # name is missing | |
42 # | |
43 function iscontained | |
44 { | |
45 typeset pool=$1 | |
46 typeset vdev | |
47 | |
48 if [[ -z $pool ]]; then | |
49 log_note "Missing pool name." | |
50 return 2 | |
51 fi | |
52 | |
53 shift | |
54 | |
55 for vdev in $@; do | |
56 | |
57 # remove /dev/dsk in vdev if there is | |
58 $ECHO $vdev | $GREP "^/dev/dsk" >/dev/null 2>&1 | |
59 (( $? == 0 )) && \ | |
60 vdev=${vdev##*/} | |
61 | |
62 $ZPOOL status "$pool" | $AWK '$1 == vdevname {exit 1}' \ | |
63 vdevname=$vdev >/dev/null 2>&1 | |
64 (( $? != 1 )) && \ | |
65 return 1 | |
66 done | |
67 | |
68 return 0; | |
69 | |
70 } | |
71 | |
72 # | |
73 # Find the storage device in /etc/vfstab | |
74 # | |
75 function find_vfstab_dev | |
76 { | |
77 typeset vfstab="/etc/vfstab" | |
78 typeset tmpfile="/tmp/vfstab.tmp" | |
79 typeset vfstabdev | |
80 typeset vfstabdevs="" | |
81 typeset line | |
82 | |
83 $CAT $vfstab | $GREP "^/dev/dsk" >$tmpfile | |
84 while read -r line | |
85 do | |
86 vfstabdev=`$ECHO "$line" | $AWK '{print $1}'` | |
87 vfstabdev=${vfstabdev%%:} | |
88 vfstabdevs="$vfstabdev $vfstabdevs" | |
89 done <$tmpfile | |
90 | |
91 $RM -f $tmpfile | |
92 $ECHO $vfstabdevs | |
93 } | |
94 | |
95 # | |
96 # Find the storage device in /etc/mnttab | |
97 # | |
98 function find_mnttab_dev | |
99 { | |
100 typeset mnttab="/etc/mnttab" | |
101 typeset tmpfile="/tmp/mnttab.tmp" | |
102 typeset mnttabdev | |
103 typeset mnttabdevs="" | |
104 typeset line | |
105 | |
106 $CAT $mnttab | $GREP "^/dev/dsk" >$tmpfile | |
107 while read -r line | |
108 do | |
109 mnttabdev=`$ECHO "$line" | $AWK '{print $1}'` | |
110 mnttabdev=${mnttabdev%%:} | |
111 mnttabdevs="$mnttabdev $mnttabdevs" | |
112 done <$tmpfile | |
113 | |
114 $RM -f $tmpfile | |
115 $ECHO $mnttabdevs | |
116 } | |
117 | |
118 # | |
119 # Save the systme current dump device configuration | |
120 # | |
121 function save_dump_dev | |
122 { | |
123 | |
124 typeset dumpdev | |
125 typeset fnd="Dump device" | |
126 | |
127 dumpdev=`$DUMPADM | $GREP "$fnd" | $CUT -f2 -d : | \ | |
128 $AWK '{print $1}'` | |
129 $ECHO $dumpdev | |
130 } | |
131 | |
132 # | |
133 # Common cleanup routine for partitions used in testing | |
134 # | |
135 function partition_cleanup | |
136 { | |
137 | |
138 if [[ -n $DISK ]]; then | |
139 partition_disk $SIZE $DISK 7 | |
140 else | |
141 typeset disk="" | |
142 for disk in $DISK0 $DISK1; do | |
143 partition_disk $SIZE $disk 7 | |
144 done | |
145 fi | |
146 | |
147 } |