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 PUTFH operation test - negative tests
27
28 # include all test enironment
29 source PUTFH.env
30
31 # connect to the test server
32 Connect
33
34 # setting local variables
35 set TNAME $argv0
36 set fh [ get_fh "$BASEDIRS" ]
37
38 # Start testing
39 # --------------------------------------------------------------
40 # a: try to putfh of a bad FH="0000", expect BADHANDLE
41 set expcode "BADHANDLE"
42 set tag "$TNAME{a}"
43 set ASSERTION "Putfh a bad FH='0000', expect $expcode"
44 putmsg stdout 0 "$tag: $ASSERTION"
45 set bfh "0000"
46 set res [compound {Putfh $bfh; Getattr type}]
47 ckres "Putfh" $status $expcode $res $PASS
48
49
50 # b: putfh of a FH w/len < valid len server provides, expect BADHANDLE
51 set expcode "BADHANDLE"
52 set tag "$TNAME{b}"
53 set ASSERTION "Putfh a FH with len < valid_FH_len from server, expect $expcode"
54 putmsg stdout 0 "$tag: $ASSERTION"
55 set fh_len [string length $fh]
56 set endck [ expr $fh_len - 1]
57 for {set i 1} {$i < $endck} {incr i} {
58 set bfh [string range $fh 0 $i]
59 set res [compound {Putfh $bfh; Getattr filehandle}]
60 set con [ckres "Putfh" $status $expcode $res $FAIL]
61 if {$con == "false"} {
62 putmsg stdout 0 " i=<$i>, bfh=<$bfh>"
63 set bfh_len [string length $bfh]
64 putmsg stdout 1 " valid_fh=<$fh>"
65 putmsg stdout 1 " fh_len=<$fh_len>, bfh_len=<$bfh_len>"
66 break
67 }
68 }
69 if {$con == "true"} {
70 putmsg stdout 0 "\t Test PASS"
71 }
72
73 # c: putfh of a FH w/len > valid len server provides, expect BADHANDLE
74 set expcode "BADHANDLE"
75 set tag "$TNAME{c}"
76 set ASSERTION "Putfh a FH with len > valid_FH_len from server, expect $expcode"
77 putmsg stdout 0 "$tag: $ASSERTION"
78 set fh_len [string length $fh]
79 set bfh $fh
80 for {set i 1} {$i < 33} {incr i} {
81 set bfh "${bfh}0"
82 set res [compound {Putfh $bfh; Getattr filehandle}]
83 set con [ckres "Putfh" $status $expcode $res $FAIL]
84 if {$con == "false"} {
85 putmsg stdout 0 " i=<$i>, bfh=<$bfh>"
86 set bfh_len [string length $bfh]
87 putmsg stdout 1 " valid_fh=<$fh>"
88 putmsg stdout 1 " fh_len=<$fh_len>, bfh_len=<$bfh_len>"
89 break
90 }
91 }
92 if {$con == "true"} {
93 putmsg stdout 0 "\t Test PASS"
94 }
95
96
97 # d: object.nfs_fh4_val=NULL, expect BADHANDLE
98 set expcode "BADHANDLE"
99 set tag "$TNAME{d}"
100 set ASSERTION "Putfh object.nfs_fh4_val=NULL, expect $expcode"
101 #putmsg stdout 0 "$tag: $ASSERTION"
102 #puts "\t Test UNTESTED: XXX need nfsv4shell to null the object.\n"
103
104
105 # e: object.nfs_fh4_len=-1, expect BADHANDLE
106 set expcode "BADHANDLE"
107 set tag "$TNAME{e}"
108 set ASSERTION "Putfh object.nfs_fh4_len=-1, expect $expcode"
109 #putmsg stdout 0 "$tag: $ASSERTION"
110 #putmsg stdout 0 "$TNAME{e}: $ASSERTION"
111 #puts "\t Test UNTESTED: XXX need nfsv4shell to set invalid len the object.\n"
112
113
114 # f: object.nfs_fh4_len=0??, expect BADHANDLE
115 set expcode "BADHANDLE"
116 set tag "$TNAME{f}"
117 set ASSERTION "Putfh object.nfs_fh4_len=0, expect $expcode"
118 #putmsg stdout 0 "$tag: $ASSERTION"
119 #puts "\t Test UNTESTED: XXX need nfsv4shell to set zero len the object.\n"
120
121
122 # g: Putfh the FH with file removed, expect STALE
123 set expcode "STALE"
124 set tag "$TNAME{g}"
125 set ASSERTION "Putfh the FH with file removed, expect $expcode"
126 putmsg stdout 0 "$tag: $ASSERTION"
127 set tmpd "tmp.[pid]"
128 set res [compound {Putfh $fh; Create $tmpd {{mode 0777}} d; Getfh}]
129 set tfh [lindex [lindex $res 2] 2]
130 set res [compound {Putfh $fh; Remove $tmpd; Putfh $tfh; Getfh}]
131 ckres "Putfh" $status $expcode $res $PASS
132
133
134 # h: putfh with WrongSec, expect WRONGSEC
135 set expcode "WRONGSEC"
136 set tag "$TNAME{h}"
137 set ASSERTION "Putfh while FH changed to KRB5, expect $expcode"
138 #putmsg stdout 0 "$tag: $ASSERTION"
139 #puts "\t Test UNTESTED: XXX need support to change SEC of FH from SERVER.\n"
140
141
142 # i: XXX how do we simulate some server errors:
143 # NFS4ERR_MOVE
144 # NFS4ERR_SERVERFAULT
145 # NFS4ERR_RESOURCE
146
147
148 # m: try to putfh of expired FH, expect FHEXPIRED
149 set expcode "FHEXPIRED"
150 set tag "$TNAME{m}"
151 set ASSERTION "Putfh an expired FH, expect $expcode"
152 #putmsg stdout 0 "$tag: $ASSERTION"
153 #puts "\t Test UNTESTED: XXX need server hook for FH to expire.\n"
154
155
156 # --------------------------------------------------------------
157 # disconnect and exit
158 Disconnect
159 exit $PASS