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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/cli_root/zpool_create/zpool_create.kshlib 29 30################################################################################ 31# 32# __stc_assertion_start 33# 34# ID: zpool_create_020_pos 35# 36# DESCRIPTION: 37# 38# zpool create -R works as expected 39# 40# STRATEGY: 41# 1. Create a -R altroot pool 42# 2. Verify the pool is mounted at the correct location 43# 3. Verify that cachefile=none for the pool 44# 4. Verify that root=<mountpoint> for the pool 45# 5. Verify that no reference to the pool is found in /etc/zfs/zpool.cache 46 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2007-07-27) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58function cleanup 59{ 60 poolexists $TESTPOOL && destroy_pool $TESTPOOL 61 [[ -d ${TESTPOOL}.root ]] && log_must $RM -rf /${TESTPOOL}.root 62} 63 64log_onexit cleanup 65 66log_assert "zpool create -R works as expected" 67 68if [[ -n $DISK ]]; then 69 disk=$DISK 70else 71 disk=$DISK0 72fi 73 74$RM -rf /${TESTPOOL}.root 75log_must $MKDIR /${TESTPOOL}.root 76log_must $ZPOOL create -R /${TESTPOOL}.root $TESTPOOL $disk 77if [ ! -d /${TESTPOOL}.root ] 78then 79 log_fail "Mountpoint was not create when using zpool with -R flag!" 80fi 81 82FS=$($ZFS list $TESTPOOL) 83if [ -z "$FS" ] 84then 85 log_fail "Mounted filesystem at /${TESTPOOL}.root isn't ZFS!" 86fi 87 88log_must $ZPOOL get all $TESTPOOL 89$ZPOOL get all $TESTPOOL > $TMPDIR/values.${TESTCASE_ID} 90 91# check for the cachefile property, verifying that it's set to 'none' 92$GREP "$TESTPOOL[ ]*cachefile[ ]*none" $TMPDIR/values.${TESTCASE_ID} > /dev/null 2>&1 93if [ $? -ne 0 ] 94then 95 log_fail "zpool property \'cachefile\' was not set to \'none\'." 96fi 97 98# check that the root = /mountpoint property is set correctly 99$GREP "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $TMPDIR/values.${TESTCASE_ID} > /dev/null 2>&1 100if [ $? -ne 0 ] 101then 102 log_fail "zpool property root was not found in pool output." 103fi 104 105$RM $TMPDIR/values.${TESTCASE_ID} 106 107# finally, check that the pool has no reference in /etc/zfs/zpool.cache 108if [[ -f /etc/zfs/zpool.cache ]] ; then 109 REF=$($STRINGS /etc/zfs/zpool.cache | $GREP ${TESTPOOL}) 110 if [ ! -z "$REF" ] 111 then 112 $STRINGS /etc/zfs/zpool.cache 113 log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" 114 fi 115fi 116 117 118log_pass "zpool create -R works as expected" 119