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.
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.
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]
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
36 # 'zfs rename' can successfully rename a volume snapshot.
39 # 1. Create a snapshot of volume.
40 # 2. Rename volume snapshot to a new one.
41 # 3. Rename volume to a new one.
42 # 4. Create a clone of the snapshot.
43 # 5. Verify that the rename operations are successful and zfs list can
46 ###############################################################################
48 verify_runnable "global"
51 # cleanup defined in zfs_rename.kshlib
55 log_assert "'zfs rename' can successfully rename a volume snapshot."
57 vol=$TESTPOOL/$TESTVOL
60 log_must eval "dd if=$DATA of=$VOL_R_PATH bs=$BS count=$CNT >/dev/null 2>&1"
61 if ! snapexists $vol@$snap; then
62 log_must zfs snapshot $vol@$snap
65 rename_dataset $vol@$snap $vol@${snap}-new
66 rename_dataset $vol ${vol}-new
67 rename_dataset ${vol}-new@${snap}-new ${vol}-new@$snap
68 rename_dataset ${vol}-new $vol
70 clone=$TESTPOOL/${snap}_clone
71 create_clone $vol@$snap $clone
74 #verify data integrity
75 for input in $VOL_R_PATH $ZVOL_RDEVDIR/$clone; do
76 log_must eval "dd if=$input of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1"
77 if ! cmp_data $VOLDATA $DATA ; then
78 log_fail "$input gets corrupted after rename operation."
83 log_must zfs destroy $vol@$snap
85 log_pass "'zfs rename' can rename volume snapshot as expected."