13b1068dasomers#!/usr/local/bin/ksh93 -p
23b1068dasomers#
33b1068dasomers# CDDL HEADER START
43b1068dasomers#
53b1068dasomers# The contents of this file are subject to the terms of the
63b1068dasomers# Common Development and Distribution License (the "License").
73b1068dasomers# You may not use this file except in compliance with the License.
83b1068dasomers#
93b1068dasomers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
103b1068dasomers# or http://www.opensolaris.org/os/licensing.
113b1068dasomers# See the License for the specific language governing permissions
123b1068dasomers# and limitations under the License.
133b1068dasomers#
143b1068dasomers# When distributing Covered Code, include this CDDL HEADER in each
153b1068dasomers# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
163b1068dasomers# If applicable, add the following below this CDDL HEADER, with the
173b1068dasomers# fields enclosed by brackets "[]" replaced with your own identifying
183b1068dasomers# information: Portions Copyright [yyyy] [name of copyright owner]
193b1068dasomers#
203b1068dasomers# CDDL HEADER END
213b1068dasomers#
223b1068dasomers
233b1068dasomers# $FreeBSD$
243b1068dasomers
253b1068dasomers#
263b1068dasomers# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
273b1068dasomers# Use is subject to license terms.
283b1068dasomers#
293b1068dasomers# ident	"@(#)zfs_rename_003_pos.ksh	1.3	07/02/06 SMI"
303b1068dasomers#
313b1068dasomers
323b1068dasomers. $STF_SUITE/include/libtest.kshlib
333b1068dasomers
343b1068dasomers#################################################################################
353b1068dasomers#
363b1068dasomers# __stc_assertion_start
373b1068dasomers#
383b1068dasomers# ID: zfs_rename_003_pos
393b1068dasomers#
403b1068dasomers# DESCRIPTION:
413b1068dasomers#	'zfs rename' can address the abbreviated snapshot name. 
423b1068dasomers#
433b1068dasomers# STRATEGY:
443b1068dasomers#	1. Create pool, fs and snap.
453b1068dasomers#	2. Verify 'zfs rename' support the abbreviated snapshot name.
463b1068dasomers#
473b1068dasomers# TESTABILITY: explicit
483b1068dasomers#
493b1068dasomers# TEST_AUTOMATION_LEVEL: automated
503b1068dasomers#
513b1068dasomers# CODING_STATUS: COMPLETED (2006-07-18)
523b1068dasomers#
533b1068dasomers# __stc_assertion_end
543b1068dasomers#
553b1068dasomers################################################################################
563b1068dasomers
573b1068dasomersverify_runnable "both"
583b1068dasomers
593b1068dasomersfunction cleanup
603b1068dasomers{
613b1068dasomers	datasetexists $snap && log_must $ZFS destroy $snap 
623b1068dasomers}
633b1068dasomers
643b1068dasomerslog_assert "'zfs rename' can address the abbreviated snapshot name."
653b1068dasomerslog_onexit cleanup
663b1068dasomers
673b1068dasomersfs=$TESTPOOL/$TESTFS; snap=$fs@snap
683b1068dasomersset -A newname "$fs@new-snap" "@new-snap" "new-snap"
693b1068dasomers
703b1068dasomerslog_must $ZFS snapshot $snap
713b1068dasomerslog_must datasetexists $snap
723b1068dasomers
733b1068dasomerstypeset -i i=0
743b1068dasomerswhile ((i < ${#newname[*]} )); do
753b1068dasomers        log_must $ZFS rename $snap ${newname[$i]}
763b1068dasomers	log_must datasetexists ${snap%%@*}@${newname[$i]##*@}
773b1068dasomers	log_must $ZFS rename ${snap%%@*}@${newname[$i]##*@} $snap
783b1068dasomers
793b1068dasomers	((i += 1))
803b1068dasomersdone
813b1068dasomers
823b1068dasomerslog_pass "'zfs rename' address the abbreviated snapshot name passed."
83