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 OPEN operation test - positive tests
27 # Basic fucntion of OPEN op
28
29 # include all test enironment
30 source OPEN.env
31 source OPEN_proc
32
33 # connect to the test server
34 Connect
35
36 # setting local variables
37 set TNAME $argv0
38 set bfh [get_fh "$BASEDIRS"]
39 set cid [getclientid $TNAME.[pid]]
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 owner "$TNAME-OpenOwner"
46
47
48 # Start testing
49 # --------------------------------------------------------------
50 # a: Open an existing RW file (access=3,deny=0,createmode=0), expect OK
51 set expcode "OK"
52 set ASSERTION \
53 "Open existing RW file (access=3,deny=0,create=0), expect $expcode"
54 set tag "$TNAME{a}"
55 putmsg stdout 0 "$tag: $ASSERTION"
56 set seqid 1
57 set TFILE $env(RWFILE)
58 set res [compound {Putfh $bfh;
59 Open $seqid 3 0 "$cid $owner-00111" {0 0 {{mode 0644}}} {0 $TFILE};
60 Getfh; Putfh $bfh; Lookup $TFILE; Getfh}]
61 set cont [ckres "Open" $status $expcode $res $FAIL]
62 if {$cont == "true"} {
63 # verify the FH of OPEN is same as LOOKUP
64 set fh1 [lindex [lindex $res 2] 2]
65 set fh2 [lindex [lindex $res 5] 2]
66 if {[fh_equal $fh1 $fh2 $cont $PASS] != "true"} {
67 putmsg stderr 0 " ** WARNING: assertion <a> did not PASS;"
68 putmsg stderr 0 \
69 "\tassertion <a1> may not run correctly as <a1> depends on <a>"
70 }
71
72 # a1: Replay the same Open request, expect OK
73 set expcode "OK"
74 set ASSERTION "Replay the same Open request, expect $expcode"
75 set tag "$TNAME{a1}"
76 putmsg stdout 0 "$tag: $ASSERTION"
77 set res [compound {Putfh $bfh;
78 Open $seqid 3 0 "$cid $owner-00111" \
79 {0 0 {{mode 0644}}} {0 $TFILE}; Getfh}]
80 if {[ckres "Open" $status $expcode $res $FAIL] == "true"} {
81 # verify the FH of OPEN is good to close)
82 set stateid [lindex [lindex $res 1] 2]
83 set rflags [lindex [lindex $res 1] 4]
84 incr seqid
85 if {[ckclose $fh1 $rflags $seqid $stateid] == "true"} {
86 logres "PASS"
87 }
88 }
89 }
90
91
92 # b: Open w/<cfh> is NAMEATTR (access=1,deny=0,createmode=0), expect OK
93 set expcode "OK"
94 set ASSERTION \
95 "Open RO file w/cfh=NAMEATTR (access=1,deny=0,create=0), expect $expcode"
96 set tag "$TNAME{b}"
97 putmsg stdout 0 "$tag: $ASSERTION"
98 set oseqid 10
99 set TFILE $env(ATTRDIR_AT1)
100 set res [compound {Putfh $bfh; Lookup $env(ATTRDIR); Openattr T; Getfh;
101 Open $oseqid 1 0 "$cid $owner-00222" {0 0 {{mode 0644}}} {0 $TFILE}
102 Getfh}]
103 if {[ckres "Open" $status $expcode $res $FAIL] == "true"} {
104 # verify the FH of OPEN is good (to close) and is same as LOOKUP
105 set stateid [lindex [lindex $res 4] 2]
106 set rflags [lindex [lindex $res 4] 4]
107 set fh1 [lindex [lindex $res 5] 2]
108 set nafh [lindex [lindex $res 3] 2]
109 set res [compound {Putfh $nafh; Lookup $TFILE; Getfh}]
110 set fh2 [lindex [lindex $res 2] 2]
111 incr oseqid
112 set cont [ckclose $fh1 $rflags $oseqid $stateid]
113 if {"$cont" == "true"} {
114 fh_equal $fh1 $fh2 $cont $PASS
115 }
116 }
117
118
119 # f: Open a file w/out Confirm, and Open another file w/same owner.
120 # Then try to confirm second OPEN, expect OK
121 set expcode "OK"
122 set A "OPEN a file w/out Confirm, OPEN another file w/same owner; \n"
123 set ASSERTION "$A \t then try to confirm 2nd OPEN, expect $expcode"
124 set tag "$TNAME{f}"
125 putmsg stdout 0 "$tag: $ASSERTION"
126 set seqid 10
127 set TFILE $env(RWFILE)
128 set res [compound {Putfh $bfh;
129 Open $seqid 3 0 "$cid $owner" {0 0 {{mode 0644}}} {0 $env(RWFILE)}; Getfh}]
130 if {$status != "OK"} {
131 putmsg stderr 0 "\t Test UNRESOLVED: failed on 1st Open $env(RWFILE)"
132 putmsg stderr 0 "\t\t expected status=($expcode), got=($status)"
133 putmsg stderr 1 "\t Res=($res)."
134 } else {
135 set oseqid 100
136 set res [compound {Putfh $bfh;
137 Open $oseqid 1 0 "$cid $owner" {0 0 {{mode 0644}}} {0 $env(TEXTFILE)};
138 Getfh}]
139 if {$status != "OK"} {
140 putmsg stderr 0 "\t Test UNRESOLVED: failed on 2nd Open $env(TEXTFILE)"
141 putmsg stderr 0 "\t\t expected status=($expcode), got=($status)"
142 putmsg stderr 1 "\t Res=($res)."
143 } else {
144 set osid [lindex [lindex $res 1] 2]
145 set rflags [lindex [lindex $res 1] 4]
146 set nfh [lindex [lindex $res 2] 2]
147 if {[expr $rflags & $OPEN4_RESULT_CONFIRM] == $OPEN4_RESULT_CONFIRM} {
148 incr oseqid
149 set res [compound {Putfh $nfh; Open_confirm $osid $oseqid}]
150 ckres "Open_conform" $status $expcode $res $PASS
151 if {$status == "OK"} {
152 set osid [lindex [lindex $res 1] 2]
153 }
154 } else {
155 putmsg stderr 0 "\t Test NOTINUSE: 2nd OPEN did not ask for confirm"
156 putmsg stderr 1 "\t Res=($res)."
157 }
158 # Close the file to make file in clear state:
159 incr oseqid
160 set res [compound {Putfh $nfh; Close $oseqid $osid}]
161 putmsg stderr 1 "\t CLOSE res=($res)."
162 }
163 }
164
165
166 # --------------------------------------------------------------
167 # disconnect and exit
168 Disconnect
169 exit $PASS