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) 2017 by Fan Yong. All rights reserved.
32 .
$STF_SUITE/tests
/functional
/projectquota
/projectquota_common.kshlib
36 # Check the basic function project{obj}used
40 # 1. Write data to fs with some project then check the project{obj}used
48 if ! lsattr
-pd > /dev
/null
2>&1; then
49 log_unsupported
"Current e2fsprogs does not support set/show project ID"
54 log_assert
"Check the basic function of project{obj}used"
57 typeset project_used
=$
(get_value
"projectused@$PRJID1" $QFS)
58 typeset file_size
='10m'
60 if [[ $project_used != 0 ]]; then
61 log_fail
"FAIL: projectused is $project_used, should be 0"
65 log_must user_run
$PUSER mkdir
$PRJDIR
66 log_must
chattr +P
-p $PRJID1 $PRJDIR
67 log_must user_run
$PUSER mkfile
$file_size $PRJDIR/qf
69 project_used
=$
(get_value
"projectused@$PRJID1" $QFS)
70 # get_value() reads the exact byte value which is slightly more than 10m
71 if [[ "$(($project_used/1024/1024))m" != "$file_size" ]]; then
72 log_note
"project $PRJID1 used is $project_used"
73 log_fail
"projectused for project $PRJID1 expected to be $file_size, " \
77 log_must
rm -rf $PRJDIR
78 typeset project_obj_used
=$
(get_value
"projectobjused@$PRJID2" $QFS)
79 typeset file_count
=100
81 if [[ $project_obj_used != 0 ]]; then
82 log_fail
"FAIL: projectobjused is $project_obj_used, should be 0"
85 log_must zfs
set xattr
=sa
$QFS
86 log_must user_run
$PUSER mkdir
$PRJDIR
87 log_must
chattr +P
-p $PRJID2 $PRJDIR
88 # $PRJDIR has already used one object with the $PRJID2
89 log_must user_run
$PUSER mkfiles
$PRJDIR/qf_ $
((file_count
- 1))
91 project_obj_used
=$
(get_value
"projectobjused@$PRJID2" $QFS)
92 if [[ $project_obj_used != $file_count ]]; then
93 log_note
"project $PRJID2 used is $project_obj_used"
94 log_fail
"projectobjused for project $PRJID2 expected to be " \
95 "$file_count, not $project_obj_used"
98 log_pass
"Check the basic function of project{obj}used pass as expect"