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 2008 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zvol_misc_007_pos.ksh 1.3 08/05/14 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33. $STF_SUITE/tests/zvol/zvol_common.kshlib 34 35############################################################################### 36# 37# __stc_assertion_start 38# 39# ID: zvol_misc_007_pos 40# 41# DESCRIPTION: 42# Verify that device nodes are modified appropriately during zfs command 43# operations on volumes. 44# 45# STRATEGY: 46# For a certain number of iterations, with root setup for each test set: 47# - Recursively snapshot the root. 48# - Recursively rename the snapshot 3 times. 49# - Destroy the root. 50# 51# - Recursively snapshot the root. 52# - Clone the volume to another name in the root. 53# - Rename the root. 54# - Destroy the renamed root. 55# 56# - Recursively snapshot the root. 57# - Send|Receive the root to another root. 58# - Destroy the original and received roots. 59# 60# At each stage, the device nodes are checked to match the expectations. 61# 62# TESTABILITY: explicit 63# 64# TEST_AUTOMATION_LEVEL: automated 65# 66# CODING_STATUS: COMPLETED (2008-03-04) 67# 68# __stc_assertion_end 69# 70################################################################################ 71 72verify_runnable "global" 73 74log_assert "Verify that ZFS volume device nodes are handled properly (part 1)." 75 76ROOTPREFIX=$TESTPOOL/007 77DIRS="dir0 dir1" 78VOLS="vol0 dir0/dvol0 dir1/dvol1" 79 80typeset -i NUM_RENAMES=5 81typeset -i NUM_ITERATIONS=10 82 83function onexit_callback 84{ 85 log_must $ZFS list -t all 86 log_note "Char devices in /dev/zvol:" 87 find /dev/zvol -type c 88} 89log_onexit onexit_callback 90 91function root_setup 92{ 93 rootds=$1 94 95 log_must $ZFS create $rootds 96 for dir in $DIRS; do 97 log_must $ZFS create $rootds/$dir 98 done 99 for vol in $VOLS; do 100 log_must $ZFS create -V 100M $rootds/$vol 101 log_must test -c /dev/zvol/$rootds/$vol 102 done 103} 104 105typeset -i i=0 106root="" 107while (( i != NUM_ITERATIONS )); do 108 root=${ROOTPREFIX}_iter${i} 109 # Test set 1: Recursive snapshot, recursive rename, and destroy 110 typeset -i cur=0 111 log_mustnot test -e /dev/zvol/$root/vol0 112 root_setup $root 113 log_must $ZFS snapshot -r $root@$cur 114 for vol in $VOLS; do 115 log_must test -c /dev/zvol/$root/$vol@$cur 116 done 117 while ((cur < $NUM_RENAMES)); do 118 ((next = cur + 1)) 119 log_must $ZFS rename -r $root@$cur $root@$next 120 for vol in $VOLS; do 121 v=$root/$vol 122 log_mustnot test -e /dev/zvol/$v@$cur 123 log_must test -c /dev/zvol/$v@$next 124 done 125 cur=$next 126 done 127 log_must $ZFS destroy -r $root 128 log_mustnot test -e /dev/zvol/$root/vol0 129 130 (( i += 1 )) 131done 132 133log_pass "ZFS volume device nodes are handled properly." 134