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 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 server name space test - negative tests
27 #
28
29 # include all test enironment
30 source SNSPC.env
31
32 set TNAME $argv0
33
34 # Start the assertion proc's here
35 # --------------------------------------------------------------
36 # a: Verify not able to Create dir in pseudo node, expect ROFS
37 proc assertion_a {pnode} {
38 global TNAME BASEDIR
39 set expcode "ROFS"
40 set ASSERTION \
41 "Verify not able to Create dir in pseudo node, expect $expcode"
42 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
43
44 # First do the compound
45 if {"/$pnode" == "$BASEDIR"} {
46 set res [compound {Putrootfh; Getfh}]
47 set pfh [lindex [lindex $res end] 2]
48 } else {
49 set pfh [get_fh $pnode]
50 }
51 set newD "newD.[pid]"
52 set res [compound {Putfh $pfh; Create $newD {{mode 0777}} d}]
53 if {$status != "$expcode"} {
54 putmsg stderr 0 "\t Test FAIL: compound got status=($status)"
55 putmsg stderr 0 "\t expected=($expcode)"
56 putmsg stderr 1 "\t res=($res)"
57 return (-1)
58 }
59
60 # Verify directory is not created
61 set res [compound {Putfh $pfh; Lookup $newD}]
62 if {$status != "NOENT"} {
63 putmsg stderr 0 "\t Test FAIL: new dir exist after Create failed"
64 putmsg stderr 1 "\t res=($res)"
65 return (-1)
66 }
67
68 logres PASS
69 return (0)
70 }
71
72
73 # b: Verify not able to Setattr in pseudo node, expect ROFS
74 proc assertion_b {pnode} {
75 global TNAME BASEDIR
76 set expcode "ROFS"
77 set ASSERTION \
78 "Verify not able to Setattr in pseudo node, expect $expcode"
79 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
80
81 # First do the compound
82 if {"/$pnode" == "$BASEDIR"} {
83 set res [compound {Putrootfh; Getfh}]
84 set pfh [lindex [lindex $res end] 2]
85 } else {
86 set pfh [get_fh $pnode]
87 }
88 set nmode 765
89 set res [compound {Putfh $pfh; Getattr mode; Setattr {0 0} {{mode $nmode}}}]
90 set stat1 $status
91 set omode [lindex [lindex [lindex [lindex $res 1] 2] 0] 1]
92 # Verify the node's mode was not changed, if changed,
93 # recover it before exiting for other tests
94 set res [compound {Putfh $pfh; Getattr mode}]
95 set nmode [lindex [lindex [lindex [lindex $res 1] 2] 0] 1]
96 if {$stat1 != "$expcode"} {
97 putmsg stderr 0 "\t Test FAIL: compound got status=($status)"
98 putmsg stderr 0 "\t expected=($expcode)"
99 putmsg stderr 1 "\t res=($res)"
100 if {$omode != $nmode} {
101 set res [compound {Putfh $pfh; Getattr mode; Setattr {0 0} {{mode $omode}}}]
102 if {$status != "OK"} {
103 putmsg stderr 0 "\t failed to recover the original mode, this may cause"
104 putmsg stderr 0 "\t other tests failed."
105 putmsg stderr 1 "\t res=($res)"
106 }
107 }
108 return (-1)
109 }
110
111 if {$omode != $nmode} {
112 putmsg stderr 0 \
113 "\t Test FAIL: pseudo node's mode was changed after Setattr failed"
114 putmsg stderr 1 "\t res=($res)"
115 set res [compound {Putfh $pfh; Getattr mode; Setattr {0 0} {{mode $omode}}}]
116 if {$status != "OK"} {
117 putmsg stderr 0 "\t failed to recover the original mode, this may cause"
118 putmsg stderr 0 "\t other tests failed."
119 putmsg stderr 1 "\t res=($res)"
120 }
121 return (-1)
122 }
123
124 logres PASS
125 return (0)
126 }
127
128
129 # Start the main program here
130 # --------------------------------------------------------------
131 # connect to the test server
132 if {[catch {connect -p ${PORT} -t ${TRANSPORT} ${SERVER}} msg]} {
133 putmsg stderr 0 "Test UNINITIATED: unable to connect to $SERVER"
134 putmsg stderr 1 $msg
135 exit $UNINITIATED
136 }
137
138 set pnode [lindex $BASEDIRS 0]
139 assertion_a $pnode
140 assertion_b $pnode
141
142
143 # --------------------------------------------------------------
144 # disconnect and exit
145 disconnect
146 exit $PASS