7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_set / mountpoint_001_pos.ksh
blob1255ae5f56669cfe118c0aa33e436aebdf47c665
1 #!/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
36 # DESCRIPTION:
37 # Setting valid mountpoint to filesystem, it is successful.
38 # Whatever is set to volume, it is failed.
39 # 'zfs set mountpoint=<path>|legacy|none <fs|ctr|vol>'
41 # STRATEGY:
42 # 1. Setup a pool and create fs, ctr within it.
43 # 2. Loop all the valid mountpoint value.
44 # 3. Check the return value.
47 verify_runnable "both"
49 export TESTDIR_NOTEXISTING=${TEST_BASE_DIR%%/}/testdir_notexisting$$
51 if is_global_zone ; then
52 set -A dataset \
53 "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTVOL"
54 else
55 set -A dataset "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR"
58 set -A values "$TESTDIR2" "legacy" "none" "$TESTDIR_NOTEXISTING"
60 function cleanup
62 log_must zfs set mountpoint=$old_ctr_mpt $TESTPOOL/$TESTCTR
63 log_must zfs set mountpoint=$old_fs_mpt $TESTPOOL/$TESTFS
64 [[ -d $TESTDIR2 ]] && log_must rm -r $TESTDIR2
65 [[ -d $TESTDIR_NOTEXISTING ]] && log_must rm -r $TESTDIR_NOTEXISTING
68 log_assert "Setting a valid mountpoint to file system, it must be successful."
69 log_onexit cleanup
71 old_fs_mpt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
72 [[ $? != 0 ]] && \
73 log_fail "Get the $TESTPOOL/$TESTFS mountpoint error."
74 old_ctr_mpt=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
75 [[ $? != 0 ]] && \
76 log_fail "Get the $TESTPOOL/$TESTCTR mountpoint error."
78 if [[ ! -d $TESTDIR2 ]]; then
79 log_must mkdir $TESTDIR2
82 typeset -i i=0
83 typeset -i j=0
84 while (( i < ${#dataset[@]} )); do
85 j=0
86 while (( j < ${#values[@]} )); do
87 if [[ ${dataset[i]} == "$TESTPOOL/$TESTVOL" ]]; then
88 set_n_check_prop "${values[j]}" "mountpoint" \
89 "${dataset[i]}" "false"
90 else
91 set_n_check_prop "${values[j]}" "mountpoint" \
92 "${dataset[i]}"
94 (( j += 1 ))
95 done
96 cleanup
97 (( i += 1 ))
98 done
100 log_pass "Setting mountpoint to filesystem pass."