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