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 operation test - positive tests
27 # verify reading of a textfile with different offset/count
28
29 # include all test enironment
30 source READ.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
39 # Get the size of the $TEXTFILE file
40 set res [compound {Putfh $bfh; Lookup $env(TEXTFILE); Getattr size}]
41 set fsize [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
42
43
44 # Start testing
45 # --------------------------------------------------------------
46 # a: Read a regular file using count > filesize - expect OK
47 set expcode "OK"
48 set ASSERTION "Read a regular file using count > filesize, expect $expcode"
49 set tag "$TNAME{a}"
50 putmsg stdout 0 "$tag: $ASSERTION"
51 set count [expr $fsize + 100]
52 ckread $bfh "$env(TEXTFILE)" 0 $count $expcode $fsize "true"
53
54
55 # b: Read a regular file using offset > filesize - expect OK
56 set expcode "OK"
57 set ASSERTION "Read a regular file using offset > filesize, expect $expcode"
58 set tag "$TNAME{b}"
59 putmsg stdout 0 "$tag: $ASSERTION"
60 set offset [expr $fsize + 100]
61 ckread $bfh "$env(TEXTFILE)" $offset 256 $expcode 0 "true"
62
63
64 # c: Read a regular file using count=0 - expect OK
65 set expcode "OK"
66 set ASSERTION "Read a regular file using count=0, expect $expcode"
67 set tag "$TNAME{c}"
68 putmsg stdout 0 "$tag: $ASSERTION"
69 set count 0
70 ckread $bfh "$env(TEXTFILE)" 0 $count $expcode $count "false"
71
72
73 # d: Read an empty file using offset/count > 0 - expect OK
74 set expcode "OK"
75 set ASSERTION "Read an empty file using offset/count > 0, expect $expcode"
76 set tag "$TNAME{d}"
77 putmsg stdout 0 "$tag: $ASSERTION"
78 ckread $bfh "$env(ROEMPTY)" 0 256 $expcode 0 "true"
79
80
81 # e: Read a regular file using offset=count=1/4(fsize) - expect OK
82 set expcode "OK"
83 set ASSERTION "Read a regular file w/offset=count=1/3(fsize), expect $expcode"
84 set tag "$TNAME{e}"
85 putmsg stdout 0 "$tag: $ASSERTION"
86 set count [expr $fsize / 3]
87 ckread $bfh "$env(TEXTFILE)" $count $count $expcode $count "false"
88
89
90 # f: Read a regular file till eof - expect OK
91 set expcode "OK"
92 set ASSERTION "Read a regular file till EOF, expect $expcode"
93 set tag "$TNAME{f}"
94 putmsg stdout 0 "$tag: $ASSERTION"
95 set count [expr $fsize * 2]
96 ckread $bfh "$env(TEXTFILE)" 0 $count $expcode $fsize "true"
97
98
99 # i: Read a regular file with max count (-1) - expect OK
100 set expcode "OK"
101 set ASSERTION "Read a regular file with max count (-1), expect $expcode"
102 set tag "$TNAME{i}"
103 putmsg stdout 0 "$tag: $ASSERTION"
104 set count -1
105 ckread $bfh "$env(TEXTFILE)" 0 $count $expcode $fsize "true"
106
107
108 # j: Read a regular file with max offset (-1) - expect OK
109 set expcode "OK"
110 set ASSERTION "Read a regular file with max offset (-1), expect $expcode"
111 set tag "$TNAME{j}"
112 putmsg stdout 0 "$tag: $ASSERTION"
113 set off -1
114 ckread $bfh "$env(TEXTFILE)" $off 16 $expcode 0 "true"
115
116
117 # --------------------------------------------------------------
118 # disconnect and exit
119 Disconnect
120 exit $PASS