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################################################################################
28#
29# __stc_assertion_start
30#
31# ID: userquota_002_pos
32#
33# DESCRIPTION:
34#       the userquota and groupquota can be set during zpool or zfs creation"
35#
36#
37# STRATEGY:
38#       1. Set userquota and groupquota via "zpool -O or zfs create -o"
39#
40# TESTABILITY: explicit
41#
42# TEST_AUTOMATION_LEVEL: automated
43#
44# CODING STATUS: COMPLETED (2009-04-16)
45#
46# __stc_assertion_end
47#
48###############################################################################
49
50. $STF_SUITE/include/libtest.kshlib
51. $STF_SUITE/tests/userquota/userquota_common.kshlib
52
53verify_runnable "global"
54
55function cleanup
56{
57	destroy_pool $TESTPOOL1
58
59	if [[ -f $pool_vdev ]]; then
60		$RM -f $pool_vdev
61	fi
62}
63
64log_onexit cleanup
65
66log_assert \
67	"the userquota and groupquota can be set during zpool,zfs creation"
68
69typeset pool_vdev=$TMPDIR/pool_dev.${TESTCASE_ID}
70
71log_must create_vdevs $pool_vdev
72destroy_pool $TESTPOOL1
73
74log_must $ZPOOL create -O userquota@$QUSER1=$UQUOTA_SIZE \
75	-O groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL1 $pool_vdev
76
77log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
78	$TESTPOOL1 > /dev/null 2>&1"
79
80log_must check_quota "userquota@$QUSER1" $TESTPOOL1 "$UQUOTA_SIZE"
81log_must check_quota "groupquota@$QGROUP" $TESTPOOL1 "$GQUOTA_SIZE"
82
83log_must $ZFS create -o userquota@$QUSER1=$UQUOTA_SIZE \
84	-o groupquota@$QGROUP=$GQUOTA_SIZE $TESTPOOL1/fs
85
86log_must eval "$ZFS list -r -o userquota@$QUSER1,groupquota@$QGROUP \
87	$TESTPOOL1 > /dev/null 2>&1"
88
89log_must check_quota "userquota@$QUSER1" $TESTPOOL1/fs "$UQUOTA_SIZE"
90log_must check_quota "groupquota@$QGROUP" $TESTPOOL1/fs "$GQUOTA_SIZE"
91
92log_pass \
93	"the userquota and groupquota can be set during zpool,zfs creation"
94