Mercurial > illumos > illumos-gate
comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_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 |
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 2009 Sun Microsystems, Inc. All rights reserved. | |
25 # Use is subject to license terms. | |
26 # | |
27 | |
28 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib | |
29 . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_list_d.kshlib | |
30 | |
31 # | |
32 # DESCRIPTION: | |
33 # Setting the valid option and properties, 'zfs get' should return the | |
34 # correct property value. | |
35 # | |
36 # STRATEGY: | |
37 # 1. Create pool, filesystem, volume and snapshot. | |
38 # 2. Setting valid parameter, 'zfs get' should succeed. | |
39 # 3. Compare the output property name with the original input property. | |
40 # | |
41 | |
42 verify_runnable "both" | |
43 | |
44 typeset options=("" "-p" "-r" "-H") | |
45 | |
46 typeset -i i=${#options[*]} | |
47 typeset -i j=0 | |
48 while ((j<${#depth_options[*]})); | |
49 do | |
50 options[$i]=-"${depth_options[$j]}" | |
51 ((j+=1)) | |
52 ((i+=1)) | |
53 done | |
54 | |
55 typeset zfs_props=("type" used available creation volsize referenced \ | |
56 compressratio mounted origin recordsize quota reservation mountpoint \ | |
57 sharenfs checksum compression atime devices exec readonly setuid zoned \ | |
58 snapdir aclmode aclinherit canmount primarycache secondarycache \ | |
59 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ | |
60 version) | |
61 | |
62 typeset userquota_props=(userquota@root groupquota@root userused@root \ | |
63 groupused@root) | |
64 typeset all_props=("${zfs_props[@]}" "${userquota_props[@]}") | |
65 typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ | |
66 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) | |
67 | |
68 # | |
69 # According to dataset and option, checking if 'zfs get' return correct | |
70 # property information. | |
71 # | |
72 # $1 dataset | |
73 # $2 properties which are expected to output into $TESTDIR/$TESTFILE0 | |
74 # $3 option | |
75 # | |
76 function check_return_value | |
77 { | |
78 typeset dst=$1 | |
79 typeset props=$2 | |
80 typeset opt=$3 | |
81 typeset -i found=0 | |
82 typeset p | |
83 | |
84 for p in $props; do | |
85 found=0 | |
86 | |
87 while read line; do | |
88 typeset item | |
89 item=$($ECHO $line | $AWK '{print $2}' 2>&1) | |
90 | |
91 if [[ $item == $p ]]; then | |
92 ((found += 1)) | |
93 break | |
94 fi | |
95 done < $TESTDIR/$TESTFILE0 | |
96 | |
97 if ((found == 0)); then | |
98 log_fail "'zfs get $opt $props $dst' return " \ | |
99 "error message.'$p' haven't been found." | |
100 fi | |
101 done | |
102 | |
103 log_note "SUCCESS: '$ZFS get $opt $prop $dst'." | |
104 } | |
105 | |
106 log_assert "Setting the valid options and properties 'zfs get' should return " \ | |
107 "the correct property value." | |
108 log_onexit cleanup | |
109 | |
110 # Create filesystem and volume's snapshot | |
111 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP | |
112 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP | |
113 | |
114 typeset -i i=0 | |
115 while ((i < ${#dataset[@]})); do | |
116 for opt in "${options[@]}"; do | |
117 for prop in ${all_props[@]}; do | |
118 eval "$ZFS get $opt $prop ${dataset[i]} > \ | |
119 $TESTDIR/$TESTFILE0" | |
120 ret=$? | |
121 if [[ $ret != 0 ]]; then | |
122 log_fail "$ZFS get returned: $ret" | |
123 fi | |
124 check_return_value ${dataset[i]} "$prop" "$opt" | |
125 done | |
126 done | |
127 ((i += 1)) | |
128 done | |
129 | |
130 log_pass "Setting the valid options to dataset, it should succeed and return " \ | |
131 "valid value. 'zfs get' pass." |