]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_rename/zfs_rename_001_pos.ksh
Add the ZFS Test Suite
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_rename / zfs_rename_001_pos.ksh
1 #!/bin/ksh -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 #
27 . $STF_SUITE/include/libtest.shlib
28 . $STF_SUITE/tests/functional/cli_root/zfs_rename/zfs_rename.kshlib
29
30 #
31 # DESCRIPTION:
32 # 'zfs rename' should successfully rename valid datasets.
33 # As a sub-assertion we check to ensure the datasets that can
34 # be mounted are mounted.
35 #
36 # STRATEGY:
37 # 1. Given a file system, snapshot and volume.
38 # 2. Rename each dataset object to a new name.
39 # 3. Verify that only the new name is displayed by zfs list.
40 # 4. Verify mountable datasets are mounted.
41 #
42 ###############################################################################
43
44 verify_runnable "both"
45
46 set -A dataset "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS1" \
47 "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTCTR1" \
48 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS-clone"
49 set -A mountable "$TESTPOOL/$TESTFS1-new" "$TESTPOOL/$TESTFS@snapshot-new" \
50 "$TESTPOOL/$TESTCTR/$TESTFS1-new" "$TESTPOOL/$TESTFS-clone-new"
51
52 #
53 # cleanup defined in zfs_rename.kshlib
54 #
55 log_onexit cleanup
56
57 log_assert "'zfs rename' should successfully rename valid datasets"
58
59 additional_setup
60
61 typeset -i i=0
62 while (( i < ${#dataset[*]} )); do
63 rename_dataset ${dataset[i]} ${dataset[i]}-new
64
65 ((i = i + 1))
66 done
67
68 log_note "Verify mountable datasets are mounted in their new namespace."
69 typeset mtpt
70 i=0
71 while (( i < ${#mountable[*]} )); do
72 # Snapshot have no mountpoint
73 if [[ ${mountable[i]} != *@* ]]; then
74 log_must mounted ${mountable[i]}
75 mtpt=$(get_prop mountpoint ${mountable[i]})
76 else
77 mtpt=$(snapshot_mountpoint ${mountable[i]})
78 fi
79
80 if ! cmp_data $DATA $mtpt/$TESTFILE0 ; then
81 log_fail "$mtpt/$TESTFILE0 gets corrupted after rename operation."
82 fi
83
84 ((i = i + 1))
85 done
86
87 #verify the data integrity in zvol
88 if is_global_zone; then
89 log_must eval "$DD if=${VOL_R_PATH}-new of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1"
90 if ! cmp_data $VOLDATA $DATA ; then
91 log_fail "$VOLDATA gets corrupted after rename operation."
92 fi
93 fi
94
95 # rename back fs
96 typeset -i i=0
97 while ((i < ${#dataset[*]} )); do
98 if datasetexists ${dataset[i]}-new ; then
99 log_must $ZFS rename ${dataset[i]}-new ${dataset[i]}
100 fi
101 ((i = i + 1))
102 done
103
104 log_pass "'zfs rename' successfully renamed each dataset type."