xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_set/zfs_set_003_neg.ksh (revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f)
1d583b39bSJohn Wren Kennedy#!/bin/ksh -p
2d583b39bSJohn Wren Kennedy#
3d583b39bSJohn Wren Kennedy# CDDL HEADER START
4d583b39bSJohn Wren Kennedy#
5d583b39bSJohn Wren Kennedy# The contents of this file are subject to the terms of the
6d583b39bSJohn Wren Kennedy# Common Development and Distribution License (the "License").
7d583b39bSJohn Wren Kennedy# You may not use this file except in compliance with the License.
8d583b39bSJohn Wren Kennedy#
9d583b39bSJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d583b39bSJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing.
11d583b39bSJohn Wren Kennedy# See the License for the specific language governing permissions
12d583b39bSJohn Wren Kennedy# and limitations under the License.
13d583b39bSJohn Wren Kennedy#
14d583b39bSJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
15d583b39bSJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16d583b39bSJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
17d583b39bSJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
18d583b39bSJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
19d583b39bSJohn Wren Kennedy#
20d583b39bSJohn Wren Kennedy# CDDL HEADER END
21d583b39bSJohn Wren Kennedy#
22d583b39bSJohn Wren Kennedy
23d583b39bSJohn Wren Kennedy#
24d583b39bSJohn Wren Kennedy# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25d583b39bSJohn Wren Kennedy# Use is subject to license terms.
26d583b39bSJohn Wren Kennedy#
27d583b39bSJohn Wren Kennedy
28*1d32ba66SJohn Wren Kennedy#
29*1d32ba66SJohn Wren Kennedy# Copyright (c) 2016 by Delphix. All rights reserved.
30*1d32ba66SJohn Wren Kennedy#
31*1d32ba66SJohn Wren Kennedy
32d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
33d583b39bSJohn Wren Kennedy
34d583b39bSJohn Wren Kennedy#
35d583b39bSJohn Wren Kennedy# DESCRIPTION:
36d583b39bSJohn Wren Kennedy# 'zfs set mountpoint/sharenfs' should fail when the mountpoint is invlid
37d583b39bSJohn Wren Kennedy#
38d583b39bSJohn Wren Kennedy# STRATEGY:
39d583b39bSJohn Wren Kennedy# 1. Create invalid scenarios
40d583b39bSJohn Wren Kennedy# 2. Run zfs set mountpoint/sharenfs with invalid value
41d583b39bSJohn Wren Kennedy# 3. Verify that zfs set returns expected errors
42d583b39bSJohn Wren Kennedy#
43d583b39bSJohn Wren Kennedy
44d583b39bSJohn Wren Kennedyverify_runnable "both"
45d583b39bSJohn Wren Kennedy
46d583b39bSJohn Wren Kennedyfunction cleanup
47d583b39bSJohn Wren Kennedy{
48d583b39bSJohn Wren Kennedy	if [ -e $badpath ]; then
49*1d32ba66SJohn Wren Kennedy		rm -f $badpath
50d583b39bSJohn Wren Kennedy	fi
51d583b39bSJohn Wren Kennedy	if datasetexists $TESTPOOL/foo; then
52*1d32ba66SJohn Wren Kennedy		log_must zfs destroy $TESTPOOL/foo
53d583b39bSJohn Wren Kennedy	fi
54d583b39bSJohn Wren Kennedy}
55d583b39bSJohn Wren Kennedy
56d583b39bSJohn Wren Kennedylog_assert "'zfs set mountpoint/sharenfs' fails with invalid scenarios"
57d583b39bSJohn Wren Kennedylog_onexit cleanup
58d583b39bSJohn Wren Kennedy
59d583b39bSJohn Wren Kennedybadpath=/tmp/foo1.$$
60*1d32ba66SJohn Wren Kennedytouch $badpath
61d583b39bSJohn Wren Kennedylongpath=$(gen_dataset_name 1030 "abcdefg")
62d583b39bSJohn Wren Kennedy
63*1d32ba66SJohn Wren Kennedylog_must zfs create -o mountpoint=legacy $TESTPOOL/foo
64d583b39bSJohn Wren Kennedy
65d583b39bSJohn Wren Kennedy# Do the negative testing about "property may be set but unable to remount filesystem"
66*1d32ba66SJohn Wren Kennedylog_mustnot eval "zfs set mountpoint=$badpath $TESTPOOL/foo >/dev/null 2>&1"
67d583b39bSJohn Wren Kennedy
68d583b39bSJohn Wren Kennedy# Do the negative testing about "property may be set but unable to reshare filesystem"
69*1d32ba66SJohn Wren Kennedylog_mustnot eval "zfs set sharenfs=on $TESTPOOL/foo >/dev/null 2>&1"
70d583b39bSJohn Wren Kennedy
71d583b39bSJohn Wren Kennedy# Do the negative testing about "sharenfs property can not be set to null"
72*1d32ba66SJohn Wren Kennedylog_mustnot eval "zfs set sharenfs= $TESTPOOL/foo >/dev/null 2>&1"
73d583b39bSJohn Wren Kennedy
74d583b39bSJohn Wren Kennedy# Do the too long pathname testing (>1024)
75*1d32ba66SJohn Wren Kennedylog_mustnot eval "zfs set mountpoint=/$longpath $TESTPOOL/foo >/dev/null 2>&1"
76d583b39bSJohn Wren Kennedy
77d583b39bSJohn Wren Kennedylog_pass "'zfs set mountpoint/sharenfs' fails with invalid scenarios as expected."
78