canmount_001_pos.ksh revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f
0N/A#!/bin/ksh -p
0N/A#
0N/A# CDDL HEADER START
0N/A#
407N/A# The contents of this file are subject to the terms of the
0N/A# Common Development and Distribution License (the "License").
0N/A# You may not use this file except in compliance with the License.
0N/A#
0N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A# or http://www.opensolaris.org/os/licensing.
0N/A# See the License for the specific language governing permissions
0N/A# and limitations under the License.
0N/A#
0N/A# When distributing Covered Code, include this CDDL HEADER in each
0N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A# If applicable, add the following below this CDDL HEADER, with the
0N/A# fields enclosed by brackets "[]" replaced with your own identifying
0N/A# information: Portions Copyright [yyyy] [name of copyright owner]
0N/A#
0N/A# CDDL HEADER END
0N/A#
0N/A
0N/A#
0N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
0N/A# Use is subject to license terms.
0N/A#
4N/A
421N/A#
0N/A# Copyright (c) 2016 by Delphix. All rights reserved.
0N/A#
0N/A
0N/A. $STF_SUITE/include/libtest.shlib
421N/A. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
0N/A
165N/A#
165N/A# DESCRIPTION:
165N/A# Setting valid canmount to filesystem, it is successful.
165N/A# Whatever is set to volume or snapshot, it is failed.
165N/A# 'zfs set canmount=on|off <fs>'
165N/A#
165N/A# STRATEGY:
165N/A# 1. Setup a pool and create fs, volume, snapshot clone within it.
165N/A# 2. Loop all the valid mountpoint value.
165N/A# 3. Check the return value.
165N/A#
165N/A
165N/Averify_runnable "both"
165N/A
165N/Aset -A dataset_pos \
165N/A "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTCLONE"
165N/A
165N/Aif is_global_zone ; then
165N/A set -A dataset_neg \
165N/A "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS@$TESTSNAP" \
165N/A "$TESTPOOL/$TESTVOL@$TESTSNAP" "$TESTPOOL/$TESTCLONE1"
165N/Aelse
165N/A set -A dataset_neg \
165N/A "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTVOL@$TESTSNAP"
165N/Afi
165N/A
165N/A
165N/Aset -A values "on" "off"
165N/A
165N/Afunction cleanup
165N/A{
165N/A if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then
165N/A log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
165N/A fi
165N/A if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then
165N/A log_must zfs destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP
165N/A fi
165N/A
165N/A [[ -n $old_ctr_canmount ]] && \
165N/A log_must zfs set canmount=$old_ctr_canmount $TESTPOOL/$TESTCTR
165N/A [[ -n $old_fs_canmount ]] && \
165N/A log_must zfs set canmount=$old_fs_canmount $TESTPOOL/$TESTFS
165N/A
165N/A zfs unmount -a > /dev/null 2>&1
165N/A log_must zfs mount -a
165N/A}
165N/A
165N/Alog_assert "Setting a valid property of canmount to file system, it must be successful."
165N/Alog_onexit cleanup
165N/A
165N/Atypeset old_fs_canmount="" old_ctr_canmount=""
165N/A
165N/Aold_fs_canmount=$(get_prop canmount $TESTPOOL/$TESTFS)
165N/A[[ $? != 0 ]] && \
165N/A log_fail "Get the $TESTPOOL/$TESTFS canmount error."
165N/Aold_ctr_canmount=$(get_prop canmount $TESTPOOL/$TESTCTR)
165N/A[[ $? != 0 ]] && \
165N/A log_fail "Get the $TESTPOOL/$TESTCTR canmount error."
165N/A
165N/Alog_must zfs snapshot $TESTPOOL/$TESTFS@$TESTSNAP
165N/Alog_must zfs snapshot $TESTPOOL/$TESTVOL@$TESTSNAP
165N/Alog_must zfs clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE
165N/Alog_must zfs clone $TESTPOOL/$TESTVOL@$TESTSNAP $TESTPOOL/$TESTCLONE1
165N/A
165N/Afor dataset in "${dataset_pos[@]}" ; do
165N/A for value in "${values[@]}" ; do
165N/A set_n_check_prop "$value" "canmount" "$dataset"
165N/A if [[ $value == "off" ]]; then
165N/A log_mustnot ismounted $dataset
165N/A log_mustnot zfs mount $dataset
165N/A log_mustnot ismounted $dataset
165N/A else
165N/A if ! ismounted $dataset ; then
165N/A log_must zfs mount $dataset
165N/A fi
165N/A log_must ismounted $dataset
165N/A fi
165N/A done
165N/Adone
165N/A
762N/Afor dataset in "${dataset_neg[@]}" ; do
165N/A for value in "${values[@]}" ; do
0N/A set_n_check_prop "$value" "canmount" \
0N/A "$dataset" "false"
0N/A log_mustnot ismounted $dataset
0N/A done
0N/Adone
0N/A
0N/Alog_pass "Setting canmount to filesystem pass."
0N/A