1#!/bin/ksh -p
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2015 by Delphix. All rights reserved.
15#
16
17. $STF_SUITE/include/libtest.shlib
18
19#
20# DESCRIPTION:
21#   Verify that zfs mount succeeds with a non-empty directory
22#
23
24#
25# STRATEGY:
26# 1. Unmount the dataset
27# 2. Create a new empty directory
28# 3. Set the dataset's mountpoint, this should mount the dataset
29# 4. Verify the mount succeeds
30# 5. Unmount the dataset
31# 6. Create a file in the directory created in step 2
32# 7. Attempt to mount the dataset
33# 8. Verify the mount succeeds
34#
35
36verify_runnable "both"
37
38log_assert "zfs mount succeeds with non-empty directory"
39
40fs=$TESTPOOL/$TESTFS
41
42log_must zfs umount $fs
43log_must mkdir -p $TESTDIR
44log_must zfs set mountpoint=$TESTDIR $fs
45log_must ismounted $fs
46log_must zfs umount $fs
47log_must touch $TESTDIR/testfile.$$
48log_must zfs mount $fs
49log_must zfs umount $fs
50log_must rm -rf $TESTDIR
51
52log_pass "zfs mount succeeds with non-empty directory as expected."
53