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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_rename_002_pos.ksh 1.3 07/07/31 SMI" 30# 31. $STF_SUITE/include/libtest.kshlib 32. $STF_SUITE/tests/cli_root/zfs_rename/zfs_rename.kshlib 33 34################################################################################ 35# 36# __stc_assertion_start 37# 38# ID: zfs_rename_002_pos 39# 40# DESCRIPTION: 41# 'zfs rename' should successfully be capable of renaming 42# valid datasets back and forth multiple times. 43# 44# STRATEGY: 45# 1. Given a file system, snapshot and volume. 46# 2. Rename each dataset object to a new name. 47# 3. Rename each dataset back to its original name. 48# 4. Repeat steps 2 and 3 multiple times. 49# 5. Verify that the correct name is displayed by zfs list. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-06-29) 56# 57# __stc_assertion_end 58# 59############################################################################### 60 61verify_runnable "both" 62 63set -A dataset "$TESTPOOL/$TESTFS@snapshot" "$TESTPOOL/$TESTFS1" \ 64 "$TESTPOOL/$TESTCTR/$TESTFS1" "$TESTPOOL/$TESTCTR1" \ 65 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS-clone" 66 67# 68# cleanup defined in zfs_rename.kshlib 69# 70log_onexit cleanup 71 72log_assert "'zfs rename' should successfully rename valid datasets" 73 74additional_setup 75 76typeset -i i=0 77typeset -i iters=10 78 79while ((i < ${#dataset[*]} )); do 80 j=0 81 while ((j < iters )); do 82 rename_dataset ${dataset[i]} ${dataset[i]}-new 83 rename_dataset ${dataset[i]}-new ${dataset[i]} 84 85 ((j = j + 1)) 86 done 87 88 if [[ ${dataset[i]} == *@* ]]; then 89 data=$(snapshot_mountpoint ${dataset[i]})/$TESTFILE0 90 elif [[ ${dataset[i]} == "$TESTPOOL/$TESTVOL" ]] && is_global_zone; then 91 log_must eval "$DD if=$VOL_R_PATH of=$VOLDATA bs=$BS count=$CNT >/dev/null 2>&1" 92 data=$VOLDATA 93 else 94 data=$(get_prop mountpoint ${dataset[i]})/$TESTFILE0 95 fi 96 97 if ! cmp_data $DATA $data; then 98 log_fail "$data gets corrupted after $iters times rename operations." 99 fi 100 101 ((i = i + 1)) 102done 103 104log_pass "'zfs rename' renamed each dataset type multiple times as expected." 105