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 "@(#)pool_names_001_pos.ksh 1.2 07/01/09 SMI" 30# 31 32. $STF_SUITE/include/libtest.kshlib 33 34############################################################################### 35# 36# __stc_assertion_start 37# 38# ID: pool_names_001_pos 39# 40# DESCRIPTION: 41# 42# Test that a set of valid names can be used to create pools. Further 43# verify that the created pools can be destroyed. 44# 45# STRATEGY: 46# 1) For each valid character in the character set, try to create 47# and destroy the pool. 48# 2) Given a list of valid pool names, try to create and destroy 49# pools with the given names. 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2005-11-21) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61verify_runnable "global" 62 63log_assert "Ensure that pool names can use the ASCII subset of UTF-8" 64 65function cleanup 66{ 67 [[ -n "$name" ]] && destroy_pool $name 68 69 if [[ -d $TESTDIR ]]; then 70 log_must $RM -rf $TESTDIR 71 fi 72 73} 74 75log_onexit cleanup 76 77if [[ ! -e $TESTDIR ]]; then 78 log_must $MKDIR $TESTDIR 79fi 80 81log_note "Ensure letters of the alphabet are allowable" 82 83typeset name="" 84 85for name in A B C D E F G H I J K L M \ 86 N O P Q R S T U V W X Y Z \ 87 a b c d e f g h i j k l m \ 88 n o p q r s t u v w x y z 89do 90 log_must $ZPOOL create -m $TESTDIR $name $DISK 91 if ! poolexists $name; then 92 log_fail "Could not create a pool called '$name'" 93 fi 94 95 log_must $ZPOOL destroy $name 96done 97 98log_note "Ensure a variety of unusual names passes" 99 100name="" 101 102for name in "a.............................." "a_" "a-" "a:" \ 103 "a." "a123456" "bc0t0d0" "m1rr0r_p00l" "ra1dz_p00l" \ 104 "araidz2" "C0t2d0" "cc0t0" "raid2:-_." "mirr_:-." \ 105 "m1rr0r-p00l" "ra1dz-p00l" "spar3_p00l" \ 106 "spar3-p00l" "hiddenmirrorpool" "hiddenraidzpool" \ 107 "hiddensparepool" 108do 109 log_must $ZPOOL create -m $TESTDIR $name $DISK 110 if ! poolexists $name; then 111 log_fail "Could not create a pool called '$name'" 112 fi 113 114 # 115 # Since the naming convention applies to datasets too, 116 # create datasets with the same names as above. 117 # 118 log_must $ZFS create $name/$name 119 log_must $ZFS snapshot $name/$name@$name 120 log_must $ZFS clone $name/$name@$name $name/clone_$name 121 log_must $ZFS create -V 150m $name/$name/$name 122 123 log_must $ZPOOL destroy $name 124done 125 126log_pass "Valid pool names were accepted correctly." 127