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 READ/WRITE operation test - positive boundary tests
27 # verify reading/writing of a attribute file around the boundary
28
29 # include all test enironment
30 source WRITE.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 res [compound {Putfh $bfh; Lookup $env(ATTRFILE); Openattr F; Getfh}]
39 if {$status != "OK"} {
40 putmsg stdout 0 "$TNAME: test setup - getclientid"
41 putmsg stderr 0 "\t Test UNRESOLVED: unable to get ATTRFILE filehandle."
42 putmsg stderr 1 "\tRes: $res"
43 exit $UNRESOLVED
44 }
45 set ofh [lindex [lindex $res 3] 2]
46
47 # First create a tmp file under ATTRDIR for testing
48 set hid "[pid][clock seconds]"
49 set cid [getclientid $hid]
50 if {$cid == -1} {
51 putmsg stdout 0 "$TNAME: test setup - getclientid"
52 putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
53 exit $UNRESOLVED
54 }
55 # Open to create the temp file:
56 set TFILE "$TNAME.[pid]"
57 set owner "owner-$TFILE"
58 set otype 1
59 set cid_owner "$cid $owner"
60 set nfh [basic_open $ofh $TFILE $otype $cid_owner open_sid oseqid status]
61 if {$nfh == -1} {
62 putmsg stdout 0 "$TNAME: test setup - basic_open"
63 putmsg stderr 0 \
64 "\t Test UNRESOLVED: create $TFILE failed, status=$status"
65 exit $UNRESOLVED
66 }
67
68 set 2G 2147483648
69
70
71 # Start testing
72 # --------------------------------------------------------------
73 # a: Write attr file up to 2G boundary (offset=2g-4K, data=4K) - expect OK
74 set expcode "OK"
75 set ASSERTION \
76 "Write attr file up to 2G boundary (off=2g-4K, data=4K), expect $expcode"
77 set tag "$TNAME{a}"
78 putmsg stdout 0 "$tag: $ASSERTION"
79 set count 4096
80 set off [expr $2G - $count]
81 set data [string repeat "A" $count]
82 set res [compound {Putfh $nfh; Write $open_sid $off f a $data; Getattr size}]
83 if {$status != "OK"} {
84 putmsg stderr 0 "\t Test FAIL: failed to write at $off for 4K."
85 putmsg stderr 1 "\t\t Res: $res"
86 } else {
87 set fsize [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
88 if {$fsize != $2G} {
89 putmsg stderr 0 "\t Test FAIL: incorrect file size after Write"
90 putmsg stderr 0 "\t\t expected=(2G); got=($fsize)"
91 putmsg stderr 1 "\t\t Res: $res"
92 } else {
93 logres PASS
94 }
95 }
96
97
98 # b: Read attr file up to 2G boundary (offset=2g-4K, count=4K) - expect OK
99 set expcode "OK"
100 set ASSERTION \
101 "Read attr file up to 2G boundary (off=2g-4K, count=4K), expect $expcode"
102 set tag "$TNAME{b}"
103 putmsg stdout 0 "$tag: $ASSERTION"
104 set res [compound {Putfh $nfh; Read $open_sid $off $count; Getattr size}]
105 if {$status != "OK"} {
106 putmsg stderr 0 "\t Test FAIL: failed to read at $off for $count."
107 putmsg stderr 1 "\t\t Res: $res"
108 } else {
109 set rsize [lindex [lindex [lindex [lindex $res 1] 2] 1] 1]
110 if {$rsize != $count} {
111 putmsg stderr 0 "\t Test FAIL: incorrect read len"
112 putmsg stderr 0 "\t\t expected=($count); got=($rsize)"
113 putmsg stderr 1 "\t\t Res: $res"
114 } else {
115 logres PASS
116 }
117 }
118
119
120 # c: Write attr file over 2G boundary (offset=2g-4K, data=8K) - expect OK
121 set expcode "OK"
122 set ASSERTION \
123 "Write attr file over 2G boundary (off=2g-4K, data=8K), expect $expcode"
124 set tag "$TNAME{c}"
125 putmsg stdout 0 "$tag: $ASSERTION"
126 set count 4096
127 set off [expr $2G - $count]
128 set data [string repeat "B" [expr $count * 2]]
129 set res [compound {Putfh $nfh; Write $open_sid $off f a $data; Getattr size}]
130 if {$status != "OK"} {
131 putmsg stderr 0 "\t Test FAIL: failed to write at $off for 4K."
132 putmsg stderr 1 "\t\t Res: $res"
133 } else {
134 set fsize [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
135 if {[expr $fsize - $count] != $2G} {
136 putmsg stderr 0 "\t Test FAIL: incorrect file size after Write"
137 putmsg stderr 0 "\t\t expected=(2G+4K); got=($fsize)"
138 putmsg stderr 1 "\t\t Res: $res"
139 } else {
140 logres PASS
141 }
142 }
143
144
145 # d: Read attr file over 2G boundary (offset=2g-4K, count=8K) - expect OK
146 set expcode "OK"
147 set ASSERTION \
148 "Read attr file over 2G boundary (off=2g-4K, count=8K), expect $expcode"
149 set tag "$TNAME{d}"
150 putmsg stdout 0 "$tag: $ASSERTION"
151 set count 8192
152 set res [compound {Putfh $nfh; Read $open_sid $off $count; Getattr size}]
153 if {$status != "OK"} {
154 putmsg stderr 0 "\t Test FAIL: failed to read at $off for $count."
155 putmsg stderr 1 "\t\t Res: $res"
156 } else {
157 set rsize [lindex [lindex [lindex [lindex $res 1] 2] 1] 1]
158 if {$rsize != $count} {
159 putmsg stderr 0 "\t Test FAIL: incorrect read len"
160 putmsg stderr 0 "\t\t expected=($count); got=($rsize)"
161 putmsg stderr 1 "\t\t Res: $res"
162 } else {
163 logres PASS
164 }
165 }
166
167
168 # --------------------------------------------------------------
169 # Cleanup the temp file:
170 incr oseqid
171 set res [compound {Putfh $nfh; Close $oseqid $open_sid;
172 Putfh $ofh; Remove $TFILE}]
173 if { "$status" != "OK" } {
174 putmsg stderr 0 "\t WARNING: cleanup to remove $TFILE failed"
175 putmsg stderr 0 "\t status=$status; please cleanup manually."
176 putmsg stderr 1 "\t res=($res)"
177 putmsg stderr 1 " "
178 exit $WARNING
179 }
180
181 # disconnect and exit
182 Disconnect
183 exit $PASS