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 other file types.
28 # NOTE: All tests here needs the server's FS exported with root permission.
29 # XXX pending on decision of what to do with such FS ...
30
31 # include all test enironment
32 source CREATE.env
33
34 # connect to the test server
35 Connect
36
37
38 # setting local variables
39 set TNAME $argv0
40 set bfh [get_fh $BASEDIRS]
41
42 # Start testing
43 # --------------------------------------------------------------
44 # a: create a new blk, expect OK
45 set expcode "OK"
46 set LFILE $env(TEXTFILE)
47 set nlnkf "newlnkf.[pid]"
48 set ASSERTION "Create a new link to a file, expect $expcode"
49 set tag $TNAME{a}
50 putmsg stdout 0 "$tag: $ASSERTION"
51 set res [compound {Putfh $bfh; Create $nlnkf {{mode 0640}} l $LFILE;
52 Getfh; Getattr type}]
53 set cont [ckres "Create" $status $expcode $res $FAIL]
54 # verify filehandle from CREATE should be good
55 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
56 if {! [string equal $cont "false"]} {
57 # check new type must be a lnk
58 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
59 if { "$ntype" != "lnk" } {
60 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
61 putmsg stderr 0 "\t expected type is (lnk)."
62 putmsg stderr 1 "\t res=($res)"
63 putmsg stderr 1 " "
64 } else {
65 logres PASS
66 }
67 }
68
69
70 # b: create a new link to dir, expect OK
71 set expcode "OK"
72 set DFILE $env(LONGDIR)
73 set nlnkd "newlnkd.[pid]"
74 set ASSERTION "Create a new link to longdir, expect $expcode"
75 set tag $TNAME{b}
76 putmsg stdout 0 "$tag: $ASSERTION"
77 set res [compound {Putfh $bfh; Create $nlnkd {{mode 0755}} l $DFILE;
78 Getfh; Getattr type}]
79 set cont [ckres "Create" $status $expcode $res $FAIL]
80 # verify filehandle from CREATE should be good
81 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
82 if {! [string equal $cont "false"]} {
83 # check new type must be a lnk
84 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
85 if { "$ntype" != "lnk" } {
86 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
87 putmsg stderr 0 "\t expected type is (lnk)."
88 putmsg stderr 1 "\t res=($res)"
89 putmsg stderr 1 " "
90 } else {
91 logres PASS
92 }
93 }
94
95
96 # c: create a new link to the link, expect OK
97 set expcode "OK"
98 set nlnkl "newlnkl.[pid]"
99 set ASSERTION "Create a new link to the link, expect $expcode"
100 set tag $TNAME{c}
101 putmsg stdout 0 "$tag: $ASSERTION"
102 set res [compound {Putfh $bfh; Create $nlnkl {{mode 0644}} l $nlnkd;
103 Getfh; Getattr type}]
104 set cont [ckres "Create" $status $expcode $res $FAIL]
105 # verify filehandle from CREATE should be good
106 set cont [verf_fh [lindex [lindex $res 2] 2] $cont $FAIL]
107 if {! [string equal $cont "false"]} {
108 # check new type must be a lnk
109 set ntype [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
110 if { "$ntype" != "lnk" } {
111 putmsg stderr 0 "\t Test FAIL: got unexpected type ($ntype)."
112 putmsg stderr 0 "\t expected type is (lnk)."
113 putmsg stderr 1 "\t res=($res)"
114 putmsg stderr 1 " "
115 } else {
116 logres PASS
117 }
118 }
119
120
121 # --------------------------------------------------------------
122 # Final cleanup
123 # - remove the created dir
124 set res [compound {Putfh $bfh; Remove $nlnkf; Remove $nlnkd; Remove $nlnkl;}]
125 if { "$status" != "OK" } {
126 putmsg stderr 0 "\t WARNING: cleanup to remove created dir failed"
127 putmsg stderr 0 "\t status=$status; please cleanup manually."
128 putmsg stderr 1 "\t res=($res)"
129 putmsg stderr 1 " "
130 exit $WARNING
131 }
132
133
134 # disconnect and exit
135 Disconnect
136 exit $PASS