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 READDIR operation test - negative tests
27 # verify SERVER errors returned with invalid Getattr.
28
29 # include all test enironment
30 source READDIR.env
31
32 Connect
33
34 # setting local variables
35 set TNAME $argv0
36 set bfh [get_fh $BASEDIRS]
37
38 # Start testing
39 # --------------------------------------------------------------
40 # a: Readdir without Putrootfh, expect NOFILEHANDLE
41 set expcode "NOFILEHANDLE"
42 set ASSERTION "Readdir without Putrootfh, expect $expcode"
43 set tag "$TNAME{a}"
44 putmsg stdout 0 "$tag: $ASSERTION"
45 set res [compound {Readdir 0 0 1024 1024 type}]
46 ckres "Readdir" $status $expcode $res $PASS
47
48
49 # b: try to Readdir while the obj is removed, expect STALE
50 set expcode "STALE"
51 set ASSERTION "try to Readdir while obj is removed, expect $expcode"
52 #set tag "$TNAME{b}"
53 #putmsg stdout 0 "$tag: $ASSERTION"
54 #set tmpd "tmp.[pid]"
55 #set res [compound {Putfh $bfh; Create $tmpd {{mode 0777}} d; Getfh}]
56 #set tfh [lindex [lindex $res 2] 2]
57 #check_op "Putfh $bfh; Remove $tmpd" "OK" "UNINITIATED"
58 #set res [compound {Putfh $tfh; Readdir 0 0 1024 1024 type; Getfh}]
59 #ckres "Readdir" $status $expcode $res $PASS
60 #puts "\t Test UNTESTED: XXX need to remove <cfh> between PUTFH/READDIR\n"
61
62
63 # d: Readdir of of dir0711 as <other>, expect ACCESS
64 set expcode "ACCESS"
65 set ASSERTION "Readdir of of dir0711 as <other>, expect $expcode"
66 set tag "$TNAME{d}"
67 putmsg stdout 0 "$tag: $ASSERTION"
68 set res [compound {Putfh $bfh; Lookup $env(DIR0711);
69 Readdir 0 0 512 512 mode}]
70 ckres "Readdir" $status $expcode $res $PASS
71
72
73 # e: Readdir of dir_noperm (mode=000), expect ACCESS
74 set expcode "ACCESS"
75 set ASSERTION "Readdir of dir_noperm (mode=000), expect $expcode"
76 set tag "$TNAME{e}"
77 putmsg stdout 0 "$tag: $ASSERTION"
78 set res [compound {Putfh $bfh; Lookup "$env(DNOPERM)";
79 Readdir 0 0 512 1024 named_attr}]
80 ckres "Readdir" $status $expcode $res $PASS
81
82
83 # m: Readdir with a bad cookie, expect BAD_COOKIE
84 set expcode "BAD_COOKIE"
85 set ASSERTION "Readdir with a bad cookie, expect $expcode"
86 set tag "$TNAME{m}"
87 putmsg stdout 0 "$tag: $ASSERTION"
88 set cookie 88888888888888888
89 set cookieverf 0
90 set res [compound {Putfh $bfh;
91 Readdir $cookie $cookieverf 512 2048 change}]
92 if { "$env(SRVOS)" == "Solaris" } {
93 putmsg stdout 0 \
94 "\t Test UNSUPPORTED: Solaris server does not return $expcode."
95 } else {
96 ckres "Readdir" $status $expcode $res $PASS
97 }
98
99 # n: Readdir with a bad cookieverf, expect BAD_COOKIE
100 set expcode "BAD_COOKIE"
101 set ASSERTION "Readdir with a bad cookieverf, expect $expcode"
102 set tag "$TNAME{n}"
103 putmsg stdout 0 "$tag: $ASSERTION"
104 set cookie 0
105 set cookieverf 88888888888888888
106 set res [compound {Putfh $bfh;
107 Readdir $cookie $cookieverf 512 2048 fsid}]
108 if { "$env(SRVOS)" == "Solaris" } {
109 putmsg stdout 0 \
110 "\t Test UNSUPPORTED: Solaris server does not return $expcode."
111 } else {
112 ckres "Readdir" $status $expcode $res $PASS
113 }
114
115 # o1: Readdir w/first cookieverf is non-zero, expect NOT_SAME
116 set expcode "NOT_SAME"
117 set ASSERTION "Readdir with first cookieverf non-zero, expect $expcode"
118 set tag "$TNAME{o1}"
119 putmsg stdout 0 "$tag: $ASSERTION"
120 set cookie 0
121 set cookieverf 1
122 set res [compound {Putfh $bfh;
123 Readdir $cookie $cookieverf 512 512 {aclsupport case_insensitive}}]
124 ckres "Readdir" $status $expcode $res $PASS
125
126 # o2: Readdir w/corrupted second cookieverf, expect NOT_SAME
127 set expcode "NOT_SAME"
128 set ASSERTION "Readdir w/corrupted 2nd cookieverf, expect $expcode"
129 set tag "$TNAME{o2}"
130 putmsg stdout 0 "$tag: $ASSERTION"
131 set cookie 0
132 set verf 0
133 set dfh [get_fh "$BASEDIRS $env(LARGEDIR)"]
134 set res [compound {Putfh $dfh;
135 Readdir $cookie $verf 1024 1024 {size mode}; Getfh}]
136 if {[ckres "Readdir" $status "OK" $res $FAIL] == "true"} {
137 set eof [lindex [lindex $res 1] 4]
138 if { $eof != "false" } {
139 putmsg stdout 0 \
140 "\t Test NOTINUSE: $env(LARGEDIR) is to get eof=false"
141 } else {
142 set rdres [lindex [lindex $res 1] 3]
143 set cookie [lindex [lindex $rdres end] 0]
144 # get the verifier and corrupt it for testing
145 set verf [lindex [lindex $res 1] 2]
146 set badverf [string replace $verf 0 2 "77"]
147 set res [compound {Putfh $dfh;
148 Readdir $cookie $badverf 1024 1024 {type}; Getfh}]
149 ckres "Readdir" $status $expcode $res $PASS
150 }
151 }
152
153 # q: Readdir w/time_modify_set set, expect INVAL|ATTRNOTSUPP
154 # Readdir should fail if request asks for WRITE-only attribute
155 set expcode "INVAL|ATTRNOTSUPP"
156 set ASSERTION "Readdir w/time_modify_set attr, expect $expcode"
157 set tag "$TNAME{q}"
158 putmsg stdout 0 "$tag: $ASSERTION"
159 set attrs "time_modify_set type";
160 set res [compound {Putfh $bfh; Lookup $env(DIR0777); Getfh;
161 Readdir 0 0 2048 2048 $attrs; Getfh}]
162 putmsg stdout 1 "compound {Putfh $bfh;"
163 putmsg stdout 1 "\t Lookup $env(DIR0777); Getfh;"
164 putmsg stdout 1 "\t Readdir 0 0 2048 2048 $attrs; Getfh}"
165 ckres "Readdir" $status $expcode $res $PASS
166
167 # r: Readdir w/time_access_set set, expect INVAL|ATTRNOTSUPP
168 # Solaris server would fail the request if it asks for WRITE-only attribute;
169 # even though "rdattr_error".
170 set expcode "INVAL|ATTRNOTSUPP"
171 set ASSERTION "Readdir w/{time_access_set rdattr_error} attrs, expect $expcode"
172 set tag "$TNAME{r}"
173 putmsg stdout 0 "$tag: $ASSERTION"
174 set attrs "time_access_set rdattr_error";
175 set res [compound {Putfh $bfh; Lookup $env(DIR0755);
176 Readdir 0 0 1024 1024 $attrs; Getfh}]
177 putmsg stdout 1 "compound {Putfh $bfh; Lookup $env(DIR0755);"
178 putmsg stdout 1 "\t Readdir 0 0 1024 1024 $attrs; Getfh}"
179 ckres "Readdir" $status $expcode $res $PASS
180
181 # s: Readdir of attrdir w/time_access/modify_set set, expect INVAL|ATTRNOTSUPP
182 set expcode "INVAL|ATTRNOTSUPP"
183 set tattrs {"time_access_set aclsupport" "rdattr_error type time_modify_set"};
184 set i 1
185 foreach attr $tattrs {
186 set tag "$TNAME{s$i}"
187 set ASSERTION "Readdir of attrdir w/{$attr} attr, expect $expcode"
188 putmsg stdout 0 "$tag: $ASSERTION"
189 set res [compound {Putfh $bfh; Lookup $env(ATTRDIR); Openattr F;
190 Readdir 0 0 1024 1024 $attr; Getfh}]
191 putmsg stdout 1 "compound {Putfh $bfh; Lookup $env(ATTRDIR);"
192 putmsg stdout 1 "\t Openattr F; Readdir 0 0 40960 2048 $attr; Getfh}"
193 ckres "Readdir" $status $expcode $res $PASS
194 incr i
195 }
196
197 # --------------------------------------------------------------
198 # disconnect and exit
199 Disconnect
200 exit $PASS