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