1#!/bin/ksh -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 https://opensource.org/licenses/CDDL-1.0. 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 28# 29# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 30# 31 32. $STF_SUITE/include/libtest.shlib 33. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.cfg 34 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 47function cleanup 48{ 49 poolexists $TESTPOOL && destroy_pool $TESTPOOL 50 rm -rf /${TESTPOOL}.root 51 rm -f $values 52} 53 54log_onexit cleanup 55 56log_assert "zpool create -R works as expected" 57 58typeset values=$TEST_BASE_DIR/values.$$ 59 60log_must rm -f /etc/zfs/zpool.cache 61log_must rm -rf /${TESTPOOL}.root 62log_must zpool create -R /${TESTPOOL}.root $TESTPOOL $DISK0 63if [ ! -d /${TESTPOOL}.root ] 64then 65 log_fail "Mountpoint was not created when using zpool with -R flag!" 66fi 67 68FS=$(zfs list $TESTPOOL) 69if [ -z "$FS" ] 70then 71 log_fail "Mounted filesystem at /${TESTPOOL}.root isn't ZFS!" 72fi 73 74log_must zpool get all $TESTPOOL 75zpool get all $TESTPOOL > $values 76 77# check for the cachefile property, verifying that it's set to 'none' 78log_must grep -q "$TESTPOOL[ ]*cachefile[ ]*none" $values 79 80# check that the root = /mountpoint property is set correctly 81log_must grep -q "$TESTPOOL[ ]*altroot[ ]*/${TESTPOOL}.root" $values 82 83rm $values 84 85# finally, check that the pool has no reference in /etc/zfs/zpool.cache 86if [[ -f /etc/zfs/zpool.cache ]] ; then 87 if strings /etc/zfs/zpool.cache | grep -q ${TESTPOOL} 88 then 89 strings /etc/zfs/zpool.cache 90 log_fail "/etc/zfs/zpool.cache appears to have a reference to $TESTPOOL" 91 fi 92fi 93 94log_pass "zpool create -R works as expected" 95