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 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26
27. $STF_SUITE/include/libtest.kshlib
28. $STF_SUITE/tests/cachefile/cachefile.kshlib
29
30################################################################################
31#
32# __stc_assertion_start
33#
34# ID: cachefile_001_pos
35#
36# DESCRIPTION:
37#
38# Creating a pool with "cachefile" set doesn't update zpool.cache
39#
40# STRATEGY:
41# 1. Create a pool with the cachefile property set
42# 2. Verify that the pool doesn't have an entry in zpool.cache
43# 3. Verify the cachefile property is set
44# 4. Create a pool without the cachefile property
45# 5. Verify the cachefile property isn't set
46# 6. Verify that zpool.cache contains an entry for the pool
47#
48# TESTABILITY: explicit
49#
50# TEST_AUTOMATION_LEVEL: automated
51#
52# CODING_STATUS: COMPLETED (2007-09-05)
53#
54# __stc_assertion_end
55#
56################################################################################
57
58function cleanup
59{
60	typeset file
61
62	destroy_pool $TESTPOOL
63	for file in $CPATH1 $CPATH2 ; do
64		if [[ -f $file ]] ; then
65			log_must $RM $file
66		fi
67	done
68}
69
70verify_runnable "global"
71
72log_assert "Creating a pool with \"cachefile\" set doesn't update zpool.cache"
73log_onexit cleanup
74
75CPATHARG="-"
76set -A opts "none" "false" "none" \
77	"$CPATH" "true" "$CPATHARG" \
78	"$CPATH1" "true" "$CPATH1" \
79	"$CPATH2" "true" "$CPATH2"
80
81typeset -i i=0
82
83while (( i < ${#opts[*]} )); do
84	log_must $ZPOOL create -o cachefile=${opts[i]} $TESTPOOL $DISKS
85	case ${opts[((i+1))]} in
86		false) log_mustnot pool_in_cache $TESTPOOL
87			;;
88		true) log_must pool_in_cache $TESTPOOL ${opts[i]}
89			;;
90	esac
91
92	PROP=$(get_pool_prop cachefile $TESTPOOL)
93	if [[ $PROP != ${opts[((i+2))]} ]]; then
94		log_fail "cachefile property not set as expected. " \
95			"Expect: ${opts[((i+2))]}, Current: $PROP"
96	fi
97	log_must $ZPOOL destroy $TESTPOOL
98	(( i = i + 3 ))
99done
100
101log_pass "Creating a pool with \"cachefile\" set doesn't update zpool.cache"
102
103