1#!/usr/local/bin/ksh93 -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 http://www.opensolaris.org/os/licensing.
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 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26. $STF_SUITE/include/libtest.kshlib
27
28################################################################################
29#
30# __stc_assertion_start
31#
32# ID: zfs_promote_007_neg
33#
34# DESCRIPTION:
35#	'zfs promote' can deal with conflicts in the namespaces.
36#
37# STRATEGY:
38#	1. Create a snapshot and a clone of the snapshot
39#	2. Create the same name snapshot for the clone
40#	3. Promote the clone filesystem
41#	4. Verify the promote operation fail due to the name conflicts.
42#
43# TESTABILITY: explicit
44#
45# TEST_AUTOMATION_LEVEL: automated
46#
47# CODING_STATUS: COMPLETED (2006-05-16)
48#
49# __stc_assertion_end
50#
51################################################################################
52
53verify_runnable "both"
54
55function cleanup
56{
57	snapexists $snap && \
58		log_must $ZFS destroy -rR $snap
59
60	typeset data
61	for data in $TESTDIR/$TESTFILE0 $TESTDIR/$TESTFILE1; do
62		[[ -e $data ]] && $RM -f $data
63	done
64}
65
66log_assert "'zfs promote' can deal with name conflicts."
67log_onexit cleanup
68
69snap=$TESTPOOL/$TESTFS@$TESTSNAP
70clone=$TESTPOOL/$TESTCLONE
71clonesnap=$TESTPOOL/$TESTCLONE@$TESTSNAP
72
73# setup for promte testing
74log_must $MKFILE $FILESIZE $TESTDIR/$TESTFILE0
75log_must $ZFS snapshot $snap
76log_must $MKFILE $FILESIZE $TESTDIR/$TESTFILE1
77log_must $RM -f $TESTDIR/$TESTFILE0
78log_must $ZFS clone $snap $clone
79log_must $MKFILE $FILESIZE /$clone/$CLONEFILE
80log_must $ZFS snapshot $clonesnap
81
82log_mustnot $ZFS promote $clone
83
84log_pass "'zfs promote' deals with name conflicts as expected."
85
86