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 LINK operation test - positive tests
27
28 # include all test enironment
29 source LINK.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: basic Link to a file, expect OK
41 set expcode "OK"
42 set ASSERTION "Basic Link to a file, expect $expcode"
43 putmsg stdout 0 "$TNAME{a}: $ASSERTION"
44 set lnk1 "NewLink.[pid]"
45 set res [compound {Putfh $bfh; Lookup $env(TEXTFILE); Savefh;
46 Putfh $bfh; Link $lnk1; Getfh}]
47 set cont [ckres "Link" $status $expcode $res $FAIL]
48 # Now verify CFH continue to be the target directory
49 set nfh [lindex [lindex $res 5] 2]
50 if { [fh_equal $bfh $nfh $cont $FAIL] } {
51 logres PASS
52 } else {
53 putmsg stderr 0 "\t Test FAIL: new FH was not changed."
54 putmsg stderr 1 "\t nfh=($nfh)"
55 putmsg stderr 1 "\t bfh=($bfh)"
56 putmsg stderr 1 " "
57 }
58
59
60 # b: Check property changes for the link file, expect OK
61 set expcode "OK"
62 set ASSERTION "Check property changes for the link file, expect $expcode"
63 set fifo "OrigFifo.[pid]"
64 set lnk2 "NewLink2.[pid]"
65 putmsg stdout 0 "$TNAME{b}: $ASSERTION"
66 set res [compound {Putfh $bfh; Create $fifo {{mode 0644}} f; Savefh;
67 Putfh $bfh; Link $lnk2; Getfh}]
68 set cont [ckres "Link" $status $expcode $res $FAIL]
69 # Now verify the property change in fifo is reflected in link file
70 if {! [string equal $cont "false"]} {
71 set res [compound {Putfh $bfh; Lookup $fifo;
72 Setattr {0 0} {{mode 666}}; Putfh $bfh; Lookup $lnk2;
73 Getattr mode}]
74 set mode [lindex [lindex [lindex [lindex $res 5] 2] 0] 1]
75 if {$mode != "666" } {
76 putmsg stderr 0 "\t Test FAIL: new mode=($mode) is unexpected."
77 putmsg stderr 1 "\t res=($res)"
78 putmsg stderr 1 " "
79 } else {
80 logres PASS
81 }
82 }
83
84
85 # c: Verify numlinks increased one after the Link, expect OK
86 set expcode "OK"
87 set ASSERTION "Verify numlinks increased one after the Link, expect $expcode"
88 putmsg stdout 0 "$TNAME{c}: $ASSERTION"
89 set lnk3 "NewLink3.[pid]"
90 set res [compound {Putfh $bfh; Lookup $env(ROFILE); Getattr numlinks; Savefh;
91 Putfh $bfh; Link $lnk3; Lookup $env(ROFILE); Getattr numlinks}]
92 set cont [ckres "Link" $status $expcode $res $FAIL]
93 # Now verify the link count on the file is one greater
94 if {! [string equal $cont "false"]} {
95 set cnt1 [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
96 set cnt2 [lindex [lindex [lindex [lindex $res 7] 2] 0] 1]
97 if {[incr cnt1] != $cnt2 } {
98 putmsg stderr 0 "\t Test FAIL: new link count is incorrect."
99 putmsg stderr 1 "\t cnt1=($cnt1)"
100 putmsg stderr 1 "\t cnt2=($cnt2)"
101 putmsg stderr 1 "\t res=($res)"
102 putmsg stderr 1 " "
103 } else {
104 logres PASS
105 }
106 }
107
108
109 # --------------------------------------------------------------
110 # Final cleanup:
111 # remove the created temp link files
112 set res [compound {Putfh $bfh; Remove $lnk1; Remove $fifo;
113 Remove $lnk2; Remove $lnk3}]
114 if { "$status" != "OK" } {
115 putmsg stderr 0 "\t WARNING: cleanup to remove created links failed"
116 putmsg stderr 0 "\t status=$status; please cleanup manually."
117 putmsg stderr 1 "\t res=($res)"
118 putmsg stderr 1 " "
119 exit $WARNING
120 }
121
122 # disconnect and exit
123 Disconnect
124 exit $PASS