1eda14cbcSMatt Macy#!/bin/ksh -p
2eda14cbcSMatt Macy#
3eda14cbcSMatt Macy# This file and its contents are supplied under the terms of the
4eda14cbcSMatt Macy# Common Development and Distribution License ("CDDL"), version 1.0.
5eda14cbcSMatt Macy# You may only use this file in accordance with the terms of version
6eda14cbcSMatt Macy# 1.0 of the CDDL.
7eda14cbcSMatt Macy#
8eda14cbcSMatt Macy# A full copy of the text of the CDDL should have accompanied this
9eda14cbcSMatt Macy# source.  A copy of the CDDL is also available via the Internet at
10eda14cbcSMatt Macy# http://www.illumos.org/license/CDDL.
11eda14cbcSMatt Macy#
12eda14cbcSMatt Macy
13eda14cbcSMatt Macy#
14eda14cbcSMatt Macy# Copyright (c) 2017 by Delphix. All rights reserved.
15eda14cbcSMatt Macy#
16eda14cbcSMatt Macy
17eda14cbcSMatt Macy. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib
18eda14cbcSMatt Macy
19eda14cbcSMatt Macy#
20eda14cbcSMatt Macy# DESCRIPTION:
21eda14cbcSMatt Macy#       zfs.exists should accurately report whether a dataset exists, and
22eda14cbcSMatt Macy#       report an error if a dataset is in another pool.
23eda14cbcSMatt Macy
24eda14cbcSMatt Macyverify_runnable "global"
25eda14cbcSMatt Macy
26eda14cbcSMatt Macy# create $TESTSNAP and $TESTCLONE
27eda14cbcSMatt Macycreate_snapshot
28eda14cbcSMatt Macycreate_clone
29eda14cbcSMatt Macy
30eda14cbcSMatt Macyfunction cleanup
31eda14cbcSMatt Macy{
32eda14cbcSMatt Macy	datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \
3381b22a98SMartin Matuska	    destroy_dataset $TESTPOOL/$TESTFS@$TESTSNAP -R
34eda14cbcSMatt Macy}
35eda14cbcSMatt Macy
36eda14cbcSMatt Macylog_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \
37eda14cbcSMatt Macy    $TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS@$TESTSNAP \
38eda14cbcSMatt Macy    $TESTPOOL/$TESTCLONE
39eda14cbcSMatt Macy
40eda14cbcSMatt Macylog_mustnot_checkerror_program "not in the target pool" \
41*716fd348SMartin Matuska    $TESTPOOL - <<<"return zfs.exists('rpool')"
42eda14cbcSMatt Macy
43eda14cbcSMatt Macylog_pass "zfs.exists() gives correct results"
44