1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # Test NFSv4:
27 # {a}: Test get attr FATTR4_MAXFILESIZE per filesystem, expect OK
28 # {b}: Test get attr FATTR4_MAXLINK for a file, expect OK
29 # {c}: Test get attr FATTR4_MAXLINK for a directory, expect OK
30 # {d}: Test get attr FATTR4_MAXNAME for a file, expect OK
31 # {e}: Test get attr FATTR4_MAXREAD of a file, expect OK
32 # {f}: Test get attr FATTR4_MAXWRITE of a file, expect OK
33 #
34
35 # Get the TESTROOT directory; set to '.' if not defined
36 #
37 set TESTROOT $env(TESTROOT)
38 set delm $env(DELM)
39
40 # include common code and init section
41 source ${TESTROOT}${delm}tcl.init
42 source ${TESTROOT}${delm}testproc
43
44 # connect to the test server
45 Connect
46
47 # setting local variables
48 set TNAME $argv0
49 set bfh [get_fh "$BASEDIRS"]
50 set expcode "OK"
51
52 # Start testing
53 # -----------------------------------------------------------------
54 # a: Test get attr FATTR4_MAXFILESIZE per filesystem, expect OK
55
56 # Generate a compound request that
57 # obtains the attributes for the path.
58
59 set tag "$TNAME{a}"
60 set ASSERTION "Test get attr FATTR4_MAXFILESIZE per filesystem, expect $expcode"
61 putmsg stdout 0 "$tag: $ASSERTION"
62
63 set attr {maxfilesize}
64 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
65 set fh [lindex [lindex $res 2] 2]
66 set attrval [ extract_attr [lindex [lindex $res 3] 2] "$attr" ]
67 prn_attrs [lindex [lindex $res 3] 2]
68 ckres "Getattr" $status $expcode $res $PASS
69
70 # -----------------------------------------------------------------
71 # b: Test get attr FATTR4_MAXLINK for a file object, expect OK
72
73 # Generate a compound request that
74 # obtains the attributes for the path.
75
76 set tag "$TNAME{b}"
77 set ASSERTION "Test get attr FATTR4_MAXLINK for a file object, expect $expcode"
78 putmsg stdout 0 "$tag: $ASSERTION"
79
80 # Get expected server value
81 set expval [ exec getconf LINK_MAX $MNTPTR${delm}$env(TEXTFILE) ]
82 if { "$expval" == "undefined" } {
83 # If getconf returns "undefined", it's infinite in this filesystem.
84 # However NFSv4 defines "maxlink" as an 32bit value; so we expect
85 # the max value of 32bit
86 set expval 4294967295
87 }
88 set attr {maxlink}
89 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
90 set cont [ckres "Getattr" $status $expcode $res $FAIL]
91
92 if { ![string equal $cont "false"] } {
93 set attrval [ extract_attr [lindex [lindex $res 3] 2] "$attr" ]
94
95 # Verify attr value response from server
96 if {[string equal $expval $attrval]} {
97 prn_attrs [lindex [lindex $res 3] 2]
98 putmsg stdout 0 "\t Test PASS"
99 } else {
100 putmsg stderr 0 "\t Test FAIL: attr values not equal"
101 putmsg stderr 0 "\t\texpval=<$expval>, attrval=<$attrval>"
102 putmsg stderr 1 "\tRes: $res"
103 }
104 }
105
106 # -----------------------------------------------------------------
107 # c: Test get attr FATTR4_MAXLINK for a dir object, expect OK
108
109 # Generate a compound request that
110 # obtains the attributes for the path.
111
112 set tag "$TNAME{c}"
113 set ASSERTION "Test get attr FATTR4_MAXLINK for a dir object, expect $expcode"
114 putmsg stdout 0 "$tag: $ASSERTION"
115
116 # Get expected value of maximum link support from the server
117 set expval [ exec getconf LINK_MAX $MNTPTR${delm}$env(DIR0777) ]
118 if { "$expval" == "undefined" } {
119 # If getconf returns "undefined", it's infinite in this filesystem.
120 # However NFSv4 defines "maxlink" as an 32bit value; so we expect
121 # the max value of 32bit
122 set expval 4294967295
123 }
124
125 set attr {maxlink}
126 set res [compound { Putfh $bfh; Lookup $env(DIR0777); Getfh; Getattr $attr }]
127 set cont [ckres "Getattr" $status $expcode $res $FAIL]
128
129 if { ![string equal $cont "false"] } {
130 set attrval [ extract_attr [lindex [lindex $res 3] 2] "$attr" ]
131
132 # Verify attr value response from server
133 if {[string equal $expval $attrval]} {
134 prn_attrs [lindex [lindex $res 3] 2]
135 putmsg stdout 0 "\t Test PASS"
136 } else {
137 putmsg stderr 0 "\t Test FAIL: attr values not equal"
138 putmsg stderr 0 "\t\texpval=<$expval>, attrval=<$attrval>"
139 putmsg stderr 1 "\tRes: $res"
140 }
141 }
142
143
144 # -----------------------------------------------------------------
145 # d: Test get attr FATTR4_MAXNAME size for a file object, expect OK
146
147 # Generate a compound request that
148 # obtains the attributes for the path.
149
150 set tag "$TNAME{d}"
151 set ASSERTION "Test get attr FATTR4_MAXNAME for a file object, expect $expcode"
152 putmsg stdout 0 "$tag: $ASSERTION"
153
154 # Get the expected value of maximum name size from server
155 set expval [ exec getconf NAME_MAX $MNTPTR${delm}$env(DIR0777) ]
156
157 set attr {maxname}
158
159 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
160 set cont [ckres "Getattr" $status $expcode $res $FAIL]
161
162 if { ![string equal $cont "false"] } {
163 set attrval [ extract_attr [lindex [lindex $res 3] 2] "maxname" ]
164
165 # Verify attr value response from server
166 if {[string equal $expval $attrval]} {
167 prn_attrs [lindex [lindex $res 3] 2]
168 putmsg stdout 0 "\t Test PASS"
169 } else {
170 putmsg stderr 0 "\t Test FAIL: attr values not equal"
171 putmsg stderr 0 "\t\texpval=<$expval>, attrval=<$attrval>"
172 putmsg stderr 1 "\tRes: $res"
173 }
174 }
175
176 # -----------------------------------------------------------------
177 # e: Test get attr FATTR4_MAXREAD size of a file object, expect OK
178
179 # Generate a compound request that
180 # obtains the attributes for the path.
181
182 set tag "$TNAME{e}"
183 set ASSERTION "Test get attr FATTR4_MAXREAD of a file object, expect $expcode"
184 putmsg stdout 0 "$tag: $ASSERTION"
185
186 # Get the expected value for MAXREAD support on server filesystem
187 set errfile [file join $::env(TMPDIR) ck_fattr.err]
188 set expval [ exec ck_fattr $MNTPTR rsize 2> $errfile]
189 if {[file size $errfile] > 0} {
190 if {[catch {open $errfile r} fileid] != 0} {
191 putmsg stdout 0 "[read $fileid]"
192 close $fileid
193 }
194 }
195 catch {file delete $errfile} dummy
196
197 set attr {maxread}
198
199 set res [compound { Putfh $bfh; Lookup $env(TEXTFILE); Getfh; Getattr $attr }]
200 set cont [ckres "Getattr" $status $expcode $res $FAIL]
201
202 if { ![string equal $cont "false"] } {
203 set attrval [ extract_attr [lindex [lindex $res 3] 2] "$attr" ]
204
205 if {[string compare $attrval $expval] == 0} {
206 prn_attrs [lindex [lindex $res 3] 2]
207 putmsg stdout 0 "\t Test PASS"
208 } else {
209 putmsg stderr 0 "\t Test FAIL: maxread_support returned $attrval"
210 putmsg stderr 0 "\t expval is $expval"
211 putmsg stderr 1 "\tRes: $res"
212 }
213 }
214
215 # -----------------------------------------------------------------
216 # f: Test get attr FATTR4_MAXWRITE size of a file object, expect OK
217
218 # Generate a compound request that
219 # obtains the attributes for the path.
220
221 set tag "$TNAME{f}"
222 set ASSERTION "Test get attr FATTR4_MAXWRITE of a file object, expect $expcode"
223 putmsg stdout 0 "$tag: $ASSERTION"
224
225 # Get the expected value for MAXWRITE support on server filesystem
226 set errfile [file join $::env(TMPDIR) ck_fattr.err]
227 set expval [ exec ck_fattr $MNTPTR wsize 2> $errfile]
228 if {[file size $errfile] > 0} {
229 if {[catch {open $errfile r} fileid] != 0} {
230 putmsg stdout 0 "[read $fileid]"
231 close $fileid
232 }
233 }
234 catch {file delete $errfile} dummy
235
236 set attr {maxwrite}
237 set filename "newfile.[pid]"
238 set tfile "[creatv4_file "$BASEDIR/$filename" 777]"
239 set res [compound { Putfh $bfh; Lookup $filename; Getfh; Getattr $attr }]
240 set cont [ckres "Getattr" $status $expcode $res $FAIL]
241
242 if { ![string equal $cont "false"] } {
243 set attrval [ extract_attr [lindex [lindex $res 3] 2] "$attr" ]
244
245 if {[string compare $attrval $expval] == 0} {
246 prn_attrs [lindex [lindex $res 3] 2]
247 putmsg stdout 0 "\t Test PASS"
248 } else {
249 putmsg stderr 0 "\t Test FAIL: maxread_support returned $attrval"
250 putmsg stderr 0 "\t expval is $expval"
251 putmsg stderr 1 "\tRes: $res"
252 }
253 }
254
255 # cleanup
256 set res [compound { Putfh $bfh; Remove $filename}]
257
258 Disconnect
259 exit $PASS