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# ident	"@(#)userquota_007_pos.ksh	1.1	09/06/22 SMI"
28#
29
30################################################################################
31#
32# __stc_assertion_start
33#
34# ID: userquota_007_pos
35#
36# DESCRIPTION:
37#
38#      userquota/groupquota can be set beyond the fs quota
39#      userquota/groupquota can be set at a smaller size than its current usage.
40#
41# STRATEGY:
42#       1. set quota to a fs and set a larger size of userquota and groupquota
43#       2. write some data to the fs and set a smaller userquota and groupquota
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
58function cleanup
59{
60	log_must cleanup_quota
61	log_must $ZFS set quota=none $QFS
62}
63
64log_onexit cleanup
65
66log_assert "Check set user|group quota to larger than the quota size of a fs"
67
68log_must $ZFS set quota=200m $QFS
69log_must $ZFS set userquota@$QUSER1=500m $QFS
70log_must $ZFS set groupquota@$QGROUP=600m $QFS
71
72log_must $ZFS get userquota@$QUSER1 $QFS
73log_must $ZFS get groupquota@$QGROUP $QFS
74
75log_note "write some data to the $QFS"
76mkmount_writable $QFS
77log_must user_run $QUSER1 $MKFILE 100m $QFILE
78$SYNC
79
80log_note "set user|group quota at a smaller size than it current usage"
81log_must $ZFS set userquota@$QUSER1=90m $QFS
82log_must $ZFS set groupquota@$QGROUP=90m $QFS
83
84log_must $ZFS get userquota@$QUSER1 $QFS
85log_must $ZFS get groupquota@$QGROUP $QFS
86
87log_pass "set user|group quota to larger than quota size of a fs pass as expect"
88