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 CREATE operation test - positive tests
27 # - testing successful creation of symlinks.
28
29 # include all test enironment
30 source CREATE.env
31
32 # connect to the test server
33 Connect
34
35
36 # setting local variables
37 set TNAME $argv0
38 set bfh [get_fh $BASEDIRS]
39
40 # Start testing
41 # --------------------------------------------------------------
42 # a: create a new link to file, expect OK
43 set expcode "OK"
44 set LFILE $env(ROFILE)
45 set nlnkf "newlnkf.[pid]"
46 set ASSERTION "Create a new link to a file, expect $expcode"
47 set tag $TNAME{a}
48 putmsg stdout 0 "$tag: $ASSERTION"
49 set res [compound {Putfh $bfh; Create $nlnkf {{mode 0555}} l $LFILE;
50 Getfh; Getattr type}]
51 set cont [ckres "Create" $status $expcode $res $FAIL]
52 # verify filehandle from CREATE should be good
53 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
54 if {! [string equal $cont "false"]} {
55 # check new type must be a lnk
56 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
57 if { "$ntype" != "lnk" } {
58 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
59 putmsg stderr 0 "\t expected type is (lnk)."
60 putmsg stderr 1 "\t res=($res)"
61 putmsg stderr 1 " "
62 } else {
63 logres PASS
64 }
65 }
66
67
68 # b: create a new link to dir, expect OK
69 set expcode "OK"
70 set DFILE $env(LONGDIR)
71 set nlnkd "newlnkd.[pid]"
72 set ASSERTION "Create a new link to longdir, expect $expcode"
73 set tag $TNAME{b}
74 putmsg stdout 0 "$tag: $ASSERTION"
75 set res [compound {Putfh $bfh; Create $nlnkd {{mode 0751}} l $DFILE;
76 Getfh; Getattr type}]
77 set cont [ckres "Create" $status $expcode $res $FAIL]
78 # Now verify - filehandle from CREATE should be good
79 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
80 if {! [string equal $cont "false"]} {
81 # check new type must be a lnk
82 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
83 if { "$ntype" != "lnk" } {
84 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
85 putmsg stderr 0 "\t expected type is (lnk)."
86 putmsg stderr 1 "\t res=($res)"
87 putmsg stderr 1 " "
88 } else {
89 logres PASS
90 }
91 }
92
93
94 # c: create a new link to the link, expect OK
95 set expcode "OK"
96 set nlnkl "newlnkl.[pid]"
97 set ASSERTION "Create a new link to the link, expect $expcode"
98 set tag $TNAME{c}
99 putmsg stdout 0 "$tag: $ASSERTION"
100 set res [compound {Putfh $bfh; Create $nlnkl {{mode 0777}} l $nlnkd;
101 Getfh; Getattr type}]
102 set cont [ckres "Create" $status $expcode $res $FAIL]
103 # Now verify - filehandle from CREATE should be good
104 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
105 if {! [string equal $cont "false"]} {
106 # check new type must be a lnk
107 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
108 if { "$ntype" != "lnk" } {
109 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
110 putmsg stderr 0 "\t expected type is (lnk)."
111 putmsg stderr 1 "\t res=($res)"
112 putmsg stderr 1 " "
113 } else {
114 logres PASS
115 }
116 }
117
118
119 # d: create a new link to none-exist object, expect OK
120 set expcode "OK"
121 set nlnk2 "newlnkl2.[pid]"
122 set ASSERTION "Create a new link to none-exist object, expect $expcode"
123 set tag $TNAME{d}
124 putmsg stdout 0 "$tag: $ASSERTION"
125 set res [compound {Putfh $bfh; Create $nlnk2 {{mode 777}} l "no-such-obj";
126 Getfh; Getattr type}]
127 set cont [ckres "Create" $status $expcode $res $FAIL]
128 # Now verify - filehandle from CREATE should be good
129 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
130 if {! [string equal $cont "false"]} {
131 # check new type must be a lnk
132 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
133 if { "$ntype" != "lnk" } {
134 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
135 putmsg stderr 0 "\t expected type is (lnk)."
136 putmsg stderr 1 "\t res=($res)"
137 putmsg stderr 1 " "
138 } else {
139 logres PASS
140 }
141 }
142
143 # --------------------------------------------------------------
144 # Final cleanup
145 # cleanup remove the created dir
146 set res [compound {Putfh $bfh; Remove $nlnkf;
147 Remove $nlnkd; Remove $nlnkl; Remove $nlnk2}]
148 if { "$status" != "OK" } {
149 putmsg stderr 0 "\t WARNING: cleanup to remove created dir failed"
150 putmsg stderr 0 "\t status=$status; please cleanup manually."
151 putmsg stderr 1 "\t res=($res)"
152 putmsg stderr 1 " "
153 exit $WARNING
154 }
155
156
157 # disconnect and exit
158 Disconnect
159 exit $PASS