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 RENEW operation test - negative tests
27
28 # include all test enironment
29 source RENEW.env
30
31 # connect to the test server
32 Connect
33
34 # setting local variables
35 set TNAME $argv0
36 set tag "$TNAME.setup"
37 set bfh [get_fh $BASEDIRS]
38
39 # Start testing
40 # --------------------------------------------------------------
41 # a: Renew without correct clientid, expect STALE_CLIENTID
42 set expcode "STALE_CLIENTID"
43 set ASSERTION "Renew without correct clientid, expect $expcode"
44 set tag "$TNAME{a}"
45 putmsg stdout 0 "$tag: $ASSERTION"
46 set res [compound {Renew "junk.id"}]
47 ckres "Renew" $status $expcode $res $PASS
48
49
50 # Get server lease time for the following assertions
51 set leasetm $LEASE_TIME
52
53 set overlease [expr ($leasetm + 8) * 1000]
54
55
56 # b: Renew with an old clientid, expect EXPIRED
57 set expcode "EXPIRED"
58 set ASSERTION "Renew with an old clientid, expect $expcode"
59 set tag "$TNAME{b}"
60 putmsg stdout 0 "$tag: $ASSERTION"
61 set owner "$TNAME.[clock seconds]-b"
62 set clientid1 [getclientid $owner]
63 if {$clientid1 == -1} {
64 putmsg stderr 0 "\t Test UNRESOLVED: getclientid failed"
65 } else {
66 putmsg stdout 1 "leasetm=$leasetm, clientid1=$clientid1"
67 # wait for lease to expire and verify it w/Open
68 after $overlease
69 set OPENexp "EXPIRED"
70 set res [compound {Putfh $bfh;
71 Open 1 3 0 {$clientid1 $owner} \
72 {0 0 {{mode 0666}}} {0 $env(ROFILE)}}]
73 if {[ckres "Open" $status $OPENexp $res $FAIL] == "true"} {
74 # Get a new clientid
75 set owner2 "$owner-2"
76 set clientid2 [getclientid $owner2]
77 if {$clientid2 == -1} {
78 putmsg stderr 0 "\t Test UNRESOLVED: getclientid2 failed"
79 } else {
80 putmsg stdout 1 "clientid2=$clientid2"
81 after 5000
82 # But use clientid1 in Renew, should fail
83 set res [compound {Renew $clientid1}]
84 ckres "Renew" $status $expcode $res $PASS
85 }
86 }
87 }
88
89
90 # c: Renew fails when lease expired, expect EXPIRED
91 set expcode "EXPIRED"
92 set ASSERTION "Renew fails when expired, expect $expcode"
93 set tag "$TNAME{c}"
94 putmsg stdout 0 "$tag: $ASSERTION"
95 set owner "$TNAME.[clock seconds]-c"
96 set clientid1 [getclientid $owner]
97 if {$clientid1 == -1} {
98 putmsg stderr 0 "\t Test UNRESOLVED: getclientid failed"
99 } else {
100 putmsg stdout 1 "leasetm=$leasetm, clientid1=$clientid1"
101 # wait for lease to expire and verify it w/Open
102 after $overlease
103 set nfh [basic_open $bfh $env(ROFILE) 0 "$clientid1 $owner" \
104 osid oseqid status 1 1]
105 if {($status != "EXPIRED") && ($status != "$expcode")} {
106 putmsg stderr 0 "Test UNRESOLVED: Open got status=($status)"
107 putmsg stderr 0 " expected status=(EXPIRED|$expcode)"
108 } else {
109 set res [compound {Renew $clientid1}]
110 ckres "Renew" $status $expcode $res $PASS
111 }
112 }
113
114
115 # --------------------------------------------------------------
116 # disconnect and exit
117 set tag "$TNAME.cleanup"
118 Disconnect
119 exit $PASS