]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/userquota/groupspace_003_pos.ksh
5f5965b648c53a60424b5d22928916554b893d31
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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
33 .
$STF_SUITE/tests
/functional
/userquota
/userquota_common.kshlib
37 # Check the user used and groupspace object counts in zfs groupspace
41 # 1. set zfs groupquota to a fs
42 # 2. create objects for different users in the same group
43 # 3. use zfs groupspace to check the object count
48 if datasetexists
$snapfs; then
49 log_must zfs destroy
$snapfs
52 log_must
rm -f ${QFILE}_
*
53 log_must cleanup_quota
56 function group_object_count
60 typeset cnt
=$
(zfs groupspace
-oname,objused
$fs |
grep $user |
67 log_assert
"Check the zfs groupspace object used"
70 log_must zfs
set xattr
=sa
$QFS
72 ((user1_cnt
= RANDOM
% 100 + 1))
73 ((user2_cnt
= RANDOM
% 100 + 1))
74 log_must user_run
$QUSER1 mkfiles
${QFILE}_1
$user1_cnt
75 log_must user_run
$QUSER2 mkfiles
${QFILE}_2
$user2_cnt
76 ((grp_cnt
= user1_cnt
+ user2_cnt
))
79 typeset snapfs
=$QFS@snap
81 log_must zfs snapshot
$snapfs
83 log_must
eval "zfs groupspace $QFS >/dev/null 2>&1"
84 log_must
eval "zfs groupspace $snapfs >/dev/null 2>&1"
86 for fs
in "$QFS" "$snapfs"; do
87 log_note
"check the object count in zfs groupspace $fs"
88 [[ $
(group_object_count
$fs $QGROUP) -eq $grp_cnt ]] ||
89 log_fail
"expected $grp_cnt"
92 log_note
"file removal"
93 log_must
rm ${QFILE}_
*
96 [[ $
(group_object_count
$QFS $QGROUP) -eq 0 ]] ||
97 log_fail
"expected 0 files for $QGROUP"
99 [[ $
(group_object_count
$snapfs $QGROUP) -eq $grp_cnt ]] ||
100 log_fail
"expected $grp_cnt files for $QGROUP"
103 log_pass
"Check the zfs groupspace object used pass as expect"