]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_002_pos.ksh
Add the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_get / zfs_get_002_pos.ksh
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
30 #
31 # DESCRIPTION:
32 # Setting the valid option and properties 'zfs get' return correct value.
33 # It should be successful.
34 #
35 # STRATEGY:
36 # 1. Create pool, filesystem, dataset, volume and snapshot.
37 # 2. Getting the options and properties random combination.
38 # 3. Using the combination as the parameters of 'zfs get' to check the
39 # command line return value.
40 #
41
42 verify_runnable "both"
43
44 typeset options=(" " p r H)
45
46 typeset zfs_props=("type" used available creation volsize referenced \
47 compressratio mounted origin recordsize quota reservation mountpoint \
48 sharenfs checksum compression atime devices exec readonly setuid zoned \
49 snapdir acltype aclinherit canmount primarycache secondarycache \
50 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version)
51
52 typeset userquota_props=(userquota@root groupquota@root userused@root \
53 groupused@root)
54 typeset props=("${zfs_props[@]}" "${userquota_props[@]}")
55 typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \
56 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)
57
58 log_assert "Setting the valid options and properties 'zfs get' return " \
59 "correct value. It should be successful."
60 log_onexit cleanup
61
62 # Create volume and filesystem's snapshot
63 create_snapshot $TESTPOOL/$TESTFS $TESTSNAP
64 create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
65
66 #
67 # Begin to test 'get [-prH] <property[,property]...>
68 # <filesystem|dataset|volume|snapshot>'
69 # 'get [-prH] <-a|-d> <filesystem|dataset|volume|snapshot>"
70 #
71 typeset -i opt_numb=8
72 typeset -i prop_numb=20
73 for dst in ${dataset[@]}; do
74 # option can be empty, so "" is necessary.
75 for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do
76 for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb)
77 do
78 $ZFS get $opt $prop $dst > /dev/null 2>&1
79 ret=$?
80 if [[ $ret != 0 ]]; then
81 log_fail "$ZFS get $opt $prop $dst (Code: $ret)"
82 fi
83 done
84 done
85 done
86
87 log_pass "Setting the valid options to dataset, 'zfs get' pass."