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 # NFSv4 server name space test - positive tests
27 #
28
29 # include all test enironment
30 source SNSPC.env
31
32 set TNAME $argv0
33
34 # Start the assertion proc's here
35 # --------------------------------------------------------------
36 # a: pseudo node's attrs are subset of supported_attrs, expect OK
37 proc assertion_a {bdir} {
38 global TNAME
39 set expcode "OK"
40 set ASSERTION \
41 "pseudo node's attrs are subset of supported_attrs, expect $expcode"
42 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
43
44 # First Get supported_attr from pseudo node
45 set pnode [lrange $bdir 0 [expr [llength $bdir] - 2]]
46 set pfh [get_fh $pnode]
47 set res [compound {Putfh $pfh; Getattr supported_attrs}]
48 if {$status != "$expcode"} {
49 putmsg stderr 0 \
50 "\t Test UNRESOLVED: Getattr pseudo node got status=($status)"
51 putmsg stderr 0 "\t expected=($expcode)"
52 putmsg stderr 1 "\t res=($res)"
53 return (-1)
54 }
55 set psattrs [lindex [lindex [lindex $res 1] 2] 1]
56
57 # Now get supported_attr from exported_FS node
58 set bfh [get_fh $bdir]
59 set res [compound {Putfh $bfh; Getattr supported_attrs}]
60 if {$status != "$expcode"} {
61 putmsg stderr 0 \
62 "\t Test UNRESOLVED: Getattr exported_FS node got status=($status)"
63 putmsg stderr 0 "\t expected=($expcode)"
64 putmsg stderr 1 "\t res=($res)"
65 return (-1)
66 }
67 set rsattrs [lindex [lindex [lindex $res 1] 2] 1]
68
69 # now check the results
70 set notmatch ""
71 foreach entry $psattrs {
72 if {[lsearch -exact $rsattr $entry] == -1} {
73 set notmatch "$notmatch $entry"
74 }
75 }
76 if {$notmatch != ""} {
77 putmsg stderr 0 \
78 "\t Test FAIL: attrs from pseudo node not found in supported_attrs:"
79 putmsg stderr 0 "\t notmatch=($notmatch)"
80 return (-1)
81 }
82
83 logres PASS
84 return (0)
85 }
86
87
88 # b: Getattr of unsupported_attrs in pseudo node, expect OK
89 proc assertion_b {bdir} {
90 global TNAME
91 set expcode "OK"
92 set ASSERTION \
93 "Getattr of unsupported_attrs in pseudo node, expect $expcode"
94 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
95
96 # First Get supported_attr from pseudo node
97 set pnode [lrange $bdir 0 [expr [llength $bdir] - 2]]
98 set pfh [get_fh $pnode]
99 set res [compound {Putfh $pfh; Getattr supported_attrs}]
100 if {$status != "$expcode"} {
101 putmsg stderr 0 \
102 "\t Test UNRESOLVED: Getattr supported_attrs got status=($status)"
103 putmsg stderr 0 "\t expected=($expcode)"
104 putmsg stderr 1 "\t res=($res)"
105 return (-1)
106 }
107 set psattrs [extract_attr [lindex [lindex $res 1] 2] "supported_attrs"]
108
109 # check if "hidden" as the supported_attr
110 set ss_attr "hidden"
111 if {[lsearch -exact $psattrs $ss_attr] >= 0} {
112 putmsg stderr 0 \
113 "\t Test NOTINUSE: attr($ss_attr) in supported in pseudo node."
114 putmsg stderr 0 "\t res=($res)"
115 return (2)
116 }
117
118 # now do the GETATTR, should be OK, but no attribute returned
119 set res [compound {Putfh $pfh; Getattr $ss_attr}]
120 if {$status != "$expcode"} {
121 putmsg stderr 0 \
122 "\t Test FAIL: Getattr $ss_attr got status=($status)"
123 putmsg stderr 0 "\t expected=($expcode)"
124 putmsg stderr 1 "\t res=($res)"
125 return (-1)
126 }
127 set attrs [lindex [lindex $res 1] 2]
128 if {$attrs != ""} {
129 putmsg stderr 0 \
130 "\t Test FAIL: attr($ss_attr) from pseudo node got attr returned"
131 putmsg stderr 0 "\t res=($res)"
132 return (-1)
133 }
134
135 logres PASS
136 return (0)
137 }
138
139
140 # Start the main program here
141 # --------------------------------------------------------------
142 # connect to the test server
143 if {[catch {connect -p ${PORT} -t ${TRANSPORT} ${SERVER}} msg]} {
144 putmsg stderr 0 "Test UNINITIATED: unable to connect to $SERVER"
145 putmsg stderr 1 $msg
146 exit $UNINITIATED
147 }
148
149 assertion_a $BASEDIRS
150 assertion_b $BASEDIRS
151
152
153 # --------------------------------------------------------------
154 # disconnect and exit
155 disconnect
156 exit $PASS