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 RELEASE_LOCKOWNER operation test - positive tests
27
28 # include all test enironment
29 source RELEASE_LOCKOWNER.env
30
31 # connect to the test server
32 Connect
33
34 # setting local variables
35 set TNAME $argv0
36 set bfh [get_fh "$BASEDIRS"]
37 set hid "[pid][expr int([expr [expr rand()] * 100000000])]"
38 set cid [getclientid $hid]
39 if {$cid == -1} {
40 putmsg stderr 0 "$TNAME: setup - getclientid"
41 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
42 exit $UNRESOLVED
43 }
44 # Create a test file and get its osid
45 set TFILE "$TNAME.[pid]"
46 set oowner "[pid]-[expr int([expr [expr rand()] * 100000000])]"
47 set nfh [basic_open $bfh $TFILE 1 "$cid $oowner" osid oseqid status \
48 1 0 664 1024]
49 if {$nfh == -1} {
50 putmsg stderr 0 "$TNAME: setup - basic_open"
51 putmsg stderr 0 "\t Test UNRESOLVED: status=($status)"
52 exit $UNRESOLVED
53 }
54 set oseqid [expr $oseqid + 1]
55 set lseqid 1
56 set lowner "$TNAME-lower.[pid]"
57
58
59 # Start testing
60 # --------------------------------------------------------------
61 # a: basic Release_lockowner w/valid clientid, non-existent lockowner, expect OK
62 set expcode "OK"
63 set ASSERTION "Release_lockowner w/valid clientid & non-existent lockowner"
64 set ASSERTION "$ASSERTION, expect $expcode"
65 set tag "$TNAME{a}"
66 putmsg stdout 0 "$tag: $ASSERTION"
67 set res [compound {Putfh $bfh; Release_lockowner $cid $lowner}]
68 ckres "Release_lockowner" $status $expcode $res $PASS
69
70 # b: Release_lockowner w/valid clientid & lockowner, expect OK
71 set expcode "OK"
72 set ASSERTION "Release_lockowner w/valid cid & lockowner, expect $expcode"
73 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
74 # First set a lock with the lock owner
75 set res [compound {Putfh $nfh;
76 Lock 1 F 0 100 T $osid $lseqid "$oseqid $cid $lowner"}]
77 if { [ckres "Lock(R)" $status $expcode $res $FAIL] != "true" } {
78 set lsid {11 22}
79 } else {
80 set lsid [lindex [lindex $res 1] 2]
81 incr lseqid
82 incr oseqid
83 set res [compound {Putfh $nfh; Locku 1 $lseqid $lsid 0 100;
84 Release_lockowner $cid $lowner}]
85 if {[ckres "Release_lockowner/Locku" $status $expcode $res $FAIL]
86 == "true"} {
87 # verify lowner is no longer valid
88 set res [compound {Putfh $nfh; Lockt 2 $cid $lowner 80 22}]
89 ckres "Release_lockowner/Lockt" $status $expcode $res $PASS
90 }
91 }
92
93 # c: Release_lockowner w/valid clientid, released lockowner, expect OK
94 set expcode "OK"
95 set ASSERTION "Release_lockowner w/valid clientid & released lockowner"
96 set ASSERTION "$ASSERTION, expect $expcode"
97 set tag "$TNAME{c}"
98 putmsg stdout 0 "$tag: $ASSERTION"
99 set res [compound {Putfh $bfh; Release_lockowner $cid $lowner}]
100 ckres "Release_lockowner" $status $expcode $res $PASS
101
102
103 # Now cleanup, close and removed created tmp file
104 set res [compound {Putfh $bfh; Remove $TFILE}]
105 if {($status != "OK") && ($status != "NOENT")} {
106 putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
107 putmsg stderr 0 "\t status=$status; please cleanup manually."
108 putmsg stderr 1 "\t res=($res)"
109 putmsg stderr 1 " "
110 exit $WARNING
111 }
112
113
114 # --------------------------------------------------------------
115 # disconnect and exit
116 Disconnect
117 exit $PASS