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# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# 31 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 \ 52 sharenfs checksum compression atime devices exec readonly setuid zoned \ 53 snapdir aclmode aclinherit canmount primarycache secondarycache \ 54 usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version) 55 56typeset userquota_props=(userquota@root groupquota@root userused@root \ 57 groupused@root) 58typeset props=("${zfs_props[@]}" "${userquota_props[@]}") 59typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ 60 $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) 61 62log_assert "Setting the valid options and properties 'zfs get' return " \ 63 "correct value. It should be successful." 64log_onexit cleanup 65 66# Create volume and filesystem's snapshot 67create_snapshot $TESTPOOL/$TESTFS $TESTSNAP 68create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP 69 70# 71# Begin to test 'get [-prH] <property[,property]...> 72# <filesystem|dataset|volume|snapshot>' 73# 'get [-prH] <-a|-d> <filesystem|dataset|volume|snapshot>" 74# 75typeset -i opt_numb=8 76typeset -i prop_numb=20 77for dst in ${dataset[@]}; do 78 # option can be empty, so "" is necessary. 79 for opt in "" $(gen_option_str "${options[*]}" "-" "" $opt_numb); do 80 for prop in $(gen_option_str "${props[*]}" "" "," $prop_numb) 81 do 82 zfs get $opt $prop $dst > /dev/null 2>&1 83 ret=$? 84 if [[ $ret != 0 ]]; then 85 log_fail "zfs get $opt $prop $dst (Code: $ret)" 86 fi 87 done 88 done 89done 90 91log_pass "Setting the valid options to dataset, 'zfs get' pass." 92