]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/zfs-tests/tests/functional/projectquota/projecttree_002_pos.ksh
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / tests / zfs-tests / tests / functional / projectquota / projecttree_002_pos.ksh
1 #!/bin/ksh -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 # Copyright (c) 2017 by Fan Yong. All rights reserved.
30 #
31
32 . $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
33
34 #
35 #
36 # DESCRIPTION:
37 #       Check project ID/flag can be operated via "zfs project"
38 #
39 #
40 # STRATEGY:
41 #       1. Create a tree with 4 level directories.
42 #       2. Set project ID on both directory and regular file via
43 #          "zfs project -p".
44 #       3. Check the project ID via "zfs project".
45 #       4. Set project inherit flag on kinds of level directories (and its
46 #          descendants for some)) via "zfs project -s [-r]".
47 #       5. Check the project ID and inherit flag via "zfs project -r".
48 #       6. Clear the project inherit flag from some directories (and its
49 #          descendants for some) via "zfs project -C [-r]".
50 #       7. Check the project ID and inherit flag via "zfs project -r".
51 #
52
53 function cleanup
54 {
55         log_must rm -rf $PRJDIR
56 }
57
58 log_onexit cleanup
59
60 log_assert "Check project ID/flag can be operated via 'zfs project'"
61
62 log_must mkdir $PRJDIR
63
64 log_must mkdir $PRJDIR/a1
65 log_must mkdir $PRJDIR/b1
66 log_must touch $PRJDIR/c1
67
68 log_must mkdir $PRJDIR/a1/a2
69 log_must mkdir $PRJDIR/a1/b2
70 log_must touch $PRJDIR/a1/c2
71
72 log_must mkdir $PRJDIR/b1/a2
73 log_must mkdir $PRJDIR/b1/b2
74 log_must touch $PRJDIR/b1/c2
75
76 log_must mkdir $PRJDIR/a1/a2/a3
77 log_must mkdir $PRJDIR/a1/a2/b3
78 log_must touch $PRJDIR/a1/a2/c3
79
80 log_must mkdir $PRJDIR/b1/a2/a3
81
82 log_must touch $PRJDIR/a1/a2/a3/c4
83 log_must touch $PRJDIR/a1/a2/a3/d4
84
85 log_must zfs project -p $PRJID1 $PRJDIR/a1/c2
86 log_must eval "zfs project $PRJDIR/a1/c2 | grep $PRJID1"
87
88 log_must zfs project -p $PRJID2 $PRJDIR/a1/a2/a3
89 log_must eval "zfs project -d $PRJDIR/a1/a2/a3 | grep $PRJID2"
90
91 log_must zfs project -s $PRJDIR/b1/a2
92 log_must eval "zfs project -d $PRJDIR/b1/a2 | grep ' P '"
93 log_must eval "zfs project -d $PRJDIR/b1/a2/a3 | grep ' \- '"
94
95 log_must zfs project -s -r -p $PRJID2 $PRJDIR/a1/a2
96 log_must zfs project -c -r $PRJDIR/a1/a2
97 log_must eval "zfs project -d $PRJDIR/a1/a2/a3 | grep ' P '"
98 log_must eval "zfs project $PRJDIR/a1/a2/a3/c4 | grep $PRJID2"
99
100 log_must zfs project -C $PRJDIR/a1/a2/a3
101 log_must eval "zfs project -cr $PRJDIR/a1/a2 | grep 'inherit flag is not set'"
102 log_must eval "zfs project $PRJDIR/a1/a2/a3/c4 | grep $PRJID2 | grep -v not"
103 log_must zfs project -p 123 $PRJDIR/a1/a2/a3/c4
104 log_must eval "zfs project -c -r $PRJDIR/a1/a2 | grep 123 | grep 'not set'"
105 log_mustnot eval "zfs project -cr -p 123 $PRJDIR/a1/a2 | grep c4 | grep -v not"
106
107 log_must zfs project -C -r $PRJDIR/a1/a2/a3
108 log_must eval "zfs project -cr $PRJDIR/a1/a2 | grep a3 | grep 'not set'"
109 log_must eval "zfs project -cr $PRJDIR/a1/a2 | grep d4 | grep 'not set'"
110 log_must eval "zfs project $PRJDIR/a1/a2/a3/d4 | grep '0 \-'"
111
112 log_must eval \
113     "zfs project -cr -0 $PRJDIR/a1/a2 | xargs -0 zfs project -s -p $PRJID2"
114 log_mustnot eval "zfs project -cr $PRJDIR/a1/a2 | grep a3 | grep 'not set'"
115 log_mustnot eval "zfs project -cr $PRJDIR/a1/a2 | grep d4 | grep 'not set'"
116
117 log_must zfs project -C -r -k $PRJDIR/a1/a2
118 log_must eval "zfs project -d $PRJDIR/a1/a2/b3 | grep '$PRJID2 \- '"
119
120 log_pass "Check project ID/flag can be operated via 'zfs project'"