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 - negative 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: Readlink without Putrootfh, expect NOFILEHANDLE
41 set expcode "NOFILEHANDLE"
42 set ASSERTION "Try to link with no Putrootfh, expect $expcode"
43 set tag "$TNAME{a}"
44 putmsg stdout 0 "$tag: $ASSERTION"
45 set res [compound {Readlink $env(SYMLFILE)}]
46 ckres "Readlink" $status $expcode $res $PASS
47
48
49 # c: Readlink w/CFH=file, expect INVAL
50 set expcode "INVAL"
51 set ASSERTION "Readlink w/CFH=file, expect $expcode"
52 set tag "$TNAME{c}"
53 putmsg stdout 0 "$tag: $ASSERTION"
54 set res [compound {Putfh $bfh; Lookup "$env(EXECFILE)";
55 Readlink; Getfh}]
56 ckres "Readlink" $status $expcode $res $PASS
57
58
59 # d: Readlink w/CFH=dir, expect ISDIR
60 set expcode "ISDIR"
61 set ASSERTION "Readlink w/CFH=dir, expect $expcode"
62 set tag "$TNAME{d}"
63 putmsg stdout 0 "$tag: $ASSERTION"
64 set res [compound {Putfh $bfh; Lookup "$env(DIR0777)";
65 Readlink; Getfh}]
66 ckres "Readlink" $status $expcode $res $PASS
67
68
69 # e: Readlink w/CFH=charfile, expect INVAL
70 set expcode "INVAL"
71 set ASSERTION "Readlink w/CFH=charfile, expect $expcode"
72 set tag "$TNAME{e}"
73 putmsg stdout 0 "$tag: $ASSERTION"
74 set res [compound {Putfh $bfh; Lookup "$env(CHARFILE)";
75 Readlink; Getfh}]
76 ckres "Readlink" $status $expcode $res $PASS
77
78
79 # f: Readlink w/CFH=attrdir, expect ISDIR
80 set expcode "ISDIR"
81 set ASSERTION "Readlink w/CFH=attrdir, expect $expcode"
82 set tag "$TNAME{f}"
83 putmsg stdout 0 "$tag: $ASSERTION"
84 set res [compound {Putfh $bfh; Lookup "$env(ATTRDIR)";
85 Openattr f; Getattr type; Readlink}]
86 ckres "Readlink" $status $expcode $res $PASS
87
88
89 # i: Readlink w/symlink pointed by CFH removed, expect STALE
90 set expcode "STALE"
91 set ASSERTION "Readlink w/symlink pointed by CFH removed, expect $expcode"
92 set tag "$TNAME{i}"
93 #putmsg stdout 0 "$tag: $ASSERTION"
94 #set nl3 "NewSymLi.[pid]"
95 #set res [compound {Putfh $bfh;
96 # Create $nl3 {{mode 0666}} l "$env(FIFOFILE)";Getfh}]
97 #set cont [ckres "Create" $status "OK" $res $FAIL]
98 #if {! [string equal $cont "false"]} {
99 # set sfh [lindex [lindex $res 2] 2]
100 # set res [compound {Putfh $bfh; Remove "$nl3";
101 # Putfh $sfh; Readlink; Getfh}]
102 # ckres "Readlink" $status $expcode $res $PASS
103 #}
104 #puts "\t Test UNTESTED: XXX need hook to remove <CFH> in server.\n"
105
106
107 # m: Readlink with WrongSec, expect WRONGSEC
108 set expcode "WRONGSEC"
109 set ASSERTION "Readlink with WrongSec, expect $expcode"
110 set tag "$TNAME{m}"
111 #putmsg stdout 0 "$tag: $ASSERTION"
112 #puts "\t Test UNTESTED: XXX need SEC changed between <cfh> and Readlink.\n"
113
114
115 # n: try to Readlink of expired FH, expect FHEXPIRED
116 set expcode "FHEXPIRED"
117 set ASSERTION "Readlink an expired FH, expect $expcode"
118 set tag "$TNAME{n}"
119 #putmsg stdout 0 "$tag: $ASSERTION"
120 #puts "\t Test UNTESTED: XXX need migration support.\n"
121
122
123 # o: try to Readlink of bad FH, expect BADHANDLE
124 set expcode "BADHANDLE"
125 set ASSERTION "Readlink with a bad FH, expect $expcode"
126 set tag "$TNAME{o}"
127 #putmsg stdout 0 "$tag: $ASSERTION"
128 #puts "\t Test UNTESTED: XXX need hooks in server to set CFH bad.\n"
129
130
131 # p: try to Readlink to a system does not support symlink, expect NOTSUPP
132 set expcode "NOTSUPP"
133 set ASSERTION "Readlink to a system does not support symlink, expect $expcode"
134 set tag "$TNAME{p}"
135 putmsg stdout 0 "$tag: $ASSERTION"
136 putmsg stdout 0 "\t Test NOTINUSE: Invalid assertion for Solaris."
137 putmsg stdout 1 "\t\t Solaris server supports symlink."
138
139
140 # x: XXX how do we simulate some server errors:
141 # NFS4ERR_MOVE
142 # NFS4ERR_IO
143 # NFS4ERR_SERVERFAULT
144 # NFS4ERR_RESOURCE
145
146
147 # --------------------------------------------------------------
148 # Final cleanup:
149 # remove the created temp link files
150 #set res [compound {Putfh $bfh; Remove $nl3}]
151 #if { "$status" != "OK" } {
152 # putmsg stderr 0 "\t WARNING: cleanup to remove created links failed"
153 # putmsg stderr 0 "\t status=$status; please cleanup manually."
154 # putmsg stderr 1 "\t res=($res)"
155 # putmsg stderr 1 " "
156 # exit $WARNING
157 #}
158
159 # disconnect and exit
160 Disconnect
161 exit $PASS