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 LOCK, LOCKT, LOCKU operation test - negative tests
27 # Verify server returns correct errors with negative requests.
28
29 # include all test enironment
30 source LOCKsid.env
31
32 # connect to the test server
33 Connect
34
35 # setting local variables
36 set TNAME $argv0
37 set bfh [get_fh $BASEDIRS]
38 set hid "[pid]-[expr int([expr [expr rand()] * 100000000])]"
39 set cid [getclientid $hid]
40 if {$cid == -1} {
41 putmsg stdout 0 "$TNAME: test setup - getclientid"
42 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
43 exit $UNRESOLVED
44 }
45 set seqid 1
46
47 # Create a temp test file and get it's filehandle
48 set TFILE "$TNAME.[pid]"
49 set size 999
50 set open_owner $TFILE
51 set nfh [basic_open $bfh $TFILE 1 "$cid $open_owner" \
52 osid oseqid status $seqid 0 666 $size]
53 if {$nfh == -1} {
54 putmsg stdout 0 "$TNAME: test setup - basic_open"
55 putmsg stderr 0 "\t Test UNRESOLVED: unable to create tmp file=($TFILE)"
56 putmsg stderr 0 "\t\t basic_open failed, status=($status)."
57 exit $UNRESOLVED
58 }
59 set oseqid [expr $oseqid + 1]
60
61
62 # Start testing
63 # --------------------------------------------------------------
64 # a: try Lock(R) while file is removed, expect STALE
65 set expcode "STALE"
66 set ASSERTION "try Lock(R) while file is removed, expect $expcode"
67 set tag "$TNAME{a}"
68 #putmsg stdout 0 "$tag: $ASSERTION"
69 #puts "\t Test UNTESTED: XXX Need different thread to remove <cfh> in server.\n"
70
71 # b: try Lockt(W) while file is removed, expect STALE
72 set expcode "STALE"
73 set ASSERTION "try Lockt(W) while file is removed, expect $expcode"
74 set tag "$TNAME{b}"
75 #putmsg stdout 0 "$tag: $ASSERTION"
76 #puts "\t Test UNTESTED: XXX Need different thread to remove <cfh> in server.\n"
77
78 # c: try Locku() while file is removed, expect STALE
79 set expcode "STALE"
80 set ASSERTION "try Locku() while file is removed, expect $expcode"
81 set tag "$TNAME{c}"
82 #putmsg stdout 0 "$tag: $ASSERTION"
83 #puts "\t Test UNTESTED: XXX Need different thread to remove <cfh> in server.\n"
84
85
86 # f: try to Lock on an expired FH, expect FHEXPIRED
87 set expcode "FHEXPIRED"
88 set ASSERTION "Lock an expired FH, expect $expcode"
89 set tag "$TNAME{f}"
90 #putmsg stdout 0 "$tag: $ASSERTION"
91 #puts "\t Test UNTESTED: XXX need hook to get FH expired.\n"
92
93 # g: try to Lockt on an expired FH, expect FHEXPIRED
94 set expcode "FHEXPIRED"
95 set ASSERTION "Lockt an expired FH, expect $expcode"
96 set tag "$TNAME{g}"
97 #putmsg stdout 0 "$tag: $ASSERTION"
98 #puts "\t Test UNTESTED: XXX need hook to get FH expired.\n"
99
100 # h: try to Locku on an expired FH, expect FHEXPIRED
101 set expcode "FHEXPIRED"
102 set ASSERTION "Locku an expired FH, expect $expcode"
103 set tag "$TNAME{h}"
104 #putmsg stdout 0 "$tag: $ASSERTION"
105 #puts "\t Test UNTESTED: XXX need hook to get FH expired.\n"
106
107
108 # l: Lock with a Bad-FH, expect BADHANDLE
109 set expcode "BADHANDLE"
110 set ASSERTION "Lock with a Bad-FH, expect $expcode"
111 set tag "$TNAME{l}"
112 #putmsg stdout 0 "$tag: $ASSERTION"
113 #puts "\t Test UNTESTED: XXX Need server hook to set Bad-FH for this test.\n"
114
115 # m: Lockt with a Bad-FH, expect BADHANDLE
116 set expcode "BADHANDLE"
117 set ASSERTION "Lockt with a Bad-FH, expect $expcode"
118 set tag "$TNAME{m}"
119 #putmsg stdout 0 "$tag: $ASSERTION"
120 #puts "\t Test UNTESTED: XXX Need server hook to set Bad-FH for this test.\n"
121
122 # n: Locku with a Bad-FH, expect BADHANDLE
123 set expcode "BADHANDLE"
124 set ASSERTION "Locku with a Bad-FH, expect $expcode"
125 set tag "$TNAME{n}"
126 #putmsg stdout 0 "$tag: $ASSERTION"
127 #puts "\t Test UNTESTED: XXX Need server hook to set Bad-FH for this test.\n"
128
129
130 # r: Lock with WrongSec, expect WRONGSEC
131 set expcode "WRONGSEC"
132 set ASSERTION "Lock with <cfh> is changed SEC, expect $expcode"
133 set tag "$TNAME{r}"
134 #putmsg stdout 0 "$tag: $ASSERTION"
135 #puts "\t Test UNTESTED: XXX Need diff thread in server to reset SEC on cfh\n"
136
137 # s: Lockt with WrongSec, expect WRONGSEC
138 set expcode "WRONGSEC"
139 set ASSERTION "Lockt with <cfh> is changed SEC, expect $expcode"
140 set tag "$TNAME{s}"
141 #putmsg stdout 0 "$tag: $ASSERTION"
142 #puts "\t Test UNTESTED: XXX Need diff thread in server to reset SEC on cfh\n"
143
144 # t: Locku with WrongSec, expect WRONGSEC
145 set expcode "WRONGSEC"
146 set ASSERTION "Lockt with <cfh> is changed SEC, expect $expcode"
147 set tag "$TNAME{t}"
148 #putmsg stdout 0 "$tag: $ASSERTION"
149 #puts "\t Test UNTESTED: XXX Need diff thread in server to reset SEC on cfh\n"
150
151
152 # y: XXX need a way to simulate these server errors:
153 # NFS4ERR_MOVED
154 # NFS4ERR_SERVERFAULT
155 # NFS4ERR_RESOURCE
156
157 # --------------------------------------------------------------
158 # Now cleanup, and removed created tmp file
159 set res [compound {Putfh $bfh; Remove $TFILE}]
160 if {($status != "OK") && ($status != "NOENT")} {
161 putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
162 putmsg stderr 0 "\t status=$status; please cleanup manually."
163 putmsg stderr 1 "\t res=($res)"
164 putmsg stderr 1 " "
165 exit $WARNING
166 }
167
168 # --------------------------------------------------------------
169 # disconnect and exit
170 Disconnect
171 exit $PASS