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# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)zfs_mount_all_001_pos.ksh 1.2 07/01/09 SMI" 28# 29. $STF_SUITE/include/libtest.kshlib 30. $STF_SUITE/tests/cli_root/zfs_mount/zfs_mount.kshlib 31 32################################################################################# 33# __stc_assertion_start 34# 35# ID: zfs_mount_all_001_pos 36# 37# DESCRIPTION: 38# Verify that 'zfs mount -a' succeeds as root. 39# 40# STRATEGY: 41# 1. Create a group of pools with specified vdev. 42# 2. Create zfs filesystems within the given pools. 43# 3. Unmount all the filesystems. 44# 4. Verify that 'zfs mount -a' command succeed, 45# and all available ZFS filesystems are mounted. 46# 5. Verify that 'zfs mount' is identical with 'df -F zfs' 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2005-07-07) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60set -A fs "$TESTFS" "$TESTFS1" 61set -A ctr "" "$TESTCTR" "$TESTCTR/$TESTCTR1" "$TESTCTR1" 62set -A vol "$TESTVOL" "$TESTVOL1" 63 64function setup_all 65{ 66 typeset -i i=0 67 typeset -i j=0 68 typeset path 69 70 while (( i < ${#ctr[*]} )); do 71 72 path=${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID}/$TESTPOOL 73 if [[ -n ${ctr[i]} ]]; then 74 path=$path/${ctr[i]} 75 76 setup_filesystem "$DISKS" "$TESTPOOL" \ 77 "${ctr[i]}" "$path" \ 78 "ctr" 79 fi 80 81 if is_global_zone ; then 82 j=0 83 while (( j < ${#vol[*]} )); do 84 setup_filesystem "$DISKS" "$TESTPOOL" \ 85 "${ctr[i]}/${vol[j]}" \ 86 "$path/${vol[j]}" \ 87 "vol" 88 ((j = j + 1)) 89 done 90 fi 91 92 j=0 93 while (( j < ${#fs[*]} )); do 94 setup_filesystem "$DISKS" "$TESTPOOL" \ 95 "${ctr[i]}/${fs[j]}" \ 96 "$path/${fs[j]}" 97 ((j = j + 1)) 98 done 99 100 ((i = i + 1)) 101 done 102 103 return 0 104} 105 106function cleanup_all 107{ 108 typeset -i i=0 109 typeset -i j=0 110 typeset path 111 112 ((i = ${#ctr[*]} - 1)) 113 114 while (( i >= 0 )); do 115 if is_global_zone ; then 116 j=0 117 while (( j < ${#vol[*]} )); do 118 cleanup_filesystem "$TESTPOOL" \ 119 "${ctr[i]}/${vol[j]}" 120 ((j = j + 1)) 121 done 122 fi 123 124 j=0 125 while (( j < ${#fs[*]} )); do 126 cleanup_filesystem "$TESTPOOL" \ 127 "${ctr[i]}/${fs[j]}" 128 ((j = j + 1)) 129 done 130 131 [[ -n ${ctr[i]} ]] && \ 132 cleanup_filesystem "$TESTPOOL" "${ctr[i]}" 133 134 ((i = i - 1)) 135 done 136 137 [[ -d ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} ]] && \ 138 $RM -rf ${TEST_BASE_DIR%%/}/testroot${TESTCASE_ID} 139} 140 141function verify_all 142{ 143 typeset -i i=0 144 typeset -i j=0 145 typeset path 146 147 while (( i < ${#ctr[*]} )); do 148 149 path=$TESTPOOL 150 [[ -n ${ctr[i]} ]] && \ 151 path=$path/${ctr[i]} 152 153 if is_global_zone ; then 154 j=0 155 while (( j < ${#vol[*]} )); do 156 log_mustnot mounted "$path/${vol[j]}" 157 ((j = j + 1)) 158 done 159 fi 160 161 j=0 162 while (( j < ${#fs[*]} )); do 163 log_must mounted "$path/${fs[j]}" 164 ((j = j + 1)) 165 done 166 167 log_must mounted "$path" 168 169 ((i = i + 1)) 170 done 171 172 return 0 173} 174 175 176log_assert "Verify that 'zfs $mountall' succeeds as root, " \ 177 "and all available ZFS filesystems are mounted." 178 179log_onexit cleanup_all 180 181log_must setup_all 182 183log_must $ZFS $unmountall 184 185log_must $ZFS $mountall 186 187verify_all 188 189log_note "Verify that 'zfs $mountcmd' will display " \ 190 "all ZFS filesystems currently mounted." 191 192verify_mount_display 193 194log_pass "'zfs $mountall' succeeds as root, " \ 195 "and all available ZFS filesystems are mounted." 196