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
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 cid [getclientid $TNAME.[pid]]
39 if {$cid == -1} {
40 putmsg stdout 0 "$TNAME: test setup - getclientid"
41 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
42 exit $UNRESOLVED
43 }
44 set owner "$TNAME-OpenOwner"
45
46
47 # Start testing
48 # --------------------------------------------------------------
49 # a: Open(CREATE/GUARDED) new file (size=888), expect OK
50 set expcode "OK"
51 set ASSERTION "Open(CREATE/UNCHECK) new file (size=888), expect $expcode"
52 set tag "$TNAME{a}"
53 putmsg stdout 0 "$tag: $ASSERTION"
54 set seqid 1
55 set size 888
56 set TFILE "$TNAME.[pid]-a"
57 set nfh [basic_open $bfh $TFILE 1 "$cid $owner-a" osid oseqid status \
58 $seqid 0 666 $size]
59 if {$nfh == -1} {
60 putmsg stderr 0 "\t Test UNRESOLVED: basic_open failed, status=($status)"
61 } else {
62 # verify new filehandle is good (to close) and size is 888
63 set oseqid [expr $oseqid + 1]
64 set res [compound {Putfh $nfh; Close $oseqid $osid; Getattr size}]
65 if {[ckres "Close" $status $expcode $res $FAIL] == "true"} {
66 set nsize [extract_attr [lindex [lindex $res 2] 2] size]
67 if {$nsize != $size} {
68 putmsg stderr 0 "\t Test FAIL: size created incorrect"
69 putmsg stderr 0 "\t\t expected=($size), got=($nsize)."
70 putmsg stderr 1 "\t\t Res: $res"
71 } else {
72 logres PASS
73 }
74 }
75 }
76
77
78
79 # b: Open(CREATE/UNCHECK) existing file (size=0) to truncate, expect OK
80 set expcode "OK"
81 set ASSERTION \
82 "Open(CREATE/UNCHECK) old file (size=0) to truncate, expect $expcode"
83 set tag "$TNAME{b}"
84 putmsg stdout 0 "$tag: $ASSERTION"
85 set seqid 10
86 set size 0
87 set nfh [basic_open $bfh $TFILE 1 "$cid $owner-b" osid oseqid status \
88 $seqid 0 666 $size]
89 if {$nfh == -1} {
90 putmsg stderr 0 "\t Test UNRESOLVED: basic_open failed, status=($status)"
91 } else {
92 # verify new filehandle is good (to close) and size is 0
93 set oseqid [expr $oseqid + 1]
94 set res [compound {Putfh $nfh; Close $oseqid $osid; Getattr size}]
95 if {[ckres "Close" $status $expcode $res $FAIL] == "true"} {
96 set nsize [extract_attr [lindex [lindex $res 2] 2] size]
97 if {$nsize != $size} {
98 putmsg stderr 0 "\t Test FAIL: size created incorrect"
99 putmsg stderr 0 "\t\t expected=($size), got=($nsize)."
100 putmsg stderr 1 "\t\t Res: $res"
101 } else {
102 logres PASS
103 }
104 }
105 }
106
107
108 # --------------------------------------------------------------
109 # Now cleanup, and removed created tmp file
110 set res [compound {Putfh $bfh; Remove $TFILE}]
111 if { "$status" != "OK" } {
112 putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
113 putmsg stderr 0 "\t status=$status; please cleanup manually."
114 putmsg stderr 1 "\t res=($res)"
115 putmsg stderr 1 " "
116 exit $WARNING
117 }
118
119 # disconnect and exit
120 Disconnect
121 exit $PASS