1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
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.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or https://opensource.org/licenses/CDDL-1.0.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
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]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2016, loli10K. All rights reserved.
25# Copyright (c) 2018 by Delphix. All rights reserved.
26#
27
28. $STF_SUITE/include/libtest.shlib
29
30#
31# DESCRIPTION:
32# Verify that 'zfs destroy' on a shared dataset, will unshare it.
33#
34# STRATEGY:
35# 1. Create and share a dataset with sharenfs.
36# 2. Verify the dataset is shared.
37# 3. Invoke 'zfs destroy' on the dataset.
38# 4. Verify the dataset is not shared.
39#
40
41verify_runnable "global"
42
43function cleanup
44{
45	datasetexists "$TESTPOOL/$TESTFS/shared1" && \
46		destroy_dataset $TESTPOOL/$TESTFS/shared1 -f
47}
48
49log_assert "Verify 'zfs destroy' will unshare the dataset"
50log_onexit cleanup
51
52# 1. Create and share a dataset with sharenfs.
53log_must zfs create \
54	-o sharenfs=on -o mountpoint=$TESTDIR/1 $TESTPOOL/$TESTFS/shared1
55
56#
57# 2. Verify the datasets is shared.
58#
59log_must is_shared $TESTDIR/1
60
61# 3. Invoke 'zfs destroy' on the dataset.
62log_must zfs destroy -f $TESTPOOL/$TESTFS/shared1
63
64# 4. Verify the dataset is not shared.
65log_mustnot is_shared $TESTDIR/1
66
67log_pass "'zfs destroy' will unshare the dataset."
68