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) 2016 by Delphix. All rights reserved.
15#
16
17. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib
18
19#
20# DESCRIPTION:
21#	Getting dataset mountpoint should work correctly.
22#
23
24verify_runnable "global"
25
26fs=$TESTPOOL/testmount
27snap=$fs@$TESTSNAP
28clone=$TESTPOOL/$TESTCLONE
29mnt1=/$fs/mnt1
30mnt2=/$fs/mnt2
31
32function cleanup
33{
34	datasetexists $clone && log_must zfs destroy $clone
35	datasetexists $fs && log_must zfs destroy -R $fs
36	log_must rm -rf $mnt1
37	log_must rm -rf $mnt2
38}
39
40log_onexit cleanup
41
42log_must zfs create $fs
43create_snapshot $fs $TESTSNAP
44create_clone $snap $clone
45
46log_must_program $TESTPOOL - <<-EOF
47	ans, src = zfs.get_prop("$fs", "mountpoint")
48        assert(ans == '/$fs')
49        assert(src == 'default')
50EOF
51
52log_must_program $TESTPOOL - <<-EOF
53	ans, src = zfs.get_prop("$snap", "mountpoint")
54	assert(ans == nil)
55	assert(src == nil)
56EOF
57
58log_must_program $TESTPOOL - <<-EOF
59	ans, src = zfs.get_prop("$clone", "mountpoint")
60	assert(ans == '/$clone')
61	assert(src == 'default')
62EOF
63
64log_must mkdir $mnt1
65log_must mkdir $mnt2
66
67log_must zfs set mountpoint=$mnt1 $fs
68log_must zfs set mountpoint=$mnt2 $clone
69
70log_must_program $TESTPOOL - <<-EOF
71	ans, src = zfs.get_prop("$fs", "mountpoint")
72	assert(ans == '$mnt1')
73	assert(src == '$fs')
74EOF
75
76log_must_program $TESTPOOL - <<-EOF
77	ans, src = zfs.get_prop("$snap", "mountpoint")
78	assert(ans == nil)
79	assert(src == nil)
80EOF
81
82log_must_program $TESTPOOL - <<-EOF
83	ans, src = zfs.get_prop("$clone", "mountpoint")
84	assert(ans == '$mnt2')
85	assert(src == '$clone')
86EOF
87
88log_pass "Getting dataset mountpoint should work correctly."
89