7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / cli_root / zfs_share / zfs_share_006_pos.ksh
blob6b06589b69e291195deaebe3239fb7a7d884c12a
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) 2016 by Delphix. All rights reserved.
32 . $STF_SUITE/include/libtest.shlib
35 # DESCRIPTION:
36 # Verify that a dataset could not be shared but filesystems are shared.
38 # STRATEGY:
39 # 1. Create a dataset and file system
40 # 2. Set the sharenfs property on the dataset
41 # 3. Verify that the dataset is unable be shared.
42 # 4. Add a new file system to the dataset.
43 # 5. Verify that the newly added file system be shared.
46 verify_runnable "global"
48 function cleanup
50 log_must zfs set sharenfs=off $TESTPOOL/$TESTCTR
51 if mounted $TESTDIR2; then
52 log_must zfs unmount $TESTDIR2
55 datasetexists $TESTPOOL/$TESTCTR/$TESTFS2 && \
56 log_must zfs destroy $TESTPOOL/$TESTCTR/$TESTFS2
58 typeset fs=""
59 for fs in $mntp $TESTDIR1 $TESTDIR2
61 log_must unshare_fs $fs
62 done
66 # Main test routine.
68 # Given a mountpoint and a dataset, this routine will set the
69 # sharenfs property on the dataset and verify that dataset
70 # is unable to be shared but the existing contained file systems
71 # could be shared.
73 function test_ctr_share # mntp ctr
75 typeset mntp=$1
76 typeset ctr=$2
78 not_shared $mntp || \
79 log_fail "Mountpoint: $mntp is already shared."
81 log_must zfs set sharenfs=on $ctr
83 not_shared $mntp || \
84 log_fail "File system $mntp is shared (set sharenfs)."
87 # Add a new file system to the dataset and verify it is shared.
89 typeset mntp2=$TESTDIR2
90 log_must zfs create $ctr/$TESTFS2
91 log_must zfs set mountpoint=$mntp2 $ctr/$TESTFS2
93 is_shared $mntp2 || \
94 log_fail "File system $mntp2 was not shared (set sharenfs)."
97 log_assert "Verify that a dataset could not be shared, " \
98 "but its sub-filesystems could be shared."
99 log_onexit cleanup
101 typeset mntp=$(get_prop mountpoint $TESTPOOL/$TESTCTR)
102 test_ctr_share $mntp $TESTPOOL/$TESTCTR
104 log_pass "A dataset could not be shared, " \
105 "but its sub-filesystems could be shared as expect."