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 READLINK operation test - positive tests
27
28 # include all test enironment
29 source READLINK.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
38 # Start testing
39 # --------------------------------------------------------------
40 # a: Reading an existing symlink file, expect OK
41 set expcode "OK"
42 set ASSERTION "Reading an existing symlink file, expect $expcode"
43 set tag "$TNAME{a}"
44 putmsg stdout 0 "$tag: $ASSERTION"
45 set res [compound {Putfh $bfh; Lookup $env(SYMLFILE);
46 Getfh; Readlink; Getfh}]
47 set cont [ckres "Readlink" $status $expcode $res $FAIL]
48 # verify Readlink result
49 if {! [string equal $cont "false"]} {
50 set ldata [lindex [lindex $res 3] 2]
51 set expd $env(EXECFILE)
52 if { $ldata != $expd } {
53 putmsg stderr 0 "\t Test FAIL: linktext returned incorrect"
54 putmsg stderr 0 "\t expected=($expd), got=($ldata)"
55 putmsg stderr 1 "\t res=($res)"
56 set cont false
57 }
58 }
59 # verify FH is not changed after successful Readdir op
60 set fh1 [lindex [lindex $res 2] 2]
61 set fh2 [lindex [lindex $res 4] 2]
62 fh_equal $fh1 $fh2 $cont $PASS
63
64
65 # b: Reading an existing symlink dir_noperm, expect OK
66 set expcode "OK"
67 set ASSERTION "Reading an existing symlink dir_noperm, expect $expcode"
68 set tag "$TNAME{b}"
69 putmsg stdout 0 "$tag: $ASSERTION"
70 set res [compound {Putfh $bfh; Lookup $env(SYMNOPD);
71 Getfh; Readlink; Getfh}]
72 set cont [ckres "Readlink" $status $expcode $res $FAIL]
73 # verify Readlink result
74 if {! [string equal $cont "false"]} {
75 set ldata [lindex [lindex $res 3] 2]
76 set expd $env(DNOPERM)
77 if { $ldata != $expd } {
78 putmsg stderr 0 "\t Test FAIL: linktext returned incorrect"
79 putmsg stderr 0 "\t expected=($expd), got=($ldata)"
80 putmsg stderr 1 "\t res=($res)"
81 set cont false
82 }
83 }
84 # verify FH is not changed after successful Readdir op
85 set fh1 [lindex [lindex $res 2] 2]
86 set fh2 [lindex [lindex $res 4] 2]
87 fh_equal $fh1 $fh2 $cont $PASS
88
89
90 # c: Reading a symlink created by NFS client, expect OK
91 set expcode "OK"
92 set ASSERTION "Reading a symlink created by NFS client, expect $expcode"
93 set tag "$TNAME{c}"
94 putmsg stdout 0 "$tag: $ASSERTION"
95 set nlc "NewSymL.[pid]"
96 set res [compound {Putfh $bfh; Create "$nlc" {{mode 0666}} l "$env(DIR0755)";
97 Getfh; Readlink; Getfh}]
98 set cont [ckres "Readlink" $status $expcode $res $FAIL]
99 # verify Readlink result
100 if {! [string equal $cont "false"]} {
101 set ldata [lindex [lindex $res 3] 2]
102 set expd $env(DIR0755)
103 if { $ldata != $expd } {
104 putmsg stderr 0 "\t Test FAIL: linktext returned incorrect"
105 putmsg stderr 0 "\t expected=($expd), got=($ldata)"
106 putmsg stderr 1 "\t res=($res)"
107 set cont false
108 }
109 }
110 # verify FH is not changed after successful Readdir op
111 set fh1 [lindex [lindex $res 2] 2]
112 set fh2 [lindex [lindex $res 4] 2]
113 fh_equal $fh1 $fh2 $cont $PASS
114
115
116 # d: Reading a symlink points to invalid obj, expect OK
117 set expcode "OK"
118 set ASSERTION "Reading a symlink points to invalid obj, expect $expcode"
119 set tag "$TNAME{d}"
120 putmsg stdout 0 "$tag: $ASSERTION"
121 set nld "BadSymL.[pid]"
122 set lksrc "No-such-thing"
123 set res [compound {Putfh $bfh; Create "$nld" {{mode 0666}} l $lksrc;
124 Getfh; Readlink; Getfh}]
125 set cont [ckres "Readlink" $status $expcode $res $FAIL]
126 # verify Readlink result
127 if {! [string equal $cont "false"]} {
128 set ldata [lindex [lindex $res 3] 2]
129 set expd $lksrc
130 if { $ldata != $expd } {
131 putmsg stderr 0 "\t Test FAIL: linktext returned incorrect"
132 putmsg stderr 0 "\t expected=($expd), got=($ldata)"
133 putmsg stderr 1 "\t res=($res)"
134 set cont false
135 }
136 }
137 # verify FH is not changed after successful Readdir op
138 set fh1 [lindex [lindex $res 2] 2]
139 set fh2 [lindex [lindex $res 4] 2]
140 fh_equal $fh1 $fh2 $cont $PASS
141
142
143 # --------------------------------------------------------------
144 # Final cleanup:
145 # remove the created temp link files
146 set res [compound {Putfh $bfh; Remove $nlc; Remove $nld}]
147 if { "$status" != "OK" } {
148 putmsg stderr 0 "\t WARNING: cleanup to remove created links failed"
149 putmsg stderr 0 "\t status=$status; please cleanup manually."
150 putmsg stderr 1 "\t res=($res)"
151 putmsg stderr 1 " "
152 exit $WARNING
153 }
154
155 # disconnect and exit
156 Disconnect
157 exit $PASS