d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#!/bin/ksh -p
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy#
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2016 by Delphix. All rights reserved.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy#
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# DESCRIPTION:
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Setting the invalid option and properties, 'zfs get' should failed.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# STRATEGY:
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Create pool, filesystem, volume and snapshot.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Getting incorrect combination by invalid parameters
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Using the combination as the parameters of 'zfs get' to check the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# command line return value.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyverify_runnable "both"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset val_opts=(p r H)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset v_props=(type used available creation volsize referenced compressratio \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy mounted origin recordsize quota reservation mountpoint sharenfs checksum \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy compression atime devices exec readonly setuid zoned snapdir aclmode \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy aclinherit canmount primarycache secondarycache \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy usedbychildren usedbydataset usedbyrefreservation usedbysnapshots version)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset userquota_props=(userquota@root groupquota@root userused@root \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy groupused@root)
4220fdc152e5dfec9a1dd51452175295f3684689Marcel Telkatypeset val_props=("${v_props[@]}" "${userquota_props[@]}")
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyset -f # Force shell does not parse '?' and '*' as the wildcard
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset inval_opts=(P R h ? *)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset inval_props=(Type 0 ? * -on --on readonl time USED RATIO MOUNTED)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset dataset=($TESTPOOL/$TESTFS $TESTPOOL/$TESTCTR $TESTPOOL/$TESTVOL \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset -i opt_numb=6
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytypeset -i prop_numb=12
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyval_opts_str=$(gen_option_str "${val_opts[*]}" "-" "" $opt_numb)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyval_props_str=$(gen_option_str "${val_props[*]}" "" "," $prop_numb)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyinval_opts_str=$(gen_option_str "${inval_opts[*]}" "-" "" $opt_numb)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyinval_props_str=$(gen_option_str "${inval_props[*]}" "" "," $prop_numb)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkatypeset val_bookmark_props=(creation)
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkatypeset bookmark=($TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK)
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Test different options and properties combination.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1 options
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2 properties
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyfunction test_options
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy{
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset opts=$1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset props=$2
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy for dst in ${dataset[@]}; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy for opt in $opts; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy for prop in $props; do
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy zfs get $opt -- $prop $dst > /dev/null 2>&1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy ret=$?
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ $ret == 0 ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_fail "zfs get $opt -- $prop " \
4220fdc152e5dfec9a1dd51452175295f3684689Marcel Telka "$dst unexpectedly succeeded."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy fi
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy done
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy done
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy done
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy}
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka#
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka# Test different options and properties combination for bookmarks.
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka#
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka# $1 options
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka# $2 properties
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka#
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkafunction test_options_bookmarks
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka{
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka typeset opts=$1
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka typeset props=$2
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka for dst in ${bookmark[@]}; do
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka for opt in $opts; do
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka for prop in $props; do
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka $ZFS get $opt -- $prop $dst > /dev/null 2>&1
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka ret=$?
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka if [[ $ret == 0 ]]; then
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka log_fail "$ZFS get $opt -- $prop " \
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka "$dst unexpectedly succeeded."
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka fi
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka done
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka done
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka done
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka}
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Setting the invalid option and properties, 'zfs get' should be \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy failed."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_onexit cleanup
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Create filesystem and volume's snapshot
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedycreate_snapshot $TESTPOOL/$TESTFS $TESTSNAP
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedycreate_snapshot $TESTPOOL/$TESTVOL $TESTSNAP
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka# Create filesystem and volume's bookmark
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkacreate_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkacreate_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telka
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Valid options + invalid properties, 'zfs get' should fail."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytest_options "$val_opts_str" "$inval_props_str"
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkatest_options_bookmark "$val_opts_str" "$inval_props_str"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Invalid options + valid properties, 'zfs get' should fail."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytest_options "$inval_opts_str" "$val_props_str"
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkatest_options_bookmark "$inval_opts_str" "$val_bookmark_props"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "Invalid options + invalid properties, 'zfs get' should fail."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedytest_options "$inval_opts_str" "$inval_props_str"
edb901aab9c738b5eb15aa55933e82b0f2f9d9a2Marcel Telkatest_options_bookmarks "$inval_opts_str" "$inval_props_str"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Setting the invalid options to dataset, 'zfs get' pass."